]>
Commit | Line | Data |
---|---|---|
9a1955a7 JF |
1 | # -*- Autoconf -*- |
2 | # Process this file with autoconf to produce a configure script. | |
3 | ||
4 | # bootstrap / init | |
5 | AC_PREREQ([2.61]) | |
6 | ||
7 | AC_INIT([corosync-qdevice], | |
a09c6604 | 8 | m4_esyscmd([build-aux/git-version-gen .tarball-version .gitarchivever]), |
9a1955a7 JF |
9 | [users@clusterlabs.org]) |
10 | ||
11 | AC_USE_SYSTEM_EXTENSIONS | |
12 | ||
13 | AM_INIT_AUTOMAKE([foreign 1.11]) | |
14 | ||
15 | LT_PREREQ([2.2.6]) | |
16 | LT_INIT | |
17 | ||
18 | AM_SILENT_RULES([yes]) | |
19 | ||
20 | AC_CONFIG_SRCDIR([qdevices/corosync-qdevice.c]) | |
21 | AC_CONFIG_HEADER([config.h]) | |
22 | AC_CONFIG_MACRO_DIR([m4]) | |
23 | ||
24 | AC_CANONICAL_HOST | |
25 | ||
26 | AC_LANG([C]) | |
27 | ||
9a1955a7 | 28 | dnl Fix default variables - "prefix" variable if not specified |
e2c682e9 JF |
29 | systemddir=${prefix}/lib/systemd/system |
30 | ||
9a1955a7 JF |
31 | if 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 | |
53 | fi | |
54 | ||
55 | if test "$srcdir" = "."; then | |
56 | AC_MSG_NOTICE([building in place srcdir:$srcdir]) | |
57 | AC_DEFINE([BUILDING_IN_PLACE], 1, [building in place]) | |
58 | else | |
59 | AC_MSG_NOTICE([building out of tree srcdir:$srcdir]) | |
60 | fi | |
61 | ||
62 | # Checks for programs. | |
63 | ||
64 | # check stolen from gnulib/m4/gnu-make.m4 | |
65 | if ! ${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]) | |
67 | fi | |
68 | ||
69 | AC_PROG_AWK | |
70 | AC_PROG_GREP | |
71 | AC_PROG_SED | |
72 | AC_PROG_CPP | |
73 | AC_PROG_CC | |
74 | AC_PROG_CC_C99 | |
75 | if test "x$ac_cv_prog_cc_c99" = "xno"; then | |
76 | AC_MSG_ERROR(["C99 support is required"]) | |
77 | fi | |
78 | AC_PROG_LN_S | |
79 | AC_PROG_INSTALL | |
80 | AC_PROG_MAKE_SET | |
81 | PKG_PROG_PKG_CONFIG | |
82 | AC_PATH_PROG([BASHPATH], [bash]) | |
83 | AC_CHECK_PROGS([GROFF], [groff]) | |
84 | ||
85 | # Checks for typedefs. | |
86 | AC_TYPE_UID_T | |
87 | AC_TYPE_INT16_T | |
88 | AC_TYPE_INT32_T | |
89 | AC_TYPE_INT64_T | |
90 | AC_TYPE_INT8_T | |
91 | AC_TYPE_UINT16_T | |
92 | AC_TYPE_UINT32_T | |
93 | AC_TYPE_UINT64_T | |
94 | AC_TYPE_UINT8_T | |
95 | AC_TYPE_SIZE_T | |
96 | AC_TYPE_SSIZE_T | |
97 | ||
98 | # Checks for libraries. | |
99 | PKG_CHECK_MODULES([nss],[nss]) | |
9a1955a7 JF |
100 | PKG_CHECK_MODULES([corosync_common], [libcorosync_common]) |
101 | PKG_CHECK_MODULES([cmap], [libcmap]) | |
102 | PKG_CHECK_MODULES([votequorum], [libvotequorum]) | |
103 | ||
104 | AC_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 | |
116 | cc_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 | |
128 | PACKAGE_FEATURES="" | |
129 | ||
130 | # local options | |
131 | AC_ARG_ENABLE([fatal-warnings], | |
132 | [ --enable-fatal-warnings : enable fatal warnings. ], | |
133 | [ default="no" ]) | |
134 | ||
135 | AC_ARG_ENABLE([debug], | |
136 | [ --enable-debug : enable debug build. ], | |
137 | [ default="no" ]) | |
138 | ||
139 | AC_ARG_ENABLE([secure-build], | |
140 | [ --enable-secure-build : enable PIE/RELRO build. ], | |
141 | [], | |
142 | [enable_secure_build="yes"]) | |
143 | ||
c6548f40 JF |
144 | AC_ARG_ENABLE([user-flags], |
145 | [ --enable-user-flags : rely on user environment. ], | |
146 | [ default="no" ]) | |
147 | AM_CONDITIONAL(BUILD_USERFLAGS, test x$enable_user_flags = xyes) | |
148 | ||
9a1955a7 | 149 | AC_ARG_ENABLE([systemd], |
eae6806f | 150 | [ --enable-systemd : Build with libsystemd and install systemd service files],, |
9a1955a7 JF |
151 | [ enable_systemd="no" ]) |
152 | AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes) | |
153 | ||
154 | AC_ARG_WITH([initconfigdir], | |
155 | [AS_HELP_STRING([--with-initconfigdir=DIR], | |
156 | [configuration directory @<:@SYSCONFDIR/sysconfig@:>@])], | |
157 | [INITCONFIGDIR="$withval"], | |
158 | [INITCONFIGDIR='${sysconfdir}/sysconfig']) | |
159 | AC_SUBST([INITCONFIGDIR]) | |
160 | ||
161 | AC_ARG_WITH([initddir], | |
162 | [ --with-initddir=DIR : path to init script directory. ], | |
163 | [ INITDDIR="$withval" ], | |
164 | [ INITDDIR="$sysconfdir/init.d" ]) | |
165 | ||
166 | AC_ARG_WITH([systemddir], | |
167 | [ --with-systemddir=DIR : path to systemd unit files directory. ], | |
168 | [ SYSTEMDDIR="$withval" ], | |
e2c682e9 | 169 | [ SYSTEMDDIR="$systemddir" ]) |
9a1955a7 JF |
170 | |
171 | AC_ARG_ENABLE([qdevices], | |
eae6806f | 172 | [ --disable-qdevices : Quorum devices support ],, |
9a1955a7 JF |
173 | [ enable_qdevices="yes" ]) |
174 | AM_CONDITIONAL(BUILD_QDEVICES, test x$enable_qdevices = xyes) | |
175 | AC_ARG_ENABLE([qnetd], | |
eae6806f | 176 | [ --disable-qnetd : Quorum Net Daemon support ],, |
9a1955a7 JF |
177 | [ enable_qnetd="yes" ]) |
178 | AM_CONDITIONAL(BUILD_QNETD, test x$enable_qnetd = xyes) | |
eae6806f JF |
179 | AC_ARG_ENABLE([runautogen], |
180 | [ --enable-runautogen : run autogen.sh (RPM specfile)],, | |
181 | [ enable_runautogen="no" ]) | |
182 | AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes]) | |
9a1955a7 JF |
183 | |
184 | # *FLAGS handling goes here | |
185 | ||
186 | ENV_CFLAGS="$CFLAGS" | |
187 | ENV_CPPFLAGS="$CPPFLAGS" | |
188 | ENV_LDFLAGS="$LDFLAGS" | |
189 | ||
190 | # debug build stuff | |
191 | if 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" | |
195 | else | |
196 | OPT_CFLAGS="-O3" | |
197 | fi | |
198 | ||
199 | # gdb flags | |
200 | if test "x${GCC}" = xyes; then | |
201 | GDB_FLAGS="-ggdb3" | |
202 | else | |
203 | GDB_FLAGS="-g" | |
204 | fi | |
205 | ||
206 | if 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 |
210 | fi |
211 | if test "x${enable_qdevices}" = xyes; then | |
212 | PACKAGE_FEATURES="$PACKAGE_FEATURES qdevices" | |
213 | fi | |
214 | if test "x${enable_qnetd}" = xyes; then | |
215 | PACKAGE_FEATURES="$PACKAGE_FEATURES qnetd" | |
216 | fi | |
217 | ||
218 | # extra warnings | |
219 | EXTRA_WARNINGS="" | |
220 | ||
221 | WARNLIST=" | |
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 | ||
242 | for j in $WARNLIST; do | |
243 | if cc_supports_flag -W$j; then | |
244 | EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j"; | |
245 | fi | |
246 | done | |
247 | ||
248 | if 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" | |
253 | else | |
254 | WERROR_CFLAGS="" | |
255 | fi | |
256 | ||
c6548f40 JF |
257 | # don't add addtional cflags |
258 | if test "x${enable_user_flags}" = xyes; then | |
259 | OPT_CFLAGS="" | |
260 | GDB_FLAGS="" | |
261 | EXTRA_WARNINGS="" | |
262 | fi | |
263 | ||
9a1955a7 JF |
264 | if 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 | |
306 | fi | |
307 | ||
308 | AC_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 | |
317 | INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include" | |
318 | ||
319 | # final build of *FLAGS | |
320 | CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \ | |
321 | $EXTRA_WARNINGS \ | |
322 | $WERROR_CFLAGS" | |
323 | CPPFLAGS="$ENV_CPPFLAGS $INCLUDE_DIRS" | |
324 | LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS" | |
325 | ||
326 | if test "$ap_cv_cc_as_needed" = "yes"; then | |
327 | LDFLAGS="$LDFLAGS -Wl,--as-needed" | |
328 | fi | |
329 | ||
330 | # substitute what we need: | |
331 | AC_SUBST([BASHPATH]) | |
332 | AC_SUBST([INITDDIR]) | |
333 | AC_SUBST([SYSTEMDDIR]) | |
334 | AC_SUBST([LOGDIR]) | |
335 | AC_SUBST([LOGROTATEDIR]) | |
336 | ||
337 | AC_SUBST([SOMAJOR]) | |
338 | AC_SUBST([SOMINOR]) | |
339 | AC_SUBST([SOMICRO]) | |
340 | AC_SUBST([SONAME]) | |
341 | ||
342 | AC_SUBST([NSS_LDFLAGS]) | |
343 | ||
344 | AM_CONDITIONAL(BUILD_HTML_DOCS, test -n "${GROFF}") | |
345 | ||
346 | AC_DEFINE_UNQUOTED([LOCALSTATEDIR], "$(eval echo ${localstatedir})", [localstate directory]) | |
347 | ||
348 | COROSYSCONFDIR=${sysconfdir}/corosync | |
349 | AC_SUBST([COROSYSCONFDIR]) | |
350 | AC_DEFINE_UNQUOTED([COROSYSCONFDIR], "$(eval echo ${COROSYSCONFDIR})", [corosync-qdevice config directory]) | |
351 | ||
352 | AC_DEFINE_UNQUOTED([PACKAGE_FEATURES], "${PACKAGE_FEATURES}", [corosync-qdevice built-in features]) | |
353 | ||
354 | AC_OUTPUT | |
355 | ||
356 | AC_MSG_RESULT([]) | |
357 | AC_MSG_RESULT([$PACKAGE configuration:]) | |
358 | AC_MSG_RESULT([ Version = ${VERSION}]) | |
359 | AC_MSG_RESULT([ Prefix = ${prefix}]) | |
360 | AC_MSG_RESULT([ Executables = ${sbindir}]) | |
361 | AC_MSG_RESULT([ Man pages = ${mandir}]) | |
362 | AC_MSG_RESULT([ Doc dir = ${docdir}]) | |
363 | AC_MSG_RESULT([ Libraries = ${libdir}]) | |
364 | AC_MSG_RESULT([ Header files = ${includedir}]) | |
365 | AC_MSG_RESULT([ Arch-independent files = ${datadir}]) | |
366 | AC_MSG_RESULT([ State information = ${localstatedir}]) | |
367 | AC_MSG_RESULT([ System configuration = ${sysconfdir}]) | |
368 | AC_MSG_RESULT([ System init.d directory = ${INITDDIR}]) | |
369 | AC_MSG_RESULT([ System systemd directory = ${SYSTEMDDIR}]) | |
370 | AC_MSG_RESULT([ Log directory = ${LOGDIR}]) | |
371 | AC_MSG_RESULT([ Log rotate directory = ${LOGROTATEDIR}]) | |
372 | AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}]) | |
373 | AC_MSG_RESULT([ init config directory = ${INITCONFIGDIR}]) | |
374 | AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}]) | |
375 | AC_MSG_RESULT([]) | |
376 | AC_MSG_RESULT([$PACKAGE build info:]) | |
377 | AC_MSG_RESULT([ Default optimization = ${OPT_CFLAGS}]) | |
c6548f40 | 378 | AC_MSG_RESULT([ Default debug options = ${GDB_FLAGS}]) |
9a1955a7 JF |
379 | AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}]) |
380 | AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}]) | |
381 | AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}]) | |
382 | AC_MSG_RESULT([ Env. defined LDFLAGS = ${ENV_LDFLAGS}]) | |
383 | AC_MSG_RESULT([ Fatal War. CFLAGS = ${WERROR_CFLAGS}]) | |
384 | AC_MSG_RESULT([ Final CFLAGS = ${CFLAGS}]) | |
385 | AC_MSG_RESULT([ Final CPPFLAGS = ${CPPFLAGS}]) | |
386 | AC_MSG_RESULT([ Final LDFLAGS = ${LDFLAGS}]) |