2003-03-27 23:29:38 +03:00
#!/bin/sh
2003-06-21 19:57:13 +04:00
#=========================================================================
#
# Program: CMake - Cross-Platform Makefile Generator
# Module: $RCSfile$
# Language: Bourne Shell
# Date: $Date$
# Version: $Revision$
#
# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
# See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the above copyright notices for more information.
#
#=========================================================================
2003-03-27 23:29:38 +03:00
CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
CMAKE_KNOWN_CXX_COMPILERS="CC g++ c++ xlC icc como aCC"
CMAKE_KNOWN_MAKE_PROCESSORS="make gmake"
CMAKE_SOURCES="\
cmake \
cmakewizard \
cmakemain \
cmMakeDepend \
cmMakefile \
cmDocumentation \
cmGlobalGenerator \
cmLocalGenerator \
cmSourceFile \
cmSystemTools \
cmGlobalUnixMakefileGenerator \
cmLocalUnixMakefileGenerator \
cmCommands \
cmTarget \
cmCustomCommand \
cmCacheManager \
cmListFileCache \
cmVariableWatch \
cmSourceGroup"
2003-06-23 16:58:58 +04:00
KWSYS_SOURCES="\
Directory \
RegularExpression \
SystemTools"
KWSYS_FILES="\
Directory.hxx \
Process.h \
RegularExpression.hxx \
SystemTools.hxx"
KWSYS_STD_FILES="
fstream \
iosfwd \
iostream \
sstream"
2003-04-22 22:32:48 +04:00
cmake_system=`uname`
2003-03-27 23:29:38 +03:00
cmake_source_dir=`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`
cmake_source_dir=`(cd "${cmake_source_dir}";pwd)`
cmake_binary_dir=`pwd`
2003-04-17 16:02:44 +04:00
cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
2003-03-27 23:29:38 +03:00
2003-05-15 17:35:16 +04:00
# Display CMake bootstrap usage
2003-03-27 23:29:38 +03:00
cmake_usage()
{
cat<<EOF
Usage: $0 [options]
Options: [defaults in brackets after descriptions]
Configuration:
--help print this message
2003-05-15 17:35:16 +04:00
--version only print version information
2003-03-27 23:29:38 +03:00
--verbose display more information
2003-05-15 17:35:16 +04:00
--parallel=n bootstrap cmake in parallel, where n is
number of nodes [1]
2003-03-27 23:29:38 +03:00
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
EOF
exit 10
}
2003-05-15 17:35:16 +04:00
# Display CMake bootstrap usage
cmake_version()
{
# Get CMake version
CMAKE_VERSION=""
for a in MAJOR MINOR PATCH; do
CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
CMAKE_VERSION="${CMAKE_VERSION}.${CMake_VERSION}"
done
CMAKE_VERSION=`echo $CMAKE_VERSION | sed "s/\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1.\2-\3/"`
echo "CMake ${CMAKE_VERSION}, Copyright (c) 2002 Kitware, Inc., Insight Consortium"
}
# Display CMake bootstrap error, display the log file and exit
2003-05-14 17:19:12 +04:00
cmake_error()
{
2003-03-27 23:29:38 +03:00
echo "---------------------------------------------"
2003-05-14 17:19:12 +04:00
echo "Error when bootstrapping CMake:"
echo "$*"
echo "---------------------------------------------"
if [ -f cmake_bootstrap.log ]; then
echo "Log of errors:"
cat cmake_bootstrap.log
echo "---------------------------------------------"
fi
exit 1
}
2003-03-27 23:29:38 +03:00
2003-06-21 19:57:13 +04:00
# Replace KWSYS_NAMESPACE with cmsys
cmake_replace_string ()
{
INFILE="$1"
OUTFILE="$2"
SEARCHFOR="$3"
REPLACEWITH="$4"
if [ -f "${INFILE}" ]; then
cat "${INFILE}" |
sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}.tmp"
if [ -f "${OUTFILE}.tmp" ]; then
if diff "${OUTFILE}" "${OUTFILE}.tmp" > /dev/null 2> /dev/null ; then
#echo "Files are the same"
rm -f "${OUTFILE}.tmp"
else
mv -f "${OUTFILE}.tmp" "${OUTFILE}"
fi
fi
2003-06-23 16:58:58 +04:00
else
cmake_error "Cannot find file ${INFILE}"
2003-06-21 19:57:13 +04:00
fi
}
2003-05-15 17:35:16 +04:00
# Write string into a file
2003-03-27 23:29:38 +03:00
cmake_report ()
{
FILE=$1
shift
echo "$*" >> ${FILE}
}
2003-05-15 17:35:16 +04:00
# Escape spaces in strings
2003-03-27 23:29:38 +03:00
cmake_escape ()
{
echo $1 | sed "s/ /\\\\ /g"
}
2003-05-15 17:35:16 +04:00
# Write message to the log
2003-03-27 23:29:38 +03:00
cmake_log ()
{
echo "$*" >> cmake_bootstrap.log
}
2003-05-15 17:35:16 +04:00
# Return temp file
2003-03-27 23:29:38 +03:00
cmake_tmp_file ()
{
echo "cmake_bootstrap_$$.test"
}
2003-05-15 17:35:16 +04:00
# Run a compiler test. First argument is compiler, second one are compiler
# flags, third one is test source file to be compiled
2003-03-27 23:29:38 +03:00
cmake_try_run ()
{
COMPILER=$1
FLAGS=$2
TESTFILE=$3
if [ ! -f "${TESTFILE}" ]; then
echo "Test file ${TESTFILE} missing. Please verify your CMake source tree."
exit 4
fi
TMPFILE=`cmake_tmp_file`
echo "Try: ${COMPILER}"
2003-06-30 17:56:33 +04:00
echo "Line: ${COMPILER} ${FLAGS} ${TESTFILE} -o ${TMPFILE}"
echo "---------- file -----------------------"
cat ${TESTFILE}
echo "------------------------------------------"
2003-03-27 23:29:38 +03:00
"${COMPILER}" ${FLAGS} "${TESTFILE}" -o "${TMPFILE}"
RES=$?
if [ "${RES}" -ne "0" ]; then
echo "${COMPILER} does not work";return 1
fi
if [ ! -f "${TMPFILE}" ] && [ ! -f "${TMPFILE}.exe" ]; then
echo "${COMPILER} does not produce output"
return 2
fi
./${TMPFILE}
RES=$?
rm -f "${TMPFILE}"
if [ "${RES}" -ne "0" ]; then
echo "${COMPILER} produces strange executable"
return 3
fi
echo "${COMPILER} works"
return 0
}
2003-05-15 17:35:16 +04:00
# Run a make test. First argument is the make interpreter.
2003-03-27 23:29:38 +03:00
cmake_try_make ()
{
MAKE_PROC=$1
echo "Try: ${MAKE_PROC}"
${MAKE_PROC}
RES=$?
if [ "${RES}" -ne "0" ]; then
echo "${MAKE_PROC} does not work";return 1
fi
if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
echo "${COMPILER} does not produce output"
return 2
fi
./test
RES=$?
rm -f "test"
if [ "${RES}" -ne "0" ]; then
echo "${MAKE_PROC} produces strange executable"
return 3
fi
echo "${MAKE_PROC} works"
return 0
}
2003-05-15 17:35:16 +04:00
# Parse arguments
2003-05-14 17:19:12 +04:00
cmake_verbose=
2003-05-14 17:27:39 +04:00
cmake_parallel_make=
2003-05-14 17:19:12 +04:00
cmake_prefix_dir="/usr/local"
for a in "$@"; do
2003-05-14 17:27:39 +04:00
if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
2003-05-14 17:19:12 +04:00
cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"`
fi
2003-05-14 17:27:39 +04:00
if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then
cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"`
fi
if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
2003-05-14 17:19:12 +04:00
cmake_usage
fi
2003-05-15 17:35:16 +04:00
if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
cmake_version
exit 2
fi
2003-05-14 17:27:39 +04:00
if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
2003-05-14 17:19:12 +04:00
cmake_verbose=TRUE
fi
done
2003-05-15 17:35:16 +04:00
# If verbose, display some information about bootstrap
2003-05-14 17:19:12 +04:00
if [ -n "${cmake_verbose}" ]; then
echo "---------------------------------------------"
echo "Source directory: ${cmake_source_dir}"
echo "Binary directory: ${cmake_binary_dir}"
echo "Prefix directory: ${cmake_prefix_dir}"
echo "System: ${cmake_system}"
2003-05-14 17:27:39 +04:00
if [ "x${cmake_parallel_make}" != "x" ]; then
echo "Doing parallel make: ${cmake_parallel_make}"
fi
echo ""
2003-05-14 17:19:12 +04:00
fi
echo "---------------------------------------------"
2003-05-15 17:35:16 +04:00
# Get CMake version
echo "`cmake_version`"
2003-05-14 17:19:12 +04:00
2003-05-15 17:35:16 +04:00
# Make bootstrap directory
2003-05-14 17:19:12 +04:00
[ -d "${cmake_bootstrap_dir}" ] || mkdir "${cmake_bootstrap_dir}"
if [ ! -d "${cmake_bootstrap_dir}" ]; then
cmake_error "Cannot create directory ${cmake_bootstrap_dir} to bootstrap CMake."
fi
cd "${cmake_bootstrap_dir}"
2003-06-23 16:58:58 +04:00
[ -d "cmsys" ] || mkdir "cmsys"
if [ ! -d "cmsys" ]; then
cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys"
fi
[ -d "cmsys/std" ] || mkdir "cmsys/std"
if [ ! -d "cmsys/std" ]; then
cmake_error "Cannot create directory ${cmake_bootstrap_dir}/cmsys/std"
fi
2003-05-15 17:35:16 +04:00
# Delete all the bootstrap files
2003-05-14 17:19:12 +04:00
rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
2003-06-30 17:56:33 +04:00
rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
2003-05-14 17:19:12 +04:00
2003-05-15 17:35:16 +04:00
# If exist compiler flags, set them
2003-03-27 23:29:38 +03:00
cmake_c_flags=${CFLAGS}
cmake_cxx_flags=${CXXFLAGS}
# Test C compiler
cmake_c_compiler=
2003-05-15 17:35:16 +04:00
# If CC is set, use that for compiler, otherwise use list of known compilers
2003-03-27 23:29:38 +03:00
if [ -n "${CC}" ]; then
cmake_c_compilers="${CC}"
else
cmake_c_compilers="${CMAKE_KNOWN_C_COMPILERS}"
fi
2003-05-15 17:35:16 +04:00
# Check if C compiler works
2003-03-27 23:29:38 +03:00
TMPFILE=`cmake_tmp_file`
cat>"${TMPFILE}.c"<<EOF
#include<stdio.h>
int main()
{
printf("1\n");
return 0;
}
EOF
for a in ${cmake_c_compilers}; do
if [ -z "${cmake_c_compiler}" ] && cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
cmake_c_compiler="${a}"
fi
done
rm -f "${TMPFILE}.c"
if [ -z "${cmake_c_compiler}" ]; then
2003-05-14 17:19:12 +04:00
cmake_error "Cannot find apropriate C compiler on this system.
Please specify one using environment variable CC."
2003-03-27 23:29:38 +03:00
fi
echo "C compiler on this system is: ${cmake_c_compiler} ${cmake_c_flags}"
# Test CXX compiler
cmake_cxx_compiler=
2003-05-15 17:35:16 +04:00
2003-06-30 17:56:33 +04:00
# On Mac OSX, CC is the same as cc, so make sure not to try CC as c++ compiler.
2003-05-15 17:35:16 +04:00
# If CC is set, use that for compiler, otherwise use list of known compilers
2003-03-27 23:29:38 +03:00
if [ -n "${CXX}" ]; then
cmake_cxx_compilers="${CXX}"
else
cmake_cxx_compilers="${CMAKE_KNOWN_CXX_COMPILERS}"
fi
2003-05-15 17:35:16 +04:00
# Check if C++ compiler works
2003-03-27 23:29:38 +03:00
TMPFILE=`cmake_tmp_file`
cat>"${TMPFILE}.cxx"<<EOF
2003-06-04 17:00:36 +04:00
#include <stdio.h>
2003-06-30 17:56:33 +04:00
class NeedCXX
{
public:
NeedCXX() { this->Foo = 1; }
int GetFoo() { return this->Foo; }
private:
int Foo;
};
2003-03-27 23:29:38 +03:00
int main()
{
2003-06-30 17:56:33 +04:00
NeedCXX c;
printf("%d\n", c.GetFoo());
2003-03-27 23:29:38 +03:00
return 0;
}
EOF
for a in ${cmake_cxx_compilers}; do
if [ -z "${cmake_cxx_compiler}" ] && cmake_try_run "${a}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
cmake_cxx_compiler="${a}"
fi
done
rm -f "${TMPFILE}.cxx"
if [ -z "${cmake_cxx_compiler}" ]; then
2003-05-14 17:19:12 +04:00
cmake_error "Cannot find apropriate C++ compiler on this system.
Please specify one using environment variable CXX."
2003-03-27 23:29:38 +03:00
fi
echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
# Test Make
cmake_make_processor=
2003-05-15 17:35:16 +04:00
# If MAKE is set, use that for make processor, otherwise use list of known make
2003-03-27 23:29:38 +03:00
if [ -n "${MAKE}" ]; then
cmake_make_processors="${MAKE}"
else
cmake_make_processors="${CMAKE_KNOWN_MAKE_PROCESSORS}"
fi
TMPFILE="`cmake_tmp_file`_dir"
rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
cd "${cmake_bootstrap_dir}/${TMPFILE}"
cat>"Makefile"<<EOF
test: test.c
${cmake_c_compiler} -o test test.c
EOF
cat>"test.c"<<EOF
#include <stdio.h>
int main(){ printf("1\n"); return 0; }
EOF
for a in ${cmake_make_processors}; do
if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" >> cmake_bootstrap.log 2>&1; then
cmake_make_processor="${a}"
fi
done
cd "${cmake_bootstrap_dir}"
rm -rf "${cmake_bootstrap_dir}/${TMPFILE}"
echo "Make processor on this system is: ${cmake_make_processor}"
2003-05-15 17:35:16 +04:00
# Ok, we have CC, CXX, and MAKE.
2003-03-27 23:29:38 +03:00
# Test C++ compiler features
2003-04-22 22:32:48 +04:00
2003-05-15 17:35:16 +04:00
# If we are on IRIX, check for -LANG:std
2003-06-26 17:44:27 +04:00
cmake_test_flags="-LANG:std"
2003-04-22 22:32:48 +04:00
if [ "x${cmake_system}" = "xIRIX64" ]; then
TMPFILE=`cmake_tmp_file`
cat>${TMPFILE}.cxx<<EOF
#include <iostream>
2003-06-26 17:44:27 +04:00
int main() { std::cout << "No need for ${cmake_test_flags}" << std::endl; return 0;}
2003-04-22 22:32:48 +04:00
EOF
cmake_need_lang_std=0
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
:
else
2003-06-26 17:44:27 +04:00
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
2003-04-22 22:32:48 +04:00
cmake_need_lang_std=1
fi
fi
if [ "x${cmake_need_lang_std}" = "x1" ]; then
2003-06-26 17:44:27 +04:00
cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
2003-04-22 22:32:48 +04:00
else
2003-06-26 17:44:27 +04:00
echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
2003-04-22 22:32:48 +04:00
fi
rm -f "${TMPFILE}.cxx"
fi
2003-06-26 17:44:27 +04:00
cmake_test_flags=
# If we are on OSF, check for -timplicit_local -no_implicit_include
cmake_test_flags="-timplicit_local -no_implicit_include"
if [ "x${cmake_system}" = "xOSF1" ]; then
TMPFILE=`cmake_tmp_file`
cat>${TMPFILE}.cxx<<EOF
#include <iostream>
int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
EOF
cmake_need_flags=1
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
:
else
cmake_need_flags=0
fi
if [ "x${cmake_need_flags}" = "x1" ]; then
cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
else
echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
fi
rm -f "${TMPFILE}.cxx"
fi
cmake_test_flags=
# If we are on OSF, check for -std strict_ansi -nopure_cname
cmake_test_flags="-std strict_ansi -nopure_cname"
if [ "x${cmake_system}" = "xOSF1" ]; then
TMPFILE=`cmake_tmp_file`
cat>${TMPFILE}.cxx<<EOF
#include <iostream>
int main() { std::cout << "We need ${cmake_test_flags}" << std::endl; return 0;}
EOF
cmake_need_flags=1
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
:
else
cmake_need_flags=0
fi
if [ "x${cmake_need_flags}" = "x1" ]; then
cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
else
echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
fi
rm -f "${TMPFILE}.cxx"
fi
cmake_test_flags=
2003-04-22 22:32:48 +04:00
2003-06-21 19:57:13 +04:00
# Just to be safe, let us store compiler and flags to the header file
cmake_report cmConfigure.h.tmp "/*"
cmake_report cmConfigure.h.tmp " * Generated by ${cmake_source_dir}/bootstrap"
cmake_report cmConfigure.h.tmp " * Binary directory: ${cmake_bootstrap_dir}"
cmake_report cmConfigure.h.tmp " * C compiler: ${cmake_c_compiler}"
cmake_report cmConfigure.h.tmp " * C flags: ${cmake_c_flags}"
cmake_report cmConfigure.h.tmp " *"
cmake_report cmConfigure.h.tmp " * C++ compiler: ${cmake_cxx_compiler}"
cmake_report cmConfigure.h.tmp " * C++ flags: ${cmake_cxx_flags}"
cmake_report cmConfigure.h.tmp " *"
cmake_report cmConfigure.h.tmp " * Make: ${cmake_make_processor}"
cmake_report cmConfigure.h.tmp " *"
cmake_report cmConfigure.h.tmp " * Sources:"
cmake_report cmConfigure.h.tmp " * ${CMAKE_SOURCES}"
2003-06-30 17:56:33 +04:00
cmake_report cmConfigure.h.tmp " * kwSys Sources:"
cmake_report cmConfigure.h.tmp " * ${KWSYS_SOURCES}"
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp " */"
2003-05-15 17:35:16 +04:00
# Test for STD namespace
2003-03-27 23:29:38 +03:00
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForSTDNamespace.cxx" >> cmake_bootstrap.log 2>&1; then
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
2003-06-23 16:58:58 +04:00
cmake_report cmConfigure.h.tmp "#define cmsys_std std"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} has STD namespace"
else
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
2003-06-23 16:58:58 +04:00
cmake_report cmConfigure.h.tmp "#define KWSYS_NO_STD_NAMESPACE"
cmake_report cmConfigure.h.tmp "#define cmsys_std"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} does not have STD namespace"
fi
2003-05-15 17:35:16 +04:00
# Test for ANSI stream headers
2003-03-27 23:29:38 +03:00
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForANSIStreamHeaders.cxx" >> cmake_bootstrap.log 2>&1; then
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} has ANSI stream headers"
else
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
2003-06-23 16:58:58 +04:00
cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STREAM_HEADERS 1"
cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STREAM_HEADERS"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} does not have ANSI stream headers"
fi
2003-05-15 17:35:16 +04:00
# Test for ansi string streams
2003-03-27 23:29:38 +03:00
TMPFILE=`cmake_tmp_file`
cat>${TMPFILE}.cxx<<EOF
#include <sstream>
int main() { return 0;}
EOF
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} has ANSI string streams"
else
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
2003-06-23 16:58:58 +04:00
cmake_report cmConfigure.h.tmp "#define KWSYS_NO_ANSI_STRING_STREAM 1"
cmake_report cmConfigure.h.tmp "#define cmsys_NO_ANSI_STRING_STREAM 1"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} does not have ANSI string streams"
fi
rm -f "${TMPFILE}.cxx"
2003-05-15 17:35:16 +04:00
# Test for ansi FOR scope
2003-03-27 23:29:38 +03:00
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} has ANSI for scoping"
else
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
2003-03-27 23:29:38 +03:00
echo "${cmake_cxx_compiler} does not have ANSI for scoping"
fi
2003-06-23 16:58:58 +04:00
cmake_report cmConfigure.h.tmp "/* Defined if std namespace is the GCC hack. */"
cmake_report cmConfigure.h.tmp "#if defined(__GNUC__) && (__GNUC__ < 3)"
cmake_report cmConfigure.h.tmp "# define cmsys_FAKE_STD_NAMESPACE"
cmake_report cmConfigure.h.tmp "#endif"
cmake_report cmConfigure.h.tmp "#define kwsys_std cmsys_std"
2003-03-27 23:29:38 +03:00
2003-05-15 17:35:16 +04:00
# Write CMake version
2003-03-27 23:29:38 +03:00
for a in MAJOR MINOR PATCH; do
CMake_VERSION=`cat "${cmake_source_dir}/CMakeLists.txt" | grep "SET(CMake_VERSION_${a} *[0-9]*)" | sed "s/SET(CMake_VERSION_${a} *\([0-9]*\))/\1/"`
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
2003-03-27 23:29:38 +03:00
done
2003-06-21 19:57:13 +04:00
cmake_report cmConfigure.h.tmp "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
cmake_report cmConfigure.h.tmp "#define CMAKE_BOOTSTRAP"
# Regenerate real cmConfigure.h
if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
rm -f cmConfigure.h.tmp
else
mv -f cmConfigure.h.tmp cmConfigure.h
2003-06-23 16:58:58 +04:00
cp cmConfigure.h cmsys/Configure.hxx
2003-06-21 19:57:13 +04:00
fi
2003-03-27 23:29:38 +03:00
2003-06-23 16:58:58 +04:00
# Prepare KWSYS
for a in ${KWSYS_FILES}; do
cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
"${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
done
for a in ${KWSYS_STD_FILES}; do
cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std_${a}.h.in" \
"${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_NAMESPACE cmsys
done
cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_std.h.in" \
"${cmake_bootstrap_dir}/cmsys/std/stl.h.in" KWSYS_NAMESPACE cmsys
2003-06-30 18:50:40 +04:00
cmake_replace_string "${cmake_source_dir}/Source/kwsys/Configure.h.in" \
"${cmake_bootstrap_dir}/cmsys/Configure.h.in" KWSYS_NAMESPACE cmsys
cmake_replace_string "${cmake_bootstrap_dir}/cmsys/Configure.h.in" \
"${cmake_bootstrap_dir}/cmsys/Configure.h" KWSYS_BUILD_SHARED 0
2003-06-23 16:58:58 +04:00
for a in string vector; do
cmake_replace_string "${cmake_bootstrap_dir}/cmsys/std/stl.h.in" \
"${cmake_bootstrap_dir}/cmsys/std/${a}" KWSYS_STL_HEADER ${a}
done
2003-03-27 23:29:38 +03:00
# Generate Makefile
dep="cmConfigure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
objs=""
2003-06-23 16:58:58 +04:00
for a in ${CMAKE_SOURCES} ${KWSYS_SOURCES}; do
2003-03-27 23:29:38 +03:00
objs="${objs} ${a}.o"
done
2003-06-21 19:57:13 +04:00
if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
fi
if [ "x${cmake_cxx_flags}" != "x" ]; then
cmake_cxx_flags="${cmake_cxx_flags} "
fi
cmake_cxx_flags="${cmake_cxx_flags}-I`cmake_escape \"${cmake_source_dir}/Source\"` -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
2003-03-27 23:29:38 +03:00
echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
2003-04-17 21:13:48 +04:00
echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
2003-03-27 23:29:38 +03:00
for a in ${CMAKE_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
done
2003-06-23 16:58:58 +04:00
for a in ${KWSYS_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.cxx"`
echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -I`cmake_escape \"${cmake_bootstrap_dir}/cmsys\"` -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
done
2003-03-27 23:29:38 +03:00
2003-04-17 16:02:44 +04:00
# Write prefix to Bootstrap.cmk/InitialConfigureFlags.cmake
2003-03-27 23:29:38 +03:00
echo "SET (CMAKE_CONFIGURE_INSTALL_PREFIX \"${cmake_prefix_dir}\" CACHE PATH \"Install path prefix, prepended onto install directories, For CMake this will always override CMAKE_INSTALL_PREFIX in the cache.\")" > "${cmake_bootstrap_dir}/InitialConfigureFlags.cmake"
echo "---------------------------------------------"
2003-05-15 17:35:16 +04:00
# Run make to build bootstrap cmake
2003-05-14 17:27:39 +04:00
if [ "x${cmake_parallel_make}" != "x" ]; then
${cmake_make_processor} -j ${cmake_parallel_make}
else
${cmake_make_processor}
fi
2003-03-27 23:29:38 +03:00
RES=$?
if [ "${RES}" -ne "0" ]; then
2003-05-14 17:19:12 +04:00
cmake_error "Problem while bootstrapping CMake"
2003-03-27 23:29:38 +03:00
fi
cd "${cmake_binary_dir}"
2003-05-15 17:35:16 +04:00
# Set C, CXX, and MAKE environment variables, so that real real cmake will be
# build with same compiler and make
CC="${cmake_c_compiler}"
CXX="${cmake_cxx_compiler}"
MAKE="${cmake_make_processor}"
export CC
export CXX
export MAKE
# Run bootstrap CMake to configure real CMake
2003-03-27 23:29:38 +03:00
"${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}"
echo "---------------------------------------------"
2003-05-15 17:35:16 +04:00
# And we are done. Now just run make
2003-06-21 19:57:13 +04:00
echo "CMake is configured. Now just run ${cmake_make_processor}."