OSDN Git Service

2003-12-11 Ed Falis <falis@gnat.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / Makefile.adalib
1 # This is the Unix/NT makefile used to build an alternate GNAT run-time.
2 # Note that no files in the original GNAT library dirctory will be
3 # modified by this procedure
4 #
5 # This Makefile requires Gnu make.
6 # Here is how to use this Makefile
7 #
8 # 1. Create a new directory (say adalib)
9 #    e.g.  $ mkdir adalib
10 #          $ cd adalib           
11 #
12 # 2. Copy this Makefile from the standard Adalib directory, e.g.
13 #    $ cp /usr/local/gnat/lib/gcc-lib/<target>/<version>/adalib/Makefile.adalib .
14 #
15 # 3. If needed (e.g for pragma Normalize_Scalars), create a gnat.adc
16 #    containing the configuration pragmas you want to use to build the library
17 #    e.g. $ echo pragma Normalize_Scalars; > gnat.adc
18 #    Note that this step is usually not needed, and most pragmas are not
19 #    relevant to the GNAT run time. 
20 #          
21 # 4. Determine the values of the following MACROS
22 #      ROOT   (location of GNAT installation, e.g /usr/local/gnat)
23 #    and optionnally
24 #      CFLAGS (back end compilation flags such as -g -O2)
25 #      ADAFLAGS (front end compilation flags such as -gnatpgn)
26 #                *beware* the minimum value for this MACRO is -gnatpg 
27 #                for proper compilation of the GNAT library
28 # 5a. If you are using a native compile, call make
29 #   e.g.  $ make -f Makefile.adalib ROOT=/usr/local/gnat CFLAGS="-g -O0"
30 #
31 # 5b. If you are using a cross compiler, you need to define two additional
32 #     MACROS:
33 #       CC    (name of the cross compiler)
34 #       AR    (name of the cross ar)
35 #
36 #   e.g.  $ make -f Makefile.adalib ROOT=/opt/gnu/gnat \
37 #     CFLAGS="-O2 -g -I/usr/wind/target/h" CC=powerpc-wrs-vxworks-gcc \
38 #     AR=arppc
39 #
40 # 6. put this new library on your Object PATH where you want to use it
41 # in place of the original one. This can be achieved for instance by
42 # updating the value of the environment variable ADA_OBJECTS_PATH
43
44 PWD_COMMAND=$${PWDCMD-pwd}
45 CC = gcc
46 AR = ar
47
48 ifeq ($(strip $(filter-out %sh,$(SHELL))),)
49    GNAT_ROOT = $(shell cd $(ROOT);${PWD_COMMAND})/
50 else
51    GNAT_ROOT = $(ROOT)/
52 endif
53
54 target = $(shell $(CC) -dumpmachine)
55 version = $(shell $(CC) -dumpversion)
56 ADA_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adainclude/
57 GCC_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/gcc-include/
58 ADA_OBJECTS_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adalib/
59
60 vpath %.adb $(ADA_INCLUDE_PATH)
61 vpath %.ads $(ADA_INCLUDE_PATH)
62 vpath %.c $(ADA_INCLUDE_PATH)
63 vpath %.h $(ADA_INCLUDE_PATH)
64
65 CFLAGS = -O2
66 GNATLIBCFLAGS = -DIN_RTS=1 -DIN_GCC=1 -fexceptions
67 ADAFLAGS = -gnatpgn
68 ALL_ADAFLAGS = $(CFLAGS) $(ADAFLAGS) -I. 
69 FORCE_DEBUG_ADAFLAGS = -g
70 INCLUDES = -I$(ADA_INCLUDE_PATH) -I$(GCC_INCLUDE_PATH)/include   \
71 -I$(GCC_INCLUDE_PATH)/gcc/config -I$(GCC_INCLUDE_PATH)/gcc       \
72 -I$(GCC_INCLUDE_PATH)/gcc/ada    -I$(GCC_INCLUDE_PATH)
73
74 # Say how to compile Ada programs.
75 .SUFFIXES: .ada .adb .ads
76
77 .c.o:
78         $(CC) -c $(CFLAGS) $(GNATLIBCFLAGS) $(INCLUDES) $<
79 .adb.o:
80         $(CC) -c $(ALL_ADAFLAGS) $<
81 .ads.o:
82         $(CC) -c $(ALL_ADAFLAGS) $<
83
84 GNAT_OBJS :=$(filter-out __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnat.a))
85 GNARL_OBJS:=$(filter-out __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnarl.a))
86 OBJS := $(GNAT_OBJS) $(GNARL_OBJS)
87
88 all: libgnat.a libgnarl.a delete_objects g-trasym.o
89         chmod 0444 *.ali *.a
90
91 delete_objects:
92         rm *.o
93
94 libgnat.a: $(GNAT_OBJS)
95         $(AR) r libgnat.a $(GNAT_OBJS)
96
97 libgnarl.a: $(GNARL_OBJS)
98         $(AR) r libgnarl.a $(GNARL_OBJS)
99
100 a-except.o: a-except.adb a-except.ads
101         $(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) -O0 -fno-inline $<
102
103 s-assert.o: s-assert.adb s-assert.ads a-except.ads
104         $(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<
105
106 s-tasdeb.o: s-tasdeb.adb
107         $(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<
108
109 s-vaflop.o: s-vaflop.adb
110         $(CC) -c $(FORCE_DEBUG_ADAFLAGS) -O $(ALL_ADAFLAGS) $<
111
112 s-memory.o: s-memory.adb s-memory.ads
113         $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) $<
114
115 s-traceb.o: s-traceb.adb
116         $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -fno-optimize-sibling-calls $(ADA_INCLUDES) $<
117
118 tracebak.o: tracebak.c
119         $(CC) -c $(CFLAGS) $(GNATLIBCFLAGS) \
120                 $(ALL_CPPFLAGS) $(INCLUDES) -fno-omit-frame-pointer $<
121
122 .PHONY: delete_objects