-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.defaults
243 lines (175 loc) · 4.97 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
ifndef MAKEFILE_DEFAULTS
MAKEFILE_DEFAULTS=1
# You may edit this makefile as long as you keep these original
# target names defined.
BUILD?=distrib
GNATMAKE?=gprbuild
GNATCLEAN?=gnatclean
GPRINSTALL?=gprinstall
INSTALL?=install
PANDOC?=$(shell which pandoc)
DYNAMO?=$(shell which dynamo)
PROCESSORS?=1
MKDIR?=mkdir
CP?=cp
LN?=ln -s
ALR?=alr --non-interactive
BUILD_COMMAND?=$(ALR) build --
BUILDS_SHARED?=no
ifeq (${OS},Windows_NT)
LIBEXT?=dll
LIBVER?=dll
else
LIBEXT?=so
LIBVER?=so.$(SO_VERSION)
endif
srcdir ?= .
top_builddir ?= .
prefix ?= /usr/local
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 install-info
else
all:: static build-test
install:: uninstall install-static install-info
endif
static::
shared::
install-data::
# Not intended for manual invocation.
# Invoked if automatic builds are enabled.
# Analyzes only on those sources that have changed.
# Does not build executables.
autobuild:
$(GNATMAKE) $(MAKE_ARGS) -gnatc -c -k -P "$(GPRPATH)"
# Clean, then build executables for all mains defined by the project.
rebuild: clean all
# Check *all* sources for errors, even those not changed.
# Does not build executables.
analyze:
$(GNATMAKE) $(MAKE_ARGS) -f -gnatc -c -k -P "$(GPRPATH)"
# Clean root project and all imported projects too.
clean_tree:
$(GNATCLEAN) -q -P "$(GPRPATH)" -r
# Clean the root project of all build products.
clean::
-rm -rf lib obj bin autom4te.cache $(CLEAN_FILES)
-rm -rf regtests/result
dist-clean:: clean
-rm -f *.log *~ config.status 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
install-info::
ifeq (${VERBOSE},1)
@echo "Environment setup:"
@echo " export ADA_PROJECT_PATH=${projectdir}:$$ADA_PROJECT_PATH"
endif
define ada_library
# static:: setup
# $(BUILD_COMMAND) $(GPRFLAGS) -p -P$(2)$(1).gpr $(STATIC_MAKE_ARGS)
install-static::
cd $(2) && $(ALR) exec -- gprinstall -p -f --prefix=$(DESTDIR)${prefix} \
$(STATIC_MAKE_ARGS) \
--build-name=static $(1).gpr
lib-setup:: obj/$(1)/static
obj/$(1)/static:
$(MKDIR) -p obj/$(1)/static
ifeq ($(BUILDS_SHARED),yes)
shared:: lib-setup
cd $(2) && $(BUILD_COMMAND) $(GPRFLAGS) $(SHARED_MAKE_ARGS)
install-shared::
cd $(2) && $(ALR) exec -- gprinstall -p -f --prefix=$(DESTDIR)${prefix} \
$(SHARED_MAKE_ARGS) \
--build-name=relocatable $(1).gpr
endif
uninstall::
-cd $(2) && $(ALR) exec -- gprinstall --uninstall -q -f --prefix=$(DESTDIR)${prefix} $(MAKE_ARGS) $(1).gpr
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)
alr -f --no-tty publish --skip-submit --manifest $(1)
mkdir -p $(aliredir)/index/$(2)
cp 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