diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-04-26 17:42:44 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-04-26 17:43:54 -0400 |
commit | e061b6da5ee46a334169d4e6a52e49857ae22f55 (patch) | |
tree | 54be48f77a01ef3dce27e2e7df812e0846ddcd12 /config | |
parent | 83dd04452498408c1d46b7282ed08e9f5a1e76a8 (diff) | |
download | bfs-e061b6da5ee46a334169d4e6a52e49857ae22f55.tar.xz |
config: Move .c files into config/{use,has} subdirectories
Diffstat (limited to 'config')
-rwxr-xr-x | config/define-if.sh (renamed from config/cc-define.sh) | 9 | ||||
-rw-r--r-- | config/has/acl-get-entry.c (renamed from config/acl-get-entry.c) | 0 | ||||
-rw-r--r-- | config/has/acl-get-file.c (renamed from config/acl-get-file.c) | 0 | ||||
-rw-r--r-- | config/has/acl-get-tag-type.c (renamed from config/acl-get-tag-type.c) | 0 | ||||
-rw-r--r-- | config/has/acl-is-trivial-np.c (renamed from config/acl-is-trivial-np.c) | 0 | ||||
-rw-r--r-- | config/has/acl-trivial.c (renamed from config/acl-trivial.c) | 0 | ||||
-rw-r--r-- | config/has/aligned-alloc.c (renamed from config/aligned-alloc.c) | 0 | ||||
-rw-r--r-- | config/has/confstr.c (renamed from config/confstr.c) | 0 | ||||
-rw-r--r-- | config/has/extattr-get-file.c (renamed from config/extattr-get-file.c) | 0 | ||||
-rw-r--r-- | config/has/extattr-get-link.c (renamed from config/extattr-get-link.c) | 0 | ||||
-rw-r--r-- | config/has/extattr-list-file.c (renamed from config/extattr-list-file.c) | 0 | ||||
-rw-r--r-- | config/has/extattr-list-link.c (renamed from config/extattr-list-link.c) | 0 | ||||
-rw-r--r-- | config/has/fdclosedir.c (renamed from config/fdclosedir.c) | 0 | ||||
-rw-r--r-- | config/has/getdents.c (renamed from config/getdents.c) | 0 | ||||
-rw-r--r-- | config/has/getdents64-syscall.c (renamed from config/getdents64-syscall.c) | 0 | ||||
-rw-r--r-- | config/has/getdents64.c (renamed from config/getdents64.c) | 0 | ||||
-rw-r--r-- | config/has/getprogname-gnu.c (renamed from config/getprogname-gnu.c) | 0 | ||||
-rw-r--r-- | config/has/getprogname.c (renamed from config/getprogname.c) | 0 | ||||
-rw-r--r-- | config/has/max-align-t.c (renamed from config/max-align-t.c) | 0 | ||||
-rw-r--r-- | config/has/pipe2.c (renamed from config/pipe2.c) | 0 | ||||
-rw-r--r-- | config/has/posix-spawn-addfchdir-np.c (renamed from config/posix-spawn-addfchdir-np.c) | 0 | ||||
-rw-r--r-- | config/has/posix-spawn-addfchdir.c (renamed from config/posix-spawn-addfchdir.c) | 0 | ||||
-rw-r--r-- | config/has/st-acmtim.c (renamed from config/st-acmtim.c) | 0 | ||||
-rw-r--r-- | config/has/st-acmtimespec.c (renamed from config/st-acmtimespec.c) | 0 | ||||
-rw-r--r-- | config/has/st-birthtim.c (renamed from config/st-birthtim.c) | 0 | ||||
-rw-r--r-- | config/has/st-birthtimespec.c (renamed from config/st-birthtimespec.c) | 0 | ||||
-rw-r--r-- | config/has/st-flags.c (renamed from config/st-flags.c) | 0 | ||||
-rw-r--r-- | config/has/statx-syscall.c (renamed from config/statx-syscall.c) | 0 | ||||
-rw-r--r-- | config/has/statx.c (renamed from config/statx.c) | 0 | ||||
-rw-r--r-- | config/has/strerror-l.c (renamed from config/strerror-l.c) | 0 | ||||
-rw-r--r-- | config/has/strerror-r-gnu.c (renamed from config/strerror-r-gnu.c) | 0 | ||||
-rw-r--r-- | config/has/strerror-r-posix.c (renamed from config/strerror-r-posix.c) | 0 | ||||
-rw-r--r-- | config/has/tm-gmtoff.c (renamed from config/tm-gmtoff.c) | 0 | ||||
-rw-r--r-- | config/has/uselocale.c (renamed from config/uselocale.c) | 0 | ||||
-rw-r--r-- | config/header.mk | 89 | ||||
-rwxr-xr-x | config/pkgconf.sh | 2 | ||||
-rw-r--r-- | config/pkgs.mk | 28 | ||||
-rw-r--r-- | config/prelude.mk | 10 | ||||
-rw-r--r-- | config/use/libacl.c (renamed from config/libacl.c) | 0 | ||||
-rw-r--r-- | config/use/libcap.c (renamed from config/libcap.c) | 0 | ||||
-rw-r--r-- | config/use/libselinux.c (renamed from config/libselinux.c) | 0 | ||||
-rw-r--r-- | config/use/liburing.c (renamed from config/liburing.c) | 0 | ||||
-rw-r--r-- | config/use/oniguruma.c (renamed from config/oniguruma.c) | 0 |
43 files changed, 70 insertions, 68 deletions
diff --git a/config/cc-define.sh b/config/define-if.sh index edb5c87..059c1ac 100755 --- a/config/cc-define.sh +++ b/config/define-if.sh @@ -3,17 +3,18 @@ # Copyright © Tavian Barnes <tavianator@tavianator.com> # SPDX-License-Identifier: 0BSD -# Output a C preprocessor definition based on whether a C source file could be -# compiled successfully +# Output a C preprocessor definition based on whether a command succeeds set -eu SLUG="${1#config/}" SLUG="${SLUG%.c}" -MACRO="BFS_HAS_$(printf '%s' "$SLUG" | tr 'a-z-' 'A-Z_')" +MACRO="BFS_$(printf '%s' "$SLUG" | tr '/a-z-' '_A-Z_')" +shift -if config/cc.sh "$1"; then +if "$@"; then printf '#define %s true\n' "$MACRO" else printf '#define %s false\n' "$MACRO" + exit 1 fi diff --git a/config/acl-get-entry.c b/config/has/acl-get-entry.c index 3cce771..3cce771 100644 --- a/config/acl-get-entry.c +++ b/config/has/acl-get-entry.c diff --git a/config/acl-get-file.c b/config/has/acl-get-file.c index 89fbf23..89fbf23 100644 --- a/config/acl-get-file.c +++ b/config/has/acl-get-file.c diff --git a/config/acl-get-tag-type.c b/config/has/acl-get-tag-type.c index 2901956..2901956 100644 --- a/config/acl-get-tag-type.c +++ b/config/has/acl-get-tag-type.c diff --git a/config/acl-is-trivial-np.c b/config/has/acl-is-trivial-np.c index 9ca9fc7..9ca9fc7 100644 --- a/config/acl-is-trivial-np.c +++ b/config/has/acl-is-trivial-np.c diff --git a/config/acl-trivial.c b/config/has/acl-trivial.c index 7efc838..7efc838 100644 --- a/config/acl-trivial.c +++ b/config/has/acl-trivial.c diff --git a/config/aligned-alloc.c b/config/has/aligned-alloc.c index 4460038..4460038 100644 --- a/config/aligned-alloc.c +++ b/config/has/aligned-alloc.c diff --git a/config/confstr.c b/config/has/confstr.c index 58280b4..58280b4 100644 --- a/config/confstr.c +++ b/config/has/confstr.c diff --git a/config/extattr-get-file.c b/config/has/extattr-get-file.c index ac9cf96..ac9cf96 100644 --- a/config/extattr-get-file.c +++ b/config/has/extattr-get-file.c diff --git a/config/extattr-get-link.c b/config/has/extattr-get-link.c index c35be5b..c35be5b 100644 --- a/config/extattr-get-link.c +++ b/config/has/extattr-get-link.c diff --git a/config/extattr-list-file.c b/config/has/extattr-list-file.c index e68a8bb..e68a8bb 100644 --- a/config/extattr-list-file.c +++ b/config/has/extattr-list-file.c diff --git a/config/extattr-list-link.c b/config/has/extattr-list-link.c index 49f0ec2..49f0ec2 100644 --- a/config/extattr-list-link.c +++ b/config/has/extattr-list-link.c diff --git a/config/fdclosedir.c b/config/has/fdclosedir.c index f4ad1f5..f4ad1f5 100644 --- a/config/fdclosedir.c +++ b/config/has/fdclosedir.c diff --git a/config/getdents.c b/config/has/getdents.c index d0d4228..d0d4228 100644 --- a/config/getdents.c +++ b/config/has/getdents.c diff --git a/config/getdents64-syscall.c b/config/has/getdents64-syscall.c index 4838c14..4838c14 100644 --- a/config/getdents64-syscall.c +++ b/config/has/getdents64-syscall.c diff --git a/config/getdents64.c b/config/has/getdents64.c index 1abf36d..1abf36d 100644 --- a/config/getdents64.c +++ b/config/has/getdents64.c diff --git a/config/getprogname-gnu.c b/config/has/getprogname-gnu.c index 6b97c5e..6b97c5e 100644 --- a/config/getprogname-gnu.c +++ b/config/has/getprogname-gnu.c diff --git a/config/getprogname.c b/config/has/getprogname.c index 83dc8e8..83dc8e8 100644 --- a/config/getprogname.c +++ b/config/has/getprogname.c diff --git a/config/max-align-t.c b/config/has/max-align-t.c index 96165ce..96165ce 100644 --- a/config/max-align-t.c +++ b/config/has/max-align-t.c diff --git a/config/pipe2.c b/config/has/pipe2.c index 4cb43b5..4cb43b5 100644 --- a/config/pipe2.c +++ b/config/has/pipe2.c diff --git a/config/posix-spawn-addfchdir-np.c b/config/has/posix-spawn-addfchdir-np.c index b870a53..b870a53 100644 --- a/config/posix-spawn-addfchdir-np.c +++ b/config/has/posix-spawn-addfchdir-np.c diff --git a/config/posix-spawn-addfchdir.c b/config/has/posix-spawn-addfchdir.c index c52ff81..c52ff81 100644 --- a/config/posix-spawn-addfchdir.c +++ b/config/has/posix-spawn-addfchdir.c diff --git a/config/st-acmtim.c b/config/has/st-acmtim.c index d687ab0..d687ab0 100644 --- a/config/st-acmtim.c +++ b/config/has/st-acmtim.c diff --git a/config/st-acmtimespec.c b/config/has/st-acmtimespec.c index f747bc0..f747bc0 100644 --- a/config/st-acmtimespec.c +++ b/config/has/st-acmtimespec.c diff --git a/config/st-birthtim.c b/config/has/st-birthtim.c index 4964571..4964571 100644 --- a/config/st-birthtim.c +++ b/config/has/st-birthtim.c diff --git a/config/st-birthtimespec.c b/config/has/st-birthtimespec.c index 91a613f..91a613f 100644 --- a/config/st-birthtimespec.c +++ b/config/has/st-birthtimespec.c diff --git a/config/st-flags.c b/config/has/st-flags.c index b1d0c32..b1d0c32 100644 --- a/config/st-flags.c +++ b/config/has/st-flags.c diff --git a/config/statx-syscall.c b/config/has/statx-syscall.c index 87ec869..87ec869 100644 --- a/config/statx-syscall.c +++ b/config/has/statx-syscall.c diff --git a/config/statx.c b/config/has/statx.c index 65f1674..65f1674 100644 --- a/config/statx.c +++ b/config/has/statx.c diff --git a/config/strerror-l.c b/config/has/strerror-l.c index 3dcc4d7..3dcc4d7 100644 --- a/config/strerror-l.c +++ b/config/has/strerror-l.c diff --git a/config/strerror-r-gnu.c b/config/has/strerror-r-gnu.c index 26ca0ee..26ca0ee 100644 --- a/config/strerror-r-gnu.c +++ b/config/has/strerror-r-gnu.c diff --git a/config/strerror-r-posix.c b/config/has/strerror-r-posix.c index 41b2d30..41b2d30 100644 --- a/config/strerror-r-posix.c +++ b/config/has/strerror-r-posix.c diff --git a/config/tm-gmtoff.c b/config/has/tm-gmtoff.c index 543df48..543df48 100644 --- a/config/tm-gmtoff.c +++ b/config/has/tm-gmtoff.c diff --git a/config/uselocale.c b/config/has/uselocale.c index a712ff8..a712ff8 100644 --- a/config/uselocale.c +++ b/config/has/uselocale.c diff --git a/config/header.mk b/config/header.mk index ccc36d3..50ad5e8 100644 --- a/config/header.mk +++ b/config/header.mk @@ -9,62 +9,61 @@ 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}/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 -${GEN}/config.h: ${HEADERS} +# 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' >>$@ - printf '#define BFS_USE_%s true\n' $$(printf '%s\n' ${PKGS} | tr 'a-z-' 'A-Z_') >>$@ 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} +# The short name of the config test +SLUG = ${@:${GEN}/%.h=%} ${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; \ + ${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 diff --git a/config/pkgconf.sh b/config/pkgconf.sh index 2fb2f1e..365ed61 100755 --- a/config/pkgconf.sh +++ b/config/pkgconf.sh @@ -41,7 +41,7 @@ if [ -z "$MODE" ]; then CFLAGS=$("$0" --cflags "$LIB") || exit 1 LDFLAGS=$("$0" --ldflags "$LIB") || exit 1 LDLIBS=$("$0" --ldlibs "$LIB") || exit 1 - config/cc.sh $CFLAGS $LDFLAGS config/$LIB.c $LDLIBS || exit 1 + config/cc.sh $CFLAGS $LDFLAGS config/use/$LIB.c $LDLIBS || exit 1 done fi diff --git a/config/pkgs.mk b/config/pkgs.mk index 2c100ab..898f262 100644 --- a/config/pkgs.mk +++ b/config/pkgs.mk @@ -8,15 +8,9 @@ include ${GEN}/vars.mk include ${GEN}/flags.mk include config/exports.mk -# External dependencies -USE_PKGS := \ - ${GEN}/libacl.use \ - ${GEN}/libcap.use \ - ${GEN}/libselinux.use \ - ${GEN}/liburing.use \ - ${GEN}/oniguruma.use +HEADERS := ${ALL_PKGS:%=${GEN}/use/%.h} -${GEN}/pkgs.mk: ${USE_PKGS} +${GEN}/pkgs.mk: ${HEADERS} ${MSG} "[ GEN] ${TGT}" printf '# %s\n' "${TGT}" >$@ gen() { \ @@ -25,18 +19,18 @@ ${GEN}/pkgs.mk: ${USE_PKGS} printf 'LDFLAGS += %s\n' "$$(config/pkgconf.sh --ldflags "$$@")"; \ printf 'LDLIBS := %s $${LDLIBS}\n' "$$(config/pkgconf.sh --ldlibs "$$@")"; \ }; \ - gen $$(cat ${.ALLSRC}) >>$@ + gen $$(grep -l ' true$$' ${.ALLSRC} | sed 's|.*/\(.*\)\.h|\1|') >>$@ ${VCAT} $@ + .PHONY: ${GEN}/pkgs.mk -# Convert ${GEN}/foo.use to foo -PKG = ${@:${GEN}/%.use=%} +# Convert ${GEN}/use/foo.h to foo +PKG = ${@:${GEN}/use/%.h=%} -${USE_PKGS}:: - if config/pkgconf.sh ${PKG} 2>$@.log; then \ - printf '%s\n' ${PKG} >$@; \ - test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s ✔\n' config/${PKG}.c; \ +${HEADERS}:: + ${MKDIR} ${@D} + if config/define-if.sh use/${PKG} config/pkgconf.sh ${PKG} >$@ 2>$@.log; then \ + test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s ✔\n' use/${PKG}.c; \ else \ - : >$@; \ - test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s ✘\n' config/${PKG}.c; \ + test "${IS_V}" || printf '[ CC ] %-${MSG_WIDTH}s ✘\n' use/${PKG}.c; \ fi diff --git a/config/prelude.mk b/config/prelude.mk index e1e7a4d..6b0b649 100644 --- a/config/prelude.mk +++ b/config/prelude.mk @@ -110,13 +110,21 @@ MSG = @msg() { \ msg # Maximum width of a short message, to align the ✔/✘ -MSG_WIDTH := 33 +MSG_WIDTH := 30 # cat a file if V=1 VCAT,y := @cat VCAT, := @: VCAT := ${VCAT,${IS_V}} +# All external dependencies +ALL_PKGS := \ + libacl \ + libcap \ + libselinux \ + liburing \ + oniguruma + # List all object files here, as they're needed by both `make config` and `make` # All object files except the entry point diff --git a/config/libacl.c b/config/use/libacl.c index de1fe50..de1fe50 100644 --- a/config/libacl.c +++ b/config/use/libacl.c diff --git a/config/libcap.c b/config/use/libcap.c index 58e832c..58e832c 100644 --- a/config/libcap.c +++ b/config/use/libcap.c diff --git a/config/libselinux.c b/config/use/libselinux.c index bca409d..bca409d 100644 --- a/config/libselinux.c +++ b/config/use/libselinux.c diff --git a/config/liburing.c b/config/use/liburing.c index bea499a..bea499a 100644 --- a/config/liburing.c +++ b/config/use/liburing.c diff --git a/config/oniguruma.c b/config/use/oniguruma.c index cb17596..cb17596 100644 --- a/config/oniguruma.c +++ b/config/use/oniguruma.c |