summaryrefslogtreecommitdiffstats
path: root/config/header.mk
blob: 50ad5e8f5fc94a31baa3bff6fa8bcede562a32c8 (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
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD

# Makefile that generates gen/config.h

include config/prelude.mk
include ${GEN}/config.mk
include config/exports.mk

# All header fragments we generate
HEADERS := \
    ${GEN}/has/acl-get-entry.h \
    ${GEN}/has/acl-get-file.h \
    ${GEN}/has/acl-get-tag-type.h \
    ${GEN}/has/acl-is-trivial-np.h \
    ${GEN}/has/acl-trivial.h \
    ${GEN}/has/aligned-alloc.h \
    ${GEN}/has/confstr.h \
    ${GEN}/has/extattr-get-file.h \
    ${GEN}/has/extattr-get-link.h \
    ${GEN}/has/extattr-list-file.h \
    ${GEN}/has/extattr-list-link.h \
    ${GEN}/has/fdclosedir.h \
    ${GEN}/has/getdents.h \
    ${GEN}/has/getdents64.h \
    ${GEN}/has/getdents64-syscall.h \
    ${GEN}/has/getprogname.h \
    ${GEN}/has/getprogname-gnu.h \
    ${GEN}/has/max-align-t.h \
    ${GEN}/has/pipe2.h \
    ${GEN}/has/posix-spawn-addfchdir.h \
    ${GEN}/has/posix-spawn-addfchdir-np.h \
    ${GEN}/has/st-acmtim.h \
    ${GEN}/has/st-acmtimespec.h \
    ${GEN}/has/st-birthtim.h \
    ${GEN}/has/st-birthtimespec.h \
    ${GEN}/has/st-flags.h \
    ${GEN}/has/statx.h \
    ${GEN}/has/statx-syscall.h \
    ${GEN}/has/strerror-l.h \
    ${GEN}/has/strerror-r-gnu.h \
    ${GEN}/has/strerror-r-posix.h \
    ${GEN}/has/tm-gmtoff.h \
    ${GEN}/has/uselocale.h

# Previously generated by pkgs.mk
PKG_HEADERS := ${ALL_PKGS:%=${GEN}/use/%.h}

${GEN}/config.h: ${PKG_HEADERS} ${HEADERS}
	${MSG} "[ GEN] ${TGT}"
	printf '// %s\n' "${TGT}" >$@
	printf '#ifndef BFS_CONFIG_H\n' >>$@
	printf '#define BFS_CONFIG_H\n' >>$@
	cat ${.ALLSRC} >>$@
	printf '#endif // BFS_CONFIG_H\n' >>$@
	cat ${.ALLSRC:%=%.log} >$@.log
	${VCAT} $@
.PHONY: ${GEN}/config.h

# The short name of the config test
SLUG = ${@:${GEN}/%.h=%}

${HEADERS}::
	${MKDIR} ${@D}
	if config/define-if.sh ${SLUG} config/cc.sh config/${SLUG}.c >$@ 2>$@.log; then \
	    test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s  ✔\n' ${SLUG}.c; \
	else \
	    test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s  ✘\n' ${SLUG}.c; \
	fi