ENH: Add copyright, cmConfigure.h is now touched only when it is modified, remove some spaces from output, add procedure that copies file and replaces atstring with another string

This commit is contained in:
Andy Cedilnik 2003-06-21 11:57:13 -04:00
parent aaf2795050
commit 324807d395
1 changed files with 84 additions and 14 deletions

View File

@ -1,5 +1,22 @@
#!/bin/sh
#=========================================================================
#
# 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.
#
#=========================================================================
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"
@ -82,6 +99,27 @@ cmake_error()
exit 1
}
# 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
fi
}
# Write string into a file
cmake_report ()
{
@ -215,7 +253,6 @@ cd "${cmake_bootstrap_dir}"
# Delete all the bootstrap files
rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
rm -f "${cmake_bootstrap_dir}/cmConfigure.h"
# If exist compiler flags, set them
cmake_c_flags=${CFLAGS}
@ -349,21 +386,38 @@ EOF
rm -f "${TMPFILE}.cxx"
fi
# 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}"
cmake_report cmConfigure.h.tmp " */"
# Test for STD namespace
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForSTDNamespace.cxx" >> cmake_bootstrap.log 2>&1; then
cmake_report cmConfigure.h "/* #undef CMAKE_NO_STD_NAMESPACE */"
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_STD_NAMESPACE */"
echo "${cmake_cxx_compiler} has STD namespace"
else
cmake_report cmConfigure.h "#define CMAKE_NO_STD_NAMESPACE 1"
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_STD_NAMESPACE 1"
echo "${cmake_cxx_compiler} does not have STD namespace"
fi
# Test for ANSI stream headers
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForANSIStreamHeaders.cxx" >> cmake_bootstrap.log 2>&1; then
cmake_report cmConfigure.h "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */"
echo "${cmake_cxx_compiler} has ANSI stream headers"
else
cmake_report cmConfigure.h "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STREAM_HEADERS 1"
echo "${cmake_cxx_compiler} does not have ANSI stream headers"
fi
@ -374,30 +428,37 @@ cat>${TMPFILE}.cxx<<EOF
int main() { return 0;}
EOF
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
cmake_report cmConfigure.h "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_STRING_STREAM */"
echo "${cmake_cxx_compiler} has ANSI string streams"
else
cmake_report cmConfigure.h "#define CMAKE_NO_ANSI_STRING_STREAM 1"
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_STRING_STREAM 1"
echo "${cmake_cxx_compiler} does not have ANSI string streams"
fi
rm -f "${TMPFILE}.cxx"
# Test for ansi FOR scope
if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${cmake_source_dir}/Modules/TestForAnsiForScope.cxx" >> cmake_bootstrap.log 2>&1; then
cmake_report cmConfigure.h "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
cmake_report cmConfigure.h.tmp "/* #undef CMAKE_NO_ANSI_FOR_SCOPE */"
echo "${cmake_cxx_compiler} has ANSI for scoping"
else
cmake_report cmConfigure.h "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
cmake_report cmConfigure.h.tmp "#define CMAKE_NO_ANSI_FOR_SCOPE 1"
echo "${cmake_cxx_compiler} does not have ANSI for scoping"
fi
# Write 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_report cmConfigure.h "#define CMake_VERSION_${a} ${CMake_VERSION}"
cmake_report cmConfigure.h.tmp "#define CMake_VERSION_${a} ${CMake_VERSION}"
done
cmake_report cmConfigure.h "#define CMAKE_ROOT_DIR \"${cmake_source_dir}\""
cmake_report cmConfigure.h "#define CMAKE_BOOTSTRAP"
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
fi
# Generate Makefile
dep="cmConfigure.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
@ -405,7 +466,16 @@ objs=""
for a in ${CMAKE_SOURCES}; do
objs="${objs} ${a}.o"
done
cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags} -I`cmake_escape \"${cmake_source_dir}/Source\"` -I`cmake_escape \"${cmake_bootstrap_dir}\"`"
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}\"`"
echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
echo " ${cmake_cxx_compiler} ${LDFLAGS} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
for a in ${CMAKE_SOURCES}; do
@ -446,4 +516,4 @@ export MAKE
echo "---------------------------------------------"
# And we are done. Now just run make
echo "CMake ${CMAKE_VERSION} is configured. Now just run ${cmake_make_processor}."
echo "CMake is configured. Now just run ${cmake_make_processor}."