]>
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 | |
108 | ]) | |
109 | ||
110 | # =============================================== | |
111 | # Helpers | |
112 | # =============================================== | |
113 | ||
114 | ## helper for CC stuff | |
115 | cc_supports_flag() { | |
116 | BACKUP="$CPPFLAGS" | |
117 | CPPFLAGS="$CPPFLAGS $@ $unknown_warnings_as_errors" | |
118 | AC_MSG_CHECKING([whether $CC supports "$@"]) | |
c65923bc | 119 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], |
9a1955a7 JF |
120 | [RC=0; AC_MSG_RESULT([yes])], |
121 | [RC=1; AC_MSG_RESULT([no])]) | |
122 | CPPFLAGS="$BACKUP" | |
123 | return $RC | |
124 | } | |
125 | ||
126 | ## local defines | |
127 | PACKAGE_FEATURES="" | |
128 | ||
129 | # local options | |
130 | AC_ARG_ENABLE([fatal-warnings], | |
131 | [ --enable-fatal-warnings : enable fatal warnings. ], | |
132 | [ default="no" ]) | |
133 | ||
134 | AC_ARG_ENABLE([debug], | |
135 | [ --enable-debug : enable debug build. ], | |
136 | [ default="no" ]) | |
137 | ||
138 | AC_ARG_ENABLE([secure-build], | |
139 | [ --enable-secure-build : enable PIE/RELRO build. ], | |
140 | [], | |
141 | [enable_secure_build="yes"]) | |
142 | ||
c6548f40 JF |
143 | AC_ARG_ENABLE([user-flags], |
144 | [ --enable-user-flags : rely on user environment. ], | |
145 | [ default="no" ]) | |
146 | AM_CONDITIONAL(BUILD_USERFLAGS, test x$enable_user_flags = xyes) | |
147 | ||
9a1955a7 | 148 | AC_ARG_ENABLE([systemd], |
eae6806f | 149 | [ --enable-systemd : Build with libsystemd and install systemd service files],, |
9a1955a7 JF |
150 | [ enable_systemd="no" ]) |
151 | AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes) | |
152 | ||
153 | AC_ARG_WITH([initconfigdir], | |
154 | [AS_HELP_STRING([--with-initconfigdir=DIR], | |
155 | [configuration directory @<:@SYSCONFDIR/sysconfig@:>@])], | |
156 | [INITCONFIGDIR="$withval"], | |
157 | [INITCONFIGDIR='${sysconfdir}/sysconfig']) | |
158 | AC_SUBST([INITCONFIGDIR]) | |
159 | ||
160 | AC_ARG_WITH([initddir], | |
161 | [ --with-initddir=DIR : path to init script directory. ], | |
162 | [ INITDDIR="$withval" ], | |
163 | [ INITDDIR="$sysconfdir/init.d" ]) | |
164 | ||
165 | AC_ARG_WITH([systemddir], | |
166 | [ --with-systemddir=DIR : path to systemd unit files directory. ], | |
167 | [ SYSTEMDDIR="$withval" ], | |
e2c682e9 | 168 | [ SYSTEMDDIR="$systemddir" ]) |
9a1955a7 JF |
169 | |
170 | AC_ARG_ENABLE([qdevices], | |
eae6806f | 171 | [ --disable-qdevices : Quorum devices support ],, |
9a1955a7 JF |
172 | [ enable_qdevices="yes" ]) |
173 | AM_CONDITIONAL(BUILD_QDEVICES, test x$enable_qdevices = xyes) | |
174 | AC_ARG_ENABLE([qnetd], | |
eae6806f | 175 | [ --disable-qnetd : Quorum Net Daemon support ],, |
9a1955a7 JF |
176 | [ enable_qnetd="yes" ]) |
177 | AM_CONDITIONAL(BUILD_QNETD, test x$enable_qnetd = xyes) | |
eae6806f JF |
178 | AC_ARG_ENABLE([runautogen], |
179 | [ --enable-runautogen : run autogen.sh (RPM specfile)],, | |
180 | [ enable_runautogen="no" ]) | |
181 | AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes]) | |
9a1955a7 JF |
182 | |
183 | # *FLAGS handling goes here | |
184 | ||
185 | ENV_CFLAGS="$CFLAGS" | |
186 | ENV_CPPFLAGS="$CPPFLAGS" | |
187 | ENV_LDFLAGS="$LDFLAGS" | |
188 | ||
189 | # debug build stuff | |
190 | if test "x${enable_debug}" = xyes; then | |
191 | AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code]) | |
192 | OPT_CFLAGS="-O0" | |
193 | PACKAGE_FEATURES="$PACKAGE_FEATURES debug" | |
194 | else | |
195 | OPT_CFLAGS="-O3" | |
196 | fi | |
197 | ||
198 | # gdb flags | |
199 | if test "x${GCC}" = xyes; then | |
200 | GDB_FLAGS="-ggdb3" | |
201 | else | |
202 | GDB_FLAGS="-g" | |
203 | fi | |
204 | ||
205 | if test "x${enable_systemd}" = xyes; then | |
206 | PKG_CHECK_MODULES([libsystemd], [libsystemd]) | |
207 | AC_DEFINE([HAVE_LIBSYSTEMD], [1], [have systemd interface library]) | |
208 | PACKAGE_FEATURES="$PACKAGE_FEATURES systemd" | |
9a1955a7 JF |
209 | fi |
210 | if test "x${enable_qdevices}" = xyes; then | |
211 | PACKAGE_FEATURES="$PACKAGE_FEATURES qdevices" | |
212 | fi | |
213 | if test "x${enable_qnetd}" = xyes; then | |
214 | PACKAGE_FEATURES="$PACKAGE_FEATURES qnetd" | |
215 | fi | |
216 | ||
217 | # extra warnings | |
218 | EXTRA_WARNINGS="" | |
219 | ||
220 | WARNLIST=" | |
221 | all | |
222 | shadow | |
223 | missing-prototypes | |
224 | missing-declarations | |
225 | strict-prototypes | |
226 | declaration-after-statement | |
227 | pointer-arith | |
228 | write-strings | |
229 | cast-align | |
230 | bad-function-cast | |
231 | missing-format-attribute | |
232 | format=2 | |
233 | format-security | |
234 | format-nonliteral | |
235 | no-long-long | |
236 | unsigned-char | |
237 | gnu89-inline | |
238 | no-strict-aliasing | |
239 | " | |
240 | ||
241 | for j in $WARNLIST; do | |
242 | if cc_supports_flag -W$j; then | |
243 | EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j"; | |
244 | fi | |
245 | done | |
246 | ||
247 | if test "x${enable_fatal_warnings}" = xyes && \ | |
248 | cc_supports_flag -Werror ; then | |
249 | AC_MSG_NOTICE([Enabling Fatal Warnings (-Werror)]) | |
250 | WERROR_CFLAGS="-Werror" | |
251 | PACKAGE_FEATURES="$PACKAGE_FEATURES fatal-warnings" | |
252 | else | |
253 | WERROR_CFLAGS="" | |
254 | fi | |
255 | ||
c6548f40 JF |
256 | # don't add addtional cflags |
257 | if test "x${enable_user_flags}" = xyes; then | |
258 | OPT_CFLAGS="" | |
259 | GDB_FLAGS="" | |
260 | EXTRA_WARNINGS="" | |
261 | fi | |
262 | ||
9a1955a7 JF |
263 | if test "x${enable_secure_build}" = xyes; then |
264 | # stolen from apache configure snippet | |
265 | AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [ | |
266 | save_CFLAGS=$CFLAGS | |
267 | save_LDFLAGS=$LDFLAGS | |
268 | CFLAGS="$CFLAGS -fPIE" | |
269 | LDFLAGS="$LDFLAGS -pie" | |
270 | AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], | |
271 | [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no], [ap_cv_cc_pie=yes]) | |
272 | CFLAGS=$save_CFLAGS | |
273 | LDFLAGS=$save_LDFLAGS | |
274 | ]) | |
275 | if test "$ap_cv_cc_pie" = "yes"; then | |
276 | SEC_FLAGS="$SEC_FLAGS -fPIE" | |
277 | SEC_LDFLAGS="$SEC_LDFLAGS -pie" | |
278 | PACKAGE_FEATURES="$PACKAGE_FEATURES pie" | |
279 | fi | |
280 | ||
281 | # similar to above | |
282 | AC_CACHE_CHECK([whether $CC accepts RELRO flags], [ap_cv_cc_relro], [ | |
283 | save_LDFLAGS=$LDFLAGS | |
284 | LDFLAGS="$LDFLAGS -Wl,-z,relro" | |
285 | AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], | |
286 | [ap_cv_cc_relro=yes], [ap_cv_cc_relro=no], [ap_cv_cc_relro=yes]) | |
287 | LDFLAGS=$save_LDFLAGS | |
288 | ]) | |
289 | if test "$ap_cv_cc_relro" = "yes"; then | |
290 | SEC_LDFLAGS="$SEC_LDFLAGS -Wl,-z,relro" | |
291 | PACKAGE_FEATURES="$PACKAGE_FEATURES relro" | |
292 | fi | |
293 | ||
294 | AC_CACHE_CHECK([whether $CC accepts BINDNOW flags], [ap_cv_cc_bindnow], [ | |
295 | save_LDFLAGS=$LDFLAGS | |
296 | LDFLAGS="$LDFLAGS -Wl,-z,now" | |
297 | AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], | |
298 | [ap_cv_cc_bindnow=yes], [ap_cv_cc_bindnow=no], [ap_cv_cc_bindnow=yes]) | |
299 | LDFLAGS=$save_LDFLAGS | |
300 | ]) | |
301 | if test "$ap_cv_cc_bindnow" = "yes"; then | |
302 | SEC_LDFLAGS="$SEC_LDFLAGS -Wl,-z,now" | |
303 | PACKAGE_FEATURES="$PACKAGE_FEATURES bindnow" | |
304 | fi | |
305 | fi | |
306 | ||
307 | AC_CACHE_CHECK([whether $CC accepts "--as-needed"], [ap_cv_cc_as_needed], [ | |
308 | save_LDFLAGS=$LDFLAGS | |
309 | LDFLAGS="$LDFLAGS -Wl,--as-needed" | |
310 | AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], | |
311 | [ap_cv_cc_as_needed=yes], [ap_cv_cc_as_needed=no], [ap_cv_cc_as_needed=yes]) | |
312 | LDFLAGS=$save_LDFLAGS | |
313 | ]) | |
314 | ||
315 | # define global include dirs | |
316 | INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include" | |
317 | ||
318 | # final build of *FLAGS | |
319 | CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \ | |
320 | $EXTRA_WARNINGS \ | |
321 | $WERROR_CFLAGS" | |
322 | CPPFLAGS="$ENV_CPPFLAGS $INCLUDE_DIRS" | |
323 | LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS" | |
324 | ||
325 | if test "$ap_cv_cc_as_needed" = "yes"; then | |
326 | LDFLAGS="$LDFLAGS -Wl,--as-needed" | |
327 | fi | |
328 | ||
329 | # substitute what we need: | |
330 | AC_SUBST([BASHPATH]) | |
331 | AC_SUBST([INITDDIR]) | |
332 | AC_SUBST([SYSTEMDDIR]) | |
333 | AC_SUBST([LOGDIR]) | |
334 | AC_SUBST([LOGROTATEDIR]) | |
335 | ||
336 | AC_SUBST([SOMAJOR]) | |
337 | AC_SUBST([SOMINOR]) | |
338 | AC_SUBST([SOMICRO]) | |
339 | AC_SUBST([SONAME]) | |
340 | ||
341 | AC_SUBST([NSS_LDFLAGS]) | |
342 | ||
343 | AM_CONDITIONAL(BUILD_HTML_DOCS, test -n "${GROFF}") | |
344 | ||
345 | AC_DEFINE_UNQUOTED([LOCALSTATEDIR], "$(eval echo ${localstatedir})", [localstate directory]) | |
346 | ||
347 | COROSYSCONFDIR=${sysconfdir}/corosync | |
348 | AC_SUBST([COROSYSCONFDIR]) | |
349 | AC_DEFINE_UNQUOTED([COROSYSCONFDIR], "$(eval echo ${COROSYSCONFDIR})", [corosync-qdevice config directory]) | |
350 | ||
351 | AC_DEFINE_UNQUOTED([PACKAGE_FEATURES], "${PACKAGE_FEATURES}", [corosync-qdevice built-in features]) | |
352 | ||
353 | AC_OUTPUT | |
354 | ||
355 | AC_MSG_RESULT([]) | |
356 | AC_MSG_RESULT([$PACKAGE configuration:]) | |
357 | AC_MSG_RESULT([ Version = ${VERSION}]) | |
358 | AC_MSG_RESULT([ Prefix = ${prefix}]) | |
359 | AC_MSG_RESULT([ Executables = ${sbindir}]) | |
360 | AC_MSG_RESULT([ Man pages = ${mandir}]) | |
361 | AC_MSG_RESULT([ Doc dir = ${docdir}]) | |
362 | AC_MSG_RESULT([ Libraries = ${libdir}]) | |
363 | AC_MSG_RESULT([ Header files = ${includedir}]) | |
364 | AC_MSG_RESULT([ Arch-independent files = ${datadir}]) | |
365 | AC_MSG_RESULT([ State information = ${localstatedir}]) | |
366 | AC_MSG_RESULT([ System configuration = ${sysconfdir}]) | |
367 | AC_MSG_RESULT([ System init.d directory = ${INITDDIR}]) | |
368 | AC_MSG_RESULT([ System systemd directory = ${SYSTEMDDIR}]) | |
369 | AC_MSG_RESULT([ Log directory = ${LOGDIR}]) | |
370 | AC_MSG_RESULT([ Log rotate directory = ${LOGROTATEDIR}]) | |
371 | AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}]) | |
372 | AC_MSG_RESULT([ init config directory = ${INITCONFIGDIR}]) | |
373 | AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}]) | |
374 | AC_MSG_RESULT([]) | |
375 | AC_MSG_RESULT([$PACKAGE build info:]) | |
376 | AC_MSG_RESULT([ Default optimization = ${OPT_CFLAGS}]) | |
c6548f40 | 377 | AC_MSG_RESULT([ Default debug options = ${GDB_FLAGS}]) |
9a1955a7 JF |
378 | AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}]) |
379 | AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}]) | |
380 | AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}]) | |
381 | AC_MSG_RESULT([ Env. defined LDFLAGS = ${ENV_LDFLAGS}]) | |
382 | AC_MSG_RESULT([ Fatal War. CFLAGS = ${WERROR_CFLAGS}]) | |
383 | AC_MSG_RESULT([ Final CFLAGS = ${CFLAGS}]) | |
384 | AC_MSG_RESULT([ Final CPPFLAGS = ${CPPFLAGS}]) | |
385 | AC_MSG_RESULT([ Final LDFLAGS = ${LDFLAGS}]) |