]>
Commit | Line | Data |
---|---|---|
11642c3a ZW |
1 | #! /bin/sh |
2 | ||
3 | # Generate gcc's config.h, which is not your normal autoconf-generated | |
4 | # config.h (that's auto-(host|build).h). $1 is the file to generate. | |
5 | # HEADERS, DEFINES, and possibly TARGET_CPU_DEFAULT are expected to be | |
6 | # set in the environment. | |
7 | ||
8 | if [ -z "$1" ]; then | |
9 | echo "Usage: HEADERS='list' DEFINES='list' mkconfig.sh FILE" >&2 | |
10 | exit 1 | |
11 | fi | |
12 | ||
13 | output=$1 | |
14 | rm -f $output.T | |
1b0ae0f9 ZW |
15 | |
16 | # We used to exec > $output.T but apparently this has bugs. | |
17 | # Use a redirected subshell instead. | |
18 | ( | |
11642c3a ZW |
19 | |
20 | # Define TARGET_CPU_DEFAULT if the system wants one. | |
21 | # This substitutes for lots of *.h files. | |
22 | if [ "$TARGET_CPU_DEFAULT" != "" ]; then | |
23 | echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" | |
24 | fi | |
25 | ||
26 | # The first entry in HEADERS may be auto-host.h or auto-build.h; | |
27 | # it wants to be included even when not -DIN_GCC. | |
28 | if [ -n "$HEADERS" ]; then | |
29 | set $HEADERS; first=$1 | |
30 | case $first in auto-* ) | |
31 | echo "#include \"$first\"" | |
32 | shift | |
33 | HEADERS=$* | |
34 | ;; | |
35 | esac | |
36 | fi | |
37 | ||
38 | if [ -n "$HEADERS" ]; then | |
39 | echo '#ifdef IN_GCC' | |
40 | for file in $HEADERS; do | |
41 | echo "# include \"$file\"" | |
42 | done | |
43 | echo '#endif' | |
44 | fi | |
45 | ||
46 | for def in $DEFINES; do | |
d2a2648c KG |
47 | echo "#ifndef $def" | sed 's/=.*//' |
48 | echo "# define $def" | sed 's/=/ /' | |
11642c3a ZW |
49 | echo "#endif" |
50 | done | |
51 | ||
1b0c37d7 ZW |
52 | # If this is tm_p.h, include tm-preds.h unconditionally. |
53 | # If this is tconfig.h or hconfig.h, include no more files. | |
e78d8e51 ZW |
54 | # Otherwise, include insn-constants.h and insn-flags.h, |
55 | # but only if GENERATOR_FILE is not defined. | |
1b0c37d7 ZW |
56 | case $output in |
57 | *tm_p.h) | |
58 | echo "#include \"tm-preds.h\"" | |
59 | ;; | |
60 | *tconfig.h | *hconfig.h) | |
61 | ;; | |
62 | *) | |
63 | echo "#ifndef GENERATOR_FILE" | |
64 | echo "# include \"insn-constants.h\"" | |
1b0c37d7 ZW |
65 | echo "# include \"insn-flags.h\"" |
66 | echo "#endif" | |
67 | ;; | |
68 | esac | |
11642c3a | 69 | |
497e89e1 ZW |
70 | # Prevent obstack.c from thinking it can do i18n of its error message |
71 | # when it's being linked against a build-side program. | |
72 | echo '#ifdef GENERATOR_FILE' | |
73 | echo '# undef ENABLE_NLS' | |
74 | echo '#endif' | |
75 | ||
1b0ae0f9 | 76 | ) > $output.T |
11642c3a ZW |
77 | |
78 | # Avoid changing the actual file if possible. | |
1b0ae0f9 | 79 | if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then |
11642c3a ZW |
80 | echo $output is unchanged >&2 |
81 | rm -f $output.T | |
82 | else | |
83 | mv -f $output.T $output | |
84 | fi | |
85 | ||
86 | # Touch a stamp file for Make's benefit. | |
87 | rm -f cs-$output | |
88 | echo timestamp > cs-$output |