FSF GCC merge 02/23/03
[official-gcc.git] / gcc / mkconfig.sh
blob64d118f1a99c9e1cbf317b442535346fbecda0b4
1 #! /bin/sh
3 # Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4 # This file is part of GCC.
6 # GCC is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # GCC is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING. If not, write to
18 # the Free Software Foundation, 59 Temple Place - Suite 330,
19 # Boston MA 02111-1307, USA.
22 # Generate gcc's various configuration headers:
23 # config.h, tconfig.h, bconfig.h, tm.h, and tm_p.h.
24 # $1 is the file to generate. DEFINES, HEADERS, and possibly
25 # TARGET_CPU_DEFAULT are expected to be set in the environment.
27 if [ -z "$1" ]; then
28 echo "Usage: DEFINES='list' HEADERS='list' \\" >&2
29 echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2
30 exit 1
33 output=$1
34 rm -f ${output}T
36 # Define TARGET_CPU_DEFAULT if the system wants one.
37 # This substitutes for lots of *.h files.
38 if [ "$TARGET_CPU_DEFAULT" != "" ]; then
39 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
42 # Provide defines for other macros set in config.gcc for this file.
43 for def in $DEFINES; do
44 echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
45 echo "# define $def" | sed 's/=/ /' >> ${output}T
46 echo "#endif" >> ${output}T
47 done
49 # The first entry in HEADERS may be auto-host.h or auto-build.h;
50 # it wants to be included even when not -DIN_GCC.
51 if [ -n "$HEADERS" ]; then
52 set $HEADERS
53 case "$1" in auto-* )
54 echo "#include \"$1\"" >> ${output}T
55 shift
57 esac
58 if [ $# -ge 1 ]; then
59 echo '#ifdef IN_GCC' >> ${output}T
60 for file in "$@"; do
61 echo "# include \"$file\"" >> ${output}T
62 done
63 echo '#endif' >> ${output}T
67 # If this is tconfig.h, now define USED_FOR_TARGET. If this is tm.h,
68 # now include insn-constants.h and insn-flags.h only if IN_GCC is
69 # defined but neither GENERATOR_FILE nor USED_FOR_TARGET is defined.
70 # (Much of this is temporary.)
72 case $output in
73 tconfig.h )
74 cat >> ${output}T <<EOF
75 #define USED_FOR_TARGET
76 EOF
78 tm.h )
79 cat >> ${output}T <<EOF
80 #if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
81 # include "insn-constants.h"
82 # include "insn-flags.h"
83 #endif
84 EOF
86 esac
88 # Avoid changing the actual file if possible.
89 if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
90 echo $output is unchanged >&2
91 rm -f ${output}T
92 else
93 mv -f ${output}T $output
96 # Touch a stamp file for Make's benefit.
97 rm -f cs-$output
98 echo timestamp > cs-$output