OSDN Git Service

* mkconfig.sh: Output to config.h, hconfig.h and tconfig.h
[pf3gnuchains/gcc-fork.git] / gcc / mkconfig.sh
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
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.
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 # 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.
42 case $output in 
43     *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"
56         ;;
57 esac
58
59 if [ -n "$HEADERS" ]; then
60     echo '#ifdef IN_GCC'
61     for file in $HEADERS; do
62         echo "# include \"$file\""
63     done
64     echo '#endif'
65 fi
66
67 for def in $DEFINES; do
68     echo "#ifndef $def" | sed 's/=.*//'
69     echo "# define $def" | sed 's/=/ /'
70     echo "#endif"
71 done
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.
77 case $output in
78     *tm_p.h)
79         echo "#include \"tm-preds.h\""
80     ;;
81     *tconfig.h | *hconfig.h)
82     ;;
83     *)
84         echo "#ifndef GENERATOR_FILE"
85         echo "# include \"insn-constants.h\""
86         echo "# include \"insn-flags.h\""
87         echo "#endif"
88     ;;
89 esac
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.
93 echo '#ifdef GENERATOR_FILE'
94 echo '# undef ENABLE_NLS'
95 echo '#endif'
96
97 ) > $output.T
98
99 # Avoid changing the actual file if possible.
100 if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then
101     echo $output is unchanged >&2
102     rm -f $output.T
103 else
104     mv -f $output.T $output
105 fi
106
107 # Touch a stamp file for Make's benefit.
108 rm -f cs-$output
109 echo timestamp > cs-$output