OSDN Git Service

Add fix test from irix_stdio_dummy_va_list
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / fixinc.interix
1 #!/bin/sh
2 rm -f include/stddef.h
3 exit
4 #
5 #   fixinc.interix  --  Install modified versions of Interix system include
6 #   files.
7 #
8 #   Based on fixinc.sco script by Ian Lance Taylor (ian@airs.com)).
9 #   With modifications by Douglas Rupp (drupp@cs.washington.edu)
10 #
11 # Copyright (C) 1999 Free Software Foundation, Inc.
12 #
13 # This file is part of GNU CC.
14
15 # GNU CC is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2, or (at your option)
18 # any later version.
19
20 # GNU CC is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24
25 # You should have received a copy of the GNU General Public License
26 # along with GNU CC; see the file COPYING.  If not, write to
27 # the Free Software Foundation, 59 Temple Place - Suite 330,
28 # Boston, MA 02111-1307, USA.
29 #
30 #  ??????  fixup comment
31 #       This script munges the native include files provided with Windows NT
32 #       3.5 SDK systems so as to provide a reasonable namespace when
33 #       compiling with gcc.  The header files by default do not
34 #       provide many essential definitions and declarations if
35 #       __STDC__ is 1.  This script modifies the header files to check
36 #       for __STRICT_ANSI__ being defined instead.  Once munged, the
37 #       resulting new system include files are placed in a directory
38 #       that GNU C will search *before* searching the Include
39 #       directory.
40 #
41 #       See README-fixinc for more information.
42
43 # Fail if no arg to specify a directory for the output.
44 if [ x$1 = x ]
45 then echo fixincludes: no output directory specified
46 exit 1
47 fi
48
49 # Directory in which to store the results.
50 LIB=${1}
51
52 # Make sure it exists.
53 if [ ! -d $LIB ]; then
54   mkdir $LIB || exit 1
55 fi
56
57 ORIG_DIR=`${PWDCMD-pwd}`
58
59 # Make LIB absolute if it is relative.
60 # Don't do this if not necessary, since may screw up automounters.
61 case $LIB in
62 /*)
63         ;;
64 *)
65         cd $LIB; LIB=`${PWDCMD-pwd}`
66         ;;
67 esac
68
69 echo 'Building fixincludes in ' ${LIB}
70
71 # Determine whether this filesystem has symbolic links.
72 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
73   rm -f $LIB/ShouldNotExist
74   LINKS=true
75 else
76   LINKS=false
77 fi
78
79 echo 'Making directories:'
80 # Directory containing the original header files.
81 shift
82 if [ $# -eq 0 ] ; then
83   set /usr/include
84 fi
85
86 INLIST="$@"
87
88 for INPUT in ${INLIST} ; do
89 cd ${ORIG_DIR}
90 cd ${INPUT}
91
92 if $LINKS; then
93   files=`ls -LR | sed -n s/:$//p`
94 else
95   files=`find . -type d -print | sed '/^\.$/d'`
96 fi
97
98 if [ "x$files" = x ]; then
99   echo No files found in $INPUT\; skipped
100   continue
101 fi
102
103 for file in $files; do
104   rm -rf $LIB/$file
105   if [ ! -d $LIB/$file ]
106   then mkdir $LIB/$file
107   fi
108 done
109
110 # treetops gets an alternating list
111 # of old directories to copy
112 # and the new directories to copy to.
113 treetops="${INPUT} ${LIB}"
114
115 set - $treetops
116 while [ $# != 0 ]; do
117   # $1 is an old directory to copy, and $2 is the new directory to copy to.
118   echo "Finding header files in $1:"
119   cd ${INPUT}
120   cd $1
121   files=`find . -name '*.[hH]' -type f -print`
122   echo "Checking header files in $1; transforming into directory $2:"
123   for file in $files; do
124     echo "   " $file
125     if [ -r $file ]; then
126       cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
127       chmod +w,a+r $2/$file
128
129 # The following have been removed from the sed command below
130 # because it is more useful to leave these things in.
131 # The only reason to remove them was for -pedantic,
132 # which isn't much of a reason. -- rms.
133 # ??? above/below
134 #         /^[   ]*#[    ]*ident/d
135 #         s/!__STDC__/!defined (__STRICT_ANSI__)/g
136
137       sed -e '/#[       ]*include.*[<"][A-Za-z]:\\/ s,\\,/,g' \
138           -e '/#[       ]*include.*[<"][A-Za-z]:\// s,\([A-Za-z]\):/,//\1/,' \
139           -e '\,#[      ]*include.*[<"]//[A-Za-z]/, y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,' \
140           -e '\,#[      ]*INCLUDE.*[<"]//[A-Za-z]/, s,INCLUDE,include,' \
141           $2/$file > $2/$file.sed
142
143       mv $2/$file.sed $2/$file
144       if cmp $file $2/$file >/dev/null 2>&1; then
145          rm $2/$file
146       else
147          echo Fixed $file
148          flip -u $2/$file
149       fi
150     fi
151   done
152   shift; shift
153 done
154
155 echo 'Removing unneeded directories:'
156 # (Rmdir leaf to root, and if the rmdir fails, who cares....)
157 cd $LIB
158 files=`find . -type d -print | sort -r`
159 for file in $files; do
160   rmdir $LIB/$file > /dev/null 2>&1
161 done
162
163 done # for include directory list
164
165 exit 0