configure.in 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. # copyright John Maddock 2003
  2. # Use, modification and distribution are subject to the
  3. # Boost Software License, Version 1.0. (See accompanying file
  4. # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #
  6. # the following variables contain our macro definitions:
  7. #
  8. required_defs=""
  9. required_undefs=""
  10. dnl Process this file with autoconf to produce a configure script.
  11. dnl disable cache processing, it has no effect here:
  12. define([AC_CACHE_LOAD], )dnl
  13. define([AC_CACHE_SAVE], )dnl
  14. AC_INIT(./tools/configure.in)
  15. AC_ARG_ENABLE(test, --enable-test tests current settings rather than defining new ones)
  16. if test "foo"$enable_test = "foo"; then
  17. enable_test="no"
  18. fi
  19. cat << EOF
  20. *** $0: boost configuration utility ***
  21. Please stand by while exploring compiler capabilities...
  22. Be patient - this could take some time...
  23. Note that this test script only gives an approximate
  24. configuration - you will need to test the results carefully
  25. using the boost regression test suite before using the results.
  26. EOF
  27. if test $enable_test = 'yes'; then
  28. cat << EOF
  29. This script reports only the difference between the detected
  30. configuration, and the existing boost configuration. Its
  31. primary aim is to quickly report how well boost is configured
  32. for one compiler.
  33. ***
  34. EOF
  35. else
  36. cat << EOF
  37. ***
  38. EOF
  39. fi
  40. AC_ARG_ENABLE(extension,[--enable-extension=<ext>],
  41. [
  42. case "$enableval" in
  43. no) AC_MSG_RESULT(Info :.cpp used as extension for tests)
  44. ac_ext=cpp
  45. ;;
  46. *) AC_MSG_RESULT(Argument : .$enableval used as extension)
  47. ac_ext=$enableval
  48. esac
  49. ],
  50. [AC_MSG_RESULT(Info : .cpp used as extension for tests)
  51. ac_ext=cpp
  52. ]
  53. )
  54. dnl figure out which version of sed to use, on some platforms
  55. dnl the version in the path is not Unix conforming (MacOS X ? )
  56. if test -f /bin/sed ; then
  57. SED=/bin/sed
  58. else
  59. if test -f /usr/bin/sed ; then
  60. SED=/usr/bin/sed
  61. else
  62. SED=sed
  63. fi
  64. fi
  65. dnl Set the boost main directory.
  66. AC_MSG_CHECKING(for boost main tree)
  67. boost_base=
  68. AC_ARG_WITH(boost,
  69. AC_HELP_STRING([--with-boost=DIR],[path to the boost main tree]),
  70. [
  71. #echo "--with boost is set"
  72. if test "x$withval" != "x"; then
  73. if test "x$withval" != no; then
  74. boost_base=`echo "$withval" | $SED 's,//*,/,g' | $SED 's,/$,,'`
  75. #echo boost_base=$boost_base
  76. if test -f "$boost_base/boost/config.hpp"; then
  77. if test -f "$boost_base/libs/config/configure"; then :; else
  78. boost_base=
  79. #echo "$boost_base/libs/config/configure" not found
  80. fi
  81. else
  82. #echo "$boost_base/boost/config.hpp" not found
  83. boost_base=
  84. fi
  85. fi
  86. fi
  87. ]
  88. )
  89. if test "x$boost_base" = "x"; then
  90. #echo '$0 = ' $0
  91. boost_base=`expr "x$0" : 'x\(.*\)/@<:@/@:>@*' \| '.'`
  92. boost_base="$boost_base/../.."
  93. #echo boost_base=$boost_base
  94. if test -f "$boost_base/boost/config.hpp"; then
  95. if test -f "$boost_base/libs/config/configure"; then :; else
  96. boost_base=
  97. fi
  98. else
  99. boost_base=
  100. fi
  101. fi
  102. if test "x$boost_base" != "x"; then
  103. AC_MSG_RESULT([$boost_base])
  104. else
  105. AC_MSG_RESULT([not found])
  106. AC_MSG_ERROR([The boost main tree was not found.
  107. Specify its location by the --with-boost option.])
  108. fi
  109. # Save that, as it is being redefined several times
  110. use_ac_ext=$ac_ext
  111. AC_PROG_CXX
  112. ac_ext=$use_ac_ext
  113. AC_LANG_CPLUSPLUS
  114. OLD_CXXFLAGS="$CXXFLAGS"
  115. if test $enable_test = 'yes'; then
  116. CXXFLAGS="-I$boost_base -I$boost_base/libs/config/test $CXXFLAGS"
  117. else
  118. CXXFLAGS="-I$boost_base -I$boost_base/libs/config/test $CXXFLAGS -DBOOST_NO_CONFIG"
  119. fi
  120. # add the -AA conformance option to CXXFLAGS for HP aCC only
  121. if test $CXX = 'aCC'; then
  122. CXXFLAGS="-AA $CXXFLAGS"
  123. fi
  124. dnl check for some standard libraries
  125. dnl without these some of the tests may fail:
  126. AC_CHECK_LIB(pthread, pthread_exit)
  127. AC_CHECK_LIB(m, cos)
  128. AC_CHECK_LIB(rt, clock)
  129. #
  130. # enumerate test files and test each one:
  131. #
  132. for file in $boost_base/libs/config/test/boost_no*.ipp; do
  133. basename=`echo $file | $SED 's/.*boost_\(.*\)\.ipp/\1/'`
  134. macroname=`cat $file | grep '^//[[ ]]*MACRO:' | $SED 's/.*MACRO:[[ ]]*\([[_A-Z0-9]]*\).*/\1/'`
  135. title=`cat $file | grep '^//[[ ]]*TITLE:' | $SED 's/.*TITLE:[[ ]]*\([[^ ]].*\)/\1/'`
  136. namespace=`echo $macroname | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
  137. #echo file = $file
  138. #echo basename = $basename
  139. #echo macroname = $macroname
  140. #echo title = $title
  141. #echo namespace = $namespace
  142. ac_ext=$use_ac_ext
  143. if test $enable_test = 'yes'; then
  144. AC_MSG_CHECKING($title (pass expected) )
  145. else
  146. AC_MSG_CHECKING($title )
  147. fi
  148. AC_TRY_RUN(
  149. [
  150. #include <boost/config.hpp>
  151. #include "test.hpp"
  152. #if !defined($macroname) || defined(BOOST_NO_CONFIG)
  153. #include "boost_$basename.ipp"
  154. #else
  155. namespace ${namespace} = empty_boost;
  156. #endif
  157. int main(){ return ${namespace}::test(); } ]
  158. ,
  159. [AC_MSG_RESULT(OK)]
  160. ,
  161. [AC_MSG_RESULT(Failed)
  162. required_defs="$macroname $required_defs"]
  163. )
  164. if test $enable_test = 'yes'; then
  165. ac_ext=$use_ac_ext
  166. AC_MSG_CHECKING($title (fail expected) )
  167. AC_TRY_RUN(
  168. [
  169. #include <boost/config.hpp>
  170. #include "test.hpp"
  171. #ifdef $macroname
  172. #include "boost_$basename.ipp"
  173. #else
  174. #error "this file should not compile"
  175. #endif
  176. int main() { return ${namespace}::test(); }]
  177. ,
  178. [AC_MSG_RESULT(failed)
  179. required_undefs="$macroname $required_undefs"]
  180. ,
  181. [AC_MSG_RESULT(OK)]
  182. )
  183. fi
  184. done
  185. #
  186. # enumerate optional test files and test each one:
  187. #
  188. for file in $boost_base/libs/config/test/boost_has*.ipp; do
  189. basename=`echo $file | $SED 's/.*boost_\(.*\)\.ipp/\1/'`
  190. macroname=`cat $file | grep '^//[[ ]]*MACRO:' | $SED 's/.*MACRO:[[ ]]*\([[_A-Z0-9]]*\).*/\1/'`
  191. title=`cat $file | grep '^//[[ ]]*TITLE:' | $SED 's/.*TITLE:[[ ]]*\([[^ ]].*\)/\1/'`
  192. namespace=`echo $macroname | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
  193. # echo $file
  194. # echo $basename
  195. # echo $macroname
  196. # echo $title
  197. ac_ext=$use_ac_ext
  198. if test $enable_test = 'yes'; then
  199. AC_MSG_CHECKING($title (pass expected) )
  200. AC_TRY_RUN(
  201. [
  202. #include <boost/config.hpp>
  203. #include "test.hpp"
  204. #ifdef $macroname
  205. #include "boost_$basename.ipp"
  206. #else
  207. namespace ${namespace} = empty_boost;
  208. #endif
  209. int main(){ return ${namespace}::test(); }]
  210. ,
  211. [AC_MSG_RESULT(OK)]
  212. ,
  213. [AC_MSG_RESULT(Failed)
  214. required_undefs="$macroname $required_undefs"]
  215. )
  216. AC_MSG_CHECKING($title (fail expected) )
  217. AC_TRY_RUN(
  218. [
  219. #include <boost/config.hpp>
  220. #include "test.hpp"
  221. #ifndef $macroname
  222. #include "boost_$basename.ipp"
  223. #else
  224. #error "this file should not compile"
  225. #endif
  226. int main(){ return ${namespace}::test(); }]
  227. ,
  228. [
  229. AC_MSG_RESULT(failed)
  230. required_defs="$macroname $required_defs"
  231. ]
  232. ,
  233. [
  234. AC_MSG_RESULT(OK)
  235. ]
  236. )
  237. else
  238. ac_ext=$use_ac_ext
  239. AC_MSG_CHECKING($title)
  240. AC_TRY_RUN(
  241. [
  242. #include <boost/config.hpp>
  243. #include "test.hpp"
  244. #include "boost_$basename.ipp"
  245. int main(){ return ${namespace}::test(); }]
  246. ,
  247. [
  248. AC_MSG_RESULT(Yes)
  249. required_defs="$macroname $required_defs"
  250. ]
  251. ,
  252. [
  253. AC_MSG_RESULT(no)
  254. ]
  255. )
  256. fi
  257. done
  258. #echo $required_defs
  259. #echo $required_undefs
  260. if test $enable_test = 'yes'; then
  261. if test "$required_defs" = ""; then
  262. echo no boost macros need to be defined
  263. echo no boost macros need to be defined >&5
  264. else
  265. echo the following macros need to be defined
  266. echo $required_defs
  267. echo the following macros need to be defined >&5
  268. echo $required_defs >&5
  269. fi
  270. if test "$required_undefs" = ""; then
  271. echo no boost macros need to be undefined
  272. echo no boost macros need to be undefined >&5
  273. else
  274. echo "the following macros need to be undef'ed"
  275. echo $required_undefs
  276. echo "the following macros need to be undef'ed" >&5
  277. echo $required_undefs >&5
  278. fi
  279. else
  280. date_string=`date`
  281. echo boost_base=$boost_base
  282. cat > user.hpp << EOF
  283. // (C) Copyright Boost.org 2001.
  284. // Do not check in modified versions of this file,
  285. // This file may be customised by the end user, but not by boost.
  286. //
  287. // Use this file to define a site and compiler specific
  288. // configuration policy, this version was auto-generated by
  289. // configure on ${date_string}
  290. // With the following options:
  291. // CXX = ${CXX}
  292. // CXXFLAGS = ${CXXFLAGS}
  293. // LDFLAGS = ${LDFLAGS}
  294. // LIBS = ${LIBS}
  295. //
  296. // define this to disable all config options,
  297. // excluding the user config. Use if your
  298. // setup is fully ISO complient, and has no
  299. // useful extentions, or for autoconf generated
  300. // setups:
  301. #ifndef BOOST_NO_CONFIG
  302. # define BOOST_NO_CONFIG
  303. #endif
  304. // define if you want to disable threading support, even
  305. // when available:
  306. // #define BOOST_DISABLE_THREADS
  307. // define if you want the regex library to use the C locale
  308. // even on Win32:
  309. // #define BOOST_REGEX_USE_C_LOCALE
  310. // define this is you want the regex library to use the C++
  311. // locale:
  312. // #define BOOST_REGEX_USE_CPP_LOCALE
  313. //
  314. // options added by configure:
  315. //
  316. EOF
  317. for name in $required_defs; do
  318. echo '#define '"$name" >> user.hpp
  319. done
  320. cat_conts=`cat user.hpp`
  321. #
  322. # post configuration step:
  323. #
  324. AC_MSG_CHECKING(original configuration )
  325. rm -f conftest$ac_exeext
  326. $CXX -I$boost_base $OLD_CXXFLAGS -DBOOST_NO_USER_CONFIG -o conftest$ac_exeext $LDFLAGS $boost_base/libs/config/test/config_info.cpp $LIBS >&5 2>&1
  327. ./conftest >&5 2>&1
  328. AC_MSG_RESULT(done)
  329. AC_MSG_CHECKING(new configuration )
  330. rm -f conftest$ac_exeext
  331. $CXX -I$boost_base -I$boost_base/libs/config $OLD_CXXFLAGS -DBOOST_USER_CONFIG='"user.hpp"' -o conftest$ac_exeext $LDFLAGS $boost_base/libs/config/test/config_info.cpp $LIBS >&5 2>&1
  332. ./conftest >&5 2>&1
  333. AC_MSG_RESULT(done)
  334. AC_OUTPUT(
  335. [],
  336. [
  337. cat > user.hpp << EEEOF
  338. ${cat_conts}
  339. EEEOF
  340. cat << EEEOF
  341. Adjustments to boost configuration have been written to
  342. user.hpp. Copy this to boost/config/user.hpp to use "as is",
  343. or define BOOST_SITE_CONFIG to point to its location.
  344. TREAT THIS FILE WITH CARE.
  345. Autoconf generated options are not infallible!
  346. EEEOF
  347. ],
  348. [
  349. cat_conts="$cat_conts"
  350. ]
  351. )
  352. fi