home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gcc-2.3.3-src.lha
/
GNU
/
src
/
amiga
/
gcc-2.3.3
/
populate
< prev
next >
Wrap
Text File
|
1994-02-06
|
6KB
|
167 lines
#!/bin/sh
#
# NAME
# populate
#
# SYNOPSIS
# populate target-dir [ source-dir ... ]
#
# DESCRIPTION
# Adjunct script for GNU C++ to populate a directory with C++
# compatible header files.
#
# For each header file (whose name ends in .h) which resides in one
# of the indicated source-dirs, create a corresponding file in the
# target-dir (with the same name) which looks like:
#
# #ifndef __IN_C_REGION__
# #define __IN_C_REGION__
# extern "C" {
# #include_next <header.h>
# }
# #undef __IN_C_REGION__
# #else
# #include_next <header.h>
# #endif
#
# Where "header.h" is the name of the original header file in the
# source-dir.
#
# If a file with the appropriate name already exists in the target
# directory, it will not be overwritten.
#
# NOTES
# This script assumes that your native header files are already
# at least compliant with ANSI C, and that all functions declared
# therein are properly prototyped (as they must be for C++).
#
# Currently, this condition is not fully satisfied by many (if any)
# systems. On System V Release 4, most of the system header files
# do seem to be properly prototyped though, and OSF/1 also has
# prototyped header files, but some of the argument type specifica-
# tions for some function prototypes in some OSF/1 header files may
# lack `const' qualifiers in certain places where they ought to appear.
# (This is due to the fact that OSF/1 conformat to POSIX-1988 rather
# than to the newer POSIX-1990 standard.)
#
# If your system's native include files are not properly prototyped,
# that's OK. This script will still do it's normal job (in the normal
# way) but the resulting (indirect) header files will not be very useful
# for g++ programming unless (and until) somebody puts in all of the
# prototypes for all of the functions which are declared in these files.
#
# Note that in some cases, a header file with a given name may exist
# in two or more of the given source directories. That's perfectly
# alright. Only one (corresponding) header file will be placed into
# the target directory for each such group of kindred source files.
#
# This script should probably be invoked from the GCC Makefile, via:
#
# populate $(libdir)/g++-include $(libsubdir)/include /usr/include
#
# That would insure the creation of a C++ compatible set of headers
# (in the sepcial g++-include directory) corresponding to all of the
# normal GCC header files and all of the native system's header files.
#
# AUTHOR
# Ron Guilmette (rfg@ncd.com)
#
# COPYRIGHT
# This file is part of GNU CC.
#
# GNU CC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU CC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU CC; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
progname=$0
progname=`basename $progname`
original_dir=`pwd`
if [ `echo $1 | wc -w` = 0 ] ; then
echo $progname\: usage\: $progname target-dir \[ source-dir \.\.\. \]
exit 1
fi
rel_target_dir=$1
shift
if [ `expr $rel_target_dir : '\(.\)'` != '/' ] ; then
abs_target_dir=$original_dir/$rel_target_dir
else
abs_target_dir=$rel_target_dir
fi
if [ \! -d $abs_target_dir ] ; then
echo $progname\: creating directory $rel_target_dir
mkdir $abs_target_dir
fi
echo $progname\: populating \`$rel_target_dir\'
if [ `echo $* | wc -w` != 0 ] ; then
for rel_source_dir in $*; do
if [ `expr $rel_source_dir : '\(.\)'` != '/' ] ; then
abs_source_dir=$original_dir/$rel_source_dir
else
abs_source_dir=$rel_source_dir
fi
echo $progname\: input dir\: \`$rel_source_dir\'
done
fi
tmp_file=/tmp/$progname.$$
rm -f $tmp_file
echo '#ifndef __IN_C_REGION__' > $tmp_file
echo '#define __IN_C_REGION__' >> $tmp_file
echo 'extern "C" {' >> $tmp_file
echo '#include_next <=>' >> $tmp_file
echo '}' >> $tmp_file
echo '#undef __IN_C_REGION__' >> $tmp_file
echo '#else' >> $tmp_file
echo '#include_next <=>' >> $tmp_file
echo '#endif' >> $tmp_file
if [ `echo $* | wc -w` != 0 ] ; then
for rel_source_dir in $*; do
if [ `expr $rel_source_dir : '\(.\)'` != '/' ] ; then
abs_source_dir=$original_dir/$rel_source_dir
else
abs_source_dir=$rel_source_dir
fi
if [ \! -d $abs_source_dir ] ; then
echo $progname\: warning\: no such directory\: \`$rel_source_dir\'
continue
fi
cd $abs_source_dir
rel_source_subdirs=`find . -type d -print | sed 's%^\./%%' | sed 's/\.//'`
if [ `echo $rel_source_subdirs | wc -w` != 0 ] ; then
for rel_source_subdir in $rel_source_subdirs; do
abs_target_subdir=$abs_target_dir/$rel_source_subdir
if [ \! -d $abs_target_subdir ] ; then
mkdir $abs_target_subdir
fi
done
fi
rel_source_files=`find . -type f -name \*.h -print | sed 's%^\./%%'`
if [ `echo $rel_source_files | wc -w` != 0 ] ; then
for rel_source_file in $rel_source_files; do
abs_source_file=$abs_source_dir/$rel_source_file
abs_target_file=$abs_target_dir/$rel_source_file
if [ \! -f $abs_target_file ] ; then
sed 's%=%'"$rel_source_file"'%' $tmp_file > $abs_target_file
fi
done
fi
done
fi
rm -f $tmp_file
exit 0