]> git.proxmox.com Git - mirror_kronosnet.git/blame - configure.ac
clusternetd: add basic stuff
[mirror_kronosnet.git] / configure.ac
CommitLineData
99afbd6e
FDN
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.63])
5AC_INIT([clusternetd], [0.1], [fdinitto@redhat.com])
6AM_INIT_AUTOMAKE([-Wno-portability])
7LT_PREREQ([2.2.6])
8LT_INIT
9
10AC_CONFIG_MACRO_DIR([m4])
11AC_CONFIG_SRCDIR([main.c])
12AC_CONFIG_HEADERS([config.h])
13
14AC_CANONICAL_HOST
15AC_PROG_LIBTOOL
16
17AC_LANG([C])
18
19if test "$prefix" = "NONE"; then
20 prefix="/usr"
21 if test "$localstatedir" = "\${prefix}/var"; then
22 localstatedir="/var"
23 fi
24 if test "$sysconfdir" = "\${prefix}/etc"; then
25 sysconfdir="/etc"
26 fi
27fi
28
29# Checks for programs.
30if ! ${MAKE-make} --version /cannot/make/this >/dev/null 2>&1; then
31 AC_MSG_ERROR([you don't seem to have GNU make; it is required])
32fi
33AC_PROG_CC
34AM_PROG_CC_C_O
35AC_PROG_LN_S
36AC_PROG_INSTALL
37AC_PROG_MAKE_SET
38AC_PROG_CXX
39AC_PROG_RANLIB
40AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
41
42## local helper functions
43# this function checks if CC support options passed as
44# args. Global CFLAGS are ignored during this test.
45cc_supports_flag() {
46 local CFLAGS="$@"
47 AC_MSG_CHECKING([whether $CC supports "$@"])
48 AC_COMPILE_IFELSE([int main(){return 0;}] ,
49 [RC=0; AC_MSG_RESULT([yes])],
50 [RC=1; AC_MSG_RESULT([no])])
51 return $RC
52}
53
54# helper macro to check libs without adding them to LIBS
55check_lib_no_libs() {
56 lib_no_libs_arg1=$1
57 shift
58 lib_no_libs_arg2=$1
59 shift
60 lib_no_libs_args=$@
61 AC_CHECK_LIB([$lib_no_libs_arg1],
62 [$lib_no_libs_arg2],,,
63 [$lib_no_libs_args])
64 LIBS=$ac_check_lib_save_LIBS
65}
66
67# Checks for libraries.
68PKG_CHECK_MODULES([logt],[liblogthread])
69
70# Checks for header files.
71AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h netinet/in.h])
72
73# Checks for typedefs, structures, and compiler characteristics.
74AC_TYPE_SIZE_T
75
76# Checks for library functions.
77AC_FUNC_MALLOC
78AC_CHECK_FUNCS([atexit ftruncate memset strdup strtol])
79
80# local options
81AC_ARG_ENABLE([debug],
82 [ --enable-debug enable debug build. ],
83 [ default="no" ])
84
85AC_ARG_WITH([syslogfacility],
86 [ --syslogfacility=FACILITY
87 default syslog facility. ],
88 [ SYSLOGFACILITY="$withval" ],
89 [ SYSLOGFACILITY="LOG_LOCAL4" ])
90
91AC_ARG_WITH([sysloglevel],
92 [ --sysloglevel=LEVEL
93 default syslog level. ],
94 [ SYSLOGLEVEL="$withval" ],
95 [ SYSLOGLEVEL="LOG_INFO" ])
96
97## random vars
98LOGDIR=${localstatedir}/log/
99RUNDIR=${localstatedir}/run/
100
101## do subst
102
103AC_DEFINE_UNQUOTED([CONFFILE], "$(eval echo ${sysconfdir}/clusternetd.conf)",
104 [Default config file])
105
106AC_DEFINE_UNQUOTED([LOGDIR], "$(eval echo ${LOGDIR})",
107 [Default logging directory])
108
109AC_DEFINE_UNQUOTED([RUNDIR], "$(eval echo ${RUNDIR})",
110 [Default run directory])
111
112AC_DEFINE_UNQUOTED([SYSLOGFACILITY], $(eval echo ${SYSLOGFACILITY}),
113 [Default syslog facility])
114
115AC_DEFINE_UNQUOTED([SYSLOGLEVEL], $(eval echo ${SYSLOGLEVEL}),
116 [Default syslog level])
117
118## *FLAGS handling
119ENV_CFLAGS="$CFLAGS"
120ENV_CPPFLAGS="$CPPFLAGS"
121ENV_LDFLAGS="$LDFLAGS"
122
123# debug build stuff
124if test "x${enable_debug}" = xyes; then
125 AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
126 OPT_CFLAGS="-O0"
127else
128 OPT_CFLAGS="-O3"
129fi
130
131# gdb flags
132if test "x${GCC}" = xyes; then
133 GDB_FLAGS="-ggdb3"
134else
135 GDB_FLAGS="-g"
136fi
137
138# extra warnings
139EXTRA_WARNINGS=""
140
141WARNLIST="
142 all
143 shadow
144 missing-prototypes
145 missing-declarations
146 strict-prototypes
147 declaration-after-statement
148 pointer-arith
149 write-strings
150 cast-align
151 bad-function-cast
152 missing-format-attribute
153 format=2
154 format-security
155 format-nonliteral
156 no-long-long
157 unsigned-char
158 gnu89-inline
159 no-strict-aliasing
160 error
161 "
162
163for j in $WARNLIST; do
164 if cc_supports_flag -W$j; then
165 EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";
166 fi
167done
168
169CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS \
170 $EXTRA_WARNINGS $WERROR_CFLAGS"
171CPPFLAGS="$ENV_CPPFLAGS"
172LDFLAGS="$ENV_LDFLAGS"
173
174AC_CONFIG_FILES([Makefile])
175
176AC_OUTPUT