patches/gcc/3.3.6/100-fix-fixincl.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Dec 23 22:20:25 2008 +0000 (2008-12-23)
changeset 1106 2051ee3d1b75
permissions -rw-r--r--
Further enhance the check for needed tools:
- update the tool_pattern to use ' || ' as a pattern separator
- which allows using | in regexp
- add checks for cut and xargs
- manually check for grep and sed because they are needed when checking for tools
- print why a test failed, with each tested tool and regexp
- move tools checks before options parsing
- apply conttibutions before computing the version string
- inform user to run make && make install

/trunk/configure | 173 111 62 0 ++++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 111 insertions(+), 62 deletions(-)
     1 See http://gcc.gnu.org/PR22541
     2 
     3 From: Dan Kegel
     4 
     5 When building gcc-3.4.3 or gcc-4.0.0 as a cross into a clean $PREFIX
     6 (the only two I've tried like this), the configure script happily copies
     7 the glibc include files from include to sys-include; here's the line
     8 from the log file (with $PREFIX instead of the real prefix):
     9 
    10 Copying $PREFIX/i686-unknown-linux-gnu/include to $PREFIX/i686-unknown-linux-gnu/sys-include
    11 
    12 But later, when running fixincludes, it gives the error message
    13  The directory that should contain system headers does not exist:
    14   $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/../../../../i686-unknown-linux-gnu/sys-include
    15 
    16 Nevertheless, it continues building; the header files it installs in
    17  $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/include
    18 do not include the boilerplate that would cause it to #include_next the
    19 glibc headers in the system header directory.
    20 Thus the resulting toolchain can't compile the following program:
    21 #include <limits.h>
    22 int x = PATH_MAX;
    23 because its limits.h doesn't include the glibc header.
    24 
    25 That's not nice.  I suspect the problem is that gcc/Makefile.in assumes that
    26 it can refer to $PREFIX/i686-unknown-linux-gnu  with the path 
    27                 $PREFIX/lib/../i686-unknown-linux-gnu, but
    28 that fails because the directory $PREFIX/lib doesn't exist during 'make all';
    29 it is only created later, during 'make install'.  (Which makes this problem
    30 confusing, since one only notices the breakage well after 'make install',
    31 at which point the path configure complained about does exist, and has the
    32 right stuff in it.)
    33 
    34 A possible fix is to replace the line in gcc/Makefile.in that says
    35     SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@
    36 with a version that gets rid of extra ..'s, e.g.
    37     SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,,;ta"`
    38 (hey, that's the first time I've ever used a label in a sed script; thanks to the sed faq
    39 for explaining the :a ... ta method of looping to repeat a search-and-replace until it doesn't match.)
    40 
    41 
    42 --- gcc-3.4.3/gcc/Makefile.in.foo	2005-05-20 11:41:39.000000000 -0700
    43 +++ gcc-3.4.3/gcc/Makefile.in	2005-05-20 12:08:46.000000000 -0700
    44 @@ -350,7 +350,10 @@
    45  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
    46  
    47  # autoconf sets SYSTEM_HEADER_DIR to one of the above.
    48 -SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@
    49 +# Purge it of unneccessary internal relative paths
    50 +# to directories that might not exist yet.
    51 +# The sed idiom for this is to repeat the search-and-replace until it doesn't match, using :a ... ta.
    52 +SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`
    53  
    54  # Control whether to run fixproto and fixincludes.
    55  STMP_FIXPROTO = @STMP_FIXPROTO@
    56 @@ -2532,11 +2535,13 @@
    57  	$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(gcc_tooldir)
    58  
    59  # Build fixed copies of system files.
    60 +# Abort if no system headers available, unless building a crosscompiler.
    61 +# FIXME: abort unless building --without-headers would be more accurate and less ugly
    62  stmp-fixinc: fixinc.sh gsyslimits.h
    63  	@if test ! -d ${SYSTEM_HEADER_DIR}; then \
    64  	  echo The directory that should contain system headers does not exist: >&2 ; \
    65  	  echo "  ${SYSTEM_HEADER_DIR}" >&2 ; \
    66 -	  if test "x${SYSTEM_HEADER_DIR}" = "x${gcc_tooldir}/sys-include"; \
    67 +	  if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`"; \
    68  	  then sleep 1; else exit 1; fi; \
    69  	fi
    70  	rm -rf include; mkdir include