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# Absolute srcdir for gcc (why do we want absolute?  I dunno)
61fsrcdir := $(shell cd $(srcdir)/../gcc/; ${PWD_COMMAND})
62
63# Useful "subroutines" for the excess includes
64INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir)/ada -I$(fsrcdir)/config \
65	-I$(fsrcdir)/../include -I$(fsrcdir)
66ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
67
68# Variables for gnattools, native
69TOOLS_FLAGS_TO_PASS_NATIVE= \
70	"CC=../../xgcc -B../../" \
71	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
72	"LDFLAGS=$(LDFLAGS)" \
73	"ADAFLAGS=$(ADAFLAGS)" \
74	"ADA_CFLAGS=$(ADA_CFLAGS)" \
75	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
76	"ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
77	"exeext=$(exeext)" \
78	"fsrcdir=$(fsrcdir)" \
79	"srcdir=$(fsrcdir)" \
80	"GNATMAKE=../../gnatmake" \
81	"GNATLINK=../../gnatlink" \
82	"GNATBIND=../../gnatbind" \
83	"TOOLSCASE=native"
84
85# Variables for regnattools
86TOOLS_FLAGS_TO_PASS_RE= \
87	"CC=../../xgcc -B../../" \
88	"CFLAGS=$(CFLAGS)" \
89	"LDFLAGS=$(LDFLAGS)" \
90	"ADAFLAGS=$(ADAFLAGS)" \
91	"ADA_CFLAGS=$(ADA_CFLAGS)" \
92	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
93	"ADA_INCLUDES=-I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
94	"exeext=$(exeext)" \
95	"fsrcdir=$(fsrcdir)" \
96	"srcdir=$(fsrcdir)" \
97	"GNATMAKE=../../gnatmake" \
98	"GNATLINK=../../gnatlink" \
99	"GNATBIND=../../gnatbind" \
100	"TOOLSCASE=cross"
101
102# Variables for gnattools, cross
103ifeq ($(build), $(host))
104  GNATMAKE_FOR_HOST=gnatmake
105  GNATLINK_FOR_HOST=gnatlink
106  GNATBIND_FOR_HOST=gnatbind
107  GNATLS_FOR_HOST=gnatls
108else
109  GNATMAKE_FOR_HOST=$(host_alias)-gnatmake
110  GNATLINK_FOR_HOST=$(host_alias)-gnatlink
111  GNATBIND_FOR_HOST=$(host_alias)-gnatbind
112  GNATLS_FOR_HOST=$(host_alias)-gnatls
113endif
114
115# Put the host RTS dir first in the PATH to hide the default runtime
116# files that are among the sources
117RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
118
119TOOLS_FLAGS_TO_PASS_CROSS= \
120	"CC=$(CC)" \
121	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
122	"LDFLAGS=$(LDFLAGS)" \
123	"ADAFLAGS=$(ADAFLAGS)"	\
124	"ADA_CFLAGS=$(ADA_CFLAGS)" \
125	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
126	"ADA_INCLUDES=-I$(RTS_DIR)../adainclude -I$(RTS_DIR) $(ADA_INCLUDES_FOR_SUBDIR)" \
127	"exeext=$(exeext)" \
128	"fsrcdir=$(fsrcdir)" \
129	"srcdir=$(fsrcdir)" \
130	"GNATMAKE=$(GNATMAKE_FOR_HOST)" \
131	"GNATLINK=$(GNATLINK_FOR_HOST)" \
132	"GNATBIND=$(GNATBIND_FOR_HOST)" \
133	"TOOLSCASE=cross" \
134	"LIBGNAT="
135
136# File lists
137# ----------
138
139# File associations set by configure
140EXTRA_GNATTOOLS = @EXTRA_GNATTOOLS@
141TOOLS_TARGET_PAIRS = @TOOLS_TARGET_PAIRS@
142
143# Makefile targets
144# ----------------
145
146.PHONY: gnattools gnattools-native gnattools-cross regnattools
147gnattools: @default_gnattools_target@
148
149# Sanity check
150$(GCC_DIR)/stamp-gnatlib-rts:
151	@if [ ! -f $(GCC_DIR)/stamp-gnatlib-rts ] ; \
152        then \
153          echo "Cannot build gnattools while gnatlib is out of date or unbuilt" ; \
154          false; \
155        else \
156          true; \
157        fi
158
159
160# Build directory for the tools. Let's copy the target-dependent
161# sources using the same mechanism as for gnatlib. The other sources are
162# accessed using the vpath directive in ada/Makefile.in
163
164$(GCC_DIR)/stamp-tools:
165	-rm -rf $(GCC_DIR)/ada/tools
166	-mkdir -p $(GCC_DIR)/ada/tools
167	-(cd $(GCC_DIR)/ada/tools; $(LN_S) ../sdefault.adb ../snames.ads ../snames.adb .)
168	-$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
169	          rm -f $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));\
170	          $(LN_S) $(fsrcdir)/ada/$(word 2,$(subst <, ,$(PAIR))) \
171	                $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));)
172	touch $(GCC_DIR)/stamp-tools
173
174# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
175# reasons: gnatmake should be built with a recent compiler, a recent compiler
176# may not generate ALI files compatible with an old gnatmake so it is important
177# to be able to build gnatmake without a version of gnatmake around. Once
178# everything has been compiled once, gnatmake can be recompiled with itself
179# (see target regnattools)
180gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
181	# gnattools1
182	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
183	  $(TOOLS_FLAGS_TO_PASS_NATIVE) \
184	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
185	# gnattools2
186	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
187	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
188
189# gnatmake/link can be built with recent gnatmake/link if they are available.
190# This is especially convenient for building cross tools or for rebuilding
191# the tools when the original bootstrap has already be done.
192regnattools: $(GCC_DIR)/stamp-gnatlib-rts
193	# gnattools1-re
194	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
195	  $(TOOLS_FLAGS_TO_PASS_RE) INCLUDES="" \
196	  gnatmake-re gnatlink-re
197	# gnattools2
198	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
199	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
200
201gnattools-cross: $(GCC_DIR)/stamp-tools
202	# gnattools1-re
203	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
204	  $(TOOLS_FLAGS_TO_PASS_CROSS) INCLUDES="" \
205	  gnatmake-re gnatlink-re
206	# gnattools2
207	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
208	  $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools
209	# Rename cross tools to where the GCC makefile wants them when
210	# installing.  FIXME: installation should be done elsewhere.
211	if [ -f $(GCC_DIR)/gnatbind$(exeext) ] ; then \
212	  mv $(GCC_DIR)/gnatbind$(exeext) $(GCC_DIR)/gnatbind-cross$(exeext); \
213	fi
214	if [ -f $(GCC_DIR)/gnatchop$(exeext) ] ; then \
215	  mv $(GCC_DIR)/gnatchop$(exeext) $(GCC_DIR)/gnatchop-cross$(exeext); \
216	fi
217	if [ -f $(GCC_DIR)/gnat$(exeext) ] ; then \
218	  mv $(GCC_DIR)/gnat$(exeext) $(GCC_DIR)/gnat-cross$(exeext); \
219	fi
220	if [ -f $(GCC_DIR)/gnatkr$(exeext) ] ; then \
221	  mv $(GCC_DIR)/gnatkr$(exeext) $(GCC_DIR)/gnatkr-cross$(exeext); \
222	fi
223	if [ -f $(GCC_DIR)/gnatlink$(exeext) ] ; then \
224	  mv $(GCC_DIR)/gnatlink$(exeext) $(GCC_DIR)/gnatlink-cross$(exeext); \
225	fi
226	if [ -f $(GCC_DIR)/gnatls$(exeext) ] ; then \
227	  mv $(GCC_DIR)/gnatls$(exeext) $(GCC_DIR)/gnatls-cross$(exeext); \
228	fi
229	if [ -f $(GCC_DIR)/gnatmake$(exeext) ] ; then \
230	  mv $(GCC_DIR)/gnatmake$(exeext) $(GCC_DIR)/gnatmake-cross$(exeext); \
231	fi
232	if [ -f $(GCC_DIR)/gnatmem$(exeext) ] ; then \
233	  mv $(GCC_DIR)/gnatmem$(exeext) $(GCC_DIR)/gnatmem-cross$(exeext); \
234	fi
235	if [ -f $(GCC_DIR)/gnatname$(exeext) ] ; then \
236	  mv $(GCC_DIR)/gnatname$(exeext) $(GCC_DIR)/gnatname-cross$(exeext); \
237	fi
238	if [ -f $(GCC_DIR)/gnatprep$(exeext) ] ; then \
239	  mv $(GCC_DIR)/gnatprep$(exeext) $(GCC_DIR)/gnatprep-cross$(exeext); \
240	fi
241	if [ -f $(GCC_DIR)/gnatxref$(exeext) ] ; then \
242	  mv $(GCC_DIR)/gnatxref$(exeext) $(GCC_DIR)/gnatxref-cross$(exeext); \
243	fi
244	if [ -f $(GCC_DIR)/gnatfind$(exeext) ] ; then \
245	  mv $(GCC_DIR)/gnatfind$(exeext) $(GCC_DIR)/gnatfind-cross$(exeext); \
246	fi
247	if [ -f $(GCC_DIR)/gnatclean$(exeext) ] ; then \
248	  mv $(GCC_DIR)/gnatclean$(exeext) $(GCC_DIR)/gnatclean-cross$(exeext); \
249	fi
250	if [ -f $(GCC_DIR)/gnatsym$(exeext) ] ; then \
251	  mv $(GCC_DIR)/gnatsym$(exeext) $(GCC_DIR)/gnatsym-cross$(exeext); \
252	fi
253
254# Other
255# -----
256
257# Check uninstalled version.
258check:
259
260# Check installed version.
261installcheck:
262
263# Build info (none here).
264info:
265
266# Build DVI (none here).
267dvi:
268
269# Build PDF (none here).
270pdf:
271
272# Build HTML (none here).
273html:
274
275.PHONY: check installcheck info dvi pdf html
276
277# Build TAGS (none here).
278TAGS:
279
280# Installation rules.
281install:
282
283install-strip: install
284
285install-info:
286
287install-pdf:
288
289install-html:
290
291.PHONY: install install-strip install-info install-pdf install-html
292
293# Cleaning rules.
294mostlyclean:
295
296clean:
297
298distclean:
299	$(RM) Makefile config.status config.log
300
301maintainer-clean:
302
303.PHONY: mostlyclean clean distclean maintainer-clean
304
305# Rules for rebuilding this Makefile.
306Makefile: $(srcdir)/Makefile.in config.status
307	CONFIG_FILES=$@ ; \
308	CONFIG_HEADERS= ; \
309	$(SHELL) ./config.status
310
311config.status: $(srcdir)/configure
312	$(SHELL) ./config.status --recheck
313
314AUTOCONF = autoconf
315configure_deps = \
316	$(srcdir)/configure.ac \
317	$(srcdir)/../config/acx.m4 \
318	$(srcdir)/../config/override.m4
319
320$(srcdir)/configure: @MAINT@ $(configure_deps)
321	cd $(srcdir) && $(AUTOCONF)
322
323# Don't export variables to the environment, in order to not confuse
324# configure.
325.NOEXPORT:
326
327