117680Spst#! /bin/sh 217680Spst 317680Spst# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. 417680Spst# This file is part of GCC. 517680Spst 617680Spst# GCC is free software; you can redistribute it and/or modify 717680Spst# it under the terms of the GNU General Public License as published by 817680Spst# the Free Software Foundation; either version 2, or (at your option) 917680Spst# any later version. 1017680Spst 1117680Spst# GCC is distributed in the hope that it will be useful, 1217680Spst# but WITHOUT ANY WARRANTY; without even the implied warranty of 1317680Spst# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1417680Spst# GNU General Public License for more details. 1517680Spst 1617680Spst# You should have received a copy of the GNU General Public License 1717680Spst# along with GCC; see the file COPYING. If not, write to 1817680Spst# the Free Software Foundation, 51 Franklin Street, Fifth Floor, 1917680Spst# Boston MA 02110-1301, USA. 2026183Sfenner 2117680Spst 2256896Sfenner# Generate gcc's various configuration headers: 2398527Sfenner# config.h, tconfig.h, bconfig.h, tm.h, and tm_p.h. 24146778Ssam# $1 is the file to generate. DEFINES, HEADERS, and possibly 2598527Sfenner# TARGET_CPU_DEFAULT are expected to be set in the environment. 2656896Sfenner 2717680Spstif [ -z "$1" ]; then 2817680Spst echo "Usage: DEFINES='list' HEADERS='list' \\" >&2 29276788Sdelphij echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2 3056896Sfenner exit 1 3156896Sfennerfi 3256896Sfenner 3356896Sfenneroutput=$1 34127675Sbmsrm -f ${output}T 3517680Spst 3698527Sfenner# This converts a file name into header guard macro format. 3717680Spsthg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,' 3817680Spstheader_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}` 3917680Spst 4075118Sfenner# Add multiple inclusion protection guard, part one. 41146778Ssamecho "#ifndef ${header_guard}" >> ${output}T 4217688Spstecho "#define ${header_guard}" >> ${output}T 43127675Sbms 44146778Ssam# A special test to ensure that build-time files don't blindly use 45214478Srpaulo# config.h. 4617680Spstif test x"$output" = x"config.h"; then 4732149Spst echo "#ifdef GENERATOR_FILE" >> ${output}T 4832149Spst echo "#error config.h is for the host, not build, machine." >> ${output}T 4932149Spst echo "#endif" >> ${output}T 5032149Spstfi 5175118Sfenner 52127675Sbms# Define TARGET_CPU_DEFAULT if the system wants one. 53127675Sbms# This substitutes for lots of *.h files. 54127675Sbmsif [ "$TARGET_CPU_DEFAULT" != "" ]; then 5532149Spst echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T 56146778Ssamfi 57146778Ssam 5832149Spst# Provide defines for other macros set in config.gcc for this file. 59146778Ssamfor def in $DEFINES; do 60146778Ssam echo "#ifndef $def" | sed 's/=.*//' >> ${output}T 61146778Ssam echo "# define $def" | sed 's/=/ /' >> ${output}T 62146778Ssam echo "#endif" >> ${output}T 63146778Ssamdone 6432149Spst 65146778Ssam# The first entry in HEADERS may be auto-FOO.h ; 66146778Ssam# it wants to be included even when not -DIN_GCC. 67146778Ssamif [ -n "$HEADERS" ]; then 68146778Ssam set $HEADERS 69146778Ssam case "$1" in auto-* ) 70146778Ssam echo "#include \"$1\"" >> ${output}T 71146778Ssam shift 72146778Ssam ;; 73146778Ssam esac 74146778Ssam if [ $# -ge 1 ]; then 75276788Sdelphij echo '#ifdef IN_GCC' >> ${output}T 76146778Ssam for file in "$@"; do 77146778Ssam echo "# include \"$file\"" >> ${output}T 78146778Ssam done 79146778Ssam echo '#endif' >> ${output}T 80146778Ssam fi 81146778Ssamfi 82146778Ssam 83146778Ssam# If this is tm.h, now include insn-constants.h and insn-flags.h only 84146778Ssam# if IN_GCC is defined but neither GENERATOR_FILE nor USED_FOR_TARGET 85127675Sbms# is defined. (Much of this is temporary.) 86127675Sbms 8798527Sfennercase $output in 8832149Spst tm.h ) 8932149Spst cat >> ${output}T <<EOF 9032149Spst#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET 9132149Spst# include "insn-constants.h" 92127675Sbms# include "insn-flags.h" 93127675Sbms#endif 9432149SpstEOF 9532149Spst ;; 96146778Ssamesac 97146778Ssam 98146778Ssam# Add multiple inclusion protection guard, part two. 99146778Ssamecho "#endif /* ${header_guard} */" >> ${output}T 100146778Ssam 101146778Ssam# Avoid changing the actual file if possible. 102146778Ssamif [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then 103146778Ssam echo $output is unchanged >&2 104146778Ssam rm -f ${output}T 105146778Ssamelse 106146778Ssam mv -f ${output}T $output 107162021Ssamfi 108146778Ssam 109162021Ssam# Touch a stamp file for Make's benefit. 110146778Ssamrm -f cs-$output 111146778Ssamecho timestamp > cs-$output 112146778Ssam