OSDN Git Service

H
[pf3gnuchains/gcc-fork.git] / gcc / fixincludes
index 8400c6f..f02bdd3 100755 (executable)
@@ -411,6 +411,37 @@ typedef __SIZE_TYPE__ size_t;\
   fi
 done
 
+# Fix #defines under Alpha OSF/1:
+# The following files contain '#pragma extern_prefix "_FOO"' followed by
+# a '#define something(x,y,z) _FOOsomething(x,y,z)'.  The intent of these
+# statements is to reduce namespace pollution.  While these macros work
+# properly in most cases, they don't allow you to take a pointer to the
+# "something" being modified.  To get around this limitation, change these
+# statements to be of the form '#define something _FOOsomething'.
+for file in libgen.h dirent.h ftw.h grp.h ndbm.h pthread.h pwd.h signal.h standards.h stdlib.h string.h stropts.h time.h unistd.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 extern_prefix
+    sed -e 's/^[       ]*#[    ]*define[       ]*\([^(]*\)\(([^)]*)\)[         ]*\(_.\)\1\2[   ]*$/#define \1 \3\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 ${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
 # Fix one other error in this file: a mismatched quote not inside a C comment.
 file=sundev/vuid_event.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@@ -1135,7 +1166,7 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
-# And also with the HP-UX 10 sys/pci.h file
+# And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
 file=sys/pci.h
 if [ -r ${LIB}/$file ]; then
   if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
@@ -1147,6 +1178,48 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# And also with a few more HP-UX 11 headers which are only broken
+# after they are "fixed".
+file=sys/ki_iface.h
+if [ -r ${LIB}/$file ]; then
+  if egrep 'These definitions are for HP Internal developers' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+  fi
+fi
+
+file=sys/ki.h
+if [ -r ${LIB}/$file ]; then
+  if egrep '11.00 HP-UX LP64' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+  fi
+fi
+
+file=sys/ki_calls.h
+if [ -r ${LIB}/$file ]; then
+  if egrep 'KI_MAX_PROCS is an arbitrary number' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+  fi
+fi
+
+file=sys/ki_defs.h
+if [ -r ${LIB}/$file ] ; then
+  if egrep 'Kernel Instrumentation Definitions' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+  fi
+fi
+
+file=sys/time.h
+if [ -r ${LIB}/$file ] ; then
+  if egrep 'For CASPEC, look in' ${LIB}/$file > /dev/null; then
+    echo Fixing $file, overeager sed script
+    rm ${LIB}/$file
+  fi
+fi
+
 # Some IRIX header files contains the string "//"
 for file in elf_abi.h elf.h; do
   if [ -r ${LIB}/$file ]; then
@@ -2848,17 +2921,42 @@ if [ -r ${LIB}/$file ]; then
   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
+# rpc/auth.h on SunOS needs prototypes for its AUTH->auth_ops function pointers
+# Similarly for 
+#   rpc/clnt.h CLIENT->clnt_ops
+#   rpc/svc.h SVCXPRT->xp_ops
+#   rpc/xdr.h XDR->xdr_ops
+for file in rpc/auth.h rpc/clnt.h rpc/svc.h rpc/xdr.h; do
+  # each file has a different name to replace, so if you add a file to
+  # that list please update the following case statement.
+  case "$file" in
+    rpc/auth.h)
+      prefix="ah_"
+      ;;
+    rpc/clnt.h)
+      prefix="cl_"
+      ;;
+    rpc/svc.h)
+      prefix="xp_"
+      ;;
+    rpc/xdr.h)
+      prefix="x_"
+      ;;
+    *)
+      # Oh Oh, we shouldn't be here
+      exit 1;
+      ;;
+  esac
 
-if [ -r ${LIB}/$file ]; then
-  echo "Checking for needed C++ prototype in $file"
-  sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
+  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/^\(.*\)\*\('$prefix'.*\)();\(.*\)/\
 #ifdef __cplusplus\
 \1*\2(...);\3\
 #else\
@@ -2866,17 +2964,18 @@ if [ -r ${LIB}/$file ]; then
 #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
+    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
+      done
+    fi
   fi
-fi
+done
 
 # sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
 # defining regex.h types.  This causes C++ library build and usage failures.