-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·393 lines (317 loc) · 12.2 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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# Flags for some of the stuff I build
ALL_OUTPUT := $(CURDIR)
O ?= $(ALL_OUTPUT)
R := $(ALL_OUTPUT)/release
HERE := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
SRC := $(HERE)
S := $(SRC)
SHELL=/bin/bash -o pipefail
MAKEFLAGS = -Rr
b0 = $(shell uname -s)
B = $(b0:Darwin=build)
tools0 = $(b0:Darwin=/win/tools:/Volumes/cmake-3.28.3-macos10.10-universal/CMake.app/Contents/bin:)
tools = $(tools0:Linux=)
# ---------- project specific options ----------
%.perfc: cov.flags="EXTRA_CFLAGS=-fprofile-arcs -ftest-coverage"
%.perf %.perfc %.perfc.g: output=$O/build.$(@:.g=)
%.perf %.perfc:
mkdir -p $(output)
cd $*/tools/perf && $(MAKE) O=$(output) V=1\
NO_JEVENTS=1 NO_LIBTRACEEVENT=1 $(cov.flags)
%.perfc.g:
cd $O/$*/tools/perf && gcov -dp $(shell find $(output) -iname '*.o')
perf.dnf:
dnf install elfutils-devel elfutils-libelf-devel
perf-static: bzip2-1.0.6.m xz.m elfutils.m
mkdir -p $O/static.perf
cd linux/tools/perf &&\
$(MAKE) O=$O/static.perf V=1 LDFLAGS="-static -L$R/lib"\
EXTRA_CFLAGS=-I$R/include
Clang_DIR = /Volumes/clang+llvm-9.0.0-x86_64-darwin-apple
elfutils.options = --enable-maintainer-mode
binutils-gdb.options.Darwin = --disable-gold --disable-ld --enable-targets=all
binutils-gdb.options = --disable-gold --enable-targets=all\
CFLAGS="-g -O2 -Wno-error=cast-function-type -Wno-error=stringop-truncation\
-Wno-error=format-truncation -Wno-error=format-overflow"
binutils-gdb.envvars = MAKEINFO=:
qemu.envvars.Darwin = PKG_CONFIG=$R/bin/pkg-config
qemu6.envvars.Darwin = $(qemu.envvars.Darwin)
qemu%: options = --target-list=x86_64-softmmu --disable-docs\
--disable-guest-agent --disable-curl\
--disable-live-block-migration --enable-slirp
# --enable-virtfs works only on Linux
qemu%: options.Linux = --enable-gtk
pkg-config.options = --with-internal-glib
__lldb.envvars = LLVM_DIR=$(Clang_DIR) Clang_DIR=$(Clang_DIR)
__lldb.options = -DCMAKE_CXX_COMPILER=$(Clang_DIR)/bin/clang++\
-D CMAKE_C_COMPILER=$(Clang_DIR)/bin/clang\
-D CMAKE_BUILD_TYPE=RelWithDebInfo\
-DLLDB_INCLUDE_TESTS=0
swig.options += -D WITH_PCRE=OFF
# RelWithDebInfo doesn't work!
lldb.options =\
-D CMAKE_BUILD_TYPE=RelWithDebInfo\
-DLLDB_USE_SYSTEM_DEBUGSERVER=ON\
-DLLDB_INCLUDE_TESTS=0\
-DLLDB_ENABLE_PYTHON=1\
-D CMAKE_EXE_LINKER_FLAGS=-g\
-D CMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -Os"
# CMAKE_INSTALL_MODE requires cmake 3.22
llvm.options =\
-D CMAKE_BUILD_TYPE=RelWithDebInfo\
-D CMAKE_CXX_FLAGS_RELWITHDEBINFO='-Os -g -DNDEBUG'\
-D LLVM_INCLUDE_TESTS=0\
-D LLVM_TARGETS_TO_BUILD=X86
# Doesn't work in cmake 3.20
# -DCMAKE_AR="ls nonsence"
clang.options = $(llvm.options)\
-DCLANG_INCLUDE_TESTS=0
rtags.options = -D\
LIBCLANG_LLVM_CONFIG_EXECUTABLE="$(Clang_DIR)/bin/llvm-config"\
-D CMAKE_CXX_COMPILER="$(Clang_DIR)/bin/clang++"
qtbase.options = -extprefix "$R" -v -opensource -confirm-license\
-qtlibinfix AndroidEmu
fuzzy_dictionary.envvars =\
CXXFLAGS="-target x86_64-gnu-linux -v\
-I /Library/Developer/CommandLineTools/usr/include/c++/v1\
-I /win/third_party/release/glibc.2.7/include\
-I /win/third_party/glibc/Kernel-headers"\
LDFLAGS="-target x86_64-gnu-linux -v\
-fuse-ld=/Volumes/clang+llvm-9.0.0-x86_64-darwin-apple/bin/ld.lld"
# fuzzy_dictionary.envvars = CXX="clang++ -v"
fuzzy_dictionary.targets = fuzzy_dictionary_lib
core6.options = --target x86_64-gnu-linux\
"CPPFLAGS=-target x86_64-gnu-linux\
-Wno-inconsistent-missing-override\
-I /Library/Developer/CommandLineTools/usr/include/c++/v1\
-I /win/third_party/release/glibc.2.7/include\
-I /win/third_party/glibc/Kernel-headers"\
"LDFLAGS=-target x86_64-gnu-linux -v\
-fuse-ld=/Volumes/clang+llvm-9.0.0-x86_64-darwin-apple/bin/ld.lld\
--sysroot=/win/third_party/release/glibc.2.7\
-rtlib=compiler-rt"
core6.overrides = MAKE="make -W kodwebd/stdafx.h.gch -W\
kdb/stdafx.h.gch"
core6.deps = $S/portable_autotools/realpath
__pdf2djvu.options = "POPPLER_CFLAGS=-I $(HERE)/../third_party/include"\
"POPPLER_LIBS=-L $(HERE)/../third_party/lib"
pdf2djvu.overrides = -f ../pdf2djvu/Makefile
usb.options = CFLAGS="-Wno-incompatible-pointer-types -Wno-format"
keyfuzz.options = --disable-lynx
_build%evince: options=-Ddjvu=enabled -Dnautilus=false\
-Dintrospection=false -Dgtk_doc=false -Duser_doc=false\
-Dgspell=disabled
zsh%: options = --with-tcsetpgrp
%emacs: options = --with-tiff=no --with-xpm=no --with-gnutls=no\
--with-jpeg=no --with-gif=no
#
# To build with OS paths baked in:
# scl enable gcc-toolset-12 'make evince.n B=global R=/usr'
#
new-emacs.n: new-fake-manuals
%fake-manuals:
mkdir -p $*emacs/info
echo "Fake" > $*emacs/info/emacs
echo "Fake" > $*emacs/info/emacs.info
noinstall.qemu make.qemu qemu6.n: pkg-config.m glib.m pixman.m
# qemu must skip meson.build
qemu8.n_: qemu8.m_
glib.m: pcre-8.45.m
lldb.n: swig.m clang.m
clang.m: llvm.m
aqemu.make: pkg-config.install_ glib.install_ pixman.install_
T = samba/source3
samba/source3.options = CFLAGS="-O -Wno-deprecated-declaration"
$R/samba.make.successful.log.txt: $T/Makefile $(MAKEFILE_LIST) $f
(cd $T && $(MAKE)) 2>&1 |tee -a [email protected]
mv -v [email protected] $@
4samba.n: zlib.m pkg-config.m
4samba.options = --without-gpgme --disable-python --without-winbind\
--without-ads --without-ldap --disable-cups --disable-iprint\
--without-pam --without-quotas --without-sendfile-support --without-utmp\
--disable-avahi --without-acl-support --without-dnsupdate\
--without-syslog --without-automount --without-dmapi --without-fam\
--without-libarchive --without-regedit --without-winexe\
--without-fake-kaserver --disable-glusterfs --disable-cephfs\
--disable-spotlight --without-systemd --without-ad-dc --without-json
HB = /win/hb
gnutls.includes0 = -I$(HB)/Cellar/gnutls/3.6.15/include\
-I$(HB)/Cellar/nettle/3.7.1/include\
-I$(HB)/Cellar/libtasn1/4.16.0_1/include\
-I$(HB)/Cellar/libidn2/2.3.0/include\
-I$(HB)/Cellar/p11-kit/0.23.22/include/p11-kit-1
gnutls.includes = -I$(HB)/include
# These are the options for configuring+building source3/ directory
# separately - that's not possible since version 4!
hbsamba.source3.options.common = --without-winbind\
--without-ads --without-ldap --disable-cups --disable-iprint\
--without-pam --without-quotas --without-sendfile-support --without-utmp\
--disable-avahi --without-acl-support\
--without-syslog --without-automount --without-dmapi --without-fam\
--without-libarchive --without-regedit\
--without-fake-kaserver --disable-glusterfs --disable-cephfs\
--disable-spotlight
hbsamba.source3.options = $(hbsamba.source3.options.common)\
--without-dnsupdate
hbsamba.source3.options.4.13 = $(hbsamba.source3.options) --without-winexe
hbsamba.options.4.11 = $(hbsamba.source3.options)\
--without-gpgme --disable-python\
--without-systemd --without-ad-dc --without-json
hbsamba415.options = $(hbsamba.source3.options.common)\
--without-gpgme --disable-python\
--without-systemd --without-ad-dc --without-json
hbsamba.options = $(hbsamba.options.4.11)
YAPPDIR = $S/Parse-Yapp-1.21
# hbsamba_.n: topconfdir = $S/$*/source3
wafout = $S/$*/bin
hbsamba.n: env = PERL5LIB=$(YAPPDIR)/lib
hbsamba.n hbsamba415.n: cenv = ln -sfv /usr/lib/libreadline.dylib $(wafout) &&\
PATH=$(HB)/bin:$(YAPPDIR):$(PATH)\
CPPFLAGS="$(gnutls.includes)"\
LDFLAGS="-L$(wafout)" $(env)
# If I change this to hbsamb%.n: per target vars don't work
hbsamba.n: $R/hbsamba.wafhb.successful.log.txt
@echo $^ is up to date
hbsamba415.n: env = PERL5LIB=$(YAPPDIR)/lib
hbsamba415.n: $R/hbsamba415.wafhb.successful.log.txt
@echo $^ is up to date
topconfdir = $S/$*
# $(HB)/bin to find pkg-config & it finds everything else
$S/%/bin/c4che/default_cache.py: $S/%/*/bin/waf $S/%/wscript\
$(MAKEFILE_LIST) $f
cd $S/$* && $(cenv) $< configure\
-t $(topconfdir) --prefix="$R" $($*.options)
$R/%.wafhb.successful.log.txt: $S/%/*/bin/waf $S/%/wscript\
$S/%/bin/c4che/default_cache.py $(MAKEFILE_LIST) $f
mkdir -p $(dir $@)
(cd $S/$* && $(env) caffeinate nice $< build -kvt $(topconfdir)) 2>&1 |\
tee -a [email protected]
mv [email protected] $@
$(AFSCTOOL) -cfvvv $S/$*
# ----------- debug ----------------------------
.PHONY: make.% %.make noinstall.% %.noinstall _build.% %.n %.m
vars:
@echo R = $R
@echo S = $S
@echo O = $O
@echo MAKEFLAGS = $(MAKEFLAGS)
@echo B = $B
@echo X = $X
subvars:
$(MAKE) vars
# ----------- common rules ---------------------
AFSCTOOL.Darwin = $(HERE)/afsctool/afsctool
AFSCTOOL = $(AFSCTOOL.$(b0))
$(AFSCTOOL.Darwin): $(AFSCTOOL.Darwin).c
gcc -o $@ $^
.PRECIOUS: $O/$B.%/Makefile $O/$B.%/build.ninja\
%/configure %/Makefile.in %/Makefile\
$R/%.installed.logc $R/%.make.successful.log.txt\
$O/$B.%/%.ninja.success.logc $R/%.waf.successful.log.txt\
$(AFSCTOOL)
$f:
echo Force=$f
noinstall.% %.noinstall %.n:
$(MAKE) _build.$*
_build.% %.n_: $R/%.waf.successful.log.txt $(AFSCTOOL) $f
$(AFSCTOOL) -cfvvv $O/$B.$*
@echo $^ is up to date
_build.% %.n_: $O/$B.%/%.ninja.success.logc $(AFSCTOOL) $f
$(AFSCTOOL) -cfvvv $O/$B.$*
@echo $^ is up to date
_build.% %.n_ %.m_: $R/%.make.successful.log.txt $(AFSCTOOL) $f
$(AFSCTOOL) -cfvvv $O/$B.$*
@echo $^ is up to date
%.m:
$(MAKE) $*.install_
%.install_: $R/%.installed.logc $(AFSCTOOL)
$(AFSCTOOL) -cfvvv $R
@echo $^ is up to date
# Build specifically with configure/make
%.make: $(AFSCTOOL) $(MAKEFILE_LIST) $O/$B.%/Makefile
PATH=$(tools)$(PATH) $(MAKE) $R/$*.make.successful.log.txt
$(AFSCTOOL) -cfvvv $O/$B.$*
$R/%.installed.logc: $S/%/*.gyp $(MAKEFILE_LIST)
(cd $* && GREP_OPTIONS= $($*.envvars)\
gyp --depth=. --format=ninja-linux &&\
ninja -vC out/Release $($*.targets)) 2>&1 |tee -a [email protected]
mv -v [email protected] $@
$R/%.installed.logc: $O/$B.%/%.ninja.success.logc $(MAKEFILE_LIST)
mkdir -p $(dir $@)
(cd $O/$B.$* && PATH=$(tools)$(PATH) CMAKE_INSTALL_MODE=SYMLINK\
ninja install) 2>&1 | tee [email protected]
mv -v [email protected] $@
$R/%.installed.logc: $R/%.make.successful.log.txt $(MAKEFILE_LIST)
mkdir -p $(dir $@)g
(cd $O/$B.$* && $(MAKE) V=1 VERBOSE=1 install) 2>&1 | tee -a [email protected]
mv -v [email protected] $@
$R/%.waf.successful.log.txt: $S/%/*/bin/waf $S/%/wscript\
$(MAKEFILE_LIST) $f
mkdir -p $(dir $@)
mkdir -p $S/$B.$*
cd $S/$B.$* && PATH=$R/bin:$(PATH) $< configure\
-t $S/$* --prefix="$R" $($*.options)
$R/%.make.successful.log.txt: $O/$B.%/Makefile $(MAKEFILE_LIST) $f
mkdir -p $(dir $@)
(cd $O/$B.$* && $(MAKE) V=1 VERBOSE=1 $($*.overrides) --trace) 2>&1 |\
tee -a [email protected]
mv -v [email protected] $@
$O/$B.%/Makefile: $S/%/configure $(MAKEFILE_LIST) $(deps)
chmod +x $(dir $<)/configure
mkdir -p $(dir $@)
cd $(dir $@) &&\
$($*.envvars) PATH=$(tools)$R/bin:$(PATH)\
$(dir $<)/configure $(options) $(options.$(b0))\
$($*.options) $($*.options.$(b0)) --prefix="$R" 2>&1|\
tee _configure.log\
CAFF = $(shell which caffeinate)
$O/$B.%/%.ninja.success.logc: $O/$B.%/build.ninja $(AFSCTOOL)\
$(MAKEFILE_LIST) $f
mkdir -p $(dir $@)
(cd $O/$B.$* &&\
PATH=$(tools)$(PATH)\
time $(CAFF) nice ninja -d explain -vj3 ) 2>&1 |\
$(AFSCTOOL) -cfvvv $O/$B.$*
mv -v [email protected] $@
$O/$B.%/build.ninja: $S/%/meson.build $S/%/meson/meson.py\
$(MAKEFILE_LIST)
mkdir -p $O/$B.$*
cd $O/$B.$* &&\
$($*.envvars) python3 $S/$*/meson/meson.py --prefix="$R"\
$($*.options) $(options) $S/$*
$O/$B.%/build.ninja: $S/%/meson.build $(MAKEFILE_LIST)
mkdir -p $O/$B.$*
cd $O/$B.$* &&\
$($*.envvars) PATH=$(tools)$(PATH) CFLAGS=-I$R/include python3.9\
$S/meson/meson.py setup\
--prefix="$R" $($*.options) $(options) $S/$* 2>&1|\
tee meson_.log
# --reconfigure
$O/$B.%/build.ninja: $S/%/CMakeLists.txt $(MAKEFILE_LIST)
mkdir -p $O/$B.$*
$($*.envvars) PATH=$(tools)$(PATH)\
cmake -DCMAKE_INSTALL_PREFIX="$R"\
-DCMAKE_EXPORT_COMPILE_COMMANDS=YES -D BUILD_TESTING=0\
-D CMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja $($*.options)\
-S $(HERE)/$* -B $O/$B.$*
%.makefile_in_src: %/Makefile
cd $(dir $^) && make --trace
# cd $(dir $^) && make --trace install PREFIX=$R
%/Makefile: %/configure $(MAKEFILE_LIST) $(deps)
mkdir -p $(dir $@)
cd $(dir $@) &&\
$($*.envvars) ./configure\
$($*.options) --prefix="$R" 2>&1| tee _configure.log\
%/Makefile.in: %/configure %/Makefile.am
cd $(dir $@) &&\
libtoolize -c -f &&\
automake --add-missing --copy --force-missing
%/configure: %/autogen.sh
cd $(dir $@) && NOCONFIGURE=1 bash $< 2>&1 | tee autogen.log
%/configure: %/configure.ac
cd $(dir $@) && autoreconf -iv
%/configure: %/configure.in
cd $(dir $@) && autoheader -v && aclocal --verbose && autoconf -v
clean:
rm -rfv $O/$B.elfutils $R