1#!/bin/sh 2rm -f include/stddef.h 3exit 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. 44if [ x$1 = x ] 45then echo fixincludes: no output directory specified 46exit 1 47fi 48 49# Directory in which to store the results. 50LIB=${1} 51 52# Make sure it exists. 53if [ ! -d $LIB ]; then 54 mkdir $LIB || exit 1 55fi 56 57ORIG_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. 61case $LIB in 62/*) 63 ;; 64*) 65 cd $LIB; LIB=`${PWDCMD-pwd}` 66 ;; 67esac 68 69echo 'Building fixincludes in ' ${LIB} 70 71# Determine whether this filesystem has symbolic links. 72if ln -s X $LIB/ShouldNotExist 2>/dev/null; then 73 rm -f $LIB/ShouldNotExist 74 LINKS=true 75else 76 LINKS=false 77fi 78 79echo 'Making directories:' 80# Directory containing the original header files. 81shift 82if [ $# -eq 0 ] ; then 83 set /usr/include 84fi 85 86INLIST="$@" 87 88for INPUT in ${INLIST} ; do 89cd ${ORIG_DIR} 90cd ${INPUT} 91 92if $LINKS; then 93 files=`ls -LR | sed -n s/:$//p` 94else 95 files=`find . -type d -print | sed '/^\.$/d'` 96fi 97 98if [ "x$files" = x ]; then 99 echo No files found in $INPUT\; skipped 100 continue 101fi 102 103for file in $files; do 104 rm -rf $LIB/$file 105 if [ ! -d $LIB/$file ] 106 then mkdir $LIB/$file 107 fi 108done 109 110# treetops gets an alternating list 111# of old directories to copy 112# and the new directories to copy to. 113treetops="${INPUT} ${LIB}" 114 115set - $treetops 116while [ $# != 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 153done 154 155echo 'Removing unneeded directories:' 156# (Rmdir leaf to root, and if the rmdir fails, who cares....) 157cd $LIB 158files=`find . -type d -print | sort -r` 159for file in $files; do 160 rmdir $LIB/$file > /dev/null 2>&1 161done 162 163done # for include directory list 164 165if [ x${INSTALL_ASSERT_H} != x ] 166then 167 cd ${ORIG_DIR} 168 rm -f include/assert.h 169 cp ${srcdir}/assert.h include/assert.h || exit 1 170 chmod a+r include/assert.h 171fi 172 173exit 0 174