configure.in 6.2 KB

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