# Makefile for GNU Ada Compiler (GNAT). # Copyright (C) 1994-2005 Free Software Foundation, Inc. #This file is part of GCC. #GCC is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2, or (at your option) #any later version. #GCC is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. #You should have received a copy of the GNU General Public License #along with GCC; see the file COPYING. If not, write to #the Free Software Foundation, 51 Franklin Street, Fifth Floor, #Boston, MA 02110-1301, USA. # The makefile built from this file lives in the language subdirectory. # Its purpose is to provide support for: # # 1) recursion where necessary, and only then (building .o's), and # 2) building and debugging cc1 from the language subdirectory, and # 3) nothing else. # # The parent makefile handles all other chores, with help from the # language makefile fragment, of course. # # The targets for external use are: # all, TAGS, ???mostlyclean, ???clean. # This makefile will only work with Gnu make. # The rules are written assuming a minimum subset of tools are available: # # Required: # MAKE: Only Gnu make will work. # MV: Must accept (at least) one, maybe wildcard, source argument, # a file or directory destination, and support creation/ # modification date preservation. Gnu mv -f works. # RM: Must accept an arbitrary number of space separated file # arguments, or one wildcard argument. Gnu rm works. # RMDIR: Must delete a directory and all its contents. Gnu rm -rf works. # ECHO: Must support command line redirection. Any Unix-like # shell will typically provide this, otherwise a custom version # is trivial to write. # AR: Gnu ar works. # MKDIR: Gnu mkdir works. # CHMOD: Gnu chmod works. # true: Does nothing and returns a normal successful return code. # pwd: Prints the current directory on stdout. # cd: Change directory. # # Optional: # BISON: Gnu bison works. # FLEX: Gnu flex works. # Other miscellaneous tools for obscure targets. # Tell GNU make 3.79 not to run this directory in parallel. # Not all of the required dependencies are present. .NOTPARALLEL: # Suppress smart makes who think they know how to automake Yacc files .y.c: # Variables that exist for you to override. # See below for how to change them for certain systems. # Various ways of specifying flags for compilations: # CFLAGS is for the user to override to, e.g., do a bootstrap with -O2. # BOOT_CFLAGS is the value of CFLAGS to pass # to the stage2 and stage3 compilations # XCFLAGS is used for most compilations but not when using the GCC just built. XCFLAGS = CFLAGS = -g BOOT_CFLAGS = -O $(CFLAGS) # These exists to be overridden by the x-* and t-* files, respectively. X_CFLAGS = T_CFLAGS = X_CPPFLAGS = T_CPPFLAGS = X_ADA_CFLAGS = T_ADA_CFLAGS = X_ADAFLAGS = T_ADAFLAGS = CC = cc BISON = bison BISONFLAGS = ECHO = echo LEX = flex LEXFLAGS = CHMOD = chmod LN = ln LN_S = ln -s CP = cp -p MV = mv -f RM = rm -f RMDIR = rm -rf MKDIR = mkdir -p AR = ar AR_FLAGS = rc LS = ls RANLIB = @RANLIB@ RANLIB_FLAGS = @ranlib_flags@ SHELL = @SHELL@ PWD_COMMAND = $${PWDCMD-pwd} # How to copy preserving the date INSTALL_DATA_DATE = cp -p MAKEINFO = makeinfo TEXI2DVI = texi2dvi TEXI2PDF = texi2pdf GNATBIND = $(STAGE_PREFIX)gnatbind GNATBIND_FLAGS = -static -x ADA_CFLAGS = ADAFLAGS = -W -Wall -gnatpg -gnata SOME_ADAFLAGS =-gnata FORCE_DEBUG_ADAFLAGS = -g GNATLIBFLAGS = -gnatpg -nostdinc GNATLIBCFLAGS = -g -O2 # LLVM local begin GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \ -DIN_RTS -DIN_TARGET_LIBS # LLVM local end ALL_ADA_CFLAGS = $(X_ADA_CFLAGS) $(T_ADA_CFLAGS) $(ADA_CFLAGS) ALL_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ $(ADAFLAGS) MOST_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ $(SOME_ADAFLAGS) THREAD_KIND = native THREADSLIB = GMEM_LIB = MISCLIB = SYMDEPS = $(LIBINTL_DEP) OUTPUT_OPTION = @OUTPUT_OPTION@ objext = .o exeext = arext = .a soext = .so shext = hyphen = - # Define this as & to perform parallel make on a Sequent. # Note that this has some bugs, and it seems currently necessary # to compile all the gen* files first by hand to avoid erroneous results. P = # This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET. # It omits XCFLAGS, and specifies -B./. # It also specifies -B$(tooldir)/ to find as and ld for a cross compiler. GCC_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) # Tools to use when building a cross-compiler. # These are used because `configure' appends `cross-make' # to the makefile when making a cross-compiler. # We don't use cross-make. Instead we use the tools from the build tree, # if they are available. # program_transform_name and objdir are set by configure.in. program_transform_name = objdir = . target_alias=@target_alias@ target=@target@ xmake_file = @xmake_file@ tmake_file = @tmake_file@ host_canonical=@host@ #version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c` #mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c` # Directory where sources are, from where we are. srcdir = @srcdir@ VPATH = $(srcdir) fsrcdir := $(shell cd $(srcdir);${PWD_COMMAND}) fsrcpfx := $(shell cd $(srcdir);${PWD_COMMAND})/ fcurdir := $(shell ${PWD_COMMAND}) fcurpfx := $(shell ${PWD_COMMAND})/ # Top build directory, relative to here. top_builddir = ../.. # Internationalization library. LIBINTL = @LIBINTL@ LIBINTL_DEP = @LIBINTL_DEP@ # Any system libraries needed just for GNAT. SYSLIBS = @GNAT_LIBEXC@ # List of extra object files linked in with various programs. EXTRA_GNATTOOLS_OBJS = ../../prefix.o ../../version.o # List of target dependent sources, overridden below as necessary TARGET_ADA_SRCS = # Type of tools build we are doing; default is not compiling tools. TOOLSCASE = # End of variables for you to override. all: all.indirect # This tells GNU Make version 3 not to put all variables in the environment. .NOEXPORT: # tmake_file and xmake_file expand to lists with entries of the form # $(srcdir)/config/... but here $(srcdir) is the ada subdirectory so we # need to adjust the paths. There can't be spaces in the subst arguments # or we get spurious spaces in the actual list of files to include. # target overrides ifneq ($(tmake_file),) include $(subst /config,/../config,$(tmake_file)) endif # host overrides ifneq ($(xmake_file),) include $(subst /config,/../config,$(xmake_file)) endif # Now figure out from those variables how to compile and link. all.indirect: Makefile ../gnat1$(exeext) # IN_GCC distinguishes between code compiled into GCC itself and other # programs built during a bootstrap. # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a cross # compiler which does not use the native libraries and headers. INTERNAL_CFLAGS = @CROSS@ -DIN_GCC # This is the variable actually used when we compile. LOOSE_CFLAGS = `echo $(CFLAGS) $(WARN2_CFLAGS)|sed -e 's/-pedantic//g' -e 's/-Wtraditional//g'` ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_CFLAGS) \ $(XCFLAGS) # Likewise. ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS) # This is where we get libiberty.a from. LIBIBERTY = ../../libiberty/libiberty.a # How to link with both our special library facilities # and the system's installed libraries. LIBS = $(LIBINTL) $(LIBIBERTY) $(SYSLIBS) LIBDEPS = $(LIBINTL_DEP) $(LIBIBERTY) # Default is no TGT_LIB; one might be passed down or something TGT_LIB = TOOLS_LIBS = $(EXTRA_GNATTOOLS_OBJS) targext.o link.o $(LIBGNAT) ../../../libiberty/libiberty.a $(SYSLIBS) $(TGT_LIB) # Specify the directories to be searched for header files. # Both . and srcdir are used, in that order, # so that tm.h and config.h will be found in the compilation # subdirectory rather than in the source directory. INCLUDES = -I- -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config \ -I$(srcdir)/../../include ADA_INCLUDES = -I- -I. -I$(srcdir) INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir) -I$(fsrcdir)/../config \ -I$(fsrcdir)/../../include -I$(fsrcdir)/.. ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir) # Avoid a lot of time thinking about remaking Makefile.in and *.def. .SUFFIXES: .in .def # Say how to compile Ada programs. .SUFFIXES: .ada .adb .ads .asm # Always use -I$(srcdir)/config when compiling. .asm.o: $(CC) -c -x assembler $< $(OUTPUT_OPTION) .c.o: $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< \ $(OUTPUT_OPTION) .adb.o: $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION) .ads.o: $(CC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION) # how to regenerate this file Makefile: ../config.status $(srcdir)/Makefile.in $(srcdir)/../version.c cd ..; \ LANGUAGES="$(CONFIG_LANGUAGES)" \ CONFIG_HEADERS= \ CONFIG_FILES=ada/Makefile $(SHELL) config.status # This tells GNU make version 3 not to export all the variables # defined in this file into the environment. .NOEXPORT: # Lists of files for various purposes. GNATLINK_OBJS = gnatlink.o \ a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \ gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \ osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \ sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \ types.o validsw.o widechar.o GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \ alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\ erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \ gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \ make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o mlib-utl.o \ namet.o nlists.o opt.o osint.o osint-m.o output.o \ prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-err.o prj-ext.o prj-nmsc.o \ prj-pars.o prj-part.o prj-proc.o prj-strt.o prj-tree.o prj-util.o \ rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \ scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o \ sinfo.o sinput.o sinput-c.o sinput-p.o \ snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o switch.o switch-m.o \ table.o targparm.o tempdir.o tree_io.o types.o \ uintp.o uname.o urealp.o usage.o widechar.o \ $(EXTRA_GNATMAKE_OBJS) # Convert the target variable into a space separated list of architecture, # manufacturer, and operating system and assign each of those to its own # variable. host:=$(subst -, ,$(host_canonical)) targ:=$(subst -, ,$(target)) arch:=$(word 1,$(targ)) ifeq ($(words $(targ)),2) manu:= osys:=$(word 2,$(targ)) else manu:=$(word 2,$(targ)) osys:=$(word 3,$(targ)) endif # LIBGNAT_TARGET_PAIRS is a list of pairs of filenames. # The members of each pair must be separated by a '<' and no whitespace. # Each pair must be separated by some amount of whitespace from the following # pair. # Non-tasking case: LIBGNAT_TARGET_PAIRS = \ a-intnam.ads SYMVEC_$$$$.opt && \ objdump --syms $(LIBGNAT_OBJS) $(GNATRTL_NONTASKING_OBJS) | \ $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt && \ echo "case_sensitive=NO" >> SYMVEC_$$$$.opt && \ ../../xgcc -g -B../../ -nostartfiles -shared -shared-libgcc \ -o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) libgnat.a \ sys\$$library:trace.exe \ --for-linker=/noinform \ --for-linker=SYMVEC_$$$$.opt \ --for-linker=gsmatch=equal,$(GSMATCH_VERSION) cd rts && echo "case_sensitive=yes" > SYMVEC_$$$$.opt && \ objdump --syms $(GNATRTL_TASKING_OBJS) | \ $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt && \ echo "case_sensitive=NO" >> SYMVEC_$$$$.opt && \ ../../xgcc -g -B../../ -nostartfiles -shared -shared-libgcc \ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \ libgnarl.a libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ sys\$$library:trace.exe \ --for-linker=/noinform \ --for-linker=SYMVEC_$$$$.opt \ --for-linker=gsmatch=equal,$(GSMATCH_VERSION) gnatlib-shared: $(MAKE) $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ $(GNATLIB_SHARED) gnatlib-sjlj: $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="" ../stamp-gnatlib1 sed -e 's/ZCX_By_Default.*/ZCX_By_Default : constant Boolean := False;/' rts/system.ads > rts/s.ads $(MV) rts/s.ads rts/system.ads $(MAKE) $(FLAGS_TO_PASS) \ EH_MECHANISM="" \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib gnatlib-zcx: $(MAKE) $(FLAGS_TO_PASS) EH_MECHANISM="-gcc" ../stamp-gnatlib1 sed -e 's/ZCX_By_Default.*/ZCX_By_Default : constant Boolean := True;/' rts/system.ads > rts/s.ads $(MV) rts/s.ads rts/system.ads $(MAKE) $(FLAGS_TO_PASS) \ EH_MECHANISM="-gcc" \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" gnatlib # .s files for cross-building gnat-cross: force make $(GNAT1_ADA_OBJS) CC="gcc -B../stage1/" CFLAGS="-S -gnatp" # Compiling object files from source files. # Note that dependencies on obstack.h are not written # because that file is not part of GCC. # Dependencies on gvarargs.h are not written # because all that file does, when not compiling with GCC, # is include the system varargs.h. b_gnatl.c : $(GNATLINK_OBJS) $(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali b_gnatl.o : b_gnatl.c b_gnatm.c : $(GNATMAKE_OBJS) $(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali b_gnatm.o : b_gnatm.c ADA_INCLUDE_DIR = $(libsubdir)/adainclude ADA_RTL_OBJ_DIR = $(libsubdir)/adalib # force no sibling call optimization on s-traceb.o so the number of stack # frames to be skipped when computing a call chain is not modified by # optimization. However we can do that only when building the runtime # (not the compiler) because the -fno-optimize-sibling-calls exists # only in GCC 3. ifneq (,$(findstring xgcc,$(CC))) NO_SIBLING_ADAFLAGS=-fno-optimize-sibling-calls else NO_SIBLING_ADAFLAGS= endif s-traceb.o : s-traceb.adb $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) \ $(NO_SIBLING_ADAFLAGS) $(ADA_INCLUDES) \ $< $(OUTPUT_OPTION) # force debugging information on s-tasdeb.o so that it is always # possible to set conditional breakpoints on tasks. s-tasdeb.o : s-tasdeb.adb s-tasdeb.ads $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) \ $< $(OUTPUT_OPTION) # force debugging information on a-except.o so that it is always # possible to set conditional breakpoints on exceptions. # use -O1 otherwise gdb isn't able to get a full backtrace on mips targets. a-except.o : a-except.adb a-except.ads $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O1 -fno-inline \ $(ADA_INCLUDES) $< $(OUTPUT_OPTION) # force debugging information on s-assert.o so that it is always # possible to set breakpoint on assert failures. s-assert.o : s-assert.adb s-assert.ads a-except.ads $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 $(ADA_INCLUDES) \ $< $(OUTPUT_OPTION) adadecode.o : adadecode.c adadecode.h aux-io.o : aux-io.c argv.o : argv.c cal.o : cal.c deftarg.o : deftarg.c errno.o : errno.c exit.o : adaint.h exit.c expect.o : expect.c final.o : final.c gmem.o : gmem.c link.o : link.c mkdir.o : mkdir.c socket.o : socket.c gsocket.h sysdep.o : sysdep.c raise-gcc.o : raise-gcc.c raise.h raise.o : raise.c raise.h gen-soccon: gen-soccon.c gsocket.h $(CC) $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ -UIN_GCC -DTARGET=\"$(target_alias)\" \ $< $(OUTPUT_OPTION) cio.o : cio.c $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) init.o : init.c adaint.h raise.h $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) initialize.o : initialize.c raise.h $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) targext.o : targext.c $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ $(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \ $< $(OUTPUT_OPTION) # No optimization to compile this file as optimizations (-O1 or above) breaks # the SEH handling on Windows. The reasons are not clear. seh_init.o : seh_init.c raise.h $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) -O0 \ $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) # Need to keep the frame pointer in this file to pop the stack properly on # some targets. tracebak.o : tracebak.c tb-alvms.c tb-alvxw.c tb-gcc.c $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ -fno-omit-frame-pointer $< $(OUTPUT_OPTION) # In GNU Make, ignore whether `stage*' exists. .PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap .PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 force: # Gnatlbr, Vms_help, and Gnat.hlp are only used on VMS ../../gnatlbr$(exeext): ../../prefix.o $(GNATMAKE) -c $(ADA_INCLUDES) gnatlbr --GCC="$(CC) $(ALL_ADAFLAGS)" $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlbr $(GNATLINK) -v gnatlbr -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS) ../../vms_help$(exeext): $(GNATMAKE) -c $(ADA_INCLUDES) vms_help --GCC="$(CC) $(ALL_ADAFLAGS)" $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vms_help $(GNATLINK) -v vms_help -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS) ../../gnat.hlp: ../../vms_help$(exeext) ../../vms_help$(exeext) $(fsrcdir)/gnat.help_in \ $(fsrcdir)/vms_data.ads ../../gnat.hlp