-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
235 lines (187 loc) · 6.05 KB
/
Makefile
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Makefile targets
# ----------------
#
# Setup: make [VAR=VALUE] setup (see below)
# Build gprbuild: make all
# Install gprbuild: make install
# Create gprbuild package: make distall
# Build tool <TOOL>: make <TOOL>
# Build libgpr: make libgpr.build
# Install libgpr: make libgpr.install
# (for libgpr you can add ".type" where type is static, static-pic or shared
# build a specific version of the lib. by default all supported variants are
# built).
# Variables which can be set:
#
# ENABLE_SHARED : yes / no (or empty)
# BUILD : debug production coverage profiling
# PROCESSORS : nb parallel compilations (0 to use all cores)
# TARGET : target triplet for cross-compilation
#
# Out-of-tree build:
#
# $ make -f <GPRBUILD_TREE>/Makefile setup
# $ make -f <GPRBUILD_TREE>/Makefile
HOST := $(shell gcc -dumpmachine)
TARGET := $(shell gcc -dumpmachine)
prefix := $(dir $(shell which gnatls))..
BUILD = production
PROCESSORS = 0
BUILD_DIR =
SOURCE_DIR := $(shell dirname "$(MAKEFILE_LIST)")
LIB_DIR = lib/
# Load current setup if any
-include makefile.setup
# target options for cross-build
ifeq ($(HOST),$(TARGET))
GTARGET=
# INSTALLER=exe/$(BUILD)/$(LIB_INSTALLER)
else
GTARGET=--target=$(TARGET)
endif
INSTALLER=$(LIB_INSTALLER)
EXEC_INSTALLER=$(INSTALLER) -XBUILD=${BUILD}
# check for out-of-tree build
ifeq ($(SOURCE_DIR),.)
RBD=
GPRBUILD_GPR=gprbuild.gpr
GPR_GPR=gpr/gpr.gpr
MAKEPREFIX=
else
RBD=--relocate-build-tree
GPRBUILD_GPR=$(SOURCE_DIR)/gprbuild.gpr
GPR_GPR=$(SOURCE_DIR)/gpr/gpr.gpr
MAKEPREFIX=$(SOURCE_DIR)/
endif
ENABLE_SHARED := $(shell gprbuild $(GTARGET) -c -q -p \
-P$(MAKEPREFIX)config/test_shared 2>/dev/null && echo "yes")
ifeq ($(ENABLE_SHARED), yes)
LIBGPR_TYPES=static shared static-pic
else
LIBGPR_TYPES=static
endif
# Make sure Windows's "OS" environment variable does not cause
# confusion for cross-Linux builds.
LIBGPR_OS = $(if $(findstring linux,$(TARGET)),-XOS=UNIX)
# Used to pass extra options to GPRBUILD, like -d for instance
GPRBUILD_OPTIONS=
BUILDER=gprbuild -p -m $(GTARGET) $(RBD) -j${PROCESSORS} -XBUILD=${BUILD} ${GPRBUILD_OPTIONS}
LIB_INSTALLER=gprinstall -p -f --target=$(TARGET) $(RBD) "--prefix=${prefix}"
CLEANER=gprclean -q $(RBD)
GPRBUILD_BUILDER=$(BUILDER) $(GPRBUILD_GPR) \
-XLIBRARY_TYPE=static -XXMLADA_BUILD=static
LIBGPR_BUILDER=$(BUILDER) $(GPR_GPR) $(LIBGPR_OS)
LIBGPR_INSTALLER=$(LIB_INSTALLER) $(GPR_GPR) $(LIBGPR_OS) -XBUILD=${BUILD} \
--install-name=gpr \
--build-var=LIBRARY_TYPE --build-var=GPR_BUILD $(GTARGET)
LIBGPR_UNINSTALLER=$(LIB_INSTALLER) $(GPR_GPR) $(LIBGPR_OS) --install-name=gpr --uninstall
#########
# build #
#########
.PHONY: all distall gprbuild gprconfig gprclean gprinstall gprname gprls
build all:
$(GPRBUILD_BUILDER)
distall: all install
gprbuild:
$(GPRBUILD_BUILDER) gprbuild-main.adb
gprinstall:
$(GPRBUILD_BUILDER) gprinstall-main.adb
gprclean:
$(GPRBUILD_BUILDER) gprclean-main.adb
gprconfig:
$(GPRBUILD_BUILDER) gprconfig-main.adb
gprname:
$(GPRBUILD_BUILDER) gprname-main.adb
gprls:
$(GPRBUILD_BUILDER) gprls-main.adb
#################################
# Gprbuild installation targets #
#################################
.PHONY: install
install:
$(EXEC_INSTALLER) --mode=usage --install-name=gprbuild \
-XINSTALL_MODE=nointernal $(GPRBUILD_GPR)
$(EXEC_INSTALLER) --target=$(TARGET) --mode=usage --install-name=gprbuild \
-XINSTALL_MODE=internal $(GPRBUILD_GPR)
complete: all install libgpr.install.static
##########
# Libgpr #
##########
.PHONY: libgpr.build libgpr.build.static libgpr.build.shared libgpr.build.static-pic
.PHONY: libgpr.install libgpr.install.static libgpr.install.shared libgpr.install.static-pic
.PHONY: libgpr.uninstall
libgpr.build: $(foreach t, $(LIBGPR_TYPES), libgpr.build.$(t))
libgpr.build.shared:
${LIBGPR_BUILDER} -XLIBRARY_TYPE=relocatable \
-XXMLADA_BUILD=relocatable
libgpr.build.static:
${LIBGPR_BUILDER} -XLIBRARY_TYPE=static \
-XXMLADA_BUILD=static
libgpr.build.static-pic:
${LIBGPR_BUILDER} -XLIBRARY_TYPE=static-pic \
-XXMLADA_BUILD=static-pic
libgpr.install: libgpr.uninstall $(foreach t, $(LIBGPR_TYPES), libgpr.install.$(t))
libgpr.install.static:
$(LIBGPR_INSTALLER) \
-XLIBRARY_TYPE=static \
-XXMLADA_BUILD=static \
--lib-subdir=${LIB_DIR}/gpr/static \
--build-name=static
libgpr.install.static-pic:
$(LIBGPR_INSTALLER) \
-XLIBRARY_TYPE=static-pic \
-XXMLADA_BUILD=static-pic \
--lib-subdir=${LIB_DIR}/gpr/static-pic \
--build-name=static-pic
libgpr.install.shared:
$(LIBGPR_INSTALLER) \
-XLIBRARY_TYPE=relocatable \
-XXMLADA_BUILD=relocatable \
--lib-subdir=${LIB_DIR}/gpr/relocatable \
--build-name=relocatable
libgpr.uninstall:
-$(LIBGPR_UNINSTALLER)
libgpr.clean:
-$(CLEANER) -XLIBRARY_TYPE=relocatable $(GPR_GPR)
-$(CLEANER) -XLIBRARY_TYPE=static $(GPR_GPR)
-$(CLEANER) -XLIBRARY_TYPE=static-pic $(GPR_GPR)
rm -fr gpr/lib gpr/libobj
#########
# setup #
#########
.SILENT: setup
setup:
echo "prefix=$(prefix)" > makefile.setup
echo "ENABLE_SHARED=$(ENABLE_SHARED)" >> makefile.setup
echo "BUILD=$(BUILD)" >> makefile.setup
echo "PROCESSORS=$(PROCESSORS)" >> makefile.setup
echo "TARGET=$(TARGET)" >> makefile.setup
echo "SOURCE_DIR=$(SOURCE_DIR)" >> makefile.setup
###################
# Cleanup targets #
###################
.PHONY: clean
clean: libgpr.clean
-$(CLEANER) -r -Pgprbuild -XBUILD=$(BUILD)
-$(CLEANER) -r -XBUILD=${BUILD} \
-XLIBRARY_TYPE=static-pic $(GPR_GPR)
-$(CLEANER) -r -XBUILD=${BUILD} \
-XLIBRARY_TYPE=static $(GPR_GPR)
ifeq ($(ENABLE_SHARED), yes)
-$(CLEANER) -r -XBUILD=${BUILD} \
-XLIBRARY_TYPE=relocatable $(GPR_GPR)
-$(CLEANER) $(GPR_GPR) -XBUILD=$(BUILD) \
-XLIBRARY_TYPE=relocatable
endif
make -C $(MAKEPREFIX)doc clean
make -C $(MAKEPREFIX)examples clean
rm -fr obj exe makefile.setup
.PHONY: doc examples
doc:
make -C $(MAKEPREFIX)doc
examples: force
make -C $(MAKEPREFIX)examples
force:
# Let gprbuild handle parallelization. In general, we don't support parallel
# runs in this Makefile, as concurrent gprinstall processes may crash.
.NOTPARALLEL: