configure.in 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. AC_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(coverage,
  157. [ --enable-coverage Coverage analysis of the codebase. ],
  158. [ default="no" ])
  159. AC_ARG_ENABLE(debug,
  160. [ --enable-debug Enable debug build. ],
  161. [ default="no" ])
  162. dnl ===============================================
  163. dnl General Processing
  164. dnl ===============================================
  165. AC_MSG_NOTICE(Sanitizing prefix: ${prefix})
  166. case $prefix in
  167. NONE) prefix=/usr;;
  168. esac
  169. AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix})
  170. case $exec_prefix in
  171. dnl For consistency with Heartbeat, map NONE->$prefix
  172. NONE) exec_prefix=$prefix;;
  173. prefix) exec_prefix=$prefix;;
  174. esac
  175. AC_MSG_NOTICE(Sanitizing libdir: ${libdir})
  176. case $libdir in
  177. dnl For consistency with Heartbeat, map NONE->$prefix
  178. prefix|NONE|*exec_prefix*)
  179. AC_MSG_CHECKING(which lib directory to use)
  180. for aDir in lib64 lib
  181. do
  182. trydir="${exec_prefix}/${aDir}"
  183. if
  184. test -d ${trydir}
  185. then
  186. libdir=${trydir}
  187. break
  188. fi
  189. done
  190. AC_MSG_RESULT($libdir);
  191. ;;
  192. esac
  193. dnl Expand autoconf variables so that we dont end up with '${prefix}'
  194. dnl in #defines and python scripts
  195. dnl NOTE: Autoconf deliberately leaves them unexpanded to allow
  196. dnl make exec_prefix=/foo install
  197. dnl No longer being able to do this seems like no great loss to me...
  198. eval prefix="`eval echo ${prefix}`"
  199. eval exec_prefix="`eval echo ${exec_prefix}`"
  200. eval bindir="`eval echo ${bindir}`"
  201. eval sbindir="`eval echo ${sbindir}`"
  202. eval libexecdir="`eval echo ${libexecdir}`"
  203. eval datadir="`eval echo ${datadir}`"
  204. eval sysconfdir="`eval echo ${sysconfdir}`"
  205. eval sharedstatedir="`eval echo ${sharedstatedir}`"
  206. eval localstatedir="`eval echo ${localstatedir}`"
  207. eval libdir="`eval echo ${libdir}`"
  208. eval includedir="`eval echo ${includedir}`"
  209. eval oldincludedir="`eval echo ${oldincludedir}`"
  210. eval infodir="`eval echo ${infodir}`"
  211. eval mandir="`eval echo ${mandir}`"
  212. eval docdir="`eval echo ${docdir}`"
  213. for j in prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir \
  214. sharedstatedir localstatedir libdir includedir oldincludedir infodir \
  215. mandir docdir
  216. do
  217. dirname=`eval echo '${'${j}'}'`
  218. if
  219. test ! -d "$dirname"
  220. then
  221. AC_MSG_WARN([$j directory ($dirname) does not exist!])
  222. fi
  223. done
  224. dnl debug build stuff
  225. if test "x${enable_debug}" = xyes; then
  226. echo Enabled Debug Build
  227. PKG_FEATURES="$PKG_FEATURES debug"
  228. CFLAGS="$CFLAGS -O0"
  229. AC_DEFINE_UNQUOTED(DEBUG, 1, Compiling Debugging code)
  230. else
  231. echo Enabled Standard Build
  232. CFLAGS="$CFLAGS -O3"
  233. fi
  234. dnl This OS-based decision-making is poor autotools practice;
  235. dnl feature-based mechanisms are strongly preferred.
  236. dnl
  237. dnl So keep this section to a bare minimum; regard as a "necessary evil".
  238. ON_DARWIN=0
  239. DYFLAGS=
  240. case "$host_os" in
  241. *bsd*)
  242. AC_DEFINE_UNQUOTED(COROSYNC_BSD, 1, Compiling for BSD platform)
  243. CFLAGS="$CFLAGS -I/usr/local/include"
  244. LD_FLAGS="$LD_FLAGS -L/usr/local/lib"
  245. DYFLAGS="$DYFLAGS -export-dynamic"
  246. ;;
  247. *solaris*)
  248. AC_DEFINE_UNQUOTED(COROSYNC_SOLARIS, 1, Compiling for Solaris platform)
  249. AC_DEFINE_UNQUOTED(TS_CLASS, 1, Prevent being scheduled RR)
  250. CFLAGS="$CFLAGS -D_REENTRANT"
  251. LDFLAGS="$LDFLAGS -Wl,--export-dynamic -Wl,-rpath-link=/usr/lib"
  252. ;;
  253. *linux*)
  254. AC_DEFINE_UNQUOTED(COROSYNC_LINUX, 1, Compiling for Linux platform)
  255. DYFLAGS="$DYFLAGS -rdynamic"
  256. ;;
  257. darwin*)
  258. ON_DARWIN=1
  259. AC_DEFINE_UNQUOTED(COROSYNC_DARWIN, 1, Compiling for Darwin platform)
  260. ;;
  261. esac
  262. AC_SUBST(DYFLAGS)
  263. AC_MSG_CHECKING(which format is needed to print uint64_t)
  264. case "$host_cpu" in
  265. s390x)U64T="%lu";;
  266. *64*) U64T="%lu";;
  267. *) U64T="%llu";;
  268. esac
  269. AC_MSG_RESULT($U64T)
  270. AC_DEFINE_UNQUOTED(U64T, "$U64T", Correct printf format for logging uint64_t)
  271. dnl Variables needed for substitution
  272. case x$LCRSODIR in
  273. x) LCRSODIR=$libexecdir/lcrso;;
  274. esac
  275. AC_DEFINE_UNQUOTED(LCRSODIR, "$LCRSODIR", Location of Corosync lcrso plugins)
  276. AC_SUBST(LCRSODIR)
  277. dnl *************************************************************************
  278. PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
  279. export PATH
  280. dnl ===============================================
  281. dnl Program Paths - Most of these need to go away
  282. dnl ===============================================
  283. AC_CHECK_PROGS(MAKE, gmake make)
  284. AC_PATH_PROGS(PKGCONFIG, pkg-config)
  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 -ggdb3"
  363. EXTRA_WARNINGS=""
  364. # We had to eliminate -Wnested-externs because of libtool changes
  365. WARNLIST="all missing-prototypes
  366. missing-declarations
  367. strict-prototypes
  368. declaration-after-statement
  369. pointer-arith
  370. write-strings
  371. cast-qual cast-align
  372. bad-function-cast
  373. missing-format-attribute
  374. format=2
  375. format-security
  376. format-nonliteral
  377. no-long-long
  378. unsigned-char
  379. gnu89-inline
  380. no-strict-aliasing"
  381. for j in $WARNLIST
  382. do
  383. if
  384. cc_supports_flag -W$j
  385. then
  386. EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j"
  387. fi
  388. done
  389. dnl Add any system specific options here.
  390. case "$host_os" in
  391. *linux*|*bsd*)
  392. if test "${enable_fatal_warnings}" = "unknown"; then
  393. enable_fatal_warnings=yes
  394. fi
  395. ;;
  396. *solaris*)
  397. ;;
  398. esac
  399. if test "x${enable_coverage}" = xyes && cc_supports_flag -ftest-coverage && cc_supports_flag -fprofile-arcs ; then
  400. echo "Enabling Coverage"
  401. CFLAGS="$CFLAGS -O0 -g -ftest-coverage -fprofile-arcs"
  402. LDFLAGS="$LDFLAGS -g -ftest-coverage -fprofile-arcs"
  403. PKG_FEATURES="$PKG_FEATURES coverage"
  404. fi
  405. if test "x${enable_ansi}" = xyes && cc_supports_flag -std=iso9899:199409 ; then
  406. echo "Enabling ANSI Compatibility"
  407. ANSI="-ansi -D_GNU_SOURCE -DANSI_ONLY"
  408. PKG_FEATURES="$PKG_FEATURES ansi"
  409. fi
  410. if test "x${enable_fatal_warnings}" = xyes && cc_supports_flag -Werror ; then
  411. echo "Enabling Fatal Warnings (-Werror)"
  412. FATAL_WARNINGS="-Werror"
  413. PKG_FEATURES="$PKG_FEATURES fatal-warnings"
  414. fi
  415. CC_WARNINGS="$EXTRA_WARNINGS $FATAL_WARNINGS $ANSI"
  416. NON_FATAL_CC_WARNINGS="$EXTRA_WARNINGS"
  417. fi
  418. dnl AC_SUBST(CC_WARNINGS)
  419. NON_FATAL_CFLAGS="$CFLAGS $NON_FATAL_CC_WARNINGS"
  420. AC_SUBST(NON_FATAL_CFLAGS)
  421. dnl
  422. dnl We reset CFLAGS to include our warnings *after* all function
  423. dnl checking goes on, so that our warning flags don't keep the
  424. dnl AC_*FUNCS() calls above from working. In particular, -Werror will
  425. dnl *always* cause us troubles if we set it before here.
  426. dnl
  427. dnl
  428. CFLAGS="$CFLAGS $CC_WARNINGS"
  429. AC_SUBST(CFLAGS)
  430. dnl This is useful for use in Makefiles that need to remove one specific flag
  431. CFLAGS_COPY="$CFLAGS"
  432. AC_SUBST(CFLAGS_COPY)
  433. AM_CONDITIONAL(BUILD_DARWIN, test $ON_DARWIN = 1)
  434. LINT_FLAGS="-weak -unrecog +posixlib +ignoresigns -fcnuse -badflag -D__gnuc_va_list=va_list -D__attribute\(x\)="
  435. AC_SUBST(LINT_FLAGS)
  436. dnl ************************************************************************
  437. AC_SUBST(LOCALE)
  438. dnl The Makefiles and shell scripts we output
  439. AC_CONFIG_FILES(Makefile \
  440. include/Makefile \
  441. lib/Makefile \
  442. lcr/Makefile \
  443. exec/Makefile \
  444. test/Makefile \
  445. tools/Makefile \
  446. services/Makefile \
  447. pkgconfig/Makefile \
  448. )
  449. dnl Now process the entire list of files added by previous
  450. dnl calls to AC_CONFIG_FILES()
  451. AC_OUTPUT()
  452. dnl *****************
  453. dnl Configure summary
  454. dnl *****************
  455. AC_MSG_RESULT([])
  456. AC_MSG_RESULT([$PACKAGE configuration:])
  457. AC_MSG_RESULT([ Version = ${VERSION}])
  458. AC_MSG_RESULT([ Prefix = ${prefix}])
  459. AC_MSG_RESULT([ Executables = ${sbindir}])
  460. AC_MSG_RESULT([ Man pages = ${mandir}])
  461. AC_MSG_RESULT([ Libraries = ${libdir}])
  462. AC_MSG_RESULT([ Header files = ${includedir}])
  463. AC_MSG_RESULT([ Arch-independent files = ${datadir}])
  464. AC_MSG_RESULT([ State information = ${localstatedir}])
  465. AC_MSG_RESULT([ System configuration = ${sysconfdir}])
  466. AC_MSG_RESULT([ Features =${PKG_FEATURES}])
  467. AC_MSG_RESULT([ CC_WARNINGS =${CC_WARNINGS}])
  468. AC_MSG_RESULT([ Mangled CFLAGS = ${CFLAGS}])
  469. AC_MSG_RESULT([ Libraries = ${LIBS}])