* doc/contrib.texi: Fix alphabetical order. Fix typos. Improve
[official-gcc.git] / gcc / mkconfig.sh
blob03c1d9d4ffc1948540e66a03082e73ff56473218
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 # We used to exec > $output.T but apparently this has bugs.
17 # Use a redirected subshell instead.
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)"
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=$*
35 esac
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'
46 for def in $DEFINES; do
47 echo "#ifndef $def" | sed 's/=.*//'
48 echo "# define $def" | sed 's/=/ /'
49 echo "#endif"
50 done
52 # Include insn-codes.h last, because it includes machmode.h,
53 # and we want EXTRA_CC_MODES to be taken into account.
54 echo "#ifndef GENERATOR_FILE"
55 echo "#include \"insn-codes.h\""
56 echo "#include \"insn-flags.h\""
57 echo "#endif"
59 ) > $output.T
61 # Avoid changing the actual file if possible.
62 if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then
63 echo $output is unchanged >&2
64 rm -f $output.T
65 else
66 mv -f $output.T $output
69 # Touch a stamp file for Make's benefit.
70 rm -f cs-$output
71 echo timestamp > cs-$output