aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/Makefile.adalib
blob: e43c1b6c82320f87030daea37141f0626ab180fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This is the Unix/NT makefile used to build an alternate GNAT run-time.
# Note that no files in the original GNAT library dirctory will be
# modified by this procedure
#
# This Makefile requires Gnu make.
# Here is how to use this Makefile
#
# 1. Create a new directory (say adalib)
#    e.g.  $ mkdir adalib
#          $ cd adalib           
#
# 2. Copy this Makefile from the standard Adalib directory, e.g.
#    $ cp /usr/local/gnat/lib/gcc-lib/<target>/2.8.1/adalib/Makefile.adalib .
#
# 3. If needed (e.g for pragma Normalize_Scalars), create a gnat.adc
#    containing the configuration pragmas you want to use to build the library
#    e.g. $ echo pragma Normalize_Scalars; > gnat.adc
#    Note that this step is usually not needed, and most pragmas are not
#    relevant to the GNAT run time. 
#          
# 4. Determine the values of the following MACROS
#      ROOT   (location of GNAT installation, e.g /usr/local)
#    and optionnally
#      CFLAGS (back end compilation flags such as -g -O2)
#      ADAFLAGS (front end compilation flags such as -gnatpgn)
#                *beware* the minimum value for this MACRO is -gnatpg 
#                for proper compilation of the GNAT library
# 5a. If you are using a native compile, call make
#   e.g.  $ make -f Makefile.adalib ROOT=/usr/local CFLAGS="-g -O0"
#
# 5b. If you are using a cross compiler, you need to define two additional
#     MACROS:
#       CC    (name of the cross compiler)
#       AR    (name of the cross ar)
#
#   e.g.  $ make -f Makefile.adalib ROOT=/opt/gnu/gnat \
#     CFLAGS="-O2 -g -I/usr/wind/target/h" CC=powerpc-wrs-vxworks-gcc \
#     AR=arppc
#
# 6. put this new library on your Object PATH where you want to use it
# in place of the original one. This can be achieved for instance by
# updating the value of the environment variable ADA_OBJECTS_PATH

SHELL=sh

CC = gcc
AR = ar
GNAT_ROOT = $(shell cd $(ROOT);pwd)/
target = $(shell $(CC) -dumpmachine)
version = $(shell $(CC) -dumpversion)
ADA_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adainclude/
ADA_OBJECTS_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adalib/

vpath %.adb $(ADA_INCLUDE_PATH)
vpath %.ads $(ADA_INCLUDE_PATH)
vpath %.c $(ADA_INCLUDE_PATH)
vpath %.h $(ADA_INCLUDE_PATH)

CFLAGS = -O2
ADAFLAGS = -gnatpgn
ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) -I. 
FORCE_DEBUG_ADAFLAGS = -g
INCLUDES = -I$(ADA_INCLUDE_PATH)

# Say how to compile Ada programs.
.SUFFIXES: .ada .adb .ads

.c.o:
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(INCLUDES) $<
.adb.o:
	$(CC) -c $(ALL_ADAFLAGS) $<
.ads.o:
	$(CC) -c $(ALL_ADAFLAGS) $<

GNAT_OBJS :=$(filter-out prefix.o __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnat.a))
GNARL_OBJS:=$(filter-out __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnarl.a))
OBJS := $(GNAT_OBJS) $(GNARL_OBJS)

all: libgnat.a libgnarl.a
	chmod 0444 *.ali *.a
	rm *.o

libgnat.a: $(GNAT_OBJS)
	$(AR) r libgnat.a $(GNAT_OBJS)

libgnarl.a: $(GNARL_OBJS)
	$(AR) r libgnarl.a $(GNARL_OBJS)

a-except.o: a-except.adb a-except.ads
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) -O0 -fno-inline $<

s-assert.o: s-assert.adb s-assert.ads a-except.ads
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<

s-tasdeb.o: s-tasdeb.adb
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<

s-vaflop.o: s-vaflop.adb
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) -O $(ALL_ADAFLAGS) $<

s-memory.o: s-memory.adb s-memory.ads
	$(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) $<

a-init.o: a-init.c a-ada.h a-types.h a-raise.h
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) \
		$(ALL_CPPFLAGS) $(INCLUDES) -fexceptions $<

a-traceb.o: a-traceb.c
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) \
		$(ALL_CPPFLAGS) $(INCLUDES) -fno-omit-frame-pointer $<

prefix.o: prefix.c gansidecl.h
	$(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
		-DPREFIX=\"$(GNAT_ROOT)\" $<