Deleted Added
full compact
mkconfig.sh (90075) mkconfig.sh (96263)
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
8if [ -z "$1" ]; then
9 echo "Usage: HEADERS='list' DEFINES='list' mkconfig.sh FILE" >&2
10 exit 1
11fi
12
13output=$1
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
8if [ -z "$1" ]; then
9 echo "Usage: HEADERS='list' DEFINES='list' mkconfig.sh FILE" >&2
10 exit 1
11fi
12
13output=$1
14rm -f $output.T
14rm -f ${output}T
15
15
16# We used to exec > $output.T but apparently this has bugs.
17# Use a redirected subshell instead.
18(
19
20# Define TARGET_CPU_DEFAULT if the system wants one.
21# This substitutes for lots of *.h files.
22if [ "$TARGET_CPU_DEFAULT" != "" ]; then
16# Define TARGET_CPU_DEFAULT if the system wants one.
17# This substitutes for lots of *.h files.
18if [ "$TARGET_CPU_DEFAULT" != "" ]; then
23 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)"
19 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
24fi
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.
28if [ -n "$HEADERS" ]; then
29 set $HEADERS; first=$1
30 case $first in auto-* )
20fi
21
22# The first entry in HEADERS may be auto-host.h or auto-build.h;
23# it wants to be included even when not -DIN_GCC.
24if [ -n "$HEADERS" ]; then
25 set $HEADERS; first=$1
26 case $first in auto-* )
31 echo "#include \"$first\""
27 echo "#include \"$first\"" >> ${output}T
32 shift
33 HEADERS=$*
34 ;;
35 esac
36fi
37
38# Provide three core typedefs used by everything, if we are compiling
39# GCC. These used to be found in rtl.h and tree.h, but this is no
40# longer practical. Providing these in config.h/tconfig.h/hconfig.h
41# rather than system.h allows the typedefs to be used anywhere in GCC.
42case $output in
43 *config.h | *hconfig.h | *tconfig.h)
28 shift
29 HEADERS=$*
30 ;;
31 esac
32fi
33
34# Provide three core typedefs used by everything, if we are compiling
35# GCC. These used to be found in rtl.h and tree.h, but this is no
36# longer practical. Providing these in config.h/tconfig.h/hconfig.h
37# rather than system.h allows the typedefs to be used anywhere in GCC.
38case $output in
39 *config.h | *hconfig.h | *tconfig.h)
44 echo "#ifdef IN_GCC"
45 echo "/* Provide three core typedefs used by everything, if we are compiling"
46 echo " GCC. These used to be found in rtl.h and tree.h, but this is no"
47 echo " longer practical. Providing these here rather that system.h allows"
48 echo " the typedefs to be used everywhere within GCC. */"
49 echo "struct rtx_def;"
50 echo "typedef struct rtx_def *rtx;"
51 echo "struct rtvec_def;"
52 echo "typedef struct rtvec_def *rtvec;"
53 echo "union tree_node;"
54 echo "typedef union tree_node *tree;"
55 echo "#endif"
40 cat >> ${output}T <<EOF
41#ifdef IN_GCC
42/* Provide three core typedefs used by everything, if we are compiling
43 GCC. These used to be found in rtl.h and tree.h, but this is no
44 longer practical. Providing these here rather that system.h allows
45 the typedefs to be used everywhere within GCC. */
46struct rtx_def;
47typedef struct rtx_def *rtx;
48struct rtvec_def;
49typedef struct rtvec_def *rtvec;
50union tree_node;
51typedef union tree_node *tree;
52#endif
53EOF
56 ;;
57esac
58
59if [ -n "$HEADERS" ]; then
54 ;;
55esac
56
57if [ -n "$HEADERS" ]; then
60 echo '#ifdef IN_GCC'
58 echo '#ifdef IN_GCC' >> ${output}T
61 for file in $HEADERS; do
59 for file in $HEADERS; do
62 echo "# include \"$file\""
60 echo "# include \"$file\"" >> ${output}T
63 done
61 done
64 echo '#endif'
62 echo '#endif' >> ${output}T
65fi
66
67for def in $DEFINES; do
63fi
64
65for def in $DEFINES; do
68 echo "#ifndef $def" | sed 's/=.*//'
69 echo "# define $def" | sed 's/=/ /'
70 echo "#endif"
66 echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
67 echo "# define $def" | sed 's/=/ /' >> ${output}T
68 echo "#endif" >> ${output}T
71done
72
73# If this is tm_p.h, include tm-preds.h unconditionally.
74# If this is tconfig.h or hconfig.h, include no more files.
75# Otherwise, include insn-constants.h and insn-flags.h,
76# but only if GENERATOR_FILE is not defined.
77case $output in
78 *tm_p.h)
69done
70
71# If this is tm_p.h, include tm-preds.h unconditionally.
72# If this is tconfig.h or hconfig.h, include no more files.
73# Otherwise, include insn-constants.h and insn-flags.h,
74# but only if GENERATOR_FILE is not defined.
75case $output in
76 *tm_p.h)
79 echo "#include \"tm-preds.h\""
77 echo "#include \"tm-preds.h\"" >> ${output}T
80 ;;
81 *tconfig.h | *hconfig.h)
82 ;;
83 *)
78 ;;
79 *tconfig.h | *hconfig.h)
80 ;;
81 *)
84 echo "#ifndef GENERATOR_FILE"
85 echo "# include \"insn-constants.h\""
86 echo "# include \"insn-flags.h\""
87 echo "#endif"
82 cat >> ${output}T <<EOF
83#ifndef GENERATOR_FILE
84# include "insn-constants.h"
85# include "insn-flags.h"
86#endif
87EOF
88 ;;
89esac
90
88 ;;
89esac
90
91# Prevent obstack.c from thinking it can do i18n of its error message
92# when it's being linked against a build-side program.
93echo '#ifdef GENERATOR_FILE'
94echo '# undef ENABLE_NLS'
95echo '#endif'
96
97) > $output.T
98
99# Avoid changing the actual file if possible.
91# Avoid changing the actual file if possible.
100if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then
92if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
101 echo $output is unchanged >&2
93 echo $output is unchanged >&2
102 rm -f $output.T
94 rm -f ${output}T
103else
95else
104 mv -f $output.T $output
96 mv -f ${output}T $output
105fi
106
107# Touch a stamp file for Make's benefit.
108rm -f cs-$output
109echo timestamp > cs-$output
97fi
98
99# Touch a stamp file for Make's benefit.
100rm -f cs-$output
101echo timestamp > cs-$output