1 # Makefile for gnattools
2 # Copyright 2003, 2004 Free Software Foundation, Inc.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Default target; must be first.
21 # Standard autoconf-set variables.
28 INSTALL_DATA = @INSTALL_DATA@
29 INSTALL_PROGRAM = @INSTALL_PROGRAM@
31 # Nonstandard autoconf-set variables.
33 target_noncanonical=@target_noncanonical@
35 # Variables for the user (or the top level) to override.
41 PWD_COMMAND = $${PWDCMD-pwd}
43 # The tedious process of getting CFLAGS right.
45 LOOSE_WARN = -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
46 GCC_WARN_CFLAGS = $(LOOSE_WARN) $(NOCOMMON_FLAG)
48 ADA_CFLAGS=@ADA_CFLAGS@
50 # Variables for gnattools.
51 ADAFLAGS= -gnatpg -gnata
52 ADA_INCLUDE_DIR = $(libsubdir)/adainclude
53 ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
55 # For finding the GCC build dir, which is used far too much
57 # Include fragment generated by GCC configure; shared with libada for now.
58 include $(GCC_DIR)/libada-mk
59 # Variables based on those gleaned from the GCC makefile. :-P
60 libsubdir=$(libdir)/gcc/$(target_noncanonical)/$(gcc_version)
62 # Get possible host-specific override for libsubdir (ick).
63 xmake_file=$(subst /config,/../gcc/config,$(gcc_xmake_file))
64 ifneq ($(xmake_file),)
68 # Absolute srcdir for gcc/ada (why do we want absolute? I dunno)
69 fsrcdir := $(shell cd $(srcdir)/../gcc/ada/; ${PWD_COMMAND})
71 # Useful "subroutines" for the excess includes
72 INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir) -I$(fsrcdir)/../config \
73 -I$(fsrcdir)/../../include -I$(fsrcdir)/..
74 ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)
76 # Variables for gnattools1, native
77 TOOLS_FLAGS_TO_PASS_1= \
78 "CC=../../xgcc -B../../" \
79 "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
80 "LDFLAGS=$(LDFLAGS)" \
81 "ADAFLAGS=$(ADAFLAGS)" \
82 "ADA_CFLAGS=$(ADA_CFLAGS)" \
83 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
84 "ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
86 "fsrcdir=$(fsrcdir)" \
88 "GNATBIND=../../gnatbind" \
91 # Variables for regnattools
92 TOOLS_FLAGS_TO_PASS_1re= \
93 "CC=../../xgcc -B../../" \
95 "ADAFLAGS=$(ADAFLAGS)" \
96 "ADA_CFLAGS=$(ADA_CFLAGS)" \
97 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
98 "ADA_INCLUDES=-I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
100 "fsrcdir=$(fsrcdir)" \
101 "srcdir=$(fsrcdir)" \
102 "GNATMAKE=../../gnatmake" \
103 "GNATLINK=../../gnatlink" \
104 "GNATBIND=../../gnatbind" \
108 # Variables for gnattools2, native
109 TOOLS_FLAGS_TO_PASS_NATIVE= \
110 "CC=../../xgcc -B../../" \
112 "ADAFLAGS=$(ADAFLAGS)" \
113 "ADA_CFLAGS=$(ADA_CFLAGS)" \
114 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
115 "ADA_INCLUDES=-I../rts $(ADA_INCLUDES_FOR_SUBDIR)" \
117 "fsrcdir=$(fsrcdir)" \
118 "srcdir=$(fsrcdir)" \
119 "GNATMAKE=../../gnatmake" \
120 "GNATLINK=../../gnatlink" \
121 "GNATBIND=../../gnatbind" \
124 # Variables for gnattools, cross
125 TOOLS_FLAGS_TO_PASS_CROSS= \
127 "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
128 "LDFLAGS=$(LDFLAGS)" \
129 "ADAFLAGS=$(ADAFLAGS)" \
130 "ADA_CFLAGS=$(ADA_CFLAGS)" \
131 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
132 "ADA_INCLUDES=-I$(RTS_DIR)../adainclude -I$(RTS_DIR) $(ADA_INCLUDES_FOR_SUBDIR)" \
134 "fsrcdir=$(fsrcdir)" \
135 "srcdir=$(fsrcdir)" \
136 "GNATMAKE=gnatmake" \
137 "GNATLINK=gnatlink" \
138 "GNATBIND=gnatbind" \
145 # File associations set by configure
146 EXTRA_GNATTOOLS = @EXTRA_GNATTOOLS@
147 TOOLS_TARGET_PAIRS = @TOOLS_TARGET_PAIRS@
152 .PHONY: gnattools gnattools-native gnattools-cross regnattools
153 gnattools: @default_gnattools_target@
156 $(GCC_DIR)/stamp-gnatlib-rts:
157 @if [ ! -f $(GCC_DIR)/stamp-gnatlib-rts ] ; \
159 echo "Cannot build gnattools while gnatlib is out of date or unbuilt" ; \
166 # Build directory for the tools. Let's copy the target-dependent
167 # sources using the same mechanism as for gnatlib. The other sources are
168 # accessed using the vpath directive in ada/Makefile.in
170 $(GCC_DIR)/stamp-tools:
171 -rm -rf $(GCC_DIR)/ada/tools
172 -mkdir -p $(GCC_DIR)/ada/tools
173 -(cd $(GCC_DIR)/ada/tools; $(LN_S) ../sdefault.adb .)
174 -$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
175 rm -f $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));\
176 $(LN_S) $(fsrcdir)/$(word 2,$(subst <, ,$(PAIR))) \
177 $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));)
178 touch $(GCC_DIR)/stamp-tools
180 # gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
181 # reasons: gnatmake should be built with a recent compiler, a recent compiler
182 # may not generate ALI files compatible with an old gnatmake so it is important
183 # to be able to build gnatmake without a version of gnatmake around. Once
184 # everything has been compiled once, gnatmake can be recompiled with itself
185 # (see target regnattools)
186 gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
188 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
189 $(TOOLS_FLAGS_TO_PASS_1) \
190 ../../gnatmake$(exeext) ../../gnatlink$(exeext)
192 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
193 $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
195 # gnatmake/link can be built with recent gnatmake/link if they are available.
196 # This is especially convenient for building cross tools or for rebuilding
197 # the tools when the original bootstrap has already be done.
198 regnattools: $(GCC_DIR)/stamp-gnatlib-rts
200 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
201 $(TOOLS_FLAGS_TO_PASS_1re) \
202 gnatmake-re gnatlink-re
204 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
205 $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
207 # For cross builds of gnattools,
208 # put the host RTS dir first in the PATH to hide the default runtime
209 # files that are among the sources
210 # FIXME: This should be done in configure.
211 RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
212 gnattools-cross: $(GCC_DIR)/stamp-tools
214 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
215 $(TOOLS_FLAGS_TO_PASS_CROSS) INCLUDES="" \
216 gnatmake-re gnatlink-re
218 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
219 $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools
220 # Rename cross tools to where the GCC makefile wants them when
221 # installing. FIXME: installation should be done elsewhere.
222 if [ -f $(GCC_DIR)/gnatbind$(exeext) ] ; then \
223 mv $(GCC_DIR)/gnatbind$(exeext) $(GCC_DIR)/gnatbind-cross$(exeext); \
225 if [ -f $(GCC_DIR)/gnatchop$(exeext) ] ; then \
226 mv $(GCC_DIR)/gnatchop$(exeext) $(GCC_DIR)/gnatchop-cross$(exeext); \
228 if [ -f $(GCC_DIR)/gnat$(exeext) ] ; then \
229 mv $(GCC_DIR)/gnat$(exeext) $(GCC_DIR)/gnat-cross$(exeext); \
231 if [ -f $(GCC_DIR)/gnatkr$(exeext) ] ; then \
232 mv $(GCC_DIR)/gnatkr$(exeext) $(GCC_DIR)/gnatkr-cross$(exeext); \
234 if [ -f $(GCC_DIR)/gnatlink$(exeext) ] ; then \
235 mv $(GCC_DIR)/gnatlink$(exeext) $(GCC_DIR)/gnatlink-cross$(exeext); \
237 if [ -f $(GCC_DIR)/gnatls$(exeext) ] ; then \
238 mv $(GCC_DIR)/gnatls$(exeext) $(GCC_DIR)/gnatls-cross$(exeext); \
240 if [ -f $(GCC_DIR)/gnatmake$(exeext) ] ; then \
241 mv $(GCC_DIR)/gnatmake$(exeext) $(GCC_DIR)/gnatmake-cross$(exeext); \
243 if [ -f $(GCC_DIR)/gnatmem$(exeext) ] ; then \
244 mv $(GCC_DIR)/gnatmem$(exeext) $(GCC_DIR)/gnatmem-cross$(exeext); \
246 if [ -f $(GCC_DIR)/gnatname$(exeext) ] ; then \
247 mv $(GCC_DIR)/gnatname$(exeext) $(GCC_DIR)/gnatname-cross$(exeext); \
249 if [ -f $(GCC_DIR)/gnatprep$(exeext) ] ; then \
250 mv $(GCC_DIR)/gnatprep$(exeext) $(GCC_DIR)/gnatprep-cross$(exeext); \
252 if [ -f $(GCC_DIR)/gnatxref$(exeext) ] ; then \
253 mv $(GCC_DIR)/gnatxref$(exeext) $(GCC_DIR)/gnatxref-cross$(exeext); \
255 if [ -f $(GCC_DIR)/gnatfind$(exeext) ] ; then \
256 mv $(GCC_DIR)/gnatfind$(exeext) $(GCC_DIR)/gnatfind-cross$(exeext); \
258 if [ -f $(GCC_DIR)/gnatclean$(exeext) ] ; then \
259 mv $(GCC_DIR)/gnatclean$(exeext) $(GCC_DIR)/gnatclean-cross$(exeext); \
261 if [ -f $(GCC_DIR)/gnatsym$(exeext) ] ; then \
262 mv $(GCC_DIR)/gnatsym$(exeext) $(GCC_DIR)/gnatsym-cross$(exeext); \
268 # Check uninstalled version.
271 # Check installed version.
274 # Build info (none here).
277 # Build DVI (none here).
280 # Build PDF (none here).
283 # Build HTML (none here).
286 # Build TAGS (none here).
289 # Installation rules.
304 $(RM) Makefile config.status config.log
308 # Rules for rebuilding this Makefile.
309 Makefile: $(srcdir)/Makefile.in config.status
312 $(SHELL) ./config.status
314 config.status: $(srcdir)/configure
315 $(SHELL) ./config.status --recheck
317 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac \
318 $(srcdir)/../config/acx.m4 $(srcdir)/../config/override.m4
319 cd $(srcdir) && autoconf
321 # Don't export variables to the environment, in order to not confuse