configure.in 15 KB

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