diff options
Diffstat (limited to 'build')
-rw-r--r-- | build/auto.mk | 54 | ||||
-rwxr-xr-x | build/cc.sh | 21 | ||||
-rw-r--r-- | build/config.mk | 27 | ||||
-rw-r--r-- | build/exports.mk | 5 | ||||
-rwxr-xr-x | build/flags-if.sh | 85 | ||||
-rw-r--r-- | build/flags.mk | 82 | ||||
-rw-r--r-- | build/flags/Wundef-prefix.c (renamed from build/has/aligned-alloc.c) | 5 | ||||
-rw-r--r-- | build/flags/pthread.c | 8 | ||||
-rw-r--r-- | build/flags/std.c | 12 | ||||
-rw-r--r-- | build/has/dprintf.c | 8 | ||||
-rw-r--r-- | build/has/io-uring-max-workers.c | 11 | ||||
-rw-r--r-- | build/has/pragma-nounroll.c | 10 | ||||
-rw-r--r-- | build/has/pthread-set-name-np.c | 10 | ||||
-rw-r--r-- | build/has/pthread-setname-np.c | 8 | ||||
-rw-r--r-- | build/has/sched-getaffinity.c | 9 | ||||
-rw-r--r-- | build/has/tcsetwinsize.c | 9 | ||||
-rw-r--r-- | build/has/timer-create.c | 9 | ||||
-rw-r--r-- | build/header.mk | 19 | ||||
-rw-r--r-- | build/pkgs.mk | 7 | ||||
-rw-r--r-- | build/prelude.mk | 21 | ||||
-rwxr-xr-x | build/version.sh | 2 |
21 files changed, 300 insertions, 122 deletions
diff --git a/build/auto.mk b/build/auto.mk new file mode 100644 index 0000000..9cdf9e3 --- /dev/null +++ b/build/auto.mk @@ -0,0 +1,54 @@ +# Copyright © Tavian Barnes <tavianator@tavianator.com> +# SPDX-License-Identifier: 0BSD + +# Makefile that generates gen/auto.mk + +include build/prelude.mk +include gen/vars.mk +include gen/early.mk +include gen/late.mk +include build/exports.mk + +# Auto-detected flags +AUTO_FLAGS := \ + gen/flags/std.mk \ + gen/flags/bind-now.mk \ + gen/flags/deps.mk \ + gen/flags/pthread.mk \ + gen/flags/Wformat.mk \ + gen/flags/Wimplicit-fallthrough.mk \ + gen/flags/Wimplicit.mk \ + gen/flags/Wmissing-decls.mk \ + gen/flags/Wmissing-var-decls.mk \ + gen/flags/Wshadow.mk \ + gen/flags/Wsign-compare.mk \ + gen/flags/Wstrict-prototypes.mk \ + gen/flags/Wundef-prefix.mk + +gen/auto.mk: ${AUTO_FLAGS} + ${MSG} "[ GEN] $@" + @printf '# %s\n' "$@" >$@ + @cat $^ >>$@ + @cat ${^:%=%.log} >gen/flags.log + ${VCAT} $@ +.PHONY: gen/auto.mk + +# Check that the C compiler works at all +cc:: + @build/cc.sh -q build/empty.c -o gen/.cc.out; \ + ret=$$?; \ + build/msg-if.sh "[ CC ] build/empty.c" test $$ret -eq 0; \ + exit $$ret + +# The short name of the config test +SLUG = ${@:gen/%.mk=%} +# The source file to build +CSRC = build/${SLUG}.c +# The hidden output file name +OUT = ${SLUG:flags/%=gen/flags/.%.out} + +${AUTO_FLAGS}: cc + @${MKDIR} ${@D} + @build/flags-if.sh ${CSRC} -o ${OUT} >$@ 2>$@.log; \ + build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 +.PHONY: ${AUTO_FLAGS} diff --git a/build/cc.sh b/build/cc.sh index e1d2b0b..b6f38b5 100755 --- a/build/cc.sh +++ b/build/cc.sh @@ -9,26 +9,11 @@ set -eu -QUIET= +# Without -q, print the executed command for config.log if [ "$1" = "-q" ]; then - QUIET=y shift -fi - -# Source files can specify their own flags with lines like -# -# /// _CFLAGS += -Wmissing-variable-declarations -# -# which will be added to the makefile on success, or lines like -# -# /// -Werror -# -# which are just used for the current file. -EXTRA_FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p;}' "$1") - -# Without -q, print the executed command for config.log -if [ -z "$QUIET" ]; then +else set -x fi -$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $EXTRA_FLAGS $XLDLIBS +$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS diff --git a/build/config.mk b/build/config.mk index 6296168..be57678 100644 --- a/build/config.mk +++ b/build/config.mk @@ -7,21 +7,23 @@ include build/prelude.mk include build/exports.mk # All configuration steps -config: gen/config.mk +config: gen/config.mk gen/config.h .PHONY: config -# Makefile fragments generated by `./configure` +# All the generated makefile fragments MKS := \ gen/vars.mk \ - gen/flags.mk \ - gen/pkgs.mk + gen/early.mk \ + gen/auto.mk \ + gen/pkgs.mk \ + gen/late.mk # The main configuration file, which includes the others -gen/config.mk: ${MKS} gen/config.h +gen/config.mk: ${MKS} ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ - @printf 'include %s\n' ${MKS} >>$@ - ${VCAT} gen/config.mk + @printf 'include %s\n' $^ >>$@ + ${VCAT} $@ .PHONY: gen/config.mk # Saves the configurable variables @@ -42,16 +44,17 @@ gen/vars.mk:: # 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 +gen/early.mk gen/late.mk: gen/vars.mk @+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/flags.mk $@ -.PHONY: gen/flags.mk + +# Auto-detected build flags +gen/auto.mk: gen/early.mk gen/late.mk + @+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/auto.mk $@ # Auto-detect dependencies and their build flags -gen/pkgs.mk: gen/flags.mk +gen/pkgs.mk: gen/auto.mk @+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/pkgs.mk $@ -.PHONY: gen/pkgs.mk # Compile-time feature detection gen/config.h: gen/pkgs.mk @+XMAKEFLAGS="$$MAKEFLAGS" ${MAKE} -sf build/header.mk $@ -.PHONY: gen/config.h diff --git a/build/exports.mk b/build/exports.mk index 913a1aa..a616c59 100644 --- a/build/exports.mk +++ b/build/exports.mk @@ -17,4 +17,9 @@ export XCFLAGS=${_CFLAGS} export XLDFLAGS=${_LDFLAGS} export XLDLIBS=${_LDLIBS} +export CONF_CPPFLAGS=${CPPFLAGS} ${EXTRA_CPPFLAGS} +export CONF_CFLAGS=${CFLAGS} ${EXTRA_CFLAGS} +export CONF_LDFLAGS=${LDFLAGS} ${EXTRA_LDFLAGS} +export CONF_LDLIBS=${LDLIBS} ${EXTRA_LDLIBS} + export XNOLIBS=${NOLIBS} diff --git a/build/flags-if.sh b/build/flags-if.sh index 81eb345..f7b4f33 100755 --- a/build/flags-if.sh +++ b/build/flags-if.sh @@ -3,26 +3,87 @@ # Copyright © Tavian Barnes <tavianator@tavianator.com> # SPDX-License-Identifier: 0BSD -# Add flags to a makefile if a build succeeds +# Add flags to a makefile if a build succeeds. Source files can specify their +# own flags with lines like +# +# /// _CFLAGS += -Wmissing-variable-declarations +# +# which will be added to the makefile on success, or lines like +# +# /// -Werror +# +# which are just used for the current file. Lines like +# +# /// --- +# +# separate groups of flags, to try multiple ways to achieve something, e.g. +# +# /// CFLAGS += -pthread +# /// --- +# /// LDLIBS += -lpthread set -eu -build/cc.sh "$@" || exit 1 +# Any new flags we're using +FLAGS="" +# Any new makefile lines we're printing +OUTPUT="" -# If the build succeeded, print any lines like -# -# /// _CFLAGS += -foo -# -# (unless they're already set) -OLD_FLAGS="$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS" +# Check the existing flags so we don't add duplicates +OLD_FLAGS=" $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS " + +add_flag() { + case "$1" in + -std=*) + # Don't overwrite -std=* flags + case "$OLD_FLAGS" in + *\ -std=*) + return 1 + ;; + esac + ;; + *) + if [ "${OLD_FLAGS#* $1 }" != "$OLD_FLAGS" ]; then + return 1 + fi + ;; + esac + + FLAGS="${FLAGS}${FLAGS:+ }$1" +} + +try_cc() { + build/cc.sh "$@" $FLAGS || return $? + printf '%s' "$OUTPUT" + exit +} while IFS="" read -r line; do case "$line" in - ///*=*) - flag="${line#*= }" - if [ "${OLD_FLAGS#*"$flag"}" = "$OLD_FLAGS" ]; then - printf '%s\n' "${line#/// }" + "/// "*) + line="${line#/// }" + ;; + *) + continue + ;; + esac + + case "$line" in + ---) + try_cc "$@" || : + FLAGS= + OUTPUT= + ;; + *=*) + if add_flag "${line#*= }"; then + OUTPUT="${OUTPUT}${line} +" fi ;; + *) + add_flag "$line" || : + ;; esac done <"$1" + +try_cc "$@" diff --git a/build/flags.mk b/build/flags.mk index 1421ce6..c64a80b 100644 --- a/build/flags.mk +++ b/build/flags.mk @@ -1,21 +1,23 @@ # Copyright © Tavian Barnes <tavianator@tavianator.com> # SPDX-License-Identifier: 0BSD -# Makefile that generates gen/flags.mk +# Makefile that generates gen/{early,late}.mk include build/prelude.mk include gen/vars.mk # Internal flags _CPPFLAGS := -Isrc -Igen -include src/prelude.h -_CFLAGS := -std=c17 -pthread +_CFLAGS := _LDFLAGS := _LDLIBS := # Platform-specific system libraries LDLIBS,DragonFly := -lposix1e +LDLIBS,FreeBSD := -lrt LDLIBS,Linux := -lrt LDLIBS,NetBSD := -lutil +LDLIBS,QNX := -lregex -lsocket LDLIBS,SunOS := -lsec -lsocket -lnsl _LDLIBS += ${LDLIBS,${OS}} @@ -24,34 +26,39 @@ _ASAN := ${TRUTHY,${ASAN}} _LSAN := ${TRUTHY,${LSAN}} _MSAN := ${TRUTHY,${MSAN}} _TSAN := ${TRUTHY,${TSAN}} +_TYSAN := ${TRUTHY,${TYSAN}} _UBSAN := ${TRUTHY,${UBSAN}} _GCOV := ${TRUTHY,${GCOV}} _LINT := ${TRUTHY,${LINT}} _RELEASE := ${TRUTHY,${RELEASE}} +LTO ?= ${RELEASE} +_LTO := ${TRUTHY,${LTO}} + ASAN_CFLAGS,y := -fsanitize=address LSAN_CFLAGS,y := -fsanitize=leak MSAN_CFLAGS,y := -fsanitize=memory -fsanitize-memory-track-origins TSAN_CFLAGS,y := -fsanitize=thread +TYSAN_CFLAGS,y := -fsanitize=type UBSAN_CFLAGS,y := -fsanitize=undefined _CFLAGS += ${ASAN_CFLAGS,${_ASAN}} _CFLAGS += ${LSAN_CFLAGS,${_LSAN}} _CFLAGS += ${MSAN_CFLAGS,${_MSAN}} _CFLAGS += ${TSAN_CFLAGS,${_TSAN}} +_CFLAGS += ${TYSAN_CFLAGS,${_TYSAN}} _CFLAGS += ${UBSAN_CFLAGS,${_UBSAN}} SAN_CFLAGS,y := -fno-sanitize-recover=all -INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_UBSAN}} +INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_TYSAN}${_UBSAN}} SAN := ${NOT,${INSANE}} _CFLAGS += ${SAN_CFLAGS,${SAN}} -# MSAN and TSAN both need all code to be instrumented -YESLIBS := ${NOT,${_MSAN}${_TSAN}} +# MSan, TSan, and TySan need all code to be instrumented +YESLIBS := ${NOT,${_MSAN}${_TSAN}${_TYSAN}} NOLIBS ?= ${NOT,${YESLIBS}} -# gcov only intercepts fork()/exec() with -std=gnu* -GCOV_CFLAGS,y := -std=gnu17 --coverage +GCOV_CFLAGS,y := --coverage _CFLAGS += ${GCOV_CFLAGS,${_GCOV}} LINT_CPPFLAGS,y := -D_FORTIFY_SOURCE=3 -DBFS_LINT @@ -61,37 +68,21 @@ _CPPFLAGS += ${LINT_CPPFLAGS,${_LINT}} _CFLAGS += ${LINT_CFLAGS,${_LINT}} RELEASE_CPPFLAGS,y := -DNDEBUG -RELEASE_CFLAGS,y := -O3 -flto=auto +RELEASE_CFLAGS,y := -O3 _CPPFLAGS += ${RELEASE_CPPFLAGS,${_RELEASE}} _CFLAGS += ${RELEASE_CFLAGS,${_RELEASE}} +LTO_CFLAGS,y := -flto=auto +_CFLAGS += ${LTO_CFLAGS,${_LTO}} + # Configurable flags CFLAGS ?= -g -Wall -# Add the configurable flags last so they can override ours -_CPPFLAGS += ${CPPFLAGS} ${EXTRA_CPPFLAGS} -_CFLAGS += ${CFLAGS} ${EXTRA_CFLAGS} -_LDFLAGS += ${LDFLAGS} ${EXTRA_LDFLAGS} -# (except LDLIBS, as earlier libs override later ones) -_LDLIBS := ${LDLIBS} ${EXTRA_LDLIBS} ${_LDLIBS} - include build/exports.mk -# Conditionally-supported flags -AUTO_FLAGS := \ - gen/flags/Wformat.mk \ - gen/flags/Wimplicit-fallthrough.mk \ - gen/flags/Wimplicit.mk \ - gen/flags/Wmissing-decls.mk \ - gen/flags/Wmissing-var-decls.mk \ - gen/flags/Wshadow.mk \ - gen/flags/Wsign-compare.mk \ - gen/flags/Wstrict-prototypes.mk \ - gen/flags/bind-now.mk \ - gen/flags/deps.mk - -gen/flags.mk: ${AUTO_FLAGS} +# Saves the internal flags +gen/early.mk:: ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ @printf '_CPPFLAGS := %s\n' "$$XCPPFLAGS" >>$@ @@ -100,27 +91,14 @@ gen/flags.mk: ${AUTO_FLAGS} @printf '_LDLIBS := %s\n' "$$XLDLIBS" >>$@ @printf 'NOLIBS := %s\n' "$$XNOLIBS" >>$@ @test "${OS}-${SAN}" != FreeBSD-y || printf 'POSTLINK = elfctl -e +noaslr $$@\n' >>$@ - @cat ${.ALLSRC} >>$@ - @cat ${.ALLSRC:%=%.log} >gen/flags.log ${VCAT} $@ -.PHONY: gen/flags.mk - -# Check that the C compiler works at all -cc:: - @build/cc.sh -q build/empty.c -o gen/.cc.out; \ - ret=$$?; \ - build/msg-if.sh "[ CC ] build/empty.c" test $$ret -eq 0; \ - exit $$ret - -# The short name of the config test -SLUG = ${@:gen/%.mk=%} -# The source file to build -CSRC = build/${SLUG}.c -# The hidden output file name -OUT = ${SLUG:flags/%=gen/flags/.%.out} - -${AUTO_FLAGS}: cc - @${MKDIR} ${@D} - @build/flags-if.sh ${CSRC} -o ${OUT} >$@ 2>$@.log; \ - build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 -.PHONY: ${AUTO_FLAGS} + +# Save explicit flags from ./configure separately so they can override the rest +gen/late.mk:: + ${MSG} "[ GEN] $@" + @printf '# %s\n' "$@" >$@ + @printf '_CPPFLAGS += %s\n' "$$CONF_CPPFLAGS" >>$@ + @printf '_CFLAGS += %s\n' "$$CONF_CFLAGS" >>$@ + @printf '_LDFLAGS += %s\n' "$$CONF_LDFLAGS" >>$@ + @printf '_LDLIBS := %s $${_LDLIBS}\n' "$$CONF_LDLIBS" >>$@ + ${VCAT} $@ diff --git a/build/has/aligned-alloc.c b/build/flags/Wundef-prefix.c index 4460038..3eaf82b 100644 --- a/build/has/aligned-alloc.c +++ b/build/flags/Wundef-prefix.c @@ -1,8 +1,9 @@ // Copyright © Tavian Barnes <tavianator@tavianator.com> // SPDX-License-Identifier: 0BSD -#include <stdlib.h> +/// _CPPFLAGS += -Wundef-prefix=BFS_ +/// -Werror int main(void) { - return !aligned_alloc(_Alignof(void *), sizeof(void *)); + return 0; } diff --git a/build/flags/pthread.c b/build/flags/pthread.c new file mode 100644 index 0000000..db09aa4 --- /dev/null +++ b/build/flags/pthread.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +/// _CFLAGS += -pthread + +int main(void) { + return 0; +} diff --git a/build/flags/std.c b/build/flags/std.c new file mode 100644 index 0000000..6030d1f --- /dev/null +++ b/build/flags/std.c @@ -0,0 +1,12 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +/// _CFLAGS += -std=c23 +/// --- +/// _CFLAGS += -std=c2x +/// --- +/// _CFLAGS += -std=c17 + +int main(void) { + return 0; +} diff --git a/build/has/dprintf.c b/build/has/dprintf.c new file mode 100644 index 0000000..c206fa3 --- /dev/null +++ b/build/has/dprintf.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <stdio.h> + +int main(void) { + return dprintf(1, "%s\n", "Hello world!"); +} diff --git a/build/has/io-uring-max-workers.c b/build/has/io-uring-max-workers.c new file mode 100644 index 0000000..34ab5b7 --- /dev/null +++ b/build/has/io-uring-max-workers.c @@ -0,0 +1,11 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <liburing.h> + +int main(void) { + struct io_uring ring; + io_uring_queue_init(1, &ring, 0); + unsigned int values[] = {0, 0}; + return io_uring_register_iowq_max_workers(&ring, values); +} diff --git a/build/has/pragma-nounroll.c b/build/has/pragma-nounroll.c new file mode 100644 index 0000000..2bdae14 --- /dev/null +++ b/build/has/pragma-nounroll.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +/// -Werror + +int main(void) { +#pragma nounroll + for (int i = 0; i < 100; ++i); + return 0; +} diff --git a/build/has/pthread-set-name-np.c b/build/has/pthread-set-name-np.c new file mode 100644 index 0000000..324aab9 --- /dev/null +++ b/build/has/pthread-set-name-np.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <pthread.h> +#include <pthread_np.h> + +int main(void) { + pthread_set_name_np(pthread_self(), "name"); + return 0; +} diff --git a/build/has/pthread-setname-np.c b/build/has/pthread-setname-np.c new file mode 100644 index 0000000..a3b94c1 --- /dev/null +++ b/build/has/pthread-setname-np.c @@ -0,0 +1,8 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <pthread.h> + +int main(void) { + return pthread_setname_np(pthread_self(), "name"); +} diff --git a/build/has/sched-getaffinity.c b/build/has/sched-getaffinity.c new file mode 100644 index 0000000..6f8fd98 --- /dev/null +++ b/build/has/sched-getaffinity.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <sched.h> + +int main(void) { + cpu_set_t set; + return sched_getaffinity(0, sizeof(set), &set); +} diff --git a/build/has/tcsetwinsize.c b/build/has/tcsetwinsize.c new file mode 100644 index 0000000..6717415 --- /dev/null +++ b/build/has/tcsetwinsize.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <termios.h> + +int main(void) { + const struct winsize ws = {0}; + return tcsetwinsize(0, &ws); +} diff --git a/build/has/timer-create.c b/build/has/timer-create.c new file mode 100644 index 0000000..d5354c3 --- /dev/null +++ b/build/has/timer-create.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes <tavianator@tavianator.com> +// SPDX-License-Identifier: 0BSD + +#include <time.h> + +int main(void) { + timer_t timer; + return timer_create(CLOCK_REALTIME, NULL, &timer); +} diff --git a/build/header.mk b/build/header.mk index abec00f..ae52c12 100644 --- a/build/header.mk +++ b/build/header.mk @@ -5,8 +5,10 @@ include build/prelude.mk include gen/vars.mk -include gen/flags.mk +include gen/early.mk +include gen/auto.mk include gen/pkgs.mk +include gen/late.mk include build/exports.mk # All header fragments we generate @@ -18,9 +20,9 @@ HEADERS := \ 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/builtin-riscv-pause.h \ gen/has/confstr.h \ + gen/has/dprintf.h \ gen/has/extattr-get-file.h \ gen/has/extattr-get-link.h \ gen/has/extattr-list-file.h \ @@ -34,10 +36,15 @@ HEADERS := \ gen/has/getmntinfo.h \ gen/has/getprogname-gnu.h \ gen/has/getprogname.h \ + gen/has/io-uring-max-workers.h \ gen/has/pipe2.h \ + gen/has/pragma-nounroll.h \ gen/has/posix-getdents.h \ gen/has/posix-spawn-addfchdir-np.h \ gen/has/posix-spawn-addfchdir.h \ + gen/has/pthread-set-name-np.h \ + gen/has/pthread-setname-np.h \ + gen/has/sched-getaffinity.h \ gen/has/st-acmtim.h \ gen/has/st-acmtimespec.h \ gen/has/st-birthtim.h \ @@ -51,7 +58,9 @@ HEADERS := \ gen/has/string-to-flags.h \ gen/has/strtofflags.h \ gen/has/tcgetwinsize.h \ + gen/has/tcsetwinsize.h \ gen/has/timegm.h \ + gen/has/timer-create.h \ gen/has/tm-gmtoff.h \ gen/has/uselocale.h @@ -63,9 +72,9 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS} @printf '// %s\n' "$@" >$@ @printf '#ifndef BFS_CONFIG_H\n' >>$@ @printf '#define BFS_CONFIG_H\n' >>$@ - @cat ${.ALLSRC} >>$@ + @cat $^ >>$@ @printf '#endif // BFS_CONFIG_H\n' >>$@ - @cat gen/flags.log ${.ALLSRC:%=%.log} >gen/config.log + @cat gen/flags.log ${^:%=%.log} >gen/config.log ${VCAT} $@ @printf '%s' "$$CONFFLAGS" | build/embed.sh >gen/confflags.i @printf '%s' "$$XCC" | build/embed.sh >gen/cc.i @@ -82,5 +91,5 @@ OUT = ${SLUG:has/%=gen/has/.%.out} ${HEADERS}:: @${MKDIR} ${@D} - @build/define-if.sh ${SLUG} build/cc.sh build/${SLUG}.c -o ${OUT} >$@ 2>$@.log; \ + @build/define-if.sh ${SLUG} build/flags-if.sh build/${SLUG}.c -o ${OUT} >$@ 2>$@.log; \ build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0 diff --git a/build/pkgs.mk b/build/pkgs.mk index 5de9ac2..bed17be 100644 --- a/build/pkgs.mk +++ b/build/pkgs.mk @@ -5,7 +5,9 @@ include build/prelude.mk include gen/vars.mk -include gen/flags.mk +include gen/early.mk +include gen/auto.mk +include gen/late.mk include build/exports.mk HEADERS := ${ALL_PKGS:%=gen/with/%.h} @@ -14,12 +16,11 @@ gen/pkgs.mk: ${HEADERS} ${MSG} "[ GEN] $@" @printf '# %s\n' "$@" >$@ @gen() { \ - printf 'PKGS := %s\n' "$$*"; \ printf '_CFLAGS += %s\n' "$$(build/pkgconf.sh --cflags "$$@")"; \ printf '_LDFLAGS += %s\n' "$$(build/pkgconf.sh --ldflags "$$@")"; \ printf '_LDLIBS := %s $${_LDLIBS}\n' "$$(build/pkgconf.sh --ldlibs "$$@")"; \ }; \ - gen $$(grep -l ' true$$' ${.ALLSRC} | sed 's|.*/\(.*\)\.h|\1|') >>$@ + gen $$(grep -l ' true$$' $^ | sed 's|.*/\(.*\)\.h|\1|') >>$@ ${VCAT} $@ .PHONY: gen/pkgs.mk diff --git a/build/prelude.mk b/build/prelude.mk index b8726d7..6250d73 100644 --- a/build/prelude.mk +++ b/build/prelude.mk @@ -9,11 +9,9 @@ # We don't use any suffix rules .SUFFIXES: -# GNU make has $^ for the full list of targets, while BSD make has $> and the -# long-form ${.ALLSRC}. We could write $^ $> to get them both, but that would -# break if one of them implemented support for the other. So instead, bring -# BSD's ${.ALLSRC} to GNU. -.ALLSRC ?= $^ +# GNU make has $^ for the full list of targets, while BSD make has $> (and the +# long-form ${.ALLSRC}). We use the GNU version, bringing it to BSD like this: +^ ?= $> # Installation paths DESTDIR ?= @@ -37,7 +35,7 @@ RM ?= rm -f # VAR=1 ${TRUTHY,${VAR}} => ${TRUTHY,1} => y # VAR=n ${TRUTHY,${VAR}} => ${TRUTHY,n} => [empty] # VAR=other ${TRUTHY,${VAR}} => ${TRUTHY,other} => [empty] -# VAR= ${TRUTHY,${VAR}} => ${TRUTHY,} => [emtpy] +# VAR= ${TRUTHY,${VAR}} => ${TRUTHY,} => [empty] # # Inspired by https://github.com/wahern/autoguess TRUTHY,y := y @@ -68,14 +66,3 @@ ALL_PKGS := \ libselinux \ liburing \ oniguruma - -# List all object files here, as they're needed by both `./configure` and `make` - -# All object files -OBJS := \ - obj/src/main.o \ - obj/tests/mksock.o \ - obj/tests/xspawnee.o \ - obj/tests/xtouch.o \ - ${LIBBFS} \ - ${UNIT_OBJS} diff --git a/build/version.sh b/build/version.sh index a14e996..734d897 100755 --- a/build/version.sh +++ b/build/version.sh @@ -14,5 +14,5 @@ if [ "${VERSION-}" ]; then elif [ -e "$DIR/.git" ] && command -v git >/dev/null 2>&1; then git -C "$DIR" describe --always --dirty else - echo "4.0.1" + echo "4.1" fi |