]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/mkconfig.sh
config.gcc (libgcc_tm_file): Define instead of including files from ../../libgcc...
[thirdparty/gcc.git] / gcc / mkconfig.sh
CommitLineData
11642c3a
ZW
1#! /bin/sh
2
80cf2e08
JM
3# Copyright (C) 2001, 2002, 2006, 2007, 2010, 2011
4# Free Software Foundation, Inc.
4977bab6
ZW
5# This file is part of GCC.
6
7# GCC is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9dcd6f09 9# the Free Software Foundation; either version 3, or (at your option)
4977bab6
ZW
10# any later version.
11
12# GCC is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
9dcd6f09
NC
18# along with GCC; see the file COPYING3. If not see
19# <http://www.gnu.org/licenses/>.
4977bab6
ZW
20
21
22# Generate gcc's various configuration headers:
80cf2e08 23# config.h, tconfig.h, bconfig.h, tm.h, libgcc_tm.h, and tm_p.h.
4977bab6
ZW
24# $1 is the file to generate. DEFINES, HEADERS, and possibly
25# TARGET_CPU_DEFAULT are expected to be set in the environment.
11642c3a
ZW
26
27if [ -z "$1" ]; then
4977bab6
ZW
28 echo "Usage: DEFINES='list' HEADERS='list' \\" >&2
29 echo " [TARGET_CPU_DEFAULT='default'] mkconfig.sh FILE" >&2
11642c3a
ZW
30 exit 1
31fi
32
33output=$1
2dbe67bb 34rm -f ${output}T
11642c3a 35
5e7537cf
NN
36# This converts a file name into header guard macro format.
37hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,'
38header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
39
40# Add multiple inclusion protection guard, part one.
41echo "#ifndef ${header_guard}" >> ${output}T
42echo "#define ${header_guard}" >> ${output}T
43
2d5bc016
DD
44# A special test to ensure that build-time files don't blindly use
45# config.h.
f9a4b91e 46if test x"$output" = x"config.h"; then
2d5bc016
DD
47 echo "#ifdef GENERATOR_FILE" >> ${output}T
48 echo "#error config.h is for the host, not build, machine." >> ${output}T
49 echo "#endif" >> ${output}T
50fi
51
11642c3a
ZW
52# Define TARGET_CPU_DEFAULT if the system wants one.
53# This substitutes for lots of *.h files.
54if [ "$TARGET_CPU_DEFAULT" != "" ]; then
2dbe67bb 55 echo "#define TARGET_CPU_DEFAULT ($TARGET_CPU_DEFAULT)" >> ${output}T
11642c3a
ZW
56fi
57
4977bab6
ZW
58# Provide defines for other macros set in config.gcc for this file.
59for def in $DEFINES; do
d5355cb2
JDA
60 echo "#ifndef $def" | sed 's/=.*//' >> ${output}T
61 echo "# define $def" | sed 's/=/ /' >> ${output}T
62 echo "#endif" >> ${output}T
63done
64
232b67d9 65# The first entry in HEADERS may be auto-FOO.h ;
11642c3a 66# it wants to be included even when not -DIN_GCC.
77ec4307
SB
67# Postpone including defaults.h until after the insn-*
68# headers, so that the HAVE_* flags are available
69# when defaults.h gets included.
70postpone_defaults_h="no"
11642c3a 71if [ -n "$HEADERS" ]; then
4977bab6
ZW
72 set $HEADERS
73 case "$1" in auto-* )
74 echo "#include \"$1\"" >> ${output}T
11642c3a 75 shift
11642c3a
ZW
76 ;;
77 esac
4977bab6
ZW
78 if [ $# -ge 1 ]; then
79 echo '#ifdef IN_GCC' >> ${output}T
80 for file in "$@"; do
77ec4307
SB
81 if test x"$file" = x"defaults.h"; then
82 postpone_defaults_h="yes"
83 else
84 echo "# include \"$file\"" >> ${output}T
85 fi
4977bab6
ZW
86 done
87 echo '#endif' >> ${output}T
88 fi
11642c3a
ZW
89fi
90
c513ce77 91# If this is tm.h, now include insn-flags.h only if IN_GCC is defined
80cf2e08
JM
92# but neither GENERATOR_FILE nor USED_FOR_TARGET is defined. Also
93# include libgcc_tm.h if USED_FOR_TARGET is defined. (Much of this is
94# temporary.)
fb2bf631 95
1b0c37d7 96case $output in
4977bab6 97 tm.h )
2dbe67bb 98 cat >> ${output}T <<EOF
4977bab6 99#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
2dbe67bb
DR
100# include "insn-flags.h"
101#endif
80cf2e08
JM
102#ifdef USED_FOR_TARGET
103# include "libgcc_tm.h"
104#endif
2dbe67bb 105EOF
1b0c37d7
ZW
106 ;;
107esac
11642c3a 108
77ec4307
SB
109# If we postponed including defaults.h, add the #include now.
110if test x"$postpone_defaults_h" = x"yes"; then
111 echo "# include \"defaults.h\"" >> ${output}T
112fi
113
5e7537cf
NN
114# Add multiple inclusion protection guard, part two.
115echo "#endif /* ${header_guard} */" >> ${output}T
116
11642c3a 117# Avoid changing the actual file if possible.
2dbe67bb 118if [ -f $output ] && cmp ${output}T $output >/dev/null 2>&1; then
11642c3a 119 echo $output is unchanged >&2
2dbe67bb 120 rm -f ${output}T
11642c3a 121else
2dbe67bb 122 mv -f ${output}T $output
11642c3a
ZW
123fi
124
125# Touch a stamp file for Make's benefit.
126rm -f cs-$output
127echo timestamp > cs-$output