2002-02-01 18:16:02 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
|
|
|
# This file is part of GCC.
|
|
|
|
|
|
|
|
# GCC 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.
|
|
|
|
|
|
|
|
# GCC 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 GCC; see the file COPYING. If not, write to
|
|
|
|
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
# Boston MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
|
|
# Generate gcc's various configuration headers:
|
|
|
|
# config.h, tconfig.h, bconfig.h, tm.h, and tm_p.h.
|
|
|
|
# $1 is the file to generate. DEFINES, HEADERS, and possibly
|
|
|
|
# TARGET_CPU_DEFAULT are expected to be set in the environment.
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2004-07-28 03:11:36 +00:00
|
|
|
echo "Usage: DEFINES='list' HEADERS='list' \\" >&2
|
|
|
|
echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2
|
2002-02-01 18:16:02 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
output=$1
|
2002-05-09 20:02:13 +00:00
|
|
|
rm -f ${output}T
|
2002-02-01 18:16:02 +00:00
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
# This converts a file name into header guard macro format.
|
|
|
|
hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,'
|
|
|
|
header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
|
|
|
|
|
|
|
|
# Add multiple inclusion protection guard, part one.
|
|
|
|
echo "#ifndef ${header_guard}" >> ${output}T
|
|
|
|
echo "#define ${header_guard}" >> ${output}T
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
# Define TARGET_CPU_DEFAULT if the system wants one.
|
|
|
|
# This substitutes for lots of *.h files.
|
|
|
|
if [ "$TARGET_CPU_DEFAULT" != "" ]; then
|
2002-05-09 20:02:13 +00:00
|
|
|
echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
|
2002-02-01 18:16:02 +00:00
|
|
|
fi
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
# Provide defines for other macros set in config.gcc for this file.
|
|
|
|
for def in $DEFINES; do
|
2003-07-11 03:40:53 +00:00
|
|
|
echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
|
|
|
|
echo "# define $def" | sed 's/=/ /' >> ${output}T
|
|
|
|
echo "#endif" >> ${output}T
|
|
|
|
done
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
# The first entry in HEADERS may be auto-host.h or auto-build.h;
|
|
|
|
# it wants to be included even when not -DIN_GCC.
|
|
|
|
if [ -n "$HEADERS" ]; then
|
2004-07-28 03:11:36 +00:00
|
|
|
set $HEADERS
|
|
|
|
case "$1" in auto-* )
|
|
|
|
echo "#include \"$1\"" >> ${output}T
|
2002-02-01 18:16:02 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
2004-07-28 03:11:36 +00:00
|
|
|
if [ $# -ge 1 ]; then
|
|
|
|
echo '#ifdef IN_GCC' >> ${output}T
|
|
|
|
for file in "$@"; do
|
|
|
|
echo "# include \"$file\"" >> ${output}T
|
|
|
|
done
|
|
|
|
echo '#endif' >> ${output}T
|
|
|
|
fi
|
2002-02-01 18:16:02 +00:00
|
|
|
fi
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
# If this is tconfig.h, now define USED_FOR_TARGET. If this is tm.h,
|
|
|
|
# now include insn-constants.h and insn-flags.h only if IN_GCC is
|
|
|
|
# defined but neither GENERATOR_FILE nor USED_FOR_TARGET is defined.
|
|
|
|
# (Much of this is temporary.)
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
case $output in
|
2004-07-28 03:11:36 +00:00
|
|
|
tconfig.h )
|
|
|
|
cat >> ${output}T <<EOF
|
|
|
|
#define USED_FOR_TARGET
|
|
|
|
EOF
|
2002-02-01 18:16:02 +00:00
|
|
|
;;
|
2004-07-28 03:11:36 +00:00
|
|
|
tm.h )
|
2002-05-09 20:02:13 +00:00
|
|
|
cat >> ${output}T <<EOF
|
2004-07-28 03:11:36 +00:00
|
|
|
#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
|
2002-05-09 20:02:13 +00:00
|
|
|
# include "insn-constants.h"
|
|
|
|
# include "insn-flags.h"
|
|
|
|
#endif
|
|
|
|
EOF
|
2002-02-01 18:16:02 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
# Add multiple inclusion protection guard, part two.
|
|
|
|
echo "#endif /* ${header_guard} */" >> ${output}T
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
# Avoid changing the actual file if possible.
|
2002-05-09 20:02:13 +00:00
|
|
|
if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
|
2002-02-01 18:16:02 +00:00
|
|
|
echo $output is unchanged >&2
|
2002-05-09 20:02:13 +00:00
|
|
|
rm -f ${output}T
|
2002-02-01 18:16:02 +00:00
|
|
|
else
|
2002-05-09 20:02:13 +00:00
|
|
|
mv -f ${output}T $output
|
2002-02-01 18:16:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Touch a stamp file for Make's benefit.
|
|
|
|
rm -f cs-$output
|
|
|
|
echo timestamp > cs-$output
|