configure.in 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # Process this file with autoconf to produce a configure script.
  2. AC_INIT()
  3. AC_CONFIG_HEADER(Source/cmConfigure.h)
  4. # find make to use to build cmake, prefer gmake
  5. AC_PATH_PROGS(RUNMAKE, gmake make)
  6. fullSrcDir=`cd $srcdir; pwd`
  7. CMAKE_ROOT_DIR=$fullSrcDir
  8. if test "x$BUILD_CMAKE_IN_SUBDIR" = "xtrue"; then
  9. #
  10. # check for some programs we use
  11. #
  12. # save the CFLAGS and CXXFLAGS specified by the user
  13. save_CFLAGS=$CFLAGS
  14. save_CXXFLAGS=$CXXFLAGS
  15. # let autoconf find cc and CC, it will try to add -g -O2 to CFLAGS and CXXFLAGS
  16. AC_PROG_CC
  17. AC_PROG_CXX
  18. # restore the flags specified by the user and get rid of any flags
  19. # found by autoconf (we do not want -02 -g by default)
  20. CFLAGS=$save_CFLAGS
  21. CXXFLAGS=$save_CXXFLAGS
  22. AC_SUBST(CMAKE_ROOT_DIR)
  23. # Step 1: set the variable "system" to hold the name and version number
  24. # for the system. This can usually be done via the "uname" command, but
  25. # there are a few systems, like Next, where this doesn't work.
  26. AC_MSG_CHECKING([system version (for dynamic loading)])
  27. if test -f /usr/lib/NextStep/software_version; then
  28. system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  29. else
  30. system=`uname -s`-`uname -r`
  31. if test "$?" -ne 0 ; then
  32. AC_MSG_RESULT([unknown (can't find uname command)])
  33. system=unknown
  34. else
  35. # Special check for weird MP-RAS system (uname returns weird
  36. # results, and the version is kept in special file).
  37. if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  38. system=MP-RAS-`awk '{print $3}' /etc/.relid'`
  39. fi
  40. AC_MSG_RESULT($system)
  41. fi
  42. fi
  43. CMAKE_CONFIG_DIR=`pwd`
  44. AC_SUBST(CMAKE_CONFIG_DIR)
  45. case $system in
  46. CYGWIN_NT*)
  47. CMAKE_CONFIG_DIR=`pwd`
  48. CMAKE_CONFIG_DIR="\"$CMAKE_CONFIG_DIR\""
  49. ;;
  50. esac
  51. CMAKE_ANSI_CFLAGS=""
  52. CMAKE_ANSI_CXXFLAGS=""
  53. # on hp use -Aa for ansi
  54. if test $ac_cv_prog_gxx = no; then
  55. case $system in
  56. HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  57. CFLAGS_ORIG="$FLAGS"
  58. CFLAGS="-Aa $CFLAGS"
  59. AC_MSG_CHECKING([whether ${CC} accepts -Aa])
  60. AC_TRY_COMPILE([
  61. void foo() {}
  62. ],,[
  63. AC_MSG_RESULT(yes)
  64. CMAKE_ANSI_CFLAGS="$CMAKE_ANSI_CFLAGS -Aa"
  65. ],[
  66. AC_MSG_RESULT(no)
  67. ])
  68. CFLAGS="$CFLAGS_ORIG"
  69. ;;
  70. IRIX-5* | IRIX-6* | IRIX64-6* | IRIX-64-6*)
  71. echo $ac_n "checking whether ${CXX} accepts -LANG:std""... $ac_c" 1>&6
  72. echo 'void f(){}' > conftest.cc
  73. if test -z "`${CXX} -LANG:std -c conftest.cc 2>&1`"; then
  74. echo "$ac_t""yes" 1>&6
  75. CMAKE_ANSI_CXXFLAGS="-LANG:std"
  76. else
  77. echo "$ac_t""no" 1>&6
  78. fi
  79. rm -f conftest*
  80. ;;
  81. OSF1-*)
  82. CXXFLAGS_ORIG="$CXXFLAGS"
  83. CXXFLAGS="-std strict_ansi -nopure_cname $CXXFLAGS"
  84. AC_MSG_CHECKING([whether ${CXX} accepts -std strict_ansi -nopure_cname])
  85. AC_LANG_SAVE
  86. AC_LANG_CPLUSPLUS
  87. AC_TRY_COMPILE([
  88. void foo() {}
  89. ],,[
  90. AC_MSG_RESULT(yes)
  91. CMAKE_ANSI_CXXFLAGS="-std strict_ansi -nopure_cname"
  92. ],[
  93. AC_MSG_RESULT(no)
  94. ])
  95. AC_LANG_RESTORE
  96. CXXFLAGS="$CXXFLAGS_ORIG"
  97. ;;
  98. esac
  99. fi
  100. AC_SUBST(CMAKE_ANSI_CFLAGS)
  101. AC_SUBST(CMAKE_ANSI_CXXFLAGS)
  102. # check non-g++ compilers to see if they have the standard
  103. # ansi stream files (without the .h)
  104. if test $ac_cv_prog_gxx = no; then
  105. CXXFLAGS_ORIG="$CXXFLAGS"
  106. CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  107. AC_MSG_CHECKING( ansi standard C++ stream headers )
  108. AC_LANG_SAVE
  109. AC_LANG_CPLUSPLUS
  110. AC_TRY_COMPILE([
  111. #include <iostream>
  112. ],,[
  113. AC_MSG_RESULT(yes)
  114. ],[
  115. AC_DEFINE(CMAKE_NO_ANSI_STREAM_HEADERS)
  116. AC_MSG_RESULT(no)
  117. ])
  118. AC_LANG_RESTORE
  119. CXXFLAGS="$CXXFLAGS_ORIG"
  120. fi
  121. # check non-g++ compilers to see if they have std::stringstream
  122. CXXFLAGS_ORIG="$CXXFLAGS"
  123. CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  124. AC_MSG_CHECKING([for ansi standard C++ stringstream])
  125. AC_LANG_SAVE
  126. AC_LANG_CPLUSPLUS
  127. AC_TRY_COMPILE([
  128. #include <sstream>
  129. ],,[
  130. AC_MSG_RESULT(yes)
  131. ],[
  132. AC_DEFINE(CMAKE_NO_ANSI_STRING_STREAM)
  133. AC_MSG_RESULT(no)
  134. ])
  135. AC_LANG_RESTORE
  136. CXXFLAGS="$CXXFLAGS_ORIG"
  137. # check to see if stl is in the std namespace
  138. if test $ac_cv_prog_gxx = no; then
  139. CXXFLAGS_ORIG="$CXXFLAGS"
  140. CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  141. AC_MSG_CHECKING([whether the std namespace is supported])
  142. AC_LANG_SAVE
  143. AC_LANG_CPLUSPLUS
  144. AC_TRY_COMPILE([
  145. #include <list>
  146. void foo() { std::list<int>(); }
  147. ],,[
  148. AC_MSG_RESULT(yes)
  149. ],[
  150. AC_DEFINE(CMAKE_NO_STD_NAMESPACE)
  151. AC_MSG_RESULT(no)
  152. ])
  153. AC_LANG_RESTORE
  154. CXXFLAGS="$CXXFLAGS_ORIG"
  155. fi
  156. # check to see if for scoping is supported
  157. if test $ac_cv_prog_gxx = no; then
  158. CXXFLAGS_ORIG="$CXXFLAGS"
  159. CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  160. AC_MSG_CHECKING([ansi for scope support])
  161. AC_LANG_SAVE
  162. AC_LANG_CPLUSPLUS
  163. AC_TRY_COMPILE([
  164. void foo() { for(int i;;); for(int i;;); }
  165. ],,[
  166. AC_MSG_RESULT(yes)
  167. ],[
  168. AC_DEFINE(CMAKE_NO_ANSI_FOR_SCOPE)
  169. AC_MSG_RESULT(no)
  170. ])
  171. AC_LANG_RESTORE
  172. CXXFLAGS="$CXXFLAGS_ORIG"
  173. fi
  174. AC_OUTPUT(Source/InitialConfigureFlags.cmake Makefile Source/Makefile)
  175. # build cmake
  176. $RUNMAKE
  177. else
  178. PRGNAME=configure # Should be `basename $0`
  179. DIRNAME=Bootstrap
  180. # Check if the bootstrap directory already exists.
  181. if test -d Bootstrap; then
  182. :
  183. else
  184. # if it does not create one
  185. mkdir Bootstrap
  186. fi
  187. if (
  188. # Build bootstrap cmake
  189. cd Bootstrap
  190. echo "Bootstrapping to directory `pwd`"
  191. BUILD_CMAKE_IN_SUBDIR=true $CMAKE_ROOT_DIR/$PRGNAME $ac_configure_args
  192. ); then
  193. # run cmake
  194. Bootstrap/Source/cmake $fullSrcDir
  195. # run cmake depends
  196. $RUNMAKE depend
  197. else
  198. echo "Problem bootstrapping CMake"
  199. exit 1
  200. fi
  201. fi