mkconfig.sh revision 90075
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 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 23 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" 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-* ) 31 echo "#include \"$first\"" 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) 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 ;; 57esac 58 59if [ -n "$HEADERS" ]; then 60 echo '#ifdef IN_GCC' 61 for file in $HEADERS; do 62 echo "# include \"$file\"" 63 done 64 echo '#endif' 65fi 66 67for def in $DEFINES; do 68 echo "#ifndef $def" | sed 's/=.*//' 69 echo "# define $def" | sed 's/=/ /' 70 echo "#endif" 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) 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 ;; 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. 100if [ -f $output ] && cmp $output.T $output >/dev/null 2>&1; then 101 echo $output is unchanged >&2 102 rm -f $output.T 103else 104 mv -f $output.T $output 105fi 106 107# Touch a stamp file for Make's benefit. 108rm -f cs-$output 109echo timestamp > cs-$output 110