* config/i386/netbsd-elf.h (LINK_SPEC): Define as
[official-gcc.git] / gcc / mkconfig.sh
blob5b86b79f8b940d9c12da5cb2573ab9fc49e4a453
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 #define GTY(x)
54 EOF
56 esac
58 if [ -n "$HEADERS" ]; then
59 echo '#ifdef IN_GCC' >> ${output}T
60 for file in $HEADERS; do
61 echo "# include \"$file\"" >> ${output}T
62 done
63 echo '#endif' >> ${output}T
66 for def in $DEFINES; do
67 echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
68 echo "# define $def" | sed 's/=/ /' >> ${output}T
69 echo "#endif" >> ${output}T
70 done
72 # If this is tm_p.h, include tm-preds.h unconditionally.
73 # If this is tconfig.h or hconfig.h, include no more files.
74 # Otherwise, include insn-constants.h and insn-flags.h,
75 # but only if GENERATOR_FILE is not defined.
76 case $output in
77 *tm_p.h)
78 echo "#include \"tm-preds.h\"" >> ${output}T
80 *tconfig.h | *hconfig.h)
83 cat >> ${output}T <<EOF
84 #ifndef GENERATOR_FILE
85 # include "insn-constants.h"
86 # include "insn-flags.h"
87 #endif
88 EOF
90 esac
92 # Avoid changing the actual file if possible.
93 if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
94 echo $output is unchanged >&2
95 rm -f ${output}T
96 else
97 mv -f ${output}T $output
100 # Touch a stamp file for Make's benefit.
101 rm -f cs-$output
102 echo timestamp > cs-$output