Implemented more intelligent test for precompiled headers

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@24370 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2007-01-16 16:40:24 +00:00
parent 001e61ec46
commit 183ae3f0e6
7 changed files with 202 additions and 48 deletions

View file

@ -1,3 +1,16 @@
2007-01-16 Nicola Pero <nicola.pero@meta-innovation.com>
* config-precomp-test: New directory
* config-precomp-test/gs_precomp_test.h,
config-precomp-test/gs_precomp_test.m,
config-precomp-test/run-test.sh: New test for ObjC precompiled
headers to properly detect if they work or not.
* configure.ac: Run the new test to determine if ObjC precompiled
headers work or not.
* configure: Regenerated.
* GNUmakefile.in (distclean): Remove config-precomp-test.log; also
remove multiple files in a go for speed.
2007-01-16 Nicola Pero <nicola.pero@meta-innovation.com>
* rules.make ($(GNUSTEP_OBJ_DIR)/PrecompiledHeaders/C/): do not

View file

@ -251,14 +251,10 @@ clean:
distclean: clean
rm -f GNUmakefile config-noarch.make config.make config.h
rm -f config.cache config.log config.status
rm -f openapp
rm -f opentool
rm -f executable.template
rm -f GNUstep.sh
rm -f GNUstep.csh
rm -f fixpath.sh
rm -f gnustep-make.spec
rm -f GNUsteprc
rm -f openapp opentool executable.template
rm -f GNUstep.sh GNUstep.csh fixpath.sh
rm -f gnustep-make.spec GNUsteprc
rm -f config-precomp-test.log
svn-tag:
svn copy $(SVNPREFIX)/trunk $(SVNPREFIX)/tags/make-$(VERTAG) \

View file

@ -0,0 +1,3 @@
@interface TestClass
+ (int) test;
@end

View file

@ -0,0 +1,13 @@
#include "gs_precomp_test.h"
@implementation TestClass
+ (int) test
{
return 0;
}
@end
int main (void)
{
return [TestClass test];
}

112
config-precomp-test/run-test.sh Executable file
View file

@ -0,0 +1,112 @@
#! /bin/sh
#
# Test for Objective-C precompiled headers
#
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# Author: Nicola Pero <nicola.pero@meta-innovation.com>
#
# This file is part of the GNUstep Makefile Package.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Check if GCC supports precompiled headers for Objective-C or not.
# You should execute this shell scripts after setting the following
# environment variables:
#
# CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS
#
# ./configure at the top-level will set them for us; you need to
# set them manually if you want to run the test manually.
# The script will execute and:
# return 0 if gcc supports ObjC precompiled headers
# return 1 if gcc does not
# It will also log everything it does to a log file that can be
# specified as the first argument to the script. If there is
# no log file specified, ./log will be used.
# This is the file where everything will be logged
gs_logfile="$1"
if test "$gs_logfile" = ""; then
gs_logfile="./log"
fi
# Clear logs
rm -f $gs_logfile
# Clear compilation results
rm -f gs_precomp_test.h.gch a.out *~
echo "** Environment" >>$gs_logfile 2>&1
echo " CC: $CC" >>$gs_logfile 2>&1
echo " CFLAGS: $CFLAGS" >>$gs_logfile 2>&1
echo " CPPFLAGS: $CPPFLAGS" >>$gs_logfile 2>&1
echo " LDFLAGS: $LDFLAGS" >>$gs_logfile 2>&1
echo " LIBS: $LIBS" >>$gs_logfile 2>&1
echo "" >>$gs_logfile 2>&1
echo " current directory: `pwd`" >>$gs_logfile 2>&1
echo " log file: $gs_logfile" >>$gs_logfile 2>&1
echo "" >>$gs_logfile 2>&1
# Get rid of '-x objective-c' in CFLAGS that we don't need and would
# prevent our '-x objective-c-headers' flag from working.
CFLAGS=`echo $CFLAGS | sed -e 's/-x objective-c//'`
echo " CFLAGS without -x objective-c: $CFLAGS" >>$gs_logfile 2>&1
echo "" >>$gs_logfile 2>&1
if test "$CC" = ""; then
echo "CC is not set: failure" >>$gs_logfile 2>&1
exit 1
fi
# Try to compile the file first
echo "** Compile the file without precompiled headers" >>$gs_logfile 2>&1
echo "$CC -o a.out $CFLAGS $CPPFLAGS $LDFLAGS $LIBS gs_precomp_test.m" >>$gs_logfile 2>&1
$CC -o a.out $CFLAGS $CPPFLAGS $LDFLAGS $LIBS gs_precomp_test.m >>$gs_logfile 2>&1
if test ! "$?" = "0"; then
echo "Failure" >>$gs_logfile 2>&1
rm -f a.out
exit 1
fi
echo "Success" >>$gs_logfile 2>&1
echo "" >>$gs_logfile 2>&1
# Now try to preprocess the header
echo "** Preprocess the header" >>$gs_logfile 2>&1
echo "$CC -c -x objective-c-header $CFLAGS $CPPFLAGS $LDFLAGS gs_precomp_test.h" >>$gs_logfile 2>&1
$CC -x objective-c-header $CFLAGS $CPPFLAGS $LDFLAGS gs_precomp_test.h >>$gs_logfile 2>&1
if test ! "$?" = "0"; then
echo "Failure" >>$gs_logfile 2>&1
rm -f a.out gs_precomp_test.h.gch
exit 1
fi
echo "Success" >>$gs_logfile 2>&1
echo "" >>$gs_logfile 2>&1
# Now try to compile again with the preprocessed header
echo "** Compile the file with precompiled headers" >>$gs_logfile 2>&1
echo "$CC -o a.out $CFLAGS $CPPFLAGS $LDFLAGS $LIBS gs_precomp_test.m" >>$gs_logfile 2>&1
$CC -o a.out $CFLAGS $CPPFLAGS $LDFLAGS $LIBS gs_precomp_test.m >>$gs_logfile 2>&1
if test ! "$?" = "0"; then
echo "Failure" >>$gs_logfile 2>&1
rm -f a.out gs_precomp_test.h.gch
exit 1
fi
echo "Success" >>$gs_logfile 2>&1
# Everything looks OK.
exit 0

52
configure vendored
View file

@ -4297,10 +4297,8 @@ fi
# Restore LIBS and CFLAGS - we are going to compile C code in the next
# test.
LIBS="$saved_LIBS"
CFLAGS="$saved_CFLAGS"
# Keep LIBS and CFLAGS as they are for a while - we need them in
# the following Objective-C tests!
#--------------------------------------------------------------------
# Check for the GCC version - this is used in the following tests
@ -4368,34 +4366,46 @@ fi
echo "$as_me:$LINENO: checking if the compiler supports precompiled headers" >&5
echo $ECHO_N "checking if the compiler supports precompiled headers... $ECHO_C" >&6
# What we want to do: set GCC_WITH_PRECOMPILED_HEADERS to yes if gcc => 3.4
# We used to check the compiler version here; this is not that
# reliable because precompiled headers were added in 3.4, then they
# were broken in 4.1, then fixed again.
# So we prefer to actually try them out! ;-)
# What we want to do: set GCC_WITH_PRECOMPILED_HEADERS to yes if gcc
# can compile and use a precompiled header.
GCC_WITH_PRECOMPILED_HEADERS=""
if test ! ${GCC} = "yes" ; then
# First, a preliminary test. If this is not gcc, precompiled headers
# are not supported.
if test ! "${GCC}" = "yes" ; then
echo "$as_me:$LINENO: result: no: it's not gcc" >&5
echo "${ECHO_T}no: it's not gcc" >&6
else
if test "${gs_cv_gcc_major_version}" -ge "4"; then
GCC_WITH_PRECOMPILED_HEADERS=yes
gs_precomp_test_log_file="`pwd`/config-precomp-test.log"
gs_precomp_test_results=`(CC="$CC"; export CC; CFLAGS="$CFLAGS"; export CFLAGS; CPPLAGS="$CPPFLAGS"; export CPPFLAGS; LDFLAGS="$LDFLAGS"; export LDFLAGS; LIBS="$LIBS"; export LIBS; cd "$srcdir/config-precomp-test/"; ./run-test.sh "$gs_precomp_test_log_file"; echo $?)`
if test "$gs_precomp_test_results" = "0"; then
GCC_WITH_PRECOMPILED_HEADERS="yes"
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
if test "${gs_cv_gcc_major_version}" = "3" ; then
if test "${gs_cv_gcc_minor_version}" -ge "4" ; then
GCC_WITH_PRECOMPILED_HEADERS=yes
fi
fi
fi
if test "${GCC_WITH_PRECOMPILED_HEADERS}" = "yes" ; then
echo "$as_me:$LINENO: result: yes: gcc version is ${gs_cv_gcc_parsed_version} >= 3.4" >&5
echo "${ECHO_T}yes: gcc version is ${gs_cv_gcc_parsed_version} >= 3.4" >&6
else
echo "$as_me:$LINENO: result: no: gcc version is ${gs_cv_gcc_parsed_version} < 3.4" >&5
echo "${ECHO_T}no: gcc version is ${gs_cv_gcc_parsed_version} < 3.4" >&6
# Please check the config-precomp-test.log log file for more info
echo "$as_me:$LINENO: result: no: old or buggy gcc" >&5
echo "${ECHO_T}no: old or buggy gcc" >&6
fi
fi
# Important - if you think there is a problem with precompiled
# headers, try adding ADDITIONAL_OBJC_FLAGS = -Winvalid-pch to your
# GNUmakefile to check that they are used.
# Restore LIBS and CFLAGS - we used to compile C code after this
# point. Useful to keep this in case we need to compile C code again.
LIBS="$saved_LIBS"
CFLAGS="$saved_CFLAGS"
#--------------------------------------------------------------------
# Check if compiler requires -shared flag on Solaris ...
#--------------------------------------------------------------------

View file

@ -873,10 +873,8 @@ fi
AC_SUBST(USE_OBJC_EXCEPTIONS)
# Restore LIBS and CFLAGS - we are going to compile C code in the next
# test.
LIBS="$saved_LIBS"
CFLAGS="$saved_CFLAGS"
# Keep LIBS and CFLAGS as they are for a while - we need them in
# the following Objective-C tests!
#--------------------------------------------------------------------
# Check for the GCC version - this is used in the following tests
@ -936,26 +934,30 @@ AC_SUBST(AUTO_DEPENDENCIES)
AC_MSG_CHECKING(if the compiler supports precompiled headers)
# What we want to do: set GCC_WITH_PRECOMPILED_HEADERS to yes if gcc => 3.4
# We used to check the compiler version here; this is not that
# reliable because precompiled headers were added in 3.4, then they
# were broken in 4.1, then fixed again.
# So we prefer to actually try them out! ;-)
# What we want to do: set GCC_WITH_PRECOMPILED_HEADERS to yes if gcc
# can compile and use a precompiled header.
GCC_WITH_PRECOMPILED_HEADERS=""
if test ! ${GCC} = "yes" ; then
# First, a preliminary test. If this is not gcc, precompiled headers
# are not supported.
if test ! "${GCC}" = "yes" ; then
AC_MSG_RESULT(no: it's not gcc)
else
if test "${gs_cv_gcc_major_version}" -ge "4"; then
GCC_WITH_PRECOMPILED_HEADERS=yes
gs_precomp_test_log_file="`pwd`/config-precomp-test.log"
gs_precomp_test_results=`(CC="$CC"; export CC; CFLAGS="$CFLAGS"; export CFLAGS; CPPLAGS="$CPPFLAGS"; export CPPFLAGS; LDFLAGS="$LDFLAGS"; export LDFLAGS; LIBS="$LIBS"; export LIBS; cd "$srcdir/config-precomp-test/"; ./run-test.sh "$gs_precomp_test_log_file"; echo $?)`
if test "$gs_precomp_test_results" = "0"; then
GCC_WITH_PRECOMPILED_HEADERS="yes"
AC_MSG_RESULT(yes)
else
if test "${gs_cv_gcc_major_version}" = "3" ; then
if test "${gs_cv_gcc_minor_version}" -ge "4" ; then
GCC_WITH_PRECOMPILED_HEADERS=yes
fi
fi
fi
if test "${GCC_WITH_PRECOMPILED_HEADERS}" = "yes" ; then
AC_MSG_RESULT(yes: gcc version is ${gs_cv_gcc_parsed_version} >= 3.4)
else
AC_MSG_RESULT(no: gcc version is ${gs_cv_gcc_parsed_version} < 3.4)
# Please check the config-precomp-test.log log file for more info
AC_MSG_RESULT(no: old or buggy gcc)
fi
fi
@ -964,6 +966,11 @@ fi
# GNUmakefile to check that they are used.
AC_SUBST(GCC_WITH_PRECOMPILED_HEADERS)
# Restore LIBS and CFLAGS - we used to compile C code after this
# point. Useful to keep this in case we need to compile C code again.
LIBS="$saved_LIBS"
CFLAGS="$saved_CFLAGS"
#--------------------------------------------------------------------
# Check if compiler requires -shared flag on Solaris ...
#--------------------------------------------------------------------