source: trunk/third/gcc/fixinc.dgux @ 8834

Revision 8834, 4.7 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# modified for dgux by hassey@dg-rtp.dg.com based on
4#
5#   fixinc.svr4  written by Ron Guilmette (rfg@ncd.com).
6#
7# This file is part of GNU CC.
8#
9# GNU CC is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13#
14# GNU CC is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with GNU CC; see the file COPYING.  If not, write to
21# the Free Software Foundation, 59 Temple Place - Suite 330,
22# Boston, MA 02111-1307, USA.
23#
24#
25#       See README-fixinc for more information.
26
27# Directory containing the original header files.
28INPUT=${2-${INPUT-/usr/include}}
29
30# Fail if no arg to specify a directory for the output.
31if [ x$1 = x ]
32then echo fixincludes: no output directory specified
33exit 1
34fi
35
36# Directory in which to store the results.
37LIB=${1?"fixincludes: output directory not specified"}
38
39# Make sure it exists.
40if [ ! -d $LIB ]; then
41  mkdir $LIB || exit 1
42fi
43
44ORIG_DIR=`pwd`
45
46# Make LIB absolute if it is relative.
47# Don't do this if not necessary, since may screw up automounters.
48case $LIB in
49/*)
50        ;;
51*)
52        cd $LIB; LIB=`${PWDCMD-pwd}`
53        ;;
54esac
55
56echo 'Building fixincludes in ' ${LIB}
57
58# Determine whether this filesystem has symbolic links.
59if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
60  rm -f $LIB/ShouldNotExist
61  LINKS=true
62else
63  LINKS=false
64fi
65
66echo 'Making directories:'
67cd ${INPUT}
68if $LINKS; then
69  files=`ls -LR | sed -n s/:$//p`
70else
71  files=`find . -type d -print | sed '/^.$/d'`
72fi
73for file in $files; do
74  rm -rf $LIB/$file
75  if [ ! -d $LIB/$file ]
76  then mkdir $LIB/$file
77  fi
78done
79
80# treetops gets an alternating list
81# of old directories to copy
82# and the new directories to copy to.
83treetops="${INPUT} ${LIB}"
84
85if $LINKS; then
86  echo 'Making internal symbolic directory links'
87  for file in $files; do
88    dest=`ls -ld $file | sed -n 's/.*-> //p'`
89    if [ "$dest" ]; then   
90      cwd=`pwd`
91      # In case $dest is relative, get to $file's dir first.
92      cd ${INPUT}
93      cd `echo ./$file | sed -n 's&[^/]*$&&p'`
94      # Check that the target directory exists.
95      # Redirections changed to avoid bug in sh on Ultrix.
96      (cd $dest) > /dev/null 2>&1
97      if [ $? = 0 ]; then
98        cd $dest
99        # X gets the dir that the link actually leads to.
100        x=`pwd`
101        # If link leads back into ${INPUT},
102        # make a similar link here.
103        if expr $x : "${INPUT}/.*" > /dev/null; then
104          # Y gets the actual target dir name, relative to ${INPUT}.
105          y=`echo $x | sed -n "s&${INPUT}/&&p"`
106          # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
107          dots=`echo "$file" |
108            sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
109          echo $file '->' $dots$y ': Making link'
110          rm -fr ${LIB}/$file > /dev/null 2>&1
111          ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
112        else
113          # If the link is to outside ${INPUT},
114          # treat this directory as if it actually contained the files.
115# This line used to have $dest instead of $x.
116# $dest seemed to be wrong for links found in subdirectories
117# of ${INPUT}.  Does this change break anything?
118          treetops="$treetops $x ${LIB}/$file"
119        fi
120      fi
121      cd $cwd
122    fi
123  done
124fi
125
126# Completely replace <_int_varargs.h> with a file that defines
127# va_list and gnuc_va_list
128
129file=_int_varargs.h
130if [ -r ${INPUT}/$file ]; then
131  echo Replacing $file
132  cat > ${LIB}/$file << EOF
133/* This file was generated by fixinc.dgux.  */
134#ifndef __INT_VARARGS_H
135#define __INT_VARARGS_H
136
137#if defined(__m88k__) && defined (__DGUX__)
138#ifndef __GNUC_VA_LIST
139#define __GNUC_VA_LIST
140typedef struct
141{
142  int  __va_arg;                /* argument number */
143  int *__va_stk;                /* start of args passed on stack */
144  int *__va_reg;                /* start of args passed in regs */
145} __gnuc_va_list;
146#endif /* not __GNUC_VA_LIST */
147#endif /* 88k && dgux */
148
149#ifndef _VA_LIST_
150#define _VA_LIST_
151typedef __gnuc_va_list va_list;
152#endif /* _VA_LIST_ */
153
154#endif /* __INT_VARARGS_H */
155
156EOF
157  chmod a+r ${LIB}/$file
158fi
159
160echo 'Removing unneeded directories:'
161cd $LIB
162files=`find . -type d -print | sort -r`
163for file in $files; do
164  rmdir $LIB/$file > /dev/null 2>&1
165done
166
167if $LINKS; then
168  echo 'Making internal symbolic non-directory links'
169  cd ${INPUT}
170  files=`find . -type l -print`
171  for file in $files; do
172    dest=`ls -ld $file | sed -n 's/.*-> //p'`
173    if expr "$dest" : '[^/].*' > /dev/null; then   
174      target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
175      if [ -f $target ]; then
176        ln -s $dest ${LIB}/$file >/dev/null 2>&1
177      fi
178    fi
179  done
180fi
181
182cd ${ORIG_DIR}
183
184exit 0
185
Note: See TracBrowser for help on using the repository browser.