blob: 5750b49a04f867b2654d863fa633963d0b93b551 (
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
|
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
# Makefile fragment that implements `make config`
include config/prelude.mk
include config/exports.mk
# All configuration steps
config: ${CONFIG} ${GEN}/config.h
.PHONY: config
# Makefile fragments generated by `make config`
MKS := \
${GEN}/vars.mk \
${GEN}/flags.mk \
${GEN}/deps.mk \
${GEN}/pkgs.mk
# The main configuration file, which includes the others
${CONFIG}: ${MKS}
${MSG} "[ GEN] ${TGT}"
@printf '# %s\n' "${TGT}" >$@
@printf 'include $${GEN}/%s\n' ${MKS:${GEN}/%=%} >>$@
${VCAT} ${CONFIG}
.PHONY: ${CONFIG}
# Saves the configurable variables
${GEN}/vars.mk::
@${MKDIR} ${@D}
${MSG} "[ GEN] ${TGT}"
@printf '# %s\n' "${TGT}" >$@
@printf 'PREFIX := %s\n' "$$XPREFIX" >>$@
@printf 'MANDIR := %s\n' "$$XMANDIR" >>$@
@printf 'OS := %s\n' "$${OS:-$$(uname)}" >>$@
@printf 'CC := %s\n' "$$XCC" >>$@
@printf 'INSTALL := %s\n' "$$XINSTALL" >>$@
@printf 'MKDIR := %s\n' "$$XMKDIR" >>$@
@printf 'PKG_CONFIG := %s\n' "$$XPKG_CONFIG" >>$@
@printf 'RM := %s\n' "$$XRM" >>$@
@printf 'PKGS :=\n' >>$@
${VCAT} $@
# Sets the build flags. This depends on vars.mk and uses a recursive make so
# that the default flags can depend on variables like ${OS}.
${GEN}/flags.mk: ${GEN}/vars.mk
@+${MAKE} -sf config/flags.mk
.PHONY: ${GEN}/flags.mk
# Check for dependency generation support
${GEN}/deps.mk: ${GEN}/flags.mk
@+${MAKE} -sf config/deps.mk
.PHONY: ${GEN}/deps.mk
# External dependencies
PKG_MKS := \
${GEN}/libacl.mk \
${GEN}/libcap.mk \
${GEN}/libselinux.mk \
${GEN}/liburing.mk \
${GEN}/oniguruma.mk
# Auto-detect dependencies and their build flags
${GEN}/pkgs.mk: ${PKG_MKS}
@printf '# %s\n' "${TGT}" >$@
@printf 'include $${GEN}/%s\n' ${.ALLSRC:${GEN}/%=%} >>$@
@+${MAKE} -sf config/pkgs.mk
.PHONY: ${GEN}/pkgs.mk
# Auto-detect dependencies
${PKG_MKS}: ${GEN}/flags.mk
@+${MAKE} -sf config/pkg.mk TARGET=$@
.PHONY: ${PKG_MKS}
# Compile-time feature detection
${GEN}/config.h: ${CONFIG}
@+${MAKE} -sf config/header.mk $@
.PHONY: ${GEN}/config.h
|