ENH: fix test, it has to return a true/false value otherwise it just passes the test...
[cmake.git] / bootstrap
blobb3989818eac1d4418a50a164ffaf5c35e72bd7a4
1 #!/bin/sh
3 #=========================================================================
5 # Program: CMake - Cross-Platform Makefile Generator
6 # Module: $RCSfile: bootstrap,v $
7 # Language: Bourne Shell
8 # Date: $Date: 2005-06-13 15:00:28 $
9 # Version: $Revision: 1.66 $
11 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
12 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
14 # This software is distributed WITHOUT ANY WARRANTY; without even
15 # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 # PURPOSE. See the above copyright notices for more information.
18 #=========================================================================
20 CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
21 CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
22 CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
24 CMAKE_PROBLEMATIC_FILES="\
25 CMakeCache.txt \
26 CMakeSystem.cmake \
27 CMakeCCompiler.cmake \
28 CMakeCXXCompiler.cmake \
29 Source/cmConfigure.h \
30 Source/CTest/Curl/config.h \
31 Utilities/cmexpat/expatConfig.h \
32 Utilities/cmexpat/expatDllConfig.h \
35 CMAKE_CXX_SOURCES="\
36 cmake \
37 cmakewizard \
38 cmakemain \
39 cmCommandArgumentLexer \
40 cmCommandArgumentParser \
41 cmCommandArgumentParserHelper \
42 cmDepends \
43 cmDependsC \
44 cmMakeDepend \
45 cmMakefile \
46 cmGeneratedFileStream \
47 cmGlobalGenerator \
48 cmLocalGenerator \
49 cmSourceFile \
50 cmSystemTools \
51 cmGlobalUnixMakefileGenerator3 \
52 cmGlobalXCodeGenerator \
53 cmLocalXCodeGenerator \
54 cmXCodeObject \
55 cmLocalUnixMakefileGenerator3 \
56 cmBootstrapCommands \
57 cmCommands \
58 cmTarget \
59 cmTest \
60 cmCustomCommand \
61 cmCacheManager \
62 cmListFileCache \
63 cmOrderLinkDirectories \
64 cmSourceGroup"
66 CMAKE_C_SOURCES="\
67 cmListFileLexer \
70 KWSYS_C_SOURCES="\
71 ProcessUNIX"
73 KWSYS_CXX_SOURCES="\
74 Directory \
75 RegularExpression \
76 SystemTools"
78 KWSYS_FILES="\
79 Directory.hxx \
80 Process.h \
81 RegularExpression.hxx \
82 SystemTools.hxx"
84 KWSYS_IOS_FILES="
85 fstream \
86 iosfwd \
87 iostream \
88 sstream"
90 cmake_system=`uname`
92 cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
93 cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
94 cmake_binary_dir=`pwd`
95 cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
96 cmake_data_dir="/share/CMake"
97 cmake_doc_dir="/doc/CMake"
98 cmake_man_dir="/man"
99 cmake_init_file=""
101 # Display CMake bootstrap usage
102 cmake_usage()
104 cat <<EOF
105 Usage: $0 [options]
106 Options: [defaults in brackets after descriptions]
107 Configuration:
108 --help print this message
109 --version only print version information
110 --verbose display more information
111 --parallel=n bootstrap cmake in parallel, where n is
112 number of nodes [1]
113 --init=FILE use FILE for cmake initialization
115 Directory and file names:
116 --prefix=PREFIX install files in tree rooted at PREFIX
117 [/usr/local]
118 --datadir=DIR install data files in PREFIX/DIR
119 [/share/CMake]
120 --docdir=DIR install documentation files in PREFIX/DIR
121 [/doc/CMake]
122 --mandir=DIR install man pages files in PREFIX/DIR/manN
123 [/man]
125 exit 10
128 # Display CMake bootstrap usage
129 cmake_version()
131 # Get CMake version
132 CMAKE_VERSION=""
133 for a in MAJOR MINOR PATCH; do
134 CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \
135 grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
136 CMAKE_VERSION="${CMAKE_VERSION}.${CMake_VERSION}"
137 done
138 if echo "$CMAKE_VERSION" | grep "\.[0-9][0-9]*\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
140 CMake_DATE=`cat "${cmake_source_dir}/Source/cmVersion.cxx" | grep "\".Date: [0-9][0-9]*/[0-9][0-9]*/[0-9][0-9]* [0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]* .\";"`
141 CMake_DATE=`echo "${CMake_DATE}" | sed "s/.*Date: \([0-9][0-9]*\)\/\([0-9][0-9]*\)\/\([0-9][0-9]*\) .*/\1\2\3/" `
142 CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-${CMake_DATE}/"`
143 else
144 CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-\3/"`
146 echo "CMake ${CMAKE_VERSION}, Copyright (c) 2002 Kitware, Inc., Insight Consortium"
149 # Display CMake bootstrap error, display the log file and exit
150 cmake_error()
152 res=$1
153 shift 1
154 echo "---------------------------------------------"
155 echo "Error when bootstrapping CMake:"
156 echo "$*"
157 echo "---------------------------------------------"
158 if [ -f cmake_bootstrap.log ]; then
159 echo "Log of errors: `pwd`/cmake_bootstrap.log"
160 #cat cmake_bootstrap.log
161 echo "---------------------------------------------"
163 exit ${res}
166 # Replace KWSYS_NAMESPACE with cmsys
167 cmake_replace_string ()
169 INFILE="$1"
170 OUTFILE="$2"
171 SEARCHFOR="$3"
172 REPLACEWITH="$4"
173 if [ -f "${INFILE}" ]; then
174 cat "${INFILE}" |
175 sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
176 if [ -f "${OUTFILE}.tmp" ]; then
177 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
178 #echo "Files are the same"
179 rm -f "${OUTFILE}.tmp"
180 else
181 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
184 else
185 cmake_error 1 "Cannot find file ${INFILE}"
189 cmake_kwsys_config_replace_string ()
191 INFILE="$1"
192 OUTFILE="$2"
193 shift 2
194 APPEND="$*"
195 if [ -f "${INFILE}" ]; then
196 echo "${APPEND}" > "${OUTFILE}.tmp"
197 cat "${INFILE}" |
198 sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
199 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
200 s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
201 s/@KWSYS_IOS_USE_ANSI@/${KWSYS_IOS_USE_ANSI}/g;
202 s/@KWSYS_IOS_HAVE_STD@/${KWSYS_IOS_HAVE_STD}/g;
203 s/@KWSYS_IOS_USE_SSTREAM@/${KWSYS_IOS_USE_SSTREAM}/g;
204 s/@KWSYS_IOS_USE_STRSTREAM_H@/${KWSYS_IOS_USE_STRSTREAM_H}/g;
205 s/@KWSYS_IOS_USE_STRSTREA_H@/${KWSYS_IOS_USE_STRSTREA_H}/g;
206 s/@KWSYS_STL_HAVE_STD@/${KWSYS_STL_HAVE_STD}/g;
207 s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g;
208 s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g;
209 s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g;
210 s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g;
211 s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g;
212 s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g;
213 s/@KWSYS_STL_HAS_ALLOCATOR_TEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}/g;
214 s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g;
215 s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g;
216 s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g;
217 s/@KWSYS_STL_HAS_ALLOCATOR_OBJECTS@/${KWSYS_STL_HAS_ALLOCATOR_OBJECTS}/g;
218 s/@KWSYS_CXX_HAS_CSTDDEF@/${KWSYS_CXX_HAS_CSTDDEF}/g;
219 s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g;
220 s/@KWSYS_CXX_HAS_MEMBER_TEMPLATES@/${KWSYS_CXX_HAS_MEMBER_TEMPLATES}/g;
221 s/@KWSYS_CXX_HAS_FULL_SPECIALIZATION@/${KWSYS_CXX_HAS_FULL_SPECIALIZATION}/g;
222 s/@KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP@/${KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP}/g;
223 s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}.tmp"
224 if [ -f "${OUTFILE}.tmp" ]; then
225 if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
226 #echo "Files are the same"
227 rm -f "${OUTFILE}.tmp"
228 else
229 mv -f "${OUTFILE}.tmp" "${OUTFILE}"
232 else
233 cmake_error 2 "Cannot find file ${INFILE}"
236 # Write string into a file
237 cmake_report ()
239 FILE=$1
240 shift
241 echo "$*" >> ${FILE}
244 # Escape spaces in strings
245 cmake_escape ()
247 echo $1 | sed "s/ /\\\\ /g"
250 # Write message to the log
251 cmake_log ()
253 echo "$*" >> cmake_bootstrap.log
256 # Return temp file
257 cmake_tmp_file ()
259 echo "cmake_bootstrap_$$.test"
262 # Run a compiler test. First argument is compiler, second one are compiler
263 # flags, third one is test source file to be compiled
264 cmake_try_run ()
266 COMPILER=$1
267 FLAGS=$2
268 TESTFILE=$3
269 if [ ! -f "${TESTFILE}" ]; then
270 echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
271 exit 4
273 TMPFILE=`cmake_tmp_file`
274 echo "Try: ${COMPILER}"
275 echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
276 echo "---------- file -----------------------"
277 cat "${TESTFILE}"
278 echo "------------------------------------------"
279 "${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
280 RES=$?
281 if [ "${RES}" -ne "0" ]; then
282 echo "Test failed to compile"
283 return 1
285 if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
286 echo "Test failed to produce executable"
287 return 2
289 ./${TMPFILE}
290 RES=$?
291 rm -f "${TMPFILE}"
292 if [ "${RES}" -ne "0" ]; then
293 echo "Test produced non-zero return code"
294 return 3
296 echo "Test succeded"
297 return 0
300 # Run a make test. First argument is the make interpreter.
301 cmake_try_make ()
303 MAKE_PROC="$1"
304 MAKE_FLAGS="$2"
305 echo "Try: ${MAKE_PROC}"
306 "${MAKE_PROC}" ${MAKE_FLAGS}
307 RES=$?
308 if [ "${RES}" -ne "0" ]; then
309 echo "${MAKE_PROC} does not work"
310 return 1
312 if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
313 echo "${COMPILER} does not produce output"
314 return 2
316 ./test
317 RES=$?
318 rm -f "test"
319 if [ "${RES}" -ne "0" ]; then
320 echo "${MAKE_PROC} produces strange executable"
321 return 3
323 echo "${MAKE_PROC} works"
324 return 0
327 # Parse arguments
328 cmake_verbose=
329 cmake_parallel_make=
330 cmake_prefix_dir="/usr/local"
331 for a in "$@"; do
332 if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
333 cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
335 if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
336 cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
338 if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then
339 cmake_data_dir=`echo $a | sed "s/^--datadir=//"`
341 if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then
342 cmake_doc_dir=`echo $a | sed "s/^--docdir=//"`
344 if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then
345 cmake_man_dir=`echo $a | sed "s/^--mandir=//"`
347 if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then
348 cmake_init_file=`echo $a | sed "s/^--init=//"`
350 if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
351 cmake_usage
353 if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
354 cmake_version
355 exit 2
357 if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
358 cmake_verbose=TRUE
360 done
362 # If verbose, display some information about bootstrap
363 if [ -n "${cmake_verbose}" ]; then
364 echo "---------------------------------------------"
365 echo "Source directory: ${cmake_source_dir}"
366 echo "Binary directory: ${cmake_binary_dir}"
367 echo "Prefix directory: ${cmake_prefix_dir}"
368 echo "System: ${cmake_system}"
369 if [ "x${cmake_parallel_make}" != "x" ]; then
370 echo "Doing parallel make: ${cmake_parallel_make}"
372 echo ""
375 echo "---------------------------------------------"
376 # Get CMake version
377 echo "`cmake_version`"
379 # Check for in-source build
380 cmake_in_source_build=
381 if [ -f "${cmake_binary_dir}/Source/cmake.cxx" -a \
382 -f "${cmake_binary_dir}/Source/cmake.h" ]; then
383 if [ -n "${cmake_verbose}" ]; then
384 echo "Warning: This is an in-source build"
386 cmake_in_source_build=TRUE
389 # If this is not an in-source build, then Bootstrap stuff should not exist.
390 if [ -z "${cmake_in_source_build}" ]; then
391 # Did somebody bootstrap in the source tree?
392 if [ -d "${cmake_source_dir}/Bootstrap.cmk" ]; then
393 cmake_error 10 "Found directory \"${cmake_source_dir}/Bootstrap.cmk\".
394 Looks like somebody did bootstrap CMake in the source tree, but now you are
395 trying to do bootstrap in the binary tree. Please remove Bootstrap.cmk
396 directory from the source tree."
398 # Is there a cache in the source tree?
399 for cmake_problematic_file in ${CMAKE_PROBLEMATIC_FILES}; do
400 if [ -f "${cmake_source_dir}/${cmake_problematic_file}" ]; then
401 cmake_error 10 "Found \"${cmake_source_dir}/${cmake_problematic_file}\".
402 Looks like somebody tried to build CMake in the source tree, but now you are
403 trying to do bootstrap in the binary tree. Please remove \"${cmake_problematic_file}\"
404 from the source tree."
406 done
409 # Make bootstrap directory
410 [ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
411 if [ ! -d "${cmake_bootstrap_dir}" ]; then
412 cmake_error 3 "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
414 cd "${cmake_bootstrap_dir}"
416 [ -d "cmsys" ] || mkdir "cmsys"
417 if [ ! -d "cmsys" ]; then
418 cmake_error 4 "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
421 for a in stl ios; do
422 [ -d "cmsys/${a}" ] || mkdir "cmsys/${a}"
423 if [ ! -d "cmsys/${a}" ]; then
424 cmake_error 5 "Cannot create directory ${cmake_bootstrap_dir}/cmsys/${a}"
426 done
428 # Delete all the bootstrap files
429 rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
430 rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
432 # If exist compiler flags, set them
433 cmake_c_flags=${CFLAGS}
434 cmake_cxx_flags=${CXXFLAGS}
436 # Test C compiler
437 cmake_c_compiler=
439 # If CC is set, use that for compiler, otherwise use list of known compilers
440 if [ -n "${CC}" ]; then
441 cmake_c_compilers="${CC}"
442 else
443 cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
446 # Check if C compiler works
447 TMPFILE=`cmake_tmp_file`
448 cat > "${TMPFILE}.c" <<EOF
449 #include<stdio.h>
450 int main()
452 printf("1\n");
453 return 0;
456 for a in ${cmake_c_compilers}; do
457 if [ -z "${cmake_c_compiler}" ] && \
458 cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
459 cmake_c_compiler="${a}"
461 done
462 rm -f "${TMPFILE}.c"
464 if [ -z "${cmake_c_compiler}" ]; then
465 cmake_error 6 "Cannot find appropriate C compiler on this system.
466 Please specify one using environment variable CC.
467 See cmake_bootstrap.log for compilers attempted.
470 echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
472 # Test CXX compiler
473 cmake_cxx_compiler=
475 # On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
477 # If CC is set, use that for compiler, otherwise use list of known compilers
478 if [ -n "${CXX}" ]; then
479 cmake_cxx_compilers="${CXX}"
480 else
481 cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
484 # Check if C++ compiler works
485 TMPFILE=`cmake_tmp_file`
486 cat > "${TMPFILE}.cxx" <<EOF
487 #if defined(TEST1)
488 # include <iostream>
489 #else
490 # include <iostream.h>
491 #endif
493 class NeedCXX
495 public:
496 NeedCXX() { this->Foo = 1; }
497 int GetFoo() { return this->Foo; }
498 private:
499 int Foo;
501 int main()
503 NeedCXX c;
504 #ifdef TEST3
505 cout << c.GetFoo() << endl;
506 #else
507 std::cout << c.GetFoo() << std::endl;
508 #endif
509 return 0;
512 for a in ${cmake_cxx_compilers}; do
513 for b in 1 2 3; do
514 if [ -z "${cmake_cxx_compiler}" ] && \
515 cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
516 cmake_cxx_compiler="${a}"
518 done
519 done
520 rm -f "${TMPFILE}.cxx"
522 if [ -z "${cmake_cxx_compiler}" ]; then
523 cmake_error 7 "Cannot find appropriate C++ compiler on this system.
524 Please specify one using environment variable CXX.
525 See cmake_bootstrap.log for compilers attempted."
527 echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
529 # Test Make
531 cmake_make_processor=
532 cmake_make_flags=
534 # If MAKE is set, use that for make processor, otherwise use list of known make
535 if [ -n "${MAKE}" ]; then
536 cmake_make_processors="${MAKE}"
537 else
538 cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
541 TMPFILE="`cmake_tmp_file`_dir"
542 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
543 mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
544 cd "${cmake_bootstrap_dir}/${TMPFILE}"
545 cat>"Makefile"<<EOF
546 test: test.c
547 "${cmake_c_compiler}" -o test test.c
549 cat>"test.c"<<EOF
550 #include <stdio.h>
551 int main(){ printf("1\n"); return 0; }
553 cmake_original_make_flags="${cmake_make_flags}"
554 if [ "x${cmake_parallel_make}" != "x" ]; then
555 cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
557 for a in ${cmake_make_processors}; do
558 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
559 cmake_make_processor="${a}"
561 done
562 cmake_full_make_flags="${cmake_make_flags}"
563 if [ "x${cmake_original_make_flags}" != "x${cmake_make_flags}" ]; then
564 if [ -z "${cmake_make_processor}" ]; then
565 cmake_make_flags="${cmake_original_make_flags}"
566 for a in ${cmake_make_processors}; do
567 if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
568 cmake_make_processor="${a}"
570 done
573 cd "${cmake_bootstrap_dir}"
574 rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
576 if [ -z "${cmake_make_processor}" ]; then
577 cmake_error 8 "Cannot find appropriate Makefile processor on this system.
578 Please specify one using environment variable MAKE."
580 echo "Makefile processor on this system is: ${cmake_make_processor}"
581 if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
582 echo "---------------------------------------------"
583 echo "Makefile processor ${cmake_make_processor} does not support parallel build"
584 echo "---------------------------------------------"
587 # Ok, we have CC, CXX, and MAKE.
589 # Test C++ compiler features
591 # Are we GCC?
593 TMPFILE=`cmake_tmp_file`
594 cat > ${TMPFILE}.cxx <<EOF
595 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
596 #include <iostream>
597 int main() { std::cout << "This is GNU" << std::endl; return 0;}
598 #endif
600 cmake_cxx_compiler_is_gnu=0
601 if cmake_try_run "${cmake_cxx_compiler}" \
602 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
603 cmake_cxx_compiler_is_gnu=1
605 if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
606 echo "${cmake_cxx_compiler} is GNU compiler"
607 else
608 echo "${cmake_cxx_compiler} is not GNU compiler"
610 rm -f "${TMPFILE}.cxx"
612 if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
613 # Check for non-GNU compiler flags
615 # If we are on IRIX, check for -LANG:std
616 cmake_test_flags="-LANG:std"
617 if [ "x${cmake_system}" = "xIRIX64" ]; then
618 TMPFILE=`cmake_tmp_file`
619 cat > ${TMPFILE}.cxx <<EOF
620 #include <iostream>
621 int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
623 cmake_need_lang_std=0
624 if cmake_try_run "${cmake_cxx_compiler}" \
625 "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
627 else
628 if cmake_try_run "${cmake_cxx_compiler}" \
629 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
630 cmake_need_lang_std=1
633 if [ "x${cmake_need_lang_std}" = "x1" ]; then
634 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
635 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
636 else
637 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
639 rm -f "${TMPFILE}.cxx"
641 cmake_test_flags=
643 # If we are on OSF, check for -timplicit_local -no_implicit_include
644 cmake_test_flags="-timplicit_local -no_implicit_include"
645 if [ "x${cmake_system}" = "xOSF1" ]; then
646 TMPFILE=`cmake_tmp_file`
647 cat > ${TMPFILE}.cxx <<EOF
648 #include <iostream>
649 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
651 cmake_need_flags=1
652 if cmake_try_run "${cmake_cxx_compiler}" \
653 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
655 else
656 cmake_need_flags=0
658 if [ "x${cmake_need_flags}" = "x1" ]; then
659 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
660 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
661 else
662 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
664 rm -f "${TMPFILE}.cxx"
666 cmake_test_flags=
668 # If we are on OSF, check for -std strict_ansi -nopure_cname
669 cmake_test_flags="-std strict_ansi -nopure_cname"
670 if [ "x${cmake_system}" = "xOSF1" ]; then
671 TMPFILE=`cmake_tmp_file`
672 cat > ${TMPFILE}.cxx <<EOF
673 #include <iostream>
674 int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
676 cmake_need_flags=1
677 if cmake_try_run "${cmake_cxx_compiler}" \
678 "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
680 else
681 cmake_need_flags=0
683 if [ "x${cmake_need_flags}" = "x1" ]; then
684 cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
685 echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
686 else
687 echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
689 rm -f "${TMPFILE}.cxx"
691 cmake_test_flags=
693 # If we are on HP-UX, check for -Ae for the C compiler.
694 cmake_test_flags="-Ae"
695 if [ "x${cmake_system}" = "xHP-UX" ]; then
696 TMPFILE=`cmake_tmp_file`
697 cat > ${TMPFILE}.c <<EOF
698 int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
700 cmake_need_Ae=0
701 if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
703 else
704 if cmake_try_run "${cmake_c_compiler}" \
705 "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
706 cmake_need_Ae=1
709 if [ "x${cmake_need_Ae}" = "x1" ]; then
710 cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
711 echo "${cmake_c_compiler} needs ${cmake_test_flags}"
712 else
713 echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
715 rm -f "${TMPFILE}.c"
717 cmake_test_flags=
720 # Test for kwsys features
721 KWSYS_NAME_IS_KWSYS=0
722 KWSYS_BUILD_SHARED=0
723 KWSYS_IOS_USE_STRSTREAM_H=0
724 KWSYS_IOS_USE_STRSTREA_H=0
725 KWSYS_IOS_HAVE_STD=0
726 KWSYS_IOS_USE_SSTREAM=0
727 KWSYS_IOS_USE_ANSI=0
728 KWSYS_STL_HAVE_STD=0
729 KWSYS_STAT_HAS_ST_MTIM=0
730 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0
731 KWSYS_STL_HAS_ITERATOR_TRAITS=0
732 KWSYS_STL_HAS_ITERATOR_CATEGORY=0
733 KWSYS_STL_HAS___ITERATOR_CATEGORY=0
734 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=0
735 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0
736 KWSYS_STL_HAS_ALLOCATOR_REBIND=0
737 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0
738 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=0
739 KWSYS_CXX_HAS_CSTDDEF=0
740 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0
741 KWSYS_CXX_HAS_MEMBER_TEMPLATES=0
742 KWSYS_CXX_HAS_FULL_SPECIALIZATION=0
743 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=0
745 # Hardcode these kwsys features. They work on all known UNIX compilers anyway.
746 KWSYS_STL_STRING_HAVE_ISTREAM=1
747 KWSYS_STL_STRING_HAVE_OSTREAM=1
749 if cmake_try_run "${cmake_cxx_compiler}" \
750 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAVE_STD" \
751 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
752 KWSYS_STL_HAVE_STD=1
753 echo "${cmake_cxx_compiler} has STL in std:: namespace"
754 else
755 echo "${cmake_cxx_compiler} does not have STL in std:: namespace"
758 if cmake_try_run "${cmake_cxx_compiler}" \
759 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_ANSI" \
760 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
761 KWSYS_IOS_USE_ANSI=1
762 echo "${cmake_cxx_compiler} has ANSI streams"
763 else
764 echo "${cmake_cxx_compiler} does not have ANSI streams"
767 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
768 if cmake_try_run "${cmake_cxx_compiler}" \
769 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_HAVE_STD" \
770 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
771 KWSYS_IOS_HAVE_STD=1
772 echo "${cmake_cxx_compiler} has streams in std:: namespace"
773 else
774 echo "${cmake_cxx_compiler} does not have streams in std:: namespace"
776 if cmake_try_run "${cmake_cxx_compiler}" \
777 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_SSTREAM" \
778 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
779 KWSYS_IOS_USE_SSTREAM=1
780 echo "${cmake_cxx_compiler} has sstream"
781 else
782 echo "${cmake_cxx_compiler} does not have sstream"
786 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x0" ]; then
787 if cmake_try_run "${cmake_cxx_compiler}" \
788 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREAM_H" \
789 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
790 KWSYS_IOS_USE_STRSTREAM_H=1
791 echo "${cmake_cxx_compiler} has strstream.h"
792 else
793 echo "${cmake_cxx_compiler} does not have strstream.h"
795 if [ "x$KWSYS_IOS_USE_STRSTREAM_H" = "x0" ]; then
796 if cmake_try_run "${cmake_cxx_compiler}" \
797 "${cmake_cxx_flags} -DTEST_KWSYS_IOS_USE_STRSTREA_H" \
798 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
799 KWSYS_IOS_USE_STRSTREA_H=1
800 echo "${cmake_cxx_compiler} has strstrea.h"
801 else
802 echo "${cmake_cxx_compiler} does not have strstrea.h"
807 if cmake_try_run "${cmake_cxx_compiler}" \
808 "${cmake_cxx_flags} -DTEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
809 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
810 KWSYS_STL_STRING_HAVE_NEQ_CHAR=1
811 echo "${cmake_cxx_compiler} has operator!=(string, char*)"
812 else
813 echo "${cmake_cxx_compiler} does not have operator!=(string, char*)"
816 if cmake_try_run "${cmake_cxx_compiler}" \
817 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
818 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
819 KWSYS_STL_HAS_ITERATOR_TRAITS=1
820 echo "${cmake_cxx_compiler} has stl iterator_traits"
821 else
822 echo "${cmake_cxx_compiler} does not have stl iterator_traits"
825 if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then
826 if cmake_try_run "${cmake_cxx_compiler}" \
827 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
828 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
829 KWSYS_STL_HAS_ITERATOR_CATEGORY=1
830 echo "${cmake_cxx_compiler} has old iterator_category"
831 else
832 echo "${cmake_cxx_compiler} does not have old iterator_category"
834 if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then
835 if cmake_try_run "${cmake_cxx_compiler}" \
836 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
837 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
838 KWSYS_STL_HAS___ITERATOR_CATEGORY=1
839 echo "${cmake_cxx_compiler} has old __iterator_category"
840 else
841 echo "${cmake_cxx_compiler} does not have old __iterator_category"
846 if cmake_try_run "${cmake_cxx_compiler}" \
847 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_TEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
848 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
849 KWSYS_STL_HAS_ALLOCATOR_TEMPLATE=1
850 echo "${cmake_cxx_compiler} has standard template allocator"
851 else
852 echo "${cmake_cxx_compiler} does not have standard template allocator"
855 if [ "x${KWSYS_STL_HAS_ALLOCATOR_TEMPLATE}" = "x1" ]; then
856 if cmake_try_run "${cmake_cxx_compiler}" \
857 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
858 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
859 KWSYS_STL_HAS_ALLOCATOR_REBIND=1
860 echo "${cmake_cxx_compiler} has allocator<>::rebind<>"
861 else
862 echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>"
865 if cmake_try_run "${cmake_cxx_compiler}" \
866 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
867 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
868 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1
869 echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument"
870 else
871 echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument"
873 else
874 if cmake_try_run "${cmake_cxx_compiler}" \
875 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
876 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
877 KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1
878 echo "${cmake_cxx_compiler} has old non-template allocator"
879 else
880 echo "${cmake_cxx_compiler} does not have old non-template allocator"
884 if cmake_try_run "${cmake_cxx_compiler}" \
885 "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_OBJECTS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \
886 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
887 KWSYS_STL_HAS_ALLOCATOR_OBJECTS=1
888 echo "${cmake_cxx_compiler} has stl containers supporting allocator objects"
889 else
890 echo "${cmake_cxx_compiler} does not have stl containers supporting allocator objects"
893 if cmake_try_run "${cmake_cxx_compiler}" \
894 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_CSTDDEF" \
895 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
896 KWSYS_CXX_HAS_CSTDDEF=1
897 echo "${cmake_cxx_compiler} has header cstddef"
898 else
899 echo "${cmake_cxx_compiler} does not have header cstddef"
902 if cmake_try_run "${cmake_cxx_compiler}" \
903 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS" \
904 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
905 echo "${cmake_cxx_compiler} does not require template friends to use <>"
906 else
907 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=1
908 echo "${cmake_cxx_compiler} requires template friends to use <>"
911 if cmake_try_run "${cmake_cxx_compiler}" \
912 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES" \
913 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
914 KWSYS_CXX_HAS_MEMBER_TEMPLATES=1
915 echo "${cmake_cxx_compiler} supports member templates"
916 else
917 echo "${cmake_cxx_compiler} does not support member templates"
920 if cmake_try_run "${cmake_cxx_compiler}" \
921 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION" \
922 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
923 KWSYS_CXX_HAS_FULL_SPECIALIZATION=1
924 echo "${cmake_cxx_compiler} has standard template specialization syntax"
925 else
926 echo "${cmake_cxx_compiler} does not have standard template specialization syntax"
929 if cmake_try_run "${cmake_cxx_compiler}" \
930 "${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP" \
931 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
932 KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP=1
933 echo "${cmake_cxx_compiler} has argument dependent lookup"
934 else
935 echo "${cmake_cxx_compiler} does not have argument dependent lookup"
938 if cmake_try_run "${cmake_cxx_compiler}" \
939 "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \
940 "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then
941 KWSYS_STAT_HAS_ST_MTIM=1
942 echo "${cmake_cxx_compiler} has struct stat with st_mtim member"
943 else
944 echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member"
947 # Just to be safe, let us store compiler and flags to the header file
949 cmake_bootstrap_version='$Revision: 1.66 $'
950 cmake_compiler_settings_comment="/*
951 * Generated by ${cmake_source_dir}/bootstrap
952 * Version: ${cmake_bootstrap_version}
954 * Source directory: ${cmake_source_dir}
955 * Binary directory: ${cmake_bootstrap_dir}
957 * C compiler: ${cmake_c_compiler}
958 * C flags: ${cmake_c_flags}
960 * C++ compiler: ${cmake_cxx_compiler}
961 * C++ flags: ${cmake_cxx_flags}
963 * Make: ${cmake_make_processor}
965 * Sources:
966 * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
967 * kwSys Sources:
968 * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
972 cmake_report cmConfigure.h.tmp "${cmake_compiler_settings_comment}"
974 if [ "x$KWSYS_STL_HAVE_STD" = "x1" ]; then
975 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
976 else
977 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
980 if [ "x$KWSYS_IOS_USE_ANSI" = "x1" ]; then
981 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
982 else
983 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
986 if [ "x$KWSYS_IOS_USE_SSTREAM" = "x1" ]; then
987 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
988 else
989 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
992 # Test for ansi FOR scope
993 if cmake_try_run "${cmake_cxx_compiler}" \
994 "${cmake_cxx_flags}" \
995 "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
996 cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
997 echo "${cmake_cxx_compiler} has ANSI for scoping"
998 else
999 cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
1000 echo "${cmake_cxx_compiler} does not have ANSI for scoping"
1003 # Write CMake version
1004 for a in MAJOR MINOR PATCH; do
1005 CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | \
1006 grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
1007 cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
1008 done
1009 cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
1010 cmake_report cmConfigure.h.tmp "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
1011 cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
1013 # Regenerate real cmConfigure.h
1014 if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
1015 rm -f cmConfigure.h.tmp
1016 else
1017 mv -f cmConfigure.h.tmp cmConfigure.h
1020 # Prepare KWSYS
1021 cmake_kwsys_config_replace_string \
1022 "${cmake_source_dir}/Source/kwsys/Configure.hxx.in" \
1023 "${cmake_bootstrap_dir}/cmsys/Configure.hxx" \
1024 "${cmake_compiler_settings_comment}"
1025 cmake_kwsys_config_replace_string \
1026 "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
1027 "${cmake_bootstrap_dir}/cmsys/Configure.h" \
1028 "${cmake_compiler_settings_comment}"
1030 for a in ${KWSYS_FILES}; do
1031 cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
1032 "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
1033 done
1035 for a in ${KWSYS_IOS_FILES}; do
1036 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
1037 "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
1038 done
1040 cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_stl.hxx.in" \
1041 "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" KWSYS_STL_HEADER_EXTRA ""
1043 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.hxx.in" \
1044 "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" KWSYS_NAMESPACE cmsys
1046 for a in string vector map; do
1047 cmake_replace_string "${cmake_bootstrap_dir}/cmsys/stl/stl.h.in" \
1048 "${cmake_bootstrap_dir}/cmsys/stl/${a}" KWSYS_STL_HEADER ${a}
1049 done
1051 # Generate Makefile
1052 dep="cmConfigure.h cmsys/Configure.hxx cmsys/Configure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
1053 objs=""
1054 for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
1055 objs="${objs} ${a}.o"
1056 done
1058 # Generate dependencies for cmBootstrapCommands.cxx
1059 for file in `grep "#include.*cm[^.]*.cxx" "${cmake_source_dir}/Source/cmBootstrapCommands.cxx" | sed "s/.* \"\(.*\)\"/\1/"`; do
1060 cmBootstrapCommandsDeps="${cmBootstrapCommandsDeps} `cmake_escape "${cmake_source_dir}/Source/$file"`"
1061 done
1062 cmBootstrapCommandsDeps=`echo $cmBootstrapCommandsDeps`
1064 if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
1065 cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
1068 if [ "x${cmake_c_flags}" != "x" ]; then
1069 cmake_c_flags="${cmake_c_flags} "
1072 if [ "x${cmake_cxx_flags}" != "x" ]; then
1073 cmake_cxx_flags="${cmake_cxx_flags} "
1076 cmake_c_flags="${cmake_c_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1077 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1078 cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` \
1079 -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
1080 echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
1081 echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
1082 for a in ${CMAKE_CXX_SOURCES}; do
1083 src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
1084 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1085 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1086 done
1087 echo "cmBootstrapCommands.o : $cmBootstrapCommandsDeps" >> "${cmake_bootstrap_dir}/Makefile"
1088 for a in ${CMAKE_C_SOURCES}; do
1089 src=`cmake_escape "${cmake_source_dir}/Source/${a}.c"`
1090 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1091 echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1092 done
1093 for a in ${KWSYS_C_SOURCES}; do
1094 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"`
1095 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1096 echo " ${cmake_c_compiler} ${cmake_c_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1097 done
1098 for a in ${KWSYS_CXX_SOURCES}; do
1099 src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
1100 echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
1101 echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
1102 done
1103 cat>>"${cmake_bootstrap_dir}/Makefile"<<EOF
1104 rebuild_cache:
1105 cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
1108 # Write our default settings to Bootstrap.cmk/InitialCacheFlags.cmake.
1109 cat > "${cmake_bootstrap_dir}/InitialCacheFlags.cmake" <<EOF
1110 # Generated by ${cmake_source_dir}/bootstrap
1111 # Default cmake settings. These may be overridden any settings below.
1112 SET (CMAKE_INSTALL_PREFIX "${cmake_prefix_dir}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
1113 SET (CMAKE_DOC_DIR "${cmake_doc_dir}" CACHE PATH "Install location for documentation (relative to prefix)." FORCE)
1114 SET (CMAKE_MAN_DIR "${cmake_man_dir}" CACHE PATH "Install location for man pages (relative to prefix)." FORCE)
1115 SET (CMAKE_DATA_DIR "${cmake_data_dir}" CACHE PATH "Install location for data (relative to prefix)." FORCE)
1118 # Add user-specified settings. Handle relative-path case for
1119 # specification of cmake_init_file.
1121 cd "${cmake_binary_dir}"
1122 if [ -f "${cmake_init_file}" ]; then
1123 cat "${cmake_init_file}" >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1127 echo "---------------------------------------------"
1129 # Run make to build bootstrap cmake
1130 if [ "x${cmake_parallel_make}" != "x" ]; then
1131 ${cmake_make_processor} ${cmake_make_flags}
1132 else
1133 ${cmake_make_processor}
1135 RES=$?
1136 if [ "${RES}" -ne "0" ]; then
1137 cmake_error 9 "Problem while running ${cmake_make_processor}"
1139 cd "${cmake_binary_dir}"
1141 # Set C, CXX, and MAKE environment variables, so that real real cmake will be
1142 # build with same compiler and make
1143 CC="${cmake_c_compiler}"
1144 CXX="${cmake_cxx_compiler}"
1145 MAKE="${cmake_make_processor}"
1146 export CC
1147 export CXX
1148 export MAKE
1150 # Run bootstrap CMake to configure real CMake
1151 "${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
1152 RES=$?
1153 if [ "${RES}" -ne "0" ]; then
1154 cmake_error 11 "Problem while running initial CMake"
1157 echo "---------------------------------------------"
1159 # And we are done. Now just run make
1160 echo "CMake has bootstrapped. Now run ${cmake_make_processor}."