1# Makefile for gnattools
2#   Copyright 2003, 2004, 2009, 2010 Free Software Foundation, Inc.
3#
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 3 of the License, or
7# (at your option) any later version.
8#
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.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING3.  If not see
16# <http://www.gnu.org/licenses/>.
17
18# Default target; must be first.
19all: gnattools
20
21# Standard autoconf-set variables.
22SHELL = @SHELL@
23srcdir = @srcdir@
24libdir = @libdir@
25build = @build@
26target = @target@
27host = @host@
28host_alias = @host_alias@
29prefix = @prefix@
30INSTALL = @INSTALL@
31INSTALL_DATA = @INSTALL_DATA@
32INSTALL_PROGRAM = @INSTALL_PROGRAM@
33
34# Nonstandard autoconf-set variables.
35LN_S=@LN_S@
36target_noncanonical=@target_noncanonical@
37
38# Variables for the user (or the top level) to override.
39exeext = @EXEEXT@
40objext=.o
41TRACE=no
42ADA_FOR_BUILD=
43ADA_FOR_TARGET=
44LDFLAGS=
45PWD_COMMAND = $${PWDCMD-pwd}
46
47# The tedious process of getting CFLAGS right.
48CFLAGS=-g
49GCC_WARN_CFLAGS = -W -Wall
50WARN_CFLAGS = @warn_cflags@
51
52ADA_CFLAGS=@ADA_CFLAGS@
53
54# Variables for gnattools.
55ADAFLAGS= -gnatpg -gnata
56
57# For finding the GCC build dir, which is used far too much
58GCC_DIR=../gcc
59
60# Full path to top source directory
61ftop_srcdir := $(shell cd $(srcdir)/..;${PWD_COMMAND})
62
63# Absolute srcdir for gcc (why do we want absolute?  I dunno)
64fsrcdir := $(shell cd $(srcdir)/../gcc/; ${PWD_COMMAND})
65
66# Useful "subroutines" for the excess includes
67INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
68		      -iquote $(fsrcdir)/ada -iquote $(fsrcdir)/config \
69		      -iquote $(fsrcdir) -I$(ftop_srcdir)/include
70ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
71
72CXX_LFLAGS = \
73 -B../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
74 -B../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
75 -L../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
76 -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs
77
78# Variables for gnattools, native
79TOOLS_FLAGS_TO_PASS_NATIVE= \
80	"CC=../../xgcc -B../../" \
81	"CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
82	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
83	"LDFLAGS=$(LDFLAGS)" \
84	"ADAFLAGS=$(ADAFLAGS)" \
85	"ADA_CFLAGS=$(ADA_CFLAGS)" \
86	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
87	"ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
88	"exeext=$(exeext)" \
89	"fsrcdir=$(fsrcdir)" \
90	"srcdir=$(fsrcdir)" \
91	"GNATMAKE=../../gnatmake" \
92	"GNATLINK=../../gnatlink" \
93	"GNATBIND=../../gnatbind" \
94	"TOOLSCASE=native"
95
96# Variables for regnattools
97TOOLS_FLAGS_TO_PASS_RE= \
98	"CC=../../xgcc -B../../" \
99	"CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
100	"CFLAGS=$(CFLAGS)" \
101	"LDFLAGS=$(LDFLAGS)" \
102	"ADAFLAGS=$(ADAFLAGS)" \
103	"ADA_CFLAGS=$(ADA_CFLAGS)" \
104	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
105	"ADA_INCLUDES=-I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
106	"exeext=$(exeext)" \
107	"fsrcdir=$(fsrcdir)" \
108	"srcdir=$(fsrcdir)" \
109	"GNATMAKE=../../gnatmake" \
110	"GNATLINK=../../gnatlink" \
111	"GNATBIND=../../gnatbind" \
112	"TOOLSCASE=cross"
113
114# Variables for gnattools, cross
115ifeq ($(build), $(host))
116  GNATMAKE_FOR_HOST=gnatmake
117  GNATLINK_FOR_HOST=gnatlink
118  GNATBIND_FOR_HOST=gnatbind
119  GNATLS_FOR_HOST=gnatls
120else
121  GNATMAKE_FOR_HOST=$(host_alias)-gnatmake
122  GNATLINK_FOR_HOST=$(host_alias)-gnatlink
123  GNATBIND_FOR_HOST=$(host_alias)-gnatbind
124  GNATLS_FOR_HOST=$(host_alias)-gnatls
125endif
126
127# Put the host RTS dir first in the PATH to hide the default runtime
128# files that are among the sources
129RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
130
131TOOLS_FLAGS_TO_PASS_CROSS= \
132	"CC=$(CC)" \
133	"CXX=$(CXX)" \
134	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
135	"LDFLAGS=$(LDFLAGS)" \
136	"ADAFLAGS=$(ADAFLAGS)"	\
137	"ADA_CFLAGS=$(ADA_CFLAGS)" \
138	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
139	"ADA_INCLUDES=-I$(RTS_DIR)/../adainclude -I$(RTS_DIR) $(ADA_INCLUDES_FOR_SUBDIR)" \
140	"exeext=$(exeext)" \
141	"fsrcdir=$(fsrcdir)" \
142	"srcdir=$(fsrcdir)" \
143	"GNATMAKE=$(GNATMAKE_FOR_HOST)" \
144	"GNATLINK=$(GNATLINK_FOR_HOST)" \
145	"GNATBIND=$(GNATBIND_FOR_HOST)" \
146	"TOOLSCASE=cross" \
147	"LIBGNAT="
148
149# File lists
150# ----------
151
152# File associations set by configure
153EXTRA_GNATTOOLS = @EXTRA_GNATTOOLS@
154TOOLS_TARGET_PAIRS = @TOOLS_TARGET_PAIRS@
155
156# Makefile targets
157# ----------------
158
159.PHONY: gnattools gnattools-native gnattools-cross regnattools
160gnattools: @default_gnattools_target@
161
162# Sanity check
163$(GCC_DIR)/stamp-gnatlib-rts:
164	@if [ ! -f $(GCC_DIR)/stamp-gnatlib-rts ] ; \
165        then \
166          echo "Cannot build gnattools while gnatlib is out of date or unbuilt" ; \
167          false; \
168        else \
169          true; \
170        fi
171
172
173# Build directory for the tools. Let's copy the target-dependent
174# sources using the same mechanism as for gnatlib. The other sources are
175# accessed using the vpath directive in ada/Makefile.in
176
177$(GCC_DIR)/stamp-tools:
178	-rm -rf $(GCC_DIR)/ada/tools
179	-mkdir -p $(GCC_DIR)/ada/tools
180	-(cd $(GCC_DIR)/ada/tools; $(LN_S) ../sdefault.adb ../snames.ads ../snames.adb .)
181	-$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
182	          rm -f $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));\
183	          $(LN_S) $(fsrcdir)/ada/$(word 2,$(subst <, ,$(PAIR))) \
184	                $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));)
185	touch $(GCC_DIR)/stamp-tools
186
187# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
188# reasons: gnatmake should be built with a recent compiler, a recent compiler
189# may not generate ALI files compatible with an old gnatmake so it is important
190# to be able to build gnatmake without a version of gnatmake around. Once
191# everything has been compiled once, gnatmake can be recompiled with itself
192# (see target regnattools)
193gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
194	# gnattools1
195	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
196	  $(TOOLS_FLAGS_TO_PASS_NATIVE) \
197	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
198	# gnattools2
199	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
200	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
201
202# gnatmake/link can be built with recent gnatmake/link if they are available.
203# This is especially convenient for building cross tools or for rebuilding
204# the tools when the original bootstrap has already be done.
205regnattools: $(GCC_DIR)/stamp-gnatlib-rts
206	# gnattools1-re
207	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
208	  $(TOOLS_FLAGS_TO_PASS_RE) INCLUDES="" \
209	  gnatmake-re gnatlink-re
210	# gnattools2
211	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
212	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
213
214gnattools-cross: $(GCC_DIR)/stamp-tools
215	# gnattools1-re
216	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
217	  $(TOOLS_FLAGS_TO_PASS_CROSS) INCLUDES="" \
218	  gnatmake-re gnatlink-re
219	# gnattools2
220	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
221	  $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools
222	# Rename cross tools to where the GCC makefile wants them when
223	# installing.  FIXME: installation should be done elsewhere.
224	if [ -f $(GCC_DIR)/gnatbind$(exeext) ] ; then \
225	  mv $(GCC_DIR)/gnatbind$(exeext) $(GCC_DIR)/gnatbind-cross$(exeext); \
226	fi
227	if [ -f $(GCC_DIR)/gnatchop$(exeext) ] ; then \
228	  mv $(GCC_DIR)/gnatchop$(exeext) $(GCC_DIR)/gnatchop-cross$(exeext); \
229	fi
230	if [ -f $(GCC_DIR)/gnat$(exeext) ] ; then \
231	  mv $(GCC_DIR)/gnat$(exeext) $(GCC_DIR)/gnat-cross$(exeext); \
232	fi
233	if [ -f $(GCC_DIR)/gnatkr$(exeext) ] ; then \
234	  mv $(GCC_DIR)/gnatkr$(exeext) $(GCC_DIR)/gnatkr-cross$(exeext); \
235	fi
236	if [ -f $(GCC_DIR)/gnatlink$(exeext) ] ; then \
237	  mv $(GCC_DIR)/gnatlink$(exeext) $(GCC_DIR)/gnatlink-cross$(exeext); \
238	fi
239	if [ -f $(GCC_DIR)/gnatls$(exeext) ] ; then \
240	  mv $(GCC_DIR)/gnatls$(exeext) $(GCC_DIR)/gnatls-cross$(exeext); \
241	fi
242	if [ -f $(GCC_DIR)/gnatmake$(exeext) ] ; then \
243	  mv $(GCC_DIR)/gnatmake$(exeext) $(GCC_DIR)/gnatmake-cross$(exeext); \
244	fi
245	if [ -f $(GCC_DIR)/gnatmem$(exeext) ] ; then \
246	  mv $(GCC_DIR)/gnatmem$(exeext) $(GCC_DIR)/gnatmem-cross$(exeext); \
247	fi
248	if [ -f $(GCC_DIR)/gnatname$(exeext) ] ; then \
249	  mv $(GCC_DIR)/gnatname$(exeext) $(GCC_DIR)/gnatname-cross$(exeext); \
250	fi
251	if [ -f $(GCC_DIR)/gnatprep$(exeext) ] ; then \
252	  mv $(GCC_DIR)/gnatprep$(exeext) $(GCC_DIR)/gnatprep-cross$(exeext); \
253	fi
254	if [ -f $(GCC_DIR)/gnatxref$(exeext) ] ; then \
255	  mv $(GCC_DIR)/gnatxref$(exeext) $(GCC_DIR)/gnatxref-cross$(exeext); \
256	fi
257	if [ -f $(GCC_DIR)/gnatfind$(exeext) ] ; then \
258	  mv $(GCC_DIR)/gnatfind$(exeext) $(GCC_DIR)/gnatfind-cross$(exeext); \
259	fi
260	if [ -f $(GCC_DIR)/gnatclean$(exeext) ] ; then \
261	  mv $(GCC_DIR)/gnatclean$(exeext) $(GCC_DIR)/gnatclean-cross$(exeext); \
262	fi
263	if [ -f $(GCC_DIR)/gnatsym$(exeext) ] ; then \
264	  mv $(GCC_DIR)/gnatsym$(exeext) $(GCC_DIR)/gnatsym-cross$(exeext); \
265	fi
266
267# Other
268# -----
269
270# Check uninstalled version.
271check:
272
273# Check installed version.
274installcheck:
275
276# Build info (none here).
277info:
278
279# Build DVI (none here).
280dvi:
281
282# Build PDF (none here).
283pdf:
284
285# Build HTML (none here).
286html:
287
288.PHONY: check installcheck info dvi pdf html
289
290# Build TAGS (none here).
291TAGS:
292
293# Installation rules.
294install:
295
296install-strip: install
297
298install-info:
299
300install-pdf:
301
302install-html:
303
304.PHONY: install install-strip install-info install-pdf install-html
305
306# Cleaning rules.
307mostlyclean:
308
309clean:
310
311distclean:
312	$(RM) Makefile config.status config.log config.cache
313
314maintainer-clean:
315
316.PHONY: mostlyclean clean distclean maintainer-clean
317
318# Rules for rebuilding this Makefile.
319Makefile: $(srcdir)/Makefile.in config.status
320	CONFIG_FILES=$@ ; \
321	CONFIG_HEADERS= ; \
322	$(SHELL) ./config.status
323
324config.status: $(srcdir)/configure
325	$(SHELL) ./config.status --recheck
326
327AUTOCONF = autoconf
328configure_deps = \
329	$(srcdir)/configure.ac \
330	$(srcdir)/../config/acx.m4 \
331	$(srcdir)/../config/override.m4
332
333$(srcdir)/configure: @MAINT@ $(configure_deps)
334	cd $(srcdir) && $(AUTOCONF)
335
336# Don't export variables to the environment, in order to not confuse
337# configure.
338.NOEXPORT:
339
340