configure.in 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. dnl
  2. dnl autoconf for Pacemaker
  3. dnl
  4. dnl License: GNU General Public License (GPL)
  5. dnl ===============================================
  6. dnl Bootstrap
  7. dnl ===============================================
  8. dnl Initialiase, with sanity check of a unique file in the hierarchy
  9. AC_INIT(configure.in)
  10. AC_PREREQ(2.53)
  11. AC_CONFIG_AUX_DIR(.)
  12. AC_CANONICAL_HOST
  13. AC_MSG_NOTICE(Host: $host)
  14. AC_MSG_NOTICE(Host OS: $host_os)
  15. AC_MSG_NOTICE(Host CPU: $host_cpu)
  16. AC_MSG_NOTICE(Host Vendor: $host_vendor)
  17. dnl Where #defines go (e.g. `AC_CHECK_HEADERS' below)
  18. dnl
  19. dnl Internal header: include/corosync/config.h
  20. dnl - Contains ALL defines
  21. dnl - include/config.h.in is generated automatically by autoheader
  22. dnl - NOT to be included in any header files except lha_internal.h
  23. dnl (which is also not to be included in any other header files)
  24. dnl
  25. dnl External header: include/corosync/cs_config.h
  26. dnl - Contains a subset of defines checked here
  27. dnl - Manually edit include/corosync/cs_config.h.in to have configure include
  28. dnl new defines
  29. dnl - Should not include HAVE_* defines
  30. dnl - Safe to include anywhere
  31. AM_CONFIG_HEADER(include/corosync/config.h include/corosync/cs_config.h)
  32. ALL_LINGUAS="en fr"
  33. AC_ARG_WITH(version,
  34. [ --with-version=name Override package version (if you're a packager needing to pretend) ],
  35. [ CS_VERSION="$withval" ],
  36. [ CS_VERSION="" ],
  37. )
  38. DTD_VERSION=1.0
  39. if test -z "$CS_VERSION" ; then
  40. CS_VERSION="1.0.0"
  41. fi
  42. PKG_NAME=corosync
  43. PKG_FEATURES=""
  44. AM_INIT_AUTOMAKE($PKG_NAME, $CS_VERSION)
  45. AC_DEFINE_UNQUOTED(CS_VERSION, "$CS_VERSION", Current pacemaker version)
  46. AC_SUBST(PKG_NAME)
  47. LDD=ldd
  48. dnl Which C compiler?
  49. dnl Defaults to GNU C compiler if available.
  50. dnl Always tries to set the compiler to ANSI C via options (AM)
  51. dnl Can force other with environment variable "CC".
  52. AC_PROG_CC
  53. AC_PROG_CC_STDC
  54. AM_PROG_CC_C_O
  55. AC_PROG_RANLIB
  56. dnl ===============================================
  57. dnl Helpers
  58. dnl ===============================================
  59. cc_supports_flag() {
  60. AC_MSG_CHECKING(whether $CC supports "$@")
  61. Cfile=/tmp/foo${$}
  62. touch ${Cfile}.c
  63. $CC -c "$@" ${Cfile}.c -o ${Cfile}.o >/dev/null 2>&1
  64. rc=$?
  65. rm -f ${Cfile}.c ${Cfile}.o
  66. case $rc in
  67. 0) AC_MSG_RESULT(yes);;
  68. *) AC_MSG_RESULT(no);;
  69. esac
  70. return $rc
  71. }
  72. extract_header_define() {
  73. AC_MSG_CHECKING(for $2 in $1)
  74. Cfile=/tmp/extract_define.$2.${$}
  75. printf "#include <stdio.h>\n" > ${Cfile}.c
  76. printf "#include <%s>\n" $1 >> ${Cfile}.c
  77. printf "int main(int argc, char **argv) { printf(\"%%s\", %s); return 0; }\n" $2 >> ${Cfile}.c
  78. $CC $CFLAGS ${Cfile}.c -o ${Cfile}
  79. value=`${Cfile}`
  80. AC_MSG_RESULT($value)
  81. printf $value
  82. rm -f ${Cfile}.c ${Cfile}
  83. }
  84. check_for_type() {
  85. type="$1"
  86. headers=""
  87. shift
  88. for arg
  89. do
  90. headers="${headers}${arg}
  91. "
  92. done
  93. program="if ((${type} *) 0) return 0;
  94. if (sizeof(${type})) return 0;
  95. return 0;"
  96. have="HAVE_`echo "$type" | tr ' ' '_' | dd conv=ucase 2>/dev/null`"
  97. varhave="heartbeat_cv_$have"
  98. AC_CACHE_CHECK([for type $type ],$varhave,[
  99. AC_TRY_COMPILE([$headers], [$program], eval $varhave=yes, eval $varhave=no
  100. , eval $varhave=cross)
  101. ])
  102. if test x"`eval echo '${'$varhave'}'`" = xyes; then
  103. return 0
  104. fi
  105. return 1
  106. }
  107. check_for_type_member() {
  108. type="$1"
  109. member="$2"
  110. headers=""
  111. shift
  112. shift
  113. for arg
  114. do
  115. headers="${headers}${arg}
  116. "
  117. done
  118. program="${type} foo;
  119. if ((${type} *) 0) return 0;
  120. if (sizeof(${type})) return 0;
  121. if (sizeof(foo)) return 0;
  122. (void*)foo.${member};
  123. return 0;"
  124. have="HAVE_`echo "$type" | tr ' ' '_' | dd conv=ucase 2>/dev/null`"
  125. varhave="heartbeat_cv_$have"
  126. AC_CACHE_CHECK([for type $type ],$varhave,[
  127. AC_TRY_COMPILE([$headers], [$program], eval $varhave=yes, eval $varhave=no
  128. , eval $varhave=cross)
  129. ])
  130. if test x"`eval echo '${'$varhave'}'`" = xyes; then
  131. return 0
  132. fi
  133. return 1
  134. }
  135. dnl ===============================================
  136. dnl Configure Options
  137. dnl ===============================================
  138. AC_ARG_ENABLE([ansi],
  139. [ --enable-ansi force GCC to compile to ANSI/ANSI standard for older compilers.
  140. [default=no]])
  141. AC_ARG_ENABLE([fatal-warnings],
  142. [ --enable-fatal-warnings very pedantic and fatal warnings for gcc
  143. [default=no]])
  144. AC_ARG_WITH(lcrso-dir,
  145. [ --with-lcrso-dir=DIR Corosync lcrso files. ],
  146. [ LCRSODIR="$withval" ])
  147. AC_ARG_ENABLE(static,
  148. [ --enable-static Dont produce dynamic libraries. ],
  149. [ default="no" ])
  150. AC_ARG_ENABLE(coverage,
  151. [ --enable-coverage Coverage analysis of the codebase. ],
  152. [ default="no" ])
  153. dnl ===============================================
  154. dnl General Processing
  155. dnl ===============================================
  156. CC_IN_CONFIGURE=yes
  157. export CC_IN_CONFIGURE
  158. AC_MSG_NOTICE(Sanitizing prefix: ${prefix})
  159. case $prefix in
  160. NONE) prefix=/usr;;
  161. esac
  162. AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix})
  163. case $exec_prefix in
  164. dnl For consistency with Heartbeat, map NONE->$prefix
  165. NONE) exec_prefix=$prefix;;
  166. prefix) exec_prefix=$prefix;;
  167. esac
  168. AC_MSG_NOTICE(Sanitizing ais_prefix: ${AISPREFIX})
  169. case $AISPREFIX in
  170. dnl For consistency with Heartbeat, map NONE->$prefix
  171. NONE) AISPREFIX=$prefix;;
  172. prefix) AISPREFIX=$prefix;;
  173. esac
  174. AC_MSG_NOTICE(Sanitizing libdir: ${libdir})
  175. case $libdir in
  176. dnl For consistency with Heartbeat, map NONE->$prefix
  177. prefix|NONE|*exec_prefix*)
  178. AC_MSG_CHECKING(which lib directory to use)
  179. for aDir in lib64 lib
  180. do
  181. trydir="${exec_prefix}/${aDir}"
  182. if
  183. test -d ${trydir}
  184. then
  185. libdir=${trydir}
  186. break
  187. fi
  188. done
  189. AC_MSG_RESULT($libdir);
  190. ;;
  191. esac
  192. dnl Expand autoconf variables so that we dont end up with '${prefix}'
  193. dnl in #defines and python scripts
  194. dnl NOTE: Autoconf deliberately leaves them unexpanded to allow
  195. dnl make exec_prefix=/foo install
  196. dnl No longer being able to do this seems like no great loss to me...
  197. eval prefix="`eval echo ${prefix}`"
  198. eval exec_prefix="`eval echo ${exec_prefix}`"
  199. eval bindir="`eval echo ${bindir}`"
  200. eval sbindir="`eval echo ${sbindir}`"
  201. eval libexecdir="`eval echo ${libexecdir}`"
  202. eval datadir="`eval echo ${datadir}`"
  203. eval sysconfdir="`eval echo ${sysconfdir}`"
  204. eval sharedstatedir="`eval echo ${sharedstatedir}`"
  205. eval localstatedir="`eval echo ${localstatedir}`"
  206. eval libdir="`eval echo ${libdir}`"
  207. eval includedir="`eval echo ${includedir}`"
  208. eval oldincludedir="`eval echo ${oldincludedir}`"
  209. eval infodir="`eval echo ${infodir}`"
  210. eval mandir="`eval echo ${mandir}`"
  211. eval docdir="`eval echo ${docdir}`"
  212. for j in prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir \
  213. sharedstatedir localstatedir libdir includedir oldincludedir infodir \
  214. mandir docdir
  215. do
  216. dirname=`eval echo '${'${j}'}'`
  217. if
  218. test ! -d "$dirname"
  219. then
  220. AC_MSG_WARN([$j directory ($dirname) does not exist!])
  221. fi
  222. done
  223. dnl This OS-based decision-making is poor autotools practice;
  224. dnl feature-based mechanisms are strongly preferred.
  225. dnl
  226. dnl So keep this section to a bare minimum; regard as a "necessary evil".
  227. ON_DARWIN=0
  228. DYFLAGS=
  229. case "$host_os" in
  230. *bsd*) LIBS="-L/usr/local/lib"
  231. CPPFLAGS="$CPPFLAGS -I/usr/local/include"
  232. AC_DEFINE_UNQUOTED(COROSYNC_BSD, 1, Compiling for BSD platform)
  233. DYFLAGS="$DYFLAGS -export-dynamic"
  234. ;;
  235. *solaris*)
  236. AC_DEFINE_UNQUOTED(COROSYNC_SOLARIS, 1, Compiling for Solaris platform)
  237. AC_DEFINE_UNQUOTED(TS_CLASS, 1, Prevent being scheduled RR)
  238. CFLAGS="$CFLAGS -D_REENTRANT"
  239. LDFLAGS="$LDFLAGS -Wl,--export-dynamic -Wl,-rpath-link=/usr/lib"
  240. ;;
  241. *linux*)
  242. AC_DEFINE_UNQUOTED(COROSYNC_LINUX, 1, Compiling for Linux platform)
  243. DYFLAGS="$DYFLAGS -rdynamic"
  244. ;;
  245. darwin*)
  246. ON_DARWIN=1
  247. AC_DEFINE_UNQUOTED(COROSYNC_DARWIN, 1, Compiling for Darwin platform)
  248. # LIBS="$LIBS -L${prefix}/lib"
  249. # CFLAGS="$CFLAGS -I${prefix}/include"
  250. ;;
  251. esac
  252. AC_SUBST(DYFLAGS)
  253. case "$host_cpu" in
  254. ppc64|powerpc64)
  255. case $CFLAGS in
  256. *powerpc64*) ;;
  257. *) if test "$GCC" = yes; then
  258. CFLAGS="$CFLAGS -m64"
  259. fi ;;
  260. esac
  261. esac
  262. AC_MSG_CHECKING(which format is needed to print uint64_t)
  263. case "$host_cpu" in
  264. s390x)U64T="%lu";;
  265. *64*) U64T="%lu";;
  266. *) U64T="%llu";;
  267. esac
  268. AC_MSG_RESULT($U64T)
  269. AC_DEFINE_UNQUOTED(U64T, "$U64T", Correct printf format for logging uint64_t)
  270. dnl Variables needed for substitution
  271. case x$LCRSODIR in
  272. x) LCRSODIR=$libexecdir/corosync/lcrso;;
  273. esac
  274. AC_DEFINE_UNQUOTED(LCRSODIR, "$LCRSODIR", Location of Corosync lcrso plugins)
  275. AC_SUBST(LCRSODIR)
  276. dnl *************************************************************************
  277. PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
  278. export PATH
  279. dnl ===============================================
  280. dnl Program Paths - Most of these need to go away
  281. dnl ===============================================
  282. AC_CHECK_PROGS(MAKE, gmake make)
  283. AC_PATH_PROGS(PKGCONFIG, pkg-config)
  284. AC_PATH_PROGS(SSH, ssh, /usr/bin/ssh)
  285. if test x"${MAKE}" = x""; then
  286. AC_MSG_ERROR(You need (g)make installed in order to build ${PKG_NAME})
  287. fi
  288. AC_SUBST(MAKE)
  289. AC_SUBST(CC)
  290. dnl ===============================================
  291. dnl Libraries
  292. dnl ===============================================
  293. AC_CHECK_LIB(dl, dlopen)
  294. AC_CHECK_LIB(nsl, t_open)
  295. AC_CHECK_LIB(socket, socket)
  296. AC_CHECK_LIB(c, getpeereid)
  297. AC_CHECK_LIB(rt, sched_getscheduler)
  298. AC_CHECK_LIB(pthread, pthread_create)
  299. dnl if test x"${PKGCONFIG}" = x""; then
  300. dnl AC_MSG_ERROR(You need pkgconfig installed in order to build ${PKG_NAME})
  301. dnl fi
  302. dnl
  303. dnl if test $PKGCONFIG --exists $GPKGNAME; then
  304. dnl CFLAGS="$CFLAGS `$GLIBCONFIG --cflags`"
  305. dnl LIBS="$LIBS `$GLIBCONFIG --libs`"
  306. dnl fi
  307. dnl ===============================================
  308. dnl Functions
  309. dnl ===============================================
  310. AC_CHECK_FUNCS(alphasort)
  311. AC_CHECK_FUNCS(scandir)
  312. AC_CHECK_FUNCS(getpeerucred)
  313. dnl ===============================================
  314. dnl Headers
  315. dnl ===============================================
  316. AC_HEADER_STDC
  317. AC_CHECK_HEADERS(sys/sockio.h)
  318. AC_CHECK_HEADERS(sys/types.h)
  319. AC_CHECK_HEADERS(sys/socket.h)
  320. AC_CHECK_HEADERS(malloc.h)
  321. AC_CHECK_HEADERS(getopt.h)
  322. dnl ===============================================
  323. dnl Typedefs
  324. dnl ===============================================
  325. dnl Check syslog.h for 'facilitynames' table
  326. dnl
  327. AC_CACHE_CHECK([for facilitynames in syslog.h],ac_cv_HAVE_SYSLOG_FACILITYNAMES,[
  328. AC_TRY_COMPILE([
  329. #define SYSLOG_NAMES
  330. #include <stdlib.h>
  331. #include <syslog.h>
  332. ],
  333. [ void *fnames; fnames = facilitynames; ],
  334. ac_cv_HAVE_SYSLOG_FACILITYNAMES=yes,ac_cv_HAVE_SYSLOG_FACILITYNAMES=no,ac_cv_HAVE_SYSLOG_FACILITYNAMES=cross)])
  335. if test x"$ac_cv_HAVE_SYSLOG_FACILITYNAMES" = x"yes"; then
  336. AC_DEFINE(HAVE_SYSLOG_FACILITYNAMES,1,[ ])
  337. fi
  338. dnl ===============================================
  339. dnl Compiler Characteristics
  340. dnl ===============================================
  341. dnl if not known on this system, #define size_t unsigned
  342. AC_TYPE_SIZE_T
  343. AC_CHECK_SIZEOF(char)
  344. AC_CHECK_SIZEOF(short)
  345. AC_CHECK_SIZEOF(int)
  346. AC_CHECK_SIZEOF(long)
  347. AC_CHECK_SIZEOF(long long)
  348. AC_C_STRINGIZE
  349. CC_WARNINGS=""
  350. dnl AC_CHECK_FUNCS(fcntl)
  351. dnl
  352. dnl Make sure that CFLAGS is not exported. If the user did
  353. dnl not have CFLAGS in their environment then this should have
  354. dnl no effect. However if CFLAGS was exported from the user's
  355. dnl environment, then the new CFLAGS will also be exported
  356. dnl to sub processes.
  357. dnl
  358. if export | fgrep " CFLAGS=" > /dev/null; then
  359. export -n CFLAGS || true # We don't want to bomb out if this fails
  360. fi
  361. if test "$GCC" != yes; then
  362. CFLAGS="$CFLAGS -g"
  363. else
  364. CFLAGS="$CFLAGS -ggdb3"
  365. EXTRA_WARNINGS=""
  366. # We had to eliminate -Wnested-externs because of libtool changes
  367. WARNLIST="all missing-prototypes
  368. missing-declarations
  369. strict-prototypes
  370. declaration-after-statement
  371. pointer-arith
  372. write-strings
  373. cast-qual cast-align
  374. bad-function-cast
  375. missing-format-attribute
  376. format=2
  377. format-security
  378. format-nonliteral
  379. no-long-long
  380. unsigned-char
  381. gnu89-inline
  382. no-strict-aliasing"
  383. for j in $WARNLIST
  384. do
  385. if
  386. cc_supports_flag -W$j
  387. then
  388. EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j"
  389. fi
  390. done
  391. dnl Add any system specific options here.
  392. case "$host_os" in
  393. *linux*|*bsd*)
  394. if test "${enable_fatal_warnings}" = "unknown"; then
  395. enable_fatal_warnings=yes
  396. fi
  397. ;;
  398. *solaris*)
  399. ;;
  400. esac
  401. if test "x${enable_coverage}" = xyes && cc_supports_flag -ftest-coverage && cc_supports_flag -fprofile-arcs ; then
  402. echo "Enabling Coverage"
  403. CFLAGS="$CFLAGS -O0 -g -ftest-coverage -fprofile-arcs"
  404. LDFLAGS="$LDFLAGS -g -ftest-coverage -fprofile-arcs"
  405. enable_static=yes
  406. PKG_FEATURES="$PKG_FEATURES coverage"
  407. fi
  408. if test "x${enable_ansi}" = xyes && cc_supports_flag -std=iso9899:199409 ; then
  409. echo "Enabling ANSI Compatibility"
  410. ANSI="-ansi -D_GNU_SOURCE -DANSI_ONLY"
  411. PKG_FEATURES="$PKG_FEATURES ansi"
  412. fi
  413. if test "x${enable_fatal_warnings}" = xyes && cc_supports_flag -Werror ; then
  414. echo "Enabling Fatal Warnings (-Werror)"
  415. FATAL_WARNINGS="-Werror"
  416. PKG_FEATURES="$PKG_FEATURES fatal-warnings"
  417. fi
  418. CC_WARNINGS="$EXTRA_WARNINGS $FATAL_WARNINGS $ANSI"
  419. NON_FATAL_CC_WARNINGS="$EXTRA_WARNINGS"
  420. fi
  421. dnl AC_SUBST(CC_WARNINGS)
  422. NON_FATAL_CFLAGS="$CFLAGS $NON_FATAL_CC_WARNINGS"
  423. AC_SUBST(NON_FATAL_CFLAGS)
  424. dnl
  425. dnl We reset CFLAGS to include our warnings *after* all function
  426. dnl checking goes on, so that our warning flags don't keep the
  427. dnl AC_*FUNCS() calls above from working. In particular, -Werror will
  428. dnl *always* cause us troubles if we set it before here.
  429. dnl
  430. dnl
  431. CFLAGS="$CFLAGS $CC_WARNINGS"
  432. AC_SUBST(CFLAGS)
  433. dnl This is useful for use in Makefiles that need to remove one specific flag
  434. CFLAGS_COPY="$CFLAGS"
  435. AC_SUBST(CFLAGS_COPY)
  436. AM_CONDITIONAL(BUILD_DARWIN, test $ON_DARWIN = 1)
  437. AM_CONDITIONAL(BUILD_DYNAMIC, test "x${enable_static}" != xyes)
  438. if test "x${enable_static}" != xyes; then
  439. PKG_FEATURES="$PKG_FEATURES static"
  440. fi
  441. LINT_FLAGS="-weak -unrecog +posixlib +ignoresigns -fcnuse -badflag -D__gnuc_va_list=va_list -D__attribute\(x\)="
  442. AC_SUBST(LINT_FLAGS)
  443. dnl ************************************************************************
  444. AC_SUBST(LOCALE)
  445. dnl The Makefiles and shell scripts we output
  446. AC_CONFIG_FILES(Makefile \
  447. include/Makefile \
  448. lib/Makefile \
  449. lcr/Makefile \
  450. exec/Makefile \
  451. test/Makefile \
  452. tools/Makefile \
  453. services/Makefile \
  454. )
  455. dnl Now process the entire list of files added by previous
  456. dnl calls to AC_CONFIG_FILES()
  457. AC_OUTPUT()
  458. dnl *****************
  459. dnl Configure summary
  460. dnl *****************
  461. AC_MSG_RESULT([])
  462. AC_MSG_RESULT([$PACKAGE configuration:])
  463. AC_MSG_RESULT([ Version = ${VERSION}])
  464. AC_MSG_RESULT([ Prefix = ${prefix}])
  465. AC_MSG_RESULT([ Executables = ${sbindir}])
  466. AC_MSG_RESULT([ Man pages = ${mandir}])
  467. AC_MSG_RESULT([ Libraries = ${libdir}])
  468. AC_MSG_RESULT([ Header files = ${includedir}])
  469. AC_MSG_RESULT([ Arch-independent files = ${datadir}])
  470. AC_MSG_RESULT([ State information = ${localstatedir}])
  471. AC_MSG_RESULT([ System configuration = ${sysconfdir}])
  472. AC_MSG_RESULT([ Features =${PKG_FEATURES}])
  473. AC_MSG_RESULT([ CC_WARNINGS = ${CC_WARNINGS}])
  474. AC_MSG_RESULT([ Mangled CFLAGS = ${CFLAGS}])
  475. AC_MSG_RESULT([ Libraries = ${LIBS}])