-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.defaults
273 lines (199 loc) · 5.83 KB
/
Makefile.defaults
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
ifndef MAKEFILE_DEFAULTS
MAKEFILE_DEFAULTS=1
# Define how to build the project: distrib, debug, optimize, coverage, profile
BUILD?=distrib
# Enable the build of shared libraries: yes, no
BUILDS_SHARED?=no
# The installation prefix for the project
PREFIX?=/usr/local
HAVE_ALIRE?=yes
# You may edit this makefile as long as you keep these original
# target names defined.
GNATMAKE?=gprbuild
GNATCLEAN?=gnatclean
GPRBUILD?=gprbuild
GPRINSTALL?=gprinstall
INSTALL?=install
PANDOC?=$(shell which pandoc 2>/dev/null)
DYNAMO?=$(shell which dynamo 2>/dev/null)
PROCESSORS?=1
MKDIR?=mkdir
CP?=cp
LN?=ln -s
ALR?=alr --non-interactive
SRC_ROOT?=$(shell pwd)
DEFAULT_ADA_PROJECT_PATH?=$(SRC_ROOT):$(ADA_PROJECT_PATH)
ifeq ($(HAVE_ALIRE),yes)
BUILD_COMMAND?=$(ALR) build --
GNATPREP?=$(ALR) exec -- gnatprep
else
BUILD_COMMAND?=env ADA_PROJECT_PATH="$(DEFAULT_ADA_PROJECT_PATH)" $(GPRBUILD)
GNATPREP?=gnatprep
endif
ifeq (${OS},Windows_NT)
LIBEXT?=dll
LIBVER?=dll
else
LIBEXT?=so
LIBVER?=so.$(SO_VERSION)
endif
srcdir ?= .
top_builddir ?= .
prefix ?= $(PREFIX)
exec_prefix ?= ${prefix}
top_builddir ?= .
includedir?=${prefix}/${infix_inc}
projectdir?=${prefix}/${infix_prj}
bindir?=${prefix}/bin
libdir?=${prefix}/${infix_lib}
alidir?=${prefix}/${infix_ali}
samplesdir?=${prefix}/share/doc/${docdir}
dynamodir=${prefix}/share/dynamo
aliredir=${prefix}/alire-index
MAKE_ARGS +=
build:: all
ifeq ($(BUILDS_SHARED),yes)
all:: static shared build-test
install:: uninstall install-shared install-static
else
all:: static build-test
install:: uninstall install-static
endif
static::
shared::
install-data::
# Clean, then build executables for all mains defined by the project.
rebuild: clean all
ifeq ($(NO_BUILD_INSTALL),)
build-install: build install
endif
# Clean the root project of all build products.
clean::
-rm -rf lib obj bin $(CLEAN_FILES)
-rm -rf regtests/result
dist-clean:: clean
-rm -f *.log *~ Makefile.conf
doc::
ifneq (${DYNAMO},)
$(DYNAMO) build-doc -markdown wiki
endif
dist::
rm -f $(DIST_FILE)
git archive -o $(DIST_FILE) --prefix=$(DIST_DIR)/ HEAD
define ada_library
ifeq ($(HAVE_ALIRE),yes)
static:: lib-setup
cd $(2) && $(BUILD_COMMAND) $(STATIC_MAKE_ARGS)
install-static::
cd $(2) && $(ALR) exec -- $(GPRINSTALL) -p -f --prefix=$(DESTDIR)${prefix} \
$(STATIC_MAKE_ARGS) \
--build-name=static $(1).gpr
else
static:: lib-setup
cd $(2) && env ADA_PROJECT_PATH="$(DEFAULT_ADA_PROJECT_PATH)" $(GPRBUILD) -P $(1).gpr $(GPRFLAGS) $(STATIC_MAKE_ARGS)
install-static::
cd $(2) && env ADA_PROJECT_PATH="$(DEFAULT_ADA_PROJECT_PATH)" $(GPRINSTALL) -p -f --prefix=$(DESTDIR)${prefix} \
$(STATIC_MAKE_ARGS) \
--build-name=static $(1).gpr
endif
lib-setup:: obj/$(1)/static
obj/$(1)/static:
$(MKDIR) -p obj/$(1)/static
ifeq ($(BUILDS_SHARED),yes)
ifeq ($(HAVE_ALIRE),yes)
shared:: lib-setup
cd $(2) && $(BUILD_COMMAND) $(SHARED_MAKE_ARGS)
install-shared::
cd $(2) && $(ALR) exec -- $(GPRINSTALL) -p -f --prefix=$(DESTDIR)${prefix} \
$(SHARED_MAKE_ARGS) \
--build-name=relocatable $(1).gpr
else
shared:: lib-setup
cd $(2) && env ADA_PROJECT_PATH="$(DEFAULT_ADA_PROJECT_PATH)" $(GPRBUILD) -P $(1).gpr $(GPRFLAGS) $(SHARED_MAKE_ARGS)
install-shared::
cd $(2) && env ADA_PROJECT_PATH="$(DEFAULT_ADA_PROJECT_PATH)" $(GPRINSTALL) -p -f --prefix=$(DESTDIR)${prefix} \
$(SHARED_MAKE_ARGS) \
--build-name=relocatable $(1).gpr
endif
endif
ifeq ($(HAVE_ALIRE),yes)
uninstall::
-cd $(2) && $(ALR) exec -- $(GPRINSTALL) --uninstall -q -f --prefix=$(DESTDIR)${prefix} $(MAKE_ARGS) $(1).gpr
else
uninstall::
-cd $(2) && $(GPRINSTALL) --uninstall -q -f --prefix=$(DESTDIR)${prefix} $(MAKE_ARGS) $(1).gpr
endif
endef
define ada_program
all:: lib-setup
$(GNATMAKE) $(GPRFLAGS) -p -P$(2)$(1).gpr $(STATIC_MAKE_ARGS)
lib-setup:: obj/$(1)/static
obj/$(1)/static:
$(MKDIR) -p obj/$(1)/static
endef
define awa_install_dir
install:: | $(DESTDIR)$(dynamodir)/$(1)/$(2)
(cd $(3) && tar --exclude='*~' -cf - $(2)) \
| (cd $(DESTDIR)$(dynamodir)/$(1)/ && tar xf -)
$(DESTDIR)$(dynamodir)/$(1)/$(2):
$(MKDIR) -p $(DESTDIR)$(dynamodir)/$(1)/$(2)
endef
define awa_install_file
install:: | $(DESTDIR)$(dynamodir)/$(1)
$(CP) $(3)/$(2) $(DESTDIR)$(dynamodir)/$(1)/$(2)
endef
define awa_install_plugin
uninstall::
rm -rf $(DESTDIR)$(dynamodir)/$(strip $(1))
$(foreach dir,$($(1)_install_dirs),$(eval $(call awa_install_dir,$(strip $(1)),$(dir),$($(1)_dir))))
$(foreach dir,$($(1)_install_files),$(eval $(call awa_install_file,$(strip $(1)),$(dir),$($(1)_dir))))
$(DESTDIR)$(dynamodir)/$(1):
$(MKDIR) -p $(DESTDIR)$(dynamodir)/$(1)
install:: | $(DESTDIR)$(dynamodir)/$(1)
$(CP) $($(1)_dir)/dynamo.xml $(DESTDIR)$(dynamodir)/$(strip $(1))/dynamo.xml
endef
define awa_plugin
$(eval $(call awa_install_plugin,$(strip $(1))))
ifdef $(1)_dynamo
generate::
cd $($(1)_dir) && $(DYNAMO) generate $($(1)_dynamo)
endif
clean::
$(RM) -r $($(1)_dir)/dynamo.log $($(1)_dir)/obj $($(1)_dir)/lib
endef
define alire_publish
publish::
-rm -f $(aliredir)/$(2)/$(3)
cd $(1) && alr -f --no-tty publish --skip-submit
mkdir -p $(aliredir)/index/$(2)
cp $(1)/alire/releases/$(3) $(aliredir)/index/$(2)/$(3)
endef
define pandoc_build
ifneq (, ${PANDOC})
doc:: docs/$(1).pdf docs/$(1).html
ifneq (${DYNAMO},)
$(DYNAMO) build-doc -markdown wiki
endif
docs/$(1).pdf: force
ifneq (${DYNAMO},)
$(DYNAMO) build-doc -pandoc docs
$(3)
endif
cd docs && $(PANDOC) $(DOC_OPTIONS) -o $(1).pdf --template=./eisvogel.tex $(2)
docs/$(1).html: docs/$(1).pdf force
cd docs && $(PANDOC) $(HTML_OPTIONS) -o $(1).html $(2)
endif
endef
force:
build-test::
uninstall::
install-static::
endif
ifdef DESTDIR
.NOTPARALLEL:
endif
setup::
echo "BUILD=$(BUILD)" > Makefile.conf
echo "PREFIX=$(prefix)" >> Makefile.conf
echo "HAVE_ALIRE=$(HAVE_ALIRE)" >> Makefile.conf
echo "BUILDS_SHARED=$(BUILDS_SHARED)" >> Makefile.conf