1# Makefile for GNU Ada Compiler (GNAT).
2#   Copyright (C) 1994-2018 Free Software Foundation, Inc.
3
4#This file is part of GCC.
5
6#GCC is free software; you can redistribute it and/or modify
7#it under the terms of the GNU General Public License as published by
8#the Free Software Foundation; either version 3, or (at your option)
9#any later version.
10
11#GCC is distributed in the hope that it will be useful,
12#but WITHOUT ANY WARRANTY; without even the implied warranty of
13#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#GNU General Public License for more details.
15
16#You should have received a copy of the GNU General Public License
17#along with GCC; see the file COPYING3.  If not see
18#<http://www.gnu.org/licenses/>.
19
20# The makefile built from this file lives in the language subdirectory.
21# Its purpose is to provide support for:
22#
23# 1) recursion where necessary, and only then (building .o's), and
24# 2) building and debugging cc1 from the language subdirectory, and
25# 3) nothing else.
26#
27# The parent makefile handles all other chores, with help from the
28# language makefile fragment, of course.
29#
30# The targets for external use are:
31# all, TAGS, ???mostlyclean, ???clean.
32
33# This makefile will only work with Gnu make.
34# The rules are written assuming a minimum subset of tools are available:
35#
36# Required:
37#      MAKE:    Only Gnu make will work.
38#      MV:      Must accept (at least) one, maybe wildcard, source argument,
39#               a file or directory destination, and support creation/
40#               modification date preservation.  Gnu mv -f works.
41#      RM:      Must accept an arbitrary number of space separated file
42#               arguments, or one wildcard argument. Gnu rm works.
43#      RMDIR:   Must delete a directory and all its contents. Gnu rm -rf works.
44#      ECHO:    Must support command line redirection. Any Unix-like
45#               shell will typically provide this, otherwise a custom version
46#               is trivial to write.
47#      AR:      Gnu ar works.
48#      MKDIR:   Gnu mkdir works.
49#      CHMOD:   Gnu chmod works.
50#      true:    Does nothing and returns a normal successful return code.
51#      pwd:     Prints the current directory on stdout.
52#      cd:      Change directory.
53#
54# Optional:
55#      BISON:   Gnu bison works.
56#      FLEX:    Gnu flex works.
57#      Other miscellaneous tools for obscure targets.
58
59# Suppress smart makes who think they know how to automake Yacc files
60.y.c:
61
62# Variables that exist for you to override.
63# See below for how to change them for certain systems.
64
65# Various ways of specifying flags for compilations:
66# CFLAGS is for the user to override to, e.g., do a bootstrap with -O2.
67# BOOT_CFLAGS is the value of CFLAGS to pass
68# to the stage2 and stage3 compilations
69CFLAGS = -g
70BOOT_CFLAGS = -O $(CFLAGS)
71# These exists to be overridden by the t-* files, respectively.
72T_CFLAGS =
73
74CC = cc
75BISON = bison
76BISONFLAGS =
77ECHO = echo
78LEX = flex
79LEXFLAGS =
80CHMOD = chmod
81LN = ln
82LN_S = ln -s
83CP = cp -p
84MV = mv -f
85RM = rm -f
86RMDIR = rm -rf
87MKDIR = mkdir -p
88AR = ar
89AR_FLAGS = rc
90LS = ls
91RANLIB = @RANLIB@
92RANLIB_FLAGS = @ranlib_flags@
93AWK = @AWK@
94
95COMPILER = $(CC)
96COMPILER_FLAGS = $(CFLAGS)
97
98SHELL = @SHELL@
99PWD_COMMAND = $${PWDCMD-pwd}
100# How to copy preserving the date
101INSTALL_DATA_DATE = cp -p
102MAKEINFO = makeinfo
103TEXI2DVI = texi2dvi
104TEXI2PDF = texi2pdf
105GNATBIND_FLAGS = -static -x
106ADA_CFLAGS =
107ADAFLAGS = -W -Wall -gnatpg -gnata
108FORCE_DEBUG_ADAFLAGS = -g
109NO_INLINE_ADAFLAGS = -fno-inline
110NO_OMIT_ADAFLAGS = -fno-omit-frame-pointer
111NO_SIBLING_ADAFLAGS = -fno-optimize-sibling-calls
112NO_REORDER_ADAFLAGS = -fno-toplevel-reorder
113GNATLIBFLAGS = -W -Wall -gnatg -nostdinc
114GNATLIBCFLAGS = -g -O2
115# Pretend that _Unwind_GetIPInfo is available for the target by default.  This
116# should be autodetected during the configuration of libada and passed down to
117# here, but we need something for --disable-libada and hope for the best.
118GNATLIBCFLAGS_FOR_C = \
119  -W -Wall $(GNATLIBCFLAGS) -fexceptions -DIN_RTS -DHAVE_GETIPINFO
120PICFLAG_FOR_TARGET = @PICFLAG_FOR_TARGET@
121ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS)
122THREAD_KIND = native
123THREADSLIB =
124GMEM_LIB =
125MISCLIB =
126OUTPUT_OPTION = -o $@
127
128objext = .o
129exeext =
130arext  = .a
131soext  = .so
132shext  =
133hyphen = -
134
135# program_transform_name and objdir are set by configure.ac.
136program_transform_name =
137objdir = .
138
139target_alias=@target_alias@
140target=@target@
141target_cpu=@target_cpu@
142target_vendor=@target_vendor@
143target_os=@target_os@
144host_cpu=@host_cpu@
145host_vendor=@host_vendor@
146host_os=@host_os@
147target_cpu_default = @target_cpu_default@
148xmake_file = @xmake_file@
149tmake_file = @tmake_file@
150#version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c`
151#mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c`
152
153# Directory where sources are, from where we are.
154VPATH = $(srcdir)/ada
155
156# Full path to top source directory
157# In particular this is used to access libgcc headers, so that references to
158# these headers from GNAT runtime objects have path names in debugging info
159# that are consistent with libgcc objects.  Also used for other references to
160# the top source directory for consistency.
161ftop_srcdir := $(shell cd $(srcdir)/..;${PWD_COMMAND})
162
163fsrcdir := $(shell cd $(srcdir);${PWD_COMMAND})
164fsrcpfx := $(shell cd $(srcdir);${PWD_COMMAND})/
165fcurdir := $(shell ${PWD_COMMAND})
166fcurpfx := $(shell ${PWD_COMMAND})/
167
168# Top build directory, relative to here.
169top_builddir = ../..
170
171# Internationalization library.
172LIBINTL = @LIBINTL@
173LIBINTL_DEP = @LIBINTL_DEP@
174
175# Character encoding conversion library.
176LIBICONV = @LIBICONV@
177LIBICONV_DEP = @LIBICONV_DEP@
178
179# Any system libraries needed just for GNAT.
180SYSLIBS = @GNAT_LIBEXC@
181
182# List extra gnattools
183EXTRA_GNATTOOLS =
184
185# List of target dependent sources, overridden below as necessary
186TARGET_ADA_SRCS =
187
188# Type of tools build we are doing; default is not compiling tools.
189TOOLSCASE =
190
191# main GNAT source directory
192GNAT_SRC=$(fsrcpfx)ada
193
194# Multilib handling
195MULTISUBDIR =
196RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
197
198# Link flags used to build gnat tools.  By default we prefer to statically
199# link with libgcc to avoid a dependency on shared libgcc (which is tricky
200# to deal with as it may conflict with the libgcc provided by the system).
201GCC_LINK_FLAGS=-static-libstdc++ -static-libgcc
202
203# End of variables for you to override.
204
205all: all.indirect
206
207# This tells GNU Make version 3 not to put all variables in the environment.
208.NOEXPORT:
209
210# target overrides
211ifneq ($(tmake_file),)
212include $(tmake_file)
213endif
214
215# host overrides
216ifneq ($(xmake_file),)
217include $(xmake_file)
218endif
219
220# Now figure out from those variables how to compile and link.
221
222all.indirect: Makefile ../gnat1$(exeext)
223
224# IN_GCC is meant to distinguish between code compiled into GCC itself, i.e.
225# for the host, and the rest.  But we also use it for the tools (link.c) and
226# even break the host/target wall by using it for the library (targext.c).
227# autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a cross
228# compiler which does not use the native libraries and headers.
229INTERNAL_CFLAGS = @CROSS@ -DIN_GCC
230
231# This is the variable actually used when we compile.
232ALL_CFLAGS = $(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS)
233
234# Likewise.
235ALL_CPPFLAGS = $(CPPFLAGS)
236
237# Used with $(COMPILER).
238ALL_COMPILERFLAGS = $(ALL_CFLAGS)
239
240# This is where we get libiberty.a from.
241LIBIBERTY = ../../libiberty/libiberty.a
242
243# We need to link against libbacktrace because diagnostic.c in
244# libcommon.a uses it.
245LIBBACKTRACE = ../../libbacktrace/.libs/libbacktrace.a
246
247# How to link with both our special library facilities
248# and the system's installed libraries.
249LIBS = $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) $(LIBIBERTY) $(SYSLIBS)
250LIBDEPS = $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBBACKTRACE) $(LIBIBERTY)
251# Default is no TGT_LIB; one might be passed down or something
252TGT_LIB =
253TOOLS_LIBS = ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
254  ../../libcommon.a ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
255  ../$(LIBBACKTRACE) ../$(LIBIBERTY) $(SYSLIBS) $(TGT_LIB)
256
257# Add -no-pie to TOOLS_LIBS since some of them are compiled with -fno-PIE.
258TOOLS_LIBS += @NO_PIE_FLAG@
259
260# Specify the directories to be searched for header files.
261# Both . and srcdir are used, in that order,
262# so that tm.h and config.h will be found in the compilation
263# subdirectory rather than in the source directory.
264INCLUDES = -iquote . -iquote .. -iquote $(srcdir)/ada -iquote $(srcdir) \
265	   -I $(ftop_srcdir)/include $(GMPINC)
266
267ADA_INCLUDES = -I- -I. -I$(srcdir)/ada
268
269# Likewise, but valid for subdirectories of the current dir.
270# FIXME: for VxWorks, we cannot add $(fsrcdir) because the regs.h file in
271# that directory conflicts with a system header file.
272ifneq ($(findstring vxworks,$(target_os)),)
273  INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
274			-iquote $(fsrcdir)/ada \
275			-I$(ftop_srcdir)/include $(GMPINC)
276else
277  INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
278			-iquote $(fsrcdir)/ada -iquote $(fsrcdir) \
279			-I$(ftop_srcdir)/include $(GMPINC)
280endif
281
282ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
283
284# Avoid a lot of time thinking about remaking Makefile.in and *.def.
285.SUFFIXES: .in .def
286
287# Say how to compile Ada programs.
288.SUFFIXES: .ada .adb .ads .asm
289
290# Always use -I$(srcdir)/config when compiling.
291.asm.o:
292	$(CC) -c -x assembler $< $(OUTPUT_OPTION)
293
294.c.o:
295	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) \
296	  $(INCLUDES) $< $(OUTPUT_OPTION)
297
298.adb.o:
299	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
300
301.ads.o:
302	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
303
304# how to regenerate this file
305Makefile: ../config.status $(srcdir)/ada/gcc-interface/Makefile.in $(srcdir)/ada/Makefile.in $(srcdir)/version.c
306	cd ..; \
307	LANGUAGES="$(CONFIG_LANGUAGES)" \
308	CONFIG_HEADERS= \
309	CONFIG_FILES="ada/gcc-interface/Makefile ada/Makefile" $(SHELL) config.status
310
311# This tells GNU make version 3 not to export all the variables
312# defined in this file into the environment.
313.NOEXPORT:
314
315# Lists of files for various purposes.
316
317GNATLINK_OBJS = gnatlink.o \
318 a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
319 gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
320 osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
321 sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o \
322 types.o validsw.o widechar.o
323
324GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \
325 atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o errout.o \
326 erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
327 gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
328 make.o makeusg.o make_util.o namet.o nlists.o opt.o osint.o osint-m.o \
329 output.o restrict.o rident.o s-exctab.o \
330 s-secsta.o s-stalib.o s-stoele.o scans.o scng.o sdefault.o sfn_scan.o \
331 s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \
332 snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \
333 switch.o switch-m.o table.o targparm.o tempdir.o types.o uintp.o \
334 uname.o urealp.o usage.o widechar.o \
335 $(EXTRA_GNATMAKE_OBJS)
336
337# Make arch match the current multilib so that the RTS selection code
338# picks up the right files. For a given target this must be coherent
339# with MULTILIB_DIRNAMES defined in gcc/config/target/t-*.
340
341ifeq ($(strip $(filter-out x86_64, $(target_cpu))),)
342  ifeq ($(strip $(MULTISUBDIR)),/32)
343    target_cpu:=i686
344  else
345    ifeq ($(strip $(MULTISUBDIR)),/x32)
346      target_cpu:=x32
347    endif
348  endif
349endif
350
351# The SuSE PowerPC64/Linux compiler is actually a 32-bit PowerPC compiler
352ifeq ($(strip $(filter-out powerpc64 suse linux%, $(target_cpu) $(target_vendor) $(target_os))),)
353  target_cpu:=powerpc
354endif
355
356# Configuration of host tools
357
358# Under linux, host tools need to be linked with -ldl
359
360ifeq ($(strip $(filter-out linux%,$(host_os))),)
361   TOOLS1_LIBS=-ldl
362endif
363
364include $(fsrcdir)/ada/Makefile.rtl
365
366LIBGNAT=../$(RTSDIR)/libgnat.a
367
368TOOLS_FLAGS_TO_PASS=		\
369	"CC=$(CC)" 		\
370	"CFLAGS=$(CFLAGS)"	\
371	"LDFLAGS=$(LDFLAGS)"	\
372	"ADAFLAGS=$(ADAFLAGS)"	\
373	"INCLUDES=$(INCLUDES_FOR_SUBDIR)"\
374	"ADA_INCLUDES=$(ADA_INCLUDES) $(ADA_INCLUDES_FOR_SUBDIR)"\
375	"libsubdir=$(libsubdir)"	\
376	"exeext=$(exeext)"	\
377	"fsrcdir=$(fsrcdir)"	\
378	"srcdir=$(fsrcdir)"	\
379	"TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)"	\
380	"GNATMAKE=$(GNATMAKE)"	\
381	"GNATLINK=$(GNATLINK)"	\
382	"GNATBIND=$(GNATBIND)"
383
384GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(LDFLAGS)
385
386# Build directory for the tools. Let's copy the target-dependent
387# sources using the same mechanism as for gnatlib. The other sources are
388# accessed using the vpath directive below
389
390../stamp-tools:
391	-$(RM) tools/*
392	-$(RMDIR) tools
393	-$(MKDIR) tools
394	-(cd tools; $(LN_S) ../sdefault.adb ../snames.ads ../snames.adb .)
395	-$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
396	          $(RM) tools/$(word 1,$(subst <, ,$(PAIR)));\
397	          $(LN_S) $(fsrcpfx)ada/$(word 2,$(subst <, ,$(PAIR))) \
398	                tools/$(word 1,$(subst <, ,$(PAIR)));)
399	touch ../stamp-tools
400
401# when compiling the tools, the runtime has to be first on the path so that
402# it hides the runtime files lying with the rest of the sources
403ifeq ($(TOOLSCASE),native)
404  vpath %.ads ../$(RTSDIR) ../
405  vpath %.adb ../$(RTSDIR) ../
406  vpath %.c   ../$(RTSDIR) ../
407  vpath %.h   ../$(RTSDIR) ../
408endif
409
410# in the cross tools case, everything is compiled with the native
411# gnatmake/link. Therefore only -I needs to be modified in ADA_INCLUDES
412ifeq ($(TOOLSCASE),cross)
413  vpath %.ads ../
414  vpath %.adb ../
415  vpath %.c   ../
416  vpath %.h   ../
417endif
418
419# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
420# reasons: gnatmake should be built with a recent compiler, a recent compiler
421# may not generate ALI files compatible with an old gnatmake so it is important
422# to be able to build gnatmake without a version of gnatmake around. Once
423# everything has been compiled once, gnatmake can be recompiled with itself
424# (see target gnattools1-re)
425gnattools1: ../stamp-tools ../stamp-gnatlib-$(RTSDIR)
426	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
427	  TOOLSCASE=native \
428	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
429
430# gnatmake/link can be built with recent gnatmake/link if they are available.
431# This is especially convenient for building cross tools or for rebuilding
432# the tools when the original bootstrap has already be done.
433gnattools1-re: ../stamp-tools
434	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
435	  TOOLSCASE=cross INCLUDES="" gnatmake-re gnatlink-re
436
437# these tools are built with gnatmake & are common to native and cross
438gnattools2: ../stamp-tools
439	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
440	  TOOLSCASE=native common-tools $(EXTRA_GNATTOOLS)
441
442common-tools: ../stamp-tools
443	$(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
444	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
445	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
446	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
447	$(GNATLINK) -v gnatcmd -o ../../gnat$(exeext) \
448	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
449	$(GNATLINK) -v gnatchop -o ../../gnatchop$(exeext) \
450	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
451	$(GNATLINK) -v gnatkr -o ../../gnatkr$(exeext) \
452	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
453	$(GNATLINK) -v gnatls -o ../../gnatls$(exeext) \
454	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
455	$(GNATLINK) -v gnatprep -o ../../gnatprep$(exeext) \
456	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
457	$(GNATLINK) -v gnatxref -o ../../gnatxref$(exeext) \
458	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
459	$(GNATLINK) -v gnatfind -o ../../gnatfind$(exeext) \
460	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
461	$(GNATLINK) -v gnatname -o ../../gnatname$(exeext) \
462	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
463	$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
464	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
465
466../../gnatdll$(exeext): ../stamp-tools
467	$(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
468	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll
469	$(GNATLINK) -v gnatdll -o $@ \
470	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
471
472gnatmake-re: ../stamp-tools
473	$(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
474	$(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
475	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
476	$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
477	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
478
479# Note the use of the "mv" command in order to allow gnatlink to be linked with
480# with the former version of gnatlink itself which cannot override itself.
481# gnatlink-re cannot be run at the same time as gnatmake-re, hence the
482# dependency
483gnatlink-re: ../stamp-tools gnatmake-re
484	$(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
485	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
486	$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
487	  --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
488	$(MV)  ../../gnatlinknew$(exeext)  ../../gnatlink$(exeext)
489
490# Needs to be built with CC=gcc
491# Since the RTL should be built with the latest compiler, remove the
492#  stamp target in the parent directory whenever gnat1 is rebuilt
493
494# Likewise for the tools
495../../gnatmake$(exeext): b_gnatm.o $(GNATMAKE_OBJS)
496	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) $(TOOLS_LIBS) $(TOOLS1_LIBS)
497
498../../gnatlink$(exeext): b_gnatl.o $(GNATLINK_OBJS)
499	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) $(TOOLS_LIBS) $(TOOLS1_LIBS)
500
501../stamp-gnatlib-$(RTSDIR):
502	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \
503	then \
504	  $(ECHO) You must first build the GNAT library: make gnatlib; \
505	  false; \
506	else \
507	  true; \
508	fi
509
510install-gcc-specs:
511#	Install all the requested GCC spec files.
512
513	$(foreach f,$(GCC_SPEC_FILES), \
514	    $(INSTALL_DATA_DATE) $(srcdir)/ada/$(f) $(DESTDIR)$(libsubdir)/;)
515
516install-gnatlib: ../stamp-gnatlib-$(RTSDIR) install-gcc-specs
517	$(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
518	$(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
519	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
520	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
521	for file in $(RTSDIR)/*.ali; do \
522	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
523	done
524	$(INSTALL_DATA_DATE) $(RTSDIR)/ada_target_properties \
525	    $(DESTDIR)$(ADA_RTL_OBJ_DIR)/../
526	-cd $(RTSDIR); for file in *$(arext);do \
527	    $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
528	    $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \
529	done
530	-$(foreach file, $(EXTRA_ADALIB_OBJS), \
531	    $(INSTALL_DATA_DATE) $(RTSDIR)/$(file) $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \
532	) true
533#     Install the shared libraries, if any, using $(INSTALL) instead
534#     of $(INSTALL_DATA). The latter may force a mode inappropriate
535#     for shared libraries on some targets, e.g. on HP-UX where the x
536#     permission is required.
537#     Also install the .dSYM directories if they exist (these directories
538#     contain the debug information for the shared libraries on darwin)
539	for file in gnat gnarl; do \
540	   if [ -f $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) ]; then \
541	      $(INSTALL) $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \
542			 $(DESTDIR)$(ADA_RTL_DSO_DIR); \
543	   fi; \
544	   if [ -f $(RTSDIR)/lib$${file}$(soext) ]; then \
545	      $(LN_S) lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \
546	      $(DESTDIR)$(ADA_RTL_DSO_DIR)/lib$${file}$(soext); \
547	   fi; \
548	   if [ -d $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM ]; then \
549	      $(CP) -r $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM \
550	        $(DESTDIR)$(ADA_RTL_DSO_DIR); \
551	   fi; \
552	done
553# This copy must be done preserving the date on the original file.
554	for file in $(RTSDIR)/*.ad[sb]*; do \
555	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \
556	done
557	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
558	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
559
560../stamp-gnatlib2-$(RTSDIR):
561	$(RM) $(RTSDIR)/s-*.ali
562	$(RM) $(RTSDIR)/s-*$(objext)
563	$(RM) $(RTSDIR)/a-*.ali
564	$(RM) $(RTSDIR)/a-*$(objext)
565	$(RM) $(RTSDIR)/*.ali
566	$(RM) $(RTSDIR)/*$(objext)
567	$(RM) $(RTSDIR)/*$(arext)
568	$(RM) $(RTSDIR)/*$(soext)
569	touch ../stamp-gnatlib2-$(RTSDIR)
570	$(RM) ../stamp-gnatlib-$(RTSDIR)
571
572../stamp-gnatlib1-$(RTSDIR): Makefile ../stamp-gnatlib2-$(RTSDIR)
573	$(MAKE) MULTISUBDIR="$(MULTISUBDIR)" THREAD_KIND="$(THREAD_KIND)" LN_S="$(LN_S)" setup-rts
574# Copy tsystem.h
575	$(CP) $(srcdir)/tsystem.h $(RTSDIR)
576	$(RM) ../stamp-gnatlib-$(RTSDIR)
577	touch ../stamp-gnatlib1-$(RTSDIR)
578
579# GCC_FOR_TARGET has paths relative to the gcc directory, so we need to adjust
580# for running it from ada/rts
581
582OSCONS_CC=$(subst ./xgcc,../../xgcc,$(subst -B./, -B../../,$(GCC_FOR_TARGET)))
583
584# The main ada source directory must be on the include path for #include "..."
585# because s-oscons-tmplt.c requires adaint.h, gsocket.h, and any file included
586# by these headers. However note that we must use -iquote, not -I, so that
587# ada/types.h does not conflict with a same-named system header (VxWorks
588# has a <types.h> header).
589
590OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -E -C \
591  -DTARGET=\"$(target)\" -iquote $(fsrcpfx)ada $(fsrcpfx)ada/s-oscons-tmplt.c > s-oscons-tmplt.i
592OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -S s-oscons-tmplt.i
593
594# Note: if you need to build with a non-GNU compiler, you could adapt the
595# following definitions (written for VMS DEC-C)
596#OSCONS_CPP=../../../$(DECC) -E /comment=as_is -DNATIVE \
597#             -DTARGET='""$(target)""' -I$(OSCONS_SRCDIR) s-oscons-tmplt.c
598#
599#OSCONS_EXTRACT=../../../$(DECC) -DNATIVE \
600#                 -DTARGET='""$(target)""' -I$(OSCONS_SRCDIR) s-oscons-tmplt.c ; \
601#  ld -o s-oscons-tmplt.exe s-oscons-tmplt.obj; \
602#  ./s-oscons-tmplt.exe > s-oscons-tmplt.s
603
604./bldtools/oscons/xoscons: xoscons.adb xutil.ads xutil.adb
605	-$(MKDIR) ./bldtools/oscons
606	$(RM) $(addprefix ./bldtools/oscons/,$(notdir $^))
607	$(CP) $^ ./bldtools/oscons
608	(cd ./bldtools/oscons ; gnatmake -q xoscons)
609
610$(RTSDIR)/s-oscons.ads: ../stamp-gnatlib1-$(RTSDIR) s-oscons-tmplt.c gsocket.h ./bldtools/oscons/xoscons
611	$(RM) $(RTSDIR)/s-oscons-tmplt.i $(RTSDIR)/s-oscons-tmplt.s
612	(cd $(RTSDIR) ; \
613	    $(OSCONS_CPP) ; \
614	    $(OSCONS_EXTRACT) ; \
615	    ../bldtools/oscons/xoscons s-oscons)
616
617gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR) $(RTSDIR)/s-oscons.ads
618	test -f $(RTSDIR)/s-oscons.ads || exit 1
619# C files
620	$(MAKE) -C $(RTSDIR) \
621		CC="`echo \"$(GCC_FOR_TARGET)\" \
622		| sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
623	        INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
624                CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
625	        FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
626		srcdir=$(fsrcdir) \
627	        -f ../Makefile $(LIBGNAT_OBJS) $(EXTRA_ADALIB_OBJS)
628# Ada files
629	$(MAKE) -C $(RTSDIR) \
630		CC="`echo \"$(GCC_FOR_TARGET)\" \
631		| sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
632	        ADA_INCLUDES="" \
633                CFLAGS="$(GNATLIBCFLAGS)" \
634	        ADAFLAGS="$(GNATLIBFLAGS)" \
635	        FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
636		srcdir=$(fsrcdir) \
637	        -f ../Makefile $(GNATRTL_OBJS)
638	$(RM) $(RTSDIR)/libgnat$(arext) $(RTSDIR)/libgnarl$(arext)
639	$(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnat$(arext) \
640	   $(addprefix $(RTSDIR)/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS))
641	$(RANLIB_FOR_TARGET) $(RTSDIR)/libgnat$(arext)
642	$(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnarl$(arext) \
643	   $(addprefix $(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
644	$(RANLIB_FOR_TARGET) $(RTSDIR)/libgnarl$(arext)
645        ifeq ($(GMEM_LIB),gmemlib)
646		$(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgmem$(arext) \
647		  $(RTSDIR)/memtrack.o
648		$(RANLIB_FOR_TARGET) $(RTSDIR)/libgmem$(arext)
649        endif
650	$(CHMOD) a-wx $(RTSDIR)/*.ali
651	touch ../stamp-gnatlib-$(RTSDIR)
652
653# Warning: this target assumes that LIBRARY_VERSION has been set correctly.
654gnatlib-shared-default:
655	$(MAKE) $(FLAGS_TO_PASS) \
656             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
657	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
658	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \
659	     MULTISUBDIR="$(MULTISUBDIR)" \
660	     THREAD_KIND="$(THREAD_KIND)" \
661	     LN_S="$(LN_S)" \
662             gnatlib
663	$(RM) $(RTSDIR)/libgna*$(soext)
664	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
665                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
666		$(PICFLAG_FOR_TARGET) \
667		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
668		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
669		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
670		$(MISCLIB) -lm
671	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
672                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
673		$(PICFLAG_FOR_TARGET) \
674		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
675		$(GNATRTL_TASKING_OBJS) \
676		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
677		$(THREADSLIB)
678	cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
679		libgnat$(soext)
680	cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
681		libgnarl$(soext)
682
683	# Create static libgnat and libgnarl compiled with -fPIC
684	$(RM) $(RTSDIR)/libgnat_pic$(arext) $(RTSDIR)/libgnarl_pic$(arext)
685	$(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnat_pic$(arext) \
686	   $(addprefix $(RTSDIR)/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS))
687	$(RANLIB_FOR_TARGET) $(RTSDIR)/libgnat_pic$(arext)
688	$(AR_FOR_TARGET) $(AR_FLAGS) $(RTSDIR)/libgnarl_pic$(arext) \
689	   $(addprefix $(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
690	$(RANLIB_FOR_TARGET) $(RTSDIR)/libgnarl_pic$(arext)
691
692gnatlib-shared-dual:
693	$(MAKE) $(FLAGS_TO_PASS) \
694             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
695	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
696	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
697	     PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
698	     MULTISUBDIR="$(MULTISUBDIR)" \
699	     THREAD_KIND="$(THREAD_KIND)" \
700	     LN_S="$(LN_S)" \
701             gnatlib-shared-default
702	$(MV) $(RTSDIR)/libgna*$(soext) .
703	$(MV) $(RTSDIR)/libgnat_pic$(arext) .
704	$(MV) $(RTSDIR)/libgnarl_pic$(arext) .
705	$(RM) ../stamp-gnatlib2-$(RTSDIR)
706	$(MAKE) $(FLAGS_TO_PASS) \
707             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
708	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
709	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
710	     MULTISUBDIR="$(MULTISUBDIR)" \
711	     THREAD_KIND="$(THREAD_KIND)" \
712	     LN_S="$(LN_S)" \
713	     gnatlib
714	$(MV) libgna*$(soext) $(RTSDIR)
715	$(MV) libgnat_pic$(arext) $(RTSDIR)
716	$(MV) libgnarl_pic$(arext) $(RTSDIR)
717
718gnatlib-shared-dual-win32:
719	$(MAKE) $(FLAGS_TO_PASS) \
720             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
721	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
722	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
723	     PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
724	     MULTISUBDIR="$(MULTISUBDIR)" \
725	     THREAD_KIND="$(THREAD_KIND)" \
726	     LN_S="$(LN_S)" \
727	     gnatlib-shared-win32
728	$(MV) $(RTSDIR)/libgna*$(soext) .
729	$(RM) ../stamp-gnatlib2-$(RTSDIR)
730	$(MAKE) $(FLAGS_TO_PASS) \
731             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
732	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
733	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
734	     MULTISUBDIR="$(MULTISUBDIR)" \
735	     THREAD_KIND="$(THREAD_KIND)" \
736	     LN_S="$(LN_S)" \
737	     gnatlib
738	$(MV) libgna*$(soext) $(RTSDIR)
739
740# ??? we need to add the option to support auto-import of arrays/records to
741# the GNATLIBFLAGS when this will be supported by GNAT. At this point we will
742# use the gnatlib-shared-dual-win32 target to build the GNAT runtimes on
743# Windows.
744gnatlib-shared-win32:
745	$(MAKE) $(FLAGS_TO_PASS) \
746             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
747	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
748	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \
749	     MULTISUBDIR="$(MULTISUBDIR)" \
750	     THREAD_KIND="$(THREAD_KIND)" \
751	     LN_S="$(LN_S)" \
752	     gnatlib
753	$(RM) $(RTSDIR)/libgna*$(soext)
754	$(CP) $(RTSDIR)/libgnat$(arext) $(RTSDIR)/libgnat_pic$(arext)
755	$(CP) $(RTSDIR)/libgnarl$(arext) $(RTSDIR)/libgnarl_pic$(arext)
756	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
757                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
758		$(PICFLAG_FOR_TARGET) \
759		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
760		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
761		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
762	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
763                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared -shared-libgcc \
764		$(PICFLAG_FOR_TARGET) \
765		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
766		$(GNATRTL_TASKING_OBJS) \
767		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
768		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
769
770gnatlib-shared-darwin:
771	$(MAKE) $(FLAGS_TO_PASS) \
772	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
773	     GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
774	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET) -fno-common" \
775	     MULTISUBDIR="$(MULTISUBDIR)" \
776	     THREAD_KIND="$(THREAD_KIND)" \
777	     LN_S="$(LN_S)" \
778	     gnatlib
779	$(RM) $(RTSDIR)/libgnat$(soext) $(RTSDIR)/libgnarl$(soext)
780	$(CP) $(RTSDIR)/libgnat$(arext) $(RTSDIR)/libgnat_pic$(arext)
781	$(CP) $(RTSDIR)/libgnarl$(arext) $(RTSDIR)/libgnarl_pic$(arext)
782	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
783                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \
784		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
785		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
786		$(SO_OPTS) \
787		-Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
788		$(MISCLIB)
789	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
790                | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \
791		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
792		$(GNATRTL_TASKING_OBJS) \
793		$(SO_OPTS) \
794		-Wl,-install_name,@rpath/libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
795		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
796	cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
797		libgnat$(soext)
798	cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
799		libgnarl$(soext)
800	cd $(RTSDIR); dsymutil libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
801	cd $(RTSDIR); dsymutil libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext)
802
803gnatlib-shared:
804	$(MAKE) $(FLAGS_TO_PASS) \
805             GNATLIBFLAGS="$(GNATLIBFLAGS)" \
806	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
807	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
808	     MULTISUBDIR="$(MULTISUBDIR)" \
809	     THREAD_KIND="$(THREAD_KIND)" \
810	     LN_S="$(LN_S)" \
811	     PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
812	     $(GNATLIB_SHARED)
813
814# When building a SJLJ runtime for VxWorks, we need to ensure that the extra
815# linker options needed for ZCX are not passed to prevent the inclusion of
816# useless objects and potential troubles from the presence of extra symbols
817# and references in some configurations.  The inhibition is performed by
818# commenting the pragma instead of deleting the line, as the latter might
819# result in getting multiple blank lines, hence possible style check errors.
820gnatlib-sjlj:
821	$(MAKE) $(FLAGS_TO_PASS) \
822	     EH_MECHANISM="" \
823	     MULTISUBDIR="$(MULTISUBDIR)" \
824	     THREAD_KIND="$(THREAD_KIND)" \
825	     LN_S="$(LN_S)" \
826	     ../stamp-gnatlib1-$(RTSDIR)
827	sed \
828	  -e 's/Frontend_Exceptions.*/Frontend_Exceptions       : constant Boolean := True;/' \
829	  -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := False;/' \
830	  $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
831	$(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
832	$(MAKE) $(FLAGS_TO_PASS) \
833	     EH_MECHANISM="" \
834	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
835	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
836	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
837	     FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
838	     MULTISUBDIR="$(MULTISUBDIR)" \
839	     THREAD_KIND="$(THREAD_KIND)" \
840	     LN_S="$(LN_S)" \
841	     gnatlib
842
843gnatlib-zcx:
844	$(MAKE) $(FLAGS_TO_PASS) \
845	     EH_MECHANISM="-gcc" \
846	     MULTISUBDIR="$(MULTISUBDIR)" \
847	     THREAD_KIND="$(THREAD_KIND)" \
848	     LN_S="$(LN_S)" \
849	     ../stamp-gnatlib1-$(RTSDIR)
850	sed \
851	  -e 's/Frontend_Exceptions.*/Frontend_Exceptions       : constant Boolean := False;/' \
852	  -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := True;/' \
853	  $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
854	$(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
855	$(MAKE) $(FLAGS_TO_PASS) \
856	     EH_MECHANISM="-gcc" \
857	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
858	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
859	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
860	     FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
861	     MULTISUBDIR="$(MULTISUBDIR)" \
862	     THREAD_KIND="$(THREAD_KIND)" \
863	     LN_S="$(LN_S)" \
864	     gnatlib
865
866# Compiling object files from source files.
867
868# Note that dependencies on obstack.h are not written
869# because that file is not part of GCC.
870# Dependencies on gvarargs.h are not written
871# because all that file does, when not compiling with GCC,
872# is include the system varargs.h.
873
874b_gnatl.adb : $(GNATLINK_OBJS)
875	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatl.adb gnatlink.ali
876
877b_gnatl.o : b_gnatl.adb
878	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) -gnatws -gnatyN \
879	    $< $(OUTPUT_OPTION)
880
881b_gnatm.adb : $(GNATMAKE_OBJS)
882	$(GNATBIND) $(ADA_INCLUDES) -o b_gnatm.adb gnatmake.ali
883
884b_gnatm.o : b_gnatm.adb
885	$(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) -gnatws -gnatyN \
886	    $< $(OUTPUT_OPTION)
887
888# Provide a `toolexeclibdir' definition for when `gnat-install-lib' is
889# wired through gcc/ in a configuration with top-level libada disabled.
890# It will be overridden with the value configured when `gnat-install-lib'
891# is invoked through libada/.
892toolexeclibdir = $(ADA_RTL_OBJ_DIR)
893
894ADA_INCLUDE_DIR = $(libsubdir)/adainclude
895ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
896ADA_RTL_DSO_DIR = $(toolexeclibdir)
897
898# Special flags
899
900# need to keep the frame pointer in tracebak.o to pop the stack properly on
901# some targets.
902
903tracebak.o  : tracebak.c
904	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) \
905	      $(INCLUDES) $(NO_OMIT_ADAFLAGS) $< $(OUTPUT_OPTION)
906
907adadecode.o : adadecode.c adadecode.h
908aux-io.o  : aux-io.c
909argv.o    : argv.c
910cal.o     : cal.c
911deftarg.o : deftarg.c
912errno.o   : errno.c
913exit.o    : adaint.h exit.c
914expect.o  : expect.c
915final.o   : final.c
916rtfinal.o : rtfinal.c
917rtinit.o  : rtinit.c
918locales.o : locales.c
919mkdir.o   : mkdir.c
920socket.o  : socket.c gsocket.h
921sysdep.o  : sysdep.c
922raise.o   : raise.c raise.h
923sigtramp-armdroid.o      : sigtramp-armdroid.c sigtramp.h
924sigtramp-armvxworks.o    : sigtramp-armvxworks.c sigtramp.h
925sigtramp-ios.o           : sigtramp-ios.c sigtramp.h
926sigtramp-vxworks.o       : sigtramp-vxworks.c $(VX_SIGTRAMP_EXTRA_SRCS)
927sigtramp-vxworks-vxsim.o : sigtramp-vxworks-vxsim.c $(VX_SIGTRAMP_EXTRA_SRCS)
928terminals.o : terminals.c
929vx_stack_info.o : vx_stack_info.c
930
931raise-gcc.o : raise-gcc.c raise.h
932	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
933		-iquote $(srcdir) -iquote $(ftop_srcdir)/libgcc \
934		$(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
935
936cio.o     : cio.c
937	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
938	         $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
939
940init.o    : init.c adaint.h raise.h
941	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
942	         $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
943
944init-vxsim.o : init-vxsim.c
945	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
946	         $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
947
948initialize.o : initialize.c raise.h
949	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
950	         $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
951
952link.o : link.c
953	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
954		$(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \
955		$< $(OUTPUT_OPTION)
956
957targext.o : targext.c
958	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) \
959		-iquote $(srcdir) \
960		$(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \
961		$< $(OUTPUT_OPTION)
962
963# In GNU Make, ignore whether `stage*' exists.
964.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap
965.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4
966
967force:
968