mkconfig.sh revision 96263
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# Define TARGET_CPU_DEFAULT if the system wants one. 17# This substitutes for lots of *.h files. 18if [ "$TARGET_CPU_DEFAULT" != "" ]; then 19 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T 20fi 21 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. 24if [ -n "$HEADERS" ]; then 25 set $HEADERS; first=$1 26 case $first in auto-* ) 27 echo "#include \"$first\"" >> ${output}T 28 shift 29 HEADERS=$* 30 ;; 31 esac 32fi 33 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. 38case $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. */ 46struct rtx_def; 47typedef struct rtx_def *rtx; 48struct rtvec_def; 49typedef struct rtvec_def *rtvec; 50union tree_node; 51typedef union tree_node *tree; 52#endif 53EOF 54 ;; 55esac 56 57if [ -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 63fi 64 65for 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 69done 70 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. 75case $output in 76 *tm_p.h) 77 echo "#include \"tm-preds.h\"" >> ${output}T 78 ;; 79 *tconfig.h | *hconfig.h) 80 ;; 81 *) 82 cat >> ${output}T <<EOF 83#ifndef GENERATOR_FILE 84# include "insn-constants.h" 85# include "insn-flags.h" 86#endif 87EOF 88 ;; 89esac 90 91# Avoid changing the actual file if possible. 92if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then 93 echo $output is unchanged >&2 94 rm -f ${output}T 95else 96 mv -f ${output}T $output 97fi 98 99# Touch a stamp file for Make's benefit. 100rm -f cs-$output 101echo timestamp > cs-$output 102