]>
Commit | Line | Data |
---|---|---|
11642c3a ZW |
1 | #! /bin/sh |
2 | ||
4977bab6 ZW |
3 | # Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
4 | # This file is part of GCC. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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. | |
20 | ||
21 | ||
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. | |
11642c3a ZW |
26 | |
27 | if [ -z "$1" ]; then | |
4977bab6 ZW |
28 | echo "Usage: DEFINES='list' HEADERS='list' \\" >&2 |
29 | echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2 | |
11642c3a ZW |
30 | exit 1 |
31 | fi | |
32 | ||
33 | output=$1 | |
2dbe67bb | 34 | rm -f ${output}T |
11642c3a | 35 | |
5e7537cf NN |
36 | # This converts a file name into header guard macro format. |
37 | hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,' | |
38 | header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}` | |
39 | ||
40 | # Add multiple inclusion protection guard, part one. | |
41 | echo "#ifndef ${header_guard}" >> ${output}T | |
42 | echo "#define ${header_guard}" >> ${output}T | |
43 | ||
11642c3a ZW |
44 | # Define TARGET_CPU_DEFAULT if the system wants one. |
45 | # This substitutes for lots of *.h files. | |
46 | if [ "$TARGET_CPU_DEFAULT" != "" ]; then | |
2dbe67bb | 47 | echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T |
11642c3a ZW |
48 | fi |
49 | ||
4977bab6 ZW |
50 | # Provide defines for other macros set in config.gcc for this file. |
51 | for def in $DEFINES; do | |
d5355cb2 JDA |
52 | echo "#ifndef $def" | sed 's/=.*//' >> ${output}T |
53 | echo "# define $def" | sed 's/=/ /' >> ${output}T | |
54 | echo "#endif" >> ${output}T | |
55 | done | |
56 | ||
11642c3a ZW |
57 | # The first entry in HEADERS may be auto-host.h or auto-build.h; |
58 | # it wants to be included even when not -DIN_GCC. | |
59 | if [ -n "$HEADERS" ]; then | |
4977bab6 ZW |
60 | set $HEADERS |
61 | case "$1" in auto-* ) | |
62 | echo "#include \"$1\"" >> ${output}T | |
11642c3a | 63 | shift |
11642c3a ZW |
64 | ;; |
65 | esac | |
4977bab6 ZW |
66 | if [ $# -ge 1 ]; then |
67 | echo '#ifdef IN_GCC' >> ${output}T | |
68 | for file in "$@"; do | |
69 | echo "# include \"$file\"" >> ${output}T | |
70 | done | |
71 | echo '#endif' >> ${output}T | |
72 | fi | |
11642c3a ZW |
73 | fi |
74 | ||
4977bab6 ZW |
75 | # If this is tconfig.h, now define USED_FOR_TARGET. If this is tm.h, |
76 | # now include insn-constants.h and insn-flags.h only if IN_GCC is | |
77 | # defined but neither GENERATOR_FILE nor USED_FOR_TARGET is defined. | |
78 | # (Much of this is temporary.) | |
fb2bf631 | 79 | |
1b0c37d7 | 80 | case $output in |
4977bab6 ZW |
81 | tconfig.h ) |
82 | cat >> ${output}T <<EOF | |
83 | #define USED_FOR_TARGET | |
84 | EOF | |
1b0c37d7 | 85 | ;; |
4977bab6 | 86 | tm.h ) |
2dbe67bb | 87 | cat >> ${output}T <<EOF |
4977bab6 | 88 | #if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET |
2dbe67bb DR |
89 | # include "insn-constants.h" |
90 | # include "insn-flags.h" | |
91 | #endif | |
92 | EOF | |
1b0c37d7 ZW |
93 | ;; |
94 | esac | |
11642c3a | 95 | |
5e7537cf NN |
96 | # Add multiple inclusion protection guard, part two. |
97 | echo "#endif /* ${header_guard} */" >> ${output}T | |
98 | ||
11642c3a | 99 | # Avoid changing the actual file if possible. |
2dbe67bb | 100 | if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then |
11642c3a | 101 | echo $output is unchanged >&2 |
2dbe67bb | 102 | rm -f ${output}T |
11642c3a | 103 | else |
2dbe67bb | 104 | mv -f ${output}T $output |
11642c3a ZW |
105 | fi |
106 | ||
107 | # Touch a stamp file for Make's benefit. | |
108 | rm -f cs-$output | |
109 | echo timestamp > cs-$output |