summaryrefslogtreecommitdiffstats
path: root/config/header.mk
blob: 7fd2f78cc5adf4bd73663fc8e2fa0fd5e52263ae (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}/acl-get-entry.h \
    ${GEN}/acl-get-file.h \
    ${GEN}/acl-get-tag-type.h \
    ${GEN}/acl-is-trivial-np.h \
    ${GEN}/acl-trivial.h \
    ${GEN}/aligned-alloc.h \
    ${GEN}/confstr.h \
    ${GEN}/extattr-get-file.h \
    ${GEN}/extattr-get-link.h \
    ${GEN}/extattr-list-file.h \
    ${GEN}/extattr-list-link.h \
    ${GEN}/fdclosedir.h \
    ${GEN}/getdents.h \
    ${GEN}/getdents64.h \
    ${GEN}/getdents64-syscall.h \
    ${GEN}/getprogname.h \
    ${GEN}/getprogname-gnu.h \
    ${GEN}/max-align-t.h \
    ${GEN}/pipe2.h \
    ${GEN}/posix-spawn-addfchdir.h \
    ${GEN}/posix-spawn-addfchdir-np.h \
    ${GEN}/st-acmtim.h \
    ${GEN}/st-acmtimespec.h \
    ${GEN}/st-birthtim.h \
    ${GEN}/st-birthtimespec.h \
    ${GEN}/st-flags.h \
    ${GEN}/statx.h \
    ${GEN}/statx-syscall.h \
    ${GEN}/strerror-l.h \
    ${GEN}/strerror-r-gnu.h \
    ${GEN}/strerror-r-posix.h \
    ${GEN}/tm-gmtoff.h \
    ${GEN}/uselocale.h

${GEN}/config.h: ${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
	${RM} ${.ALLSRC} ${.ALLSRC:%=%.log}
	${VCAT} $@
.PHONY: ${GEN}/config.h

# The C source file to attempt to compile
CSRC = ${@:${GEN}/%.h=config/%.c}

${HEADERS}::
	config/cc-define.sh ${CSRC} >$@ 2>$@.log
	if ! [ "${IS_V}" ]; then \
	    if grep -q 'true$$' $@; then \
	        printf '[ CC ] %-${MSG_WIDTH}s  ✔\n' ${CSRC}; \
	    else \
	        printf '[ CC ] %-${MSG_WIDTH}s  ✘\n' ${CSRC}; \
	    fi; \
	fi