X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ffixincludes;h=cdb25b20d28c16e92d18d83136139514e766ef9a;hb=f30b3fa0fc7e0a1a5a6dea2606dfb712384823d8;hp=1f32b534689086d871fe8daa529bdc3b0b0dc62e;hpb=22b72709c6acc913c775ccf0feb659653f436f75;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/fixincludes b/gcc/fixincludes index 1f32b534689..cdb25b20d28 100755 --- a/gcc/fixincludes +++ b/gcc/fixincludes @@ -75,14 +75,11 @@ do for d in $dirs do echo " Searching $INPUT/$d" - if [ "$d" != . ] - then - d=$d/. - fi # Find all directories under $d, relative to $d, excluding $d itself. - files="$files `find $d -type d -print | \ - sed -e '/\/\.$/d' -e '/^\.$/d'`" + # (The /. is needed after $d in case $d is a symlink.) + files="$files `find $d/. -type d -print | \ + sed -e '/\/\.$/d' -e 's@/./@/@g'`" # Find all links to directories. # Using `-exec test -d' in find fails on some systems, # and trying to run test via sh fails on others, @@ -90,7 +87,7 @@ do # First find all the links, then test each one. theselinks= $LINKS && \ - theselinks=`find $d -type l -print` + theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'` for d1 in $theselinks --dummy-- do # If the link points to a directory, @@ -185,7 +182,7 @@ if $LINKS; then # root area. for file2 in $files; do case $file2 in - $file/./*) + $file/*) dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"` echo "Duplicating ${file}'s ${dupdir}" if [ -d ${dupdir} ] @@ -264,6 +261,8 @@ while [ $# != 0 ]; do || echo "Can't copy $file" chmod +w $2/$file chmod a+r $2/$file + # The fixinc_eol stuff is to work around a bug in the sed + # program on HP/UX 10.20. # Here is how the sed commands in braces work. # (It doesn't work to put the comments inside the sed commands.) # Surround each word with spaces, to simplify matching below. @@ -273,7 +272,9 @@ while [ $# != 0 ]; do sed -e ' :loop /\\$/ N + s/\\$/\\*fixinc_eol*/ /\\$/ b loop + s/\\\*fixinc_eol\*/\\/g s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% @@ -289,7 +290,7 @@ while [ $# != 0 ]; do /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g - /#[el]*if/{ + /#[ ]*[el]*if/{ s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g s/ bsd4\([0-9]\) / __bsd4\1__ /g @@ -305,16 +306,18 @@ while [ $# != 0 ]; do s/ ns32000 / __ns32000__ /g s/ pdp11 / __pdp11__ /g s/ pyr / __pyr__ /g + s/ sel / __sel__ /g s/ sony_news / __sony_news__ /g s/ sparc / __sparc__ /g s/ sun\([a-z0-9]*\) / __sun\1__ /g + s/ tahoe / __tahoe__ /g s/ tower\([_0-9]*\) / __tower\1__ /g s/ u370 / __u370__ /g s/ u3b\([0-9]*\) / __u3b\1__ /g s/ unix / __unix__ /g s/ vax / __vax__ /g s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g - s/ _*R\([34]\)000 / __R\1000__ /g + s/ _*\([Rr][34]\)000 / __\1000__ /g s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g @@ -369,6 +372,10 @@ for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\ #ifndef __WCHAR_TYPE__\ #define __WCHAR_TYPE__ int\ +#endif\ +#ifndef __cplusplus +' \ + -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\ #endif ' \ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \ @@ -698,6 +705,31 @@ if [ -r ${LIB}/$file ]; then fi fi +# Check for (...) in C++ code in HP/UX sys/file.h. +file=sys/file.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then + echo Fixing $file, use of '(...)' + sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi + fi +fi + # Check for superfluous `static' (in Ultrix 4.2) # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken. file=machine/cpu.h @@ -876,10 +908,10 @@ if [ -r ${LIB}/$file ]; then echo Fixing $file sed -e 's/int abort/void abort/g' \ -e 's/int free/void free/g' \ - -e 's/char \* calloc/void \* calloc/g' \ - -e 's/char \* malloc/void \* malloc/g' \ - -e 's/char \* realloc/void \* realloc/g' \ - -e 's/int exit/void exit/g' \ + -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \ + -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \ + -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \ + -e 's/int[ ][ ]*exit/void exit/g' \ -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\ #ifndef _GCC_SIZE_T\ #define _GCC_SIZE_T @@ -901,6 +933,7 @@ if [ -r ${LIB}/$file ]; then fi # Fix return type of free and {c,m,re}alloc in on SunOS 4.1. +# Also fix return type of {m,re}alloc in on sysV68 file=malloc.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" @@ -912,6 +945,8 @@ if [ -r ${LIB}/$file ]; then echo Fixing $file sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \ -e 's/int[ ][ ]*free/void free/g' \ + -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \ + -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \ ${LIB}/$file > ${LIB}/${file}.sed rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -1066,6 +1101,18 @@ if [ -r ${LIB}/$file ]; then fi fi +# There is a similar problem with the VxWorks drv/netif/if_med.h file. +file=drv/netif/if_med.h +if [ -r ${LIB}/$file ]; then + if egrep 'Wind River' ${LIB}/$file > /dev/null; then + echo Fixing $file, overeager sed script + rm ${LIB}/$file + sed -e 's|//.*$||g' $file > ${LIB}/$file + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null + fi +fi + # Some IRIX header files contains the string "//" for file in elf_abi.h elf.h; do if [ -r ${LIB}/$file ]; then @@ -1155,8 +1202,9 @@ fi # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because # many other systems have similar text but correct versions of the file. # To ensure only Sun's is fixed, we grep for a likely unique string. +# Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) file=memory.h -if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then +if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then if [ ! -r ${LIB}/$file ]; then cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" chmod +w ${LIB}/$file 2>/dev/null @@ -1188,6 +1236,31 @@ EOF fi fi +# Fix return type of fread and fwrite on sysV68 +file=stdio.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file, fread and fwrite return type + sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\ +\1\3/' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + # parameters not const on DECstation Ultrix V4.0 and OSF/1. file=stdio.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then @@ -1253,7 +1326,7 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then fi if [ -r ${LIB}/$file ]; then - if grep 'class[(]' ${LIB}/$file >/dev/null; then + if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then echo Fixing $file sed -e '/class[(]/i\ #ifndef __cplusplus @@ -1410,7 +1483,9 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then fi if [ -r ${LIB}/$file ]; then echo Fixing $file - sed -e '/^extern.*double.*__const__.*cos(/s/__const__//' \ + sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \ + -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \ + -e '/^extern.*double.*__const__.*cos(/s/__const__//' \ -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -1474,6 +1549,33 @@ if [ -r ${LIB}/$file ]; then fi fi +# sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition +# of struct rusage, so the prototype (added by fixproto) causes havoc. +file=sys/wait.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ] \ + && grep 'bos325,' ${LIB}/$file >/dev/null; then + echo Fixing $file, wait3 declaration + sed -e '/^extern pid_t wait3();$/i\ +struct rusage; +'\ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. # Note that version 3 of the NeXT system has wait.h in a different directory, # so that this code won't do anything. But wait.h in version 3 has a @@ -1525,6 +1627,7 @@ if [ -r ${LIB}/$file ]; then # Don't claim to have defined va_list. sed -e 's@ va_list @ __gnuc_va_list @' \ -e 's@ va_list)@ __gnuc_va_list)@' \ + -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ va_list@ __va_list__@' \ -e 's@\*va_list@*__va_list__@' \ @@ -1567,7 +1670,7 @@ fi if [ -r ${LIB}/$file ]; then echo Fixing $file, non-const arg sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \ - -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \ + -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \ -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \ -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \ -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \ @@ -1584,6 +1687,35 @@ if [ -r ${LIB}/$file ]; then fi fi +# fix bogus recursive stdlib.h in NEWS-OS 4.0C +file=stdlib.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file, recursive inclusion + sed -e '/^#include /i\ +#if 0 +' \ + -e '/^#include /a\ +#endif +' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + # Avoid nested comments on Ultrix 4.3. file=rpc/svc.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then @@ -1654,6 +1786,40 @@ if [ -r ${LIB}/$file ]; then fi fi +# rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C +# is defined for the alpha. The problem is the declaration of malloc. +file=rpc/types.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + mkdir ${LIB}/rpc 2>/dev/null + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi +if [ -r ${LIB}/$file ]; then + if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then + true + else + echo Fixing $file + echo '#ifdef __cplusplus +extern "C" { +#endif' > ${LIB}/${file}.sed + cat ${LIB}/${file} >> ${LIB}/${file}.sed + echo '#ifdef __cplusplus +} +#endif' >> ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi + fi +fi + # In limits.h, put #ifndefs around things that are supposed to be defined # in float.h to avoid redefinition errors if float.h is included first. # On HP/UX this patch does not work, because on HP/UX limits.h uses @@ -1798,6 +1964,8 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} +# in string.h on sysV68 # Correct the return type for strlen in string.h on Lynx. # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. # Add missing const for strdup on OSF/1 V3.0. @@ -1809,10 +1977,40 @@ if [ -r $file ] && [ ! -r ${LIB}/$file ]; then fi if [ -r ${LIB}/$file ]; then - echo Fixing $file + echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \ -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \ -e 's/strdup(char \*s1);/strdup(const char *s1);/' \ + -e '/^extern char$/N' \ + -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\ + -e '/^ strncmp(),$/N'\ + -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\ +extern unsigned int\ +\2/'\ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Correct the return type for strlen in strings.h in SunOS 4. +file=strings.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file + sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \ ${LIB}/$file > ${LIB}/${file}.sed rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -1850,6 +2048,30 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix `typedef struct term;' on hppa1.1-hp-hpux9. +file=curses.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file + sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + # For C++, avoid any typedef or macro definition of bool, and use the # built in type instead. for files in curses.h; do @@ -1862,13 +2084,17 @@ for files in curses.h; do echo Fixing $file sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\ -#ifndef __cplusplus'\ +#ifndef __cplusplus +'\ -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\ -#endif'\ - -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/i\ -#ifndef __cplusplus'\ - -e '/^typedef[ ][ ]*char[ ][ ]*bool;[ ]*$/a\ -#endif'\ +#endif +'\ + -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\ +#ifndef __cplusplus +'\ + -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\ +#endif +'\ ${LIB}/$file > ${LIB}/${file}.sed rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -1933,6 +2159,33 @@ for file in stdio.h stdlib.h; do fi done +# Fix __page_size* declarations in pthread.h AIX 4.1.[34]. +# The original ones fail if uninitialized externs are not common. +# This is the default for all ANSI standard C++ compilers. +for file in pthread.h; do + if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null + fi + + if [ -r ${LIB}/$file ]; then + echo Fixing $file, __page_size* declarations + sed -e 's/^int __page_size/extern int __page_size/' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi + fi +done + # Determine if we're on Interactive Unix 2.2 or later, in which case we # need to fix some additional files. This is the same test for ISC that # Autoconf uses. @@ -2047,40 +2300,41 @@ struct exception; fi fi -# assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C -# is defined on HP/UX. -file=assert.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi +# assert.h and sys/mman.h on HP/UX are not C++ ready, even though +# NO_IMPLICIT_EXTERN_C is defined on HP/UX. +for file in assert.h sys/mman.h; do + if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null + fi -if [ -r ${LIB}/$file ]; then - if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \ - || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then - true - else - echo Fixing $file - echo '#ifdef __cplusplus + if [ -r ${LIB}/$file ]; then + if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \ + || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then + true + else + echo Fixing $file + echo '#ifdef __cplusplus extern "C" { #endif' > ${LIB}/${file}.sed - cat ${LIB}/${file} >> ${LIB}/${file}.sed - echo '#ifdef __cplusplus + cat ${LIB}/${file} >> ${LIB}/${file}.sed + echo '#ifdef __cplusplus } #endif' >> ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi if cmp $file ${LIB}/$file >/dev/null 2>&1; then rm -f ${LIB}/$file else # Find any include directives that use "file". for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do - dir=`echo $file | sed -e s'|/[^/]*$||'` - required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" done fi fi -fi +done # check for broken assert.h that needs stdio.h or stdlib.h file=assert.h @@ -2105,7 +2359,9 @@ if [ -r ${LIB}/$file ]; then true else echo "Fixing $file (needs stdlib.h)" - echo '#include ' >>${LIB}/$file + echo '#ifdef __cplusplus +#include +#endif' >>${LIB}/$file fi fi if cmp $file ${LIB}/$file >/dev/null 2>&1; then @@ -2199,6 +2455,411 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix definitions of macros used by va-i960.h in VxWorks header file. +file=arch/i960/archI960.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file + sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \ + -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Make VxWorks header which is almost gcc ready fully gcc ready. +file=types/vxTypesBase.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file + sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \ + -e '/[ ]size_t/i\ +#ifndef _GCC_SIZE_T\ +#define _GCC_SIZE_T +' \ + -e '/[ ]size_t/a\ +#endif +' \ + -e '/[ ]ptrdiff_t/i\ +#ifndef _GCC_PTRDIFF_T\ +#define _GCC_PTRDIFF_T +' \ + -e '/[ ]ptrdiff_t/a\ +#endif +' \ + -e '/[ ]wchar_t/i\ +#ifndef _GCC_WCHAR_T\ +#define _GCC_WCHAR_T +' \ + -e '/[ ]wchar_t/a\ +#endif +' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Fix VxWorks to not require including . +file=sys/stat.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + mkdir ${LIB}/sys 2>/dev/null + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then + : + else + if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \ + && [ -r types/vxTypesOld.h ]; then + echo Fixing $file + sed -e '/#define[ ][ ]*__INCstath/a\ +#include +' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi + fi + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Fix VxWorks to not require including . +file=time.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + mkdir ${LIB}/sys 2>/dev/null + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then + echo Fixing $file + sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Fix hpux10.20 to avoid invalid forward decl +file=sys/time.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + mkdir ${LIB}/sys 2>/dev/null + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then + echo Fixing $file + sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Another bad dependency in VxWorks 5.2 . +file=time.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + mkdir ${LIB}/sys 2>/dev/null + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then + if [ -r vxWorks.h ]; then + echo Fixing $file + sed -e '/VOIDFUNCPTR/i\ +#ifndef __gcc_VOIDFUNCPTR_defined\ +#ifdef __cplusplus\ +typedef void (*__gcc_VOIDFUNCPTR) (...);\ +#else\ +typedef void (*__gcc_VOIDFUNCPTR) ();\ +#endif\ +#define __gcc_VOIDFUNCPTR_defined\ +#endif +' \ + -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi + fi + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc +# doesn't understand it. +file=sys/param.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo "Fixing __asm directive in sys/param.h" + sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# signal.h on SunOS defines signal using (), which causes trouble when +# compiling with g++ -pedantic. +for file in signal.h sys/signal.h; do + if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null + fi + + if [ -r ${LIB}/$file ]; then + echo "Checking for bad C++ prototype in $file" + sed -e '/^void (\*signal())();$/i\ + #ifdef __cplusplus\ + void (*signal(...))(...);\ + #else + ' \ + -e '/^void (\*signal())();$/a\ + #endif + ' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi + fi +done + +# sys/signal.h on some versions of AIX uses volatile in the typedef of +# sig_atomic_t, which causes gcc to generate a warning about duplicate +# volatile when a sig_atomic_t variable is declared volatile, as +# required by ANSI C. +file=sys/signal.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo "Checking for duplicate volatile in sys/signal.h" + sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# Some math.h files define struct exception, which conflicts with +# the class exception defined in the C++ file std/stdexcept.h. We +# redefine it to __math_exception. This is not a great fix, but I +# haven't been able to think of anything better. +file=math.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file, exception + sed -e '/struct exception/i\ +#ifdef __cplusplus\ +#define exception __math_exception\ +#endif'\ + -e '/struct exception/a\ +#ifdef __cplusplus\ +#undef exception\ +#endif' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then + sed -e '/matherr/i\ +#ifdef __cplusplus\ +#define exception __math_exception\ +#endif'\ + -e '/matherr/a\ +#ifdef __cplusplus\ +#undef exception\ +#endif' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + fi + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers. +file=rpc/xdr.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo "Checking for needed C++ prototype in $file" + sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\ +#ifdef __cplusplus\ +\1*\2(...);\3\ +#else\ +\1*\2();\3\ +#endif/g' \ + $LIB/$file > ${LIB}/${file}.sed + + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +fi + +# sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by +# defining regex.h related types. This causes libg++ build and usage failures. +# Fixing this correctly requires checking and modifying 3 files. +for file in reg_types.h regex.h sys/lc_core.h; do + if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null + fi +done +if [ -r ${LIB}/reg_types.h ]; then + if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then + if [ -r ${LIB}/sys/lc_core.h ]; then + if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then + if [ -r ${LIB}/regex.h ]; then + if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then + true; + else + echo Fixing reg_types.h, regex.h, sys/lc_core.h + for file in reg_types.h sys/lc_core.h; do + sed -e 's/regex_t/__regex_t/g' \ + -e 's/regoff_t/__regoff_t/g' \ + -e 's/regmatch_t/__regmatch_t/g' \ + ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + done + sed -e '/#include /a\ +typedef __regex_t regex_t;\ +typedef __regoff_t regoff_t;\ +typedef __regmatch_t regmatch_t;\ +' \ + ${LIB}/regex.h > ${LIB}/regex.h.sed + rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h + fi + fi + fi + fi + fi +fi +for file in reg_types.h regex.h sys/lc_core.h; do + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + else + # Find any include directives that use "file". + for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do + dir=`echo $file | sed -e s'|/[^/]*$||'` + required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include" + done + fi +done + # This loop does not appear to do anything, because it uses file # rather than $file when setting target. It also appears to be # unnecessary, since the main loop processes symbolic links.