PR opt/3995
[official-gcc.git] / gcc / mkconfig.sh
blobf0d97ec8c628898d477f9353eb7d0e0ec3a59385
1 #! /bin/sh
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.
8 if [ -z "$1" ]; then
9 echo "Usage: HEADERS='list' DEFINES='list' mkconfig.sh FILE" >&2
10 exit 1
13 output=$1
14 rm -f ${output}T
16 # Define TARGET_CPU_DEFAULT if the system wants one.
17 # This substitutes for lots of *.h files.
18 if [ "$TARGET_CPU_DEFAULT" != "" ]; then
19 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
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.
24 if [ -n "$HEADERS" ]; then
25 set $HEADERS; first=$1
26 case $first in auto-* )
27 echo "#include \"$first\"" >> ${output}T
28 shift
29 HEADERS=$*
31 esac
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.
38 case $output in
39 *config.h | *hconfig.h | *tconfig.h)
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. */
46 struct rtx_def;
47 typedef struct rtx_def *rtx;
48 struct rtvec_def;
49 typedef struct rtvec_def *rtvec;
50 union tree_node;
51 typedef union tree_node *tree;
52 #endif
53 EOF
55 esac
57 if [ -n "$HEADERS" ]; then
58 echo '#ifdef IN_GCC' >> ${output}T
59 for file in $HEADERS; do
60 echo "# include \"$file\"" >> ${output}T
61 done
62 echo '#endif' >> ${output}T
65 for def in $DEFINES; do
66 echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
67 echo "# define $def" | sed 's/=/ /' >> ${output}T
68 echo "#endif" >> ${output}T
69 done
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.
75 case $output in
76 *tm_p.h)
77 echo "#include \"tm-preds.h\"" >> ${output}T
79 *tconfig.h | *hconfig.h)
82 cat >> ${output}T <<EOF
83 #ifndef GENERATOR_FILE
84 # include "insn-constants.h"
85 # include "insn-flags.h"
86 #endif
87 EOF
89 esac
91 # Avoid changing the actual file if possible.
92 if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
93 echo $output is unchanged >&2
94 rm -f ${output}T
95 else
96 mv -f ${output}T $output
99 # Touch a stamp file for Make's benefit.
100 rm -f cs-$output
101 echo timestamp > cs-$output