]> git.proxmox.com Git - mirror_corosync-qdevice.git/blame - configure.ac
qnetd: Improve dead peer detection
[mirror_corosync-qdevice.git] / configure.ac
CommitLineData
9a1955a7
JF
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# bootstrap / init
5AC_PREREQ([2.61])
6
7AC_INIT([corosync-qdevice],
a09c6604 8 m4_esyscmd([build-aux/git-version-gen .tarball-version .gitarchivever]),
9a1955a7
JF
9 [users@clusterlabs.org])
10
11AC_USE_SYSTEM_EXTENSIONS
12
13AM_INIT_AUTOMAKE([foreign 1.11])
14
15LT_PREREQ([2.2.6])
16LT_INIT
17
18AM_SILENT_RULES([yes])
19
20AC_CONFIG_SRCDIR([qdevices/corosync-qdevice.c])
21AC_CONFIG_HEADER([config.h])
22AC_CONFIG_MACRO_DIR([m4])
23
24AC_CANONICAL_HOST
25
26AC_LANG([C])
27
9a1955a7 28dnl Fix default variables - "prefix" variable if not specified
e2c682e9
JF
29systemddir=${prefix}/lib/systemd/system
30
9a1955a7
JF
31if test "$prefix" = "NONE"; then
32 prefix="/usr"
33
34 dnl Fix "localstatedir" variable if not specified
35 if test "$localstatedir" = "\${prefix}/var"; then
36 localstatedir="/var"
37 fi
38 dnl Fix "sysconfdir" variable if not specified
39 if test "$sysconfdir" = "\${prefix}/etc"; then
40 sysconfdir="/etc"
41 fi
e2c682e9
JF
42 if test "$systemddir" = "NONE/lib/systemd/system"; then
43 systemddir=/lib/systemd/system
44 fi
9a1955a7
JF
45 dnl Fix "libdir" variable if not specified
46 if test "$libdir" = "\${exec_prefix}/lib"; then
47 if test -e /usr/lib64; then
48 libdir="/usr/lib64"
49 else
50 libdir="/usr/lib"
51 fi
52 fi
53fi
54
55if test "$srcdir" = "."; then
56 AC_MSG_NOTICE([building in place srcdir:$srcdir])
57 AC_DEFINE([BUILDING_IN_PLACE], 1, [building in place])
58else
59 AC_MSG_NOTICE([building out of tree srcdir:$srcdir])
60fi
61
62# Checks for programs.
63
64# check stolen from gnulib/m4/gnu-make.m4
65if ! ${MAKE-make} --version /cannot/make/this >/dev/null 2>&1; then
66 AC_MSG_ERROR([you don't seem to have GNU make; it is required])
67fi
68
69AC_PROG_AWK
70AC_PROG_GREP
71AC_PROG_SED
72AC_PROG_CPP
73AC_PROG_CC
74AC_PROG_CC_C99
75if test "x$ac_cv_prog_cc_c99" = "xno"; then
76 AC_MSG_ERROR(["C99 support is required"])
77fi
78AC_PROG_LN_S
79AC_PROG_INSTALL
80AC_PROG_MAKE_SET
81PKG_PROG_PKG_CONFIG
82AC_PATH_PROG([BASHPATH], [bash])
83AC_CHECK_PROGS([GROFF], [groff])
84
85# Checks for typedefs.
86AC_TYPE_UID_T
87AC_TYPE_INT16_T
88AC_TYPE_INT32_T
89AC_TYPE_INT64_T
90AC_TYPE_INT8_T
91AC_TYPE_UINT16_T
92AC_TYPE_UINT32_T
93AC_TYPE_UINT64_T
94AC_TYPE_UINT8_T
95AC_TYPE_SIZE_T
96AC_TYPE_SSIZE_T
97
98# Checks for libraries.
99PKG_CHECK_MODULES([nss],[nss])
9a1955a7
JF
100PKG_CHECK_MODULES([corosync_common], [libcorosync_common])
101PKG_CHECK_MODULES([cmap], [libcmap])
102PKG_CHECK_MODULES([votequorum], [libvotequorum])
103
104AC_CONFIG_FILES([Makefile
105 qdevices/Makefile
106 man/Makefile
107 init/Makefile
cc7f23cf 108 corosync-qdevice.pc
9a1955a7
JF
109 ])
110
111# ===============================================
112# Helpers
113# ===============================================
114
115## helper for CC stuff
116cc_supports_flag() {
117 BACKUP="$CPPFLAGS"
118 CPPFLAGS="$CPPFLAGS $@ $unknown_warnings_as_errors"
119 AC_MSG_CHECKING([whether $CC supports "$@"])
c65923bc 120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
9a1955a7
JF
121 [RC=0; AC_MSG_RESULT([yes])],
122 [RC=1; AC_MSG_RESULT([no])])
123 CPPFLAGS="$BACKUP"
124 return $RC
125}
126
127## local defines
128PACKAGE_FEATURES=""
129
130# local options
131AC_ARG_ENABLE([fatal-warnings],
132 [ --enable-fatal-warnings : enable fatal warnings. ],
133 [ default="no" ])
134
135AC_ARG_ENABLE([debug],
136 [ --enable-debug : enable debug build. ],
137 [ default="no" ])
138
139AC_ARG_ENABLE([secure-build],
140 [ --enable-secure-build : enable PIE/RELRO build. ],
141 [],
142 [enable_secure_build="yes"])
143
c6548f40
JF
144AC_ARG_ENABLE([user-flags],
145 [ --enable-user-flags : rely on user environment. ],
146 [ default="no" ])
147AM_CONDITIONAL(BUILD_USERFLAGS, test x$enable_user_flags = xyes)
148
9a1955a7 149AC_ARG_ENABLE([systemd],
eae6806f 150 [ --enable-systemd : Build with libsystemd and install systemd service files],,
9a1955a7
JF
151 [ enable_systemd="no" ])
152AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes)
153
154AC_ARG_WITH([initconfigdir],
155 [AS_HELP_STRING([--with-initconfigdir=DIR],
156 [configuration directory @<:@SYSCONFDIR/sysconfig@:>@])],
157 [INITCONFIGDIR="$withval"],
158 [INITCONFIGDIR='${sysconfdir}/sysconfig'])
159AC_SUBST([INITCONFIGDIR])
160
161AC_ARG_WITH([initddir],
162 [ --with-initddir=DIR : path to init script directory. ],
163 [ INITDDIR="$withval" ],
164 [ INITDDIR="$sysconfdir/init.d" ])
165
166AC_ARG_WITH([systemddir],
167 [ --with-systemddir=DIR : path to systemd unit files directory. ],
168 [ SYSTEMDDIR="$withval" ],
e2c682e9 169 [ SYSTEMDDIR="$systemddir" ])
9a1955a7
JF
170
171AC_ARG_ENABLE([qdevices],
eae6806f 172 [ --disable-qdevices : Quorum devices support ],,
9a1955a7
JF
173 [ enable_qdevices="yes" ])
174AM_CONDITIONAL(BUILD_QDEVICES, test x$enable_qdevices = xyes)
175AC_ARG_ENABLE([qnetd],
eae6806f 176 [ --disable-qnetd : Quorum Net Daemon support ],,
9a1955a7
JF
177 [ enable_qnetd="yes" ])
178AM_CONDITIONAL(BUILD_QNETD, test x$enable_qnetd = xyes)
eae6806f
JF
179AC_ARG_ENABLE([runautogen],
180 [ --enable-runautogen : run autogen.sh (RPM specfile)],,
181 [ enable_runautogen="no" ])
182AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes])
9a1955a7
JF
183
184# *FLAGS handling goes here
185
186ENV_CFLAGS="$CFLAGS"
187ENV_CPPFLAGS="$CPPFLAGS"
188ENV_LDFLAGS="$LDFLAGS"
189
190# debug build stuff
191if test "x${enable_debug}" = xyes; then
192 AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
193 OPT_CFLAGS="-O0"
194 PACKAGE_FEATURES="$PACKAGE_FEATURES debug"
195else
196 OPT_CFLAGS="-O3"
197fi
198
199# gdb flags
200if test "x${GCC}" = xyes; then
201 GDB_FLAGS="-ggdb3"
202else
203 GDB_FLAGS="-g"
204fi
205
206if test "x${enable_systemd}" = xyes; then
207 PKG_CHECK_MODULES([libsystemd], [libsystemd])
208 AC_DEFINE([HAVE_LIBSYSTEMD], [1], [have systemd interface library])
209 PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
9a1955a7
JF
210fi
211if test "x${enable_qdevices}" = xyes; then
212 PACKAGE_FEATURES="$PACKAGE_FEATURES qdevices"
213fi
214if test "x${enable_qnetd}" = xyes; then
215 PACKAGE_FEATURES="$PACKAGE_FEATURES qnetd"
216fi
217
218# extra warnings
219EXTRA_WARNINGS=""
220
221WARNLIST="
222 all
223 shadow
224 missing-prototypes
225 missing-declarations
226 strict-prototypes
227 declaration-after-statement
228 pointer-arith
229 write-strings
230 cast-align
231 bad-function-cast
232 missing-format-attribute
233 format=2
234 format-security
235 format-nonliteral
236 no-long-long
237 unsigned-char
238 gnu89-inline
239 no-strict-aliasing
240 "
241
242for j in $WARNLIST; do
243 if cc_supports_flag -W$j; then
244 EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";
245 fi
246done
247
248if test "x${enable_fatal_warnings}" = xyes && \
249 cc_supports_flag -Werror ; then
250 AC_MSG_NOTICE([Enabling Fatal Warnings (-Werror)])
251 WERROR_CFLAGS="-Werror"
252 PACKAGE_FEATURES="$PACKAGE_FEATURES fatal-warnings"
253else
254 WERROR_CFLAGS=""
255fi
256
c6548f40
JF
257# don't add addtional cflags
258if test "x${enable_user_flags}" = xyes; then
259 OPT_CFLAGS=""
260 GDB_FLAGS=""
261 EXTRA_WARNINGS=""
262fi
263
9a1955a7
JF
264if test "x${enable_secure_build}" = xyes; then
265 # stolen from apache configure snippet
266 AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
267 save_CFLAGS=$CFLAGS
268 save_LDFLAGS=$LDFLAGS
269 CFLAGS="$CFLAGS -fPIE"
270 LDFLAGS="$LDFLAGS -pie"
271 AC_TRY_RUN([static int foo[30000]; int main () { return 0; }],
272 [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no], [ap_cv_cc_pie=yes])
273 CFLAGS=$save_CFLAGS
274 LDFLAGS=$save_LDFLAGS
275 ])
276 if test "$ap_cv_cc_pie" = "yes"; then
277 SEC_FLAGS="$SEC_FLAGS -fPIE"
278 SEC_LDFLAGS="$SEC_LDFLAGS -pie"
279 PACKAGE_FEATURES="$PACKAGE_FEATURES pie"
280 fi
281
282 # similar to above
283 AC_CACHE_CHECK([whether $CC accepts RELRO flags], [ap_cv_cc_relro], [
284 save_LDFLAGS=$LDFLAGS
285 LDFLAGS="$LDFLAGS -Wl,-z,relro"
286 AC_TRY_RUN([static int foo[30000]; int main () { return 0; }],
287 [ap_cv_cc_relro=yes], [ap_cv_cc_relro=no], [ap_cv_cc_relro=yes])
288 LDFLAGS=$save_LDFLAGS
289 ])
290 if test "$ap_cv_cc_relro" = "yes"; then
291 SEC_LDFLAGS="$SEC_LDFLAGS -Wl,-z,relro"
292 PACKAGE_FEATURES="$PACKAGE_FEATURES relro"
293 fi
294
295 AC_CACHE_CHECK([whether $CC accepts BINDNOW flags], [ap_cv_cc_bindnow], [
296 save_LDFLAGS=$LDFLAGS
297 LDFLAGS="$LDFLAGS -Wl,-z,now"
298 AC_TRY_RUN([static int foo[30000]; int main () { return 0; }],
299 [ap_cv_cc_bindnow=yes], [ap_cv_cc_bindnow=no], [ap_cv_cc_bindnow=yes])
300 LDFLAGS=$save_LDFLAGS
301 ])
302 if test "$ap_cv_cc_bindnow" = "yes"; then
303 SEC_LDFLAGS="$SEC_LDFLAGS -Wl,-z,now"
304 PACKAGE_FEATURES="$PACKAGE_FEATURES bindnow"
305 fi
306fi
307
308AC_CACHE_CHECK([whether $CC accepts "--as-needed"], [ap_cv_cc_as_needed], [
309 save_LDFLAGS=$LDFLAGS
310 LDFLAGS="$LDFLAGS -Wl,--as-needed"
311 AC_TRY_RUN([static int foo[30000]; int main () { return 0; }],
312 [ap_cv_cc_as_needed=yes], [ap_cv_cc_as_needed=no], [ap_cv_cc_as_needed=yes])
313 LDFLAGS=$save_LDFLAGS
314])
315
316# define global include dirs
317INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include"
318
319# final build of *FLAGS
320CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \
321 $EXTRA_WARNINGS \
322 $WERROR_CFLAGS"
323CPPFLAGS="$ENV_CPPFLAGS $INCLUDE_DIRS"
324LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS"
325
326if test "$ap_cv_cc_as_needed" = "yes"; then
327 LDFLAGS="$LDFLAGS -Wl,--as-needed"
328fi
329
330# substitute what we need:
331AC_SUBST([BASHPATH])
332AC_SUBST([INITDDIR])
333AC_SUBST([SYSTEMDDIR])
334AC_SUBST([LOGDIR])
335AC_SUBST([LOGROTATEDIR])
336
337AC_SUBST([SOMAJOR])
338AC_SUBST([SOMINOR])
339AC_SUBST([SOMICRO])
340AC_SUBST([SONAME])
341
342AC_SUBST([NSS_LDFLAGS])
343
344AM_CONDITIONAL(BUILD_HTML_DOCS, test -n "${GROFF}")
345
346AC_DEFINE_UNQUOTED([LOCALSTATEDIR], "$(eval echo ${localstatedir})", [localstate directory])
347
348COROSYSCONFDIR=${sysconfdir}/corosync
349AC_SUBST([COROSYSCONFDIR])
350AC_DEFINE_UNQUOTED([COROSYSCONFDIR], "$(eval echo ${COROSYSCONFDIR})", [corosync-qdevice config directory])
351
352AC_DEFINE_UNQUOTED([PACKAGE_FEATURES], "${PACKAGE_FEATURES}", [corosync-qdevice built-in features])
353
354AC_OUTPUT
355
356AC_MSG_RESULT([])
357AC_MSG_RESULT([$PACKAGE configuration:])
358AC_MSG_RESULT([ Version = ${VERSION}])
359AC_MSG_RESULT([ Prefix = ${prefix}])
360AC_MSG_RESULT([ Executables = ${sbindir}])
361AC_MSG_RESULT([ Man pages = ${mandir}])
362AC_MSG_RESULT([ Doc dir = ${docdir}])
363AC_MSG_RESULT([ Libraries = ${libdir}])
364AC_MSG_RESULT([ Header files = ${includedir}])
365AC_MSG_RESULT([ Arch-independent files = ${datadir}])
366AC_MSG_RESULT([ State information = ${localstatedir}])
367AC_MSG_RESULT([ System configuration = ${sysconfdir}])
368AC_MSG_RESULT([ System init.d directory = ${INITDDIR}])
369AC_MSG_RESULT([ System systemd directory = ${SYSTEMDDIR}])
370AC_MSG_RESULT([ Log directory = ${LOGDIR}])
371AC_MSG_RESULT([ Log rotate directory = ${LOGROTATEDIR}])
372AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}])
373AC_MSG_RESULT([ init config directory = ${INITCONFIGDIR}])
374AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
375AC_MSG_RESULT([])
376AC_MSG_RESULT([$PACKAGE build info:])
377AC_MSG_RESULT([ Default optimization = ${OPT_CFLAGS}])
c6548f40 378AC_MSG_RESULT([ Default debug options = ${GDB_FLAGS}])
9a1955a7
JF
379AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}])
380AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}])
381AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}])
382AC_MSG_RESULT([ Env. defined LDFLAGS = ${ENV_LDFLAGS}])
383AC_MSG_RESULT([ Fatal War. CFLAGS = ${WERROR_CFLAGS}])
384AC_MSG_RESULT([ Final CFLAGS = ${CFLAGS}])
385AC_MSG_RESULT([ Final CPPFLAGS = ${CPPFLAGS}])
386AC_MSG_RESULT([ Final LDFLAGS = ${LDFLAGS}])