summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/config.mk14
-rw-r--r--build/flags.mk20
-rw-r--r--build/flags/Wundef-prefix.c (renamed from build/has/aligned-alloc.c)5
-rw-r--r--build/flags/pthread.c8
-rw-r--r--build/has/dprintf.c8
-rw-r--r--build/has/io-uring-max-workers.c11
-rw-r--r--build/has/pragma-nounroll.c10
-rw-r--r--build/has/pthread-set-name-np.c10
-rw-r--r--build/has/pthread-setname-np.c8
-rw-r--r--build/has/sched-getaffinity.c9
-rw-r--r--build/has/tcsetwinsize.c9
-rw-r--r--build/has/timer-create.c9
-rw-r--r--build/header.mk13
-rw-r--r--build/pkgs.mk2
-rw-r--r--build/prelude.mk21
-rwxr-xr-xbuild/version.sh2
16 files changed, 120 insertions, 39 deletions
diff --git a/build/config.mk b/build/config.mk
index 6296168..663926c 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -7,21 +7,15 @@ 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`
-MKS := \
- gen/vars.mk \
- gen/flags.mk \
- gen/pkgs.mk
-
# The main configuration file, which includes the others
-gen/config.mk: ${MKS} gen/config.h
+gen/config.mk: gen/vars.mk gen/flags.mk gen/pkgs.mk
${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
diff --git a/build/flags.mk b/build/flags.mk
index 1421ce6..3748a8a 100644
--- a/build/flags.mk
+++ b/build/flags.mk
@@ -8,14 +8,16 @@ include gen/vars.mk
# Internal flags
_CPPFLAGS := -Isrc -Igen -include src/prelude.h
-_CFLAGS := -std=c17 -pthread
+_CFLAGS := -std=c17
_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}}
@@ -29,6 +31,9 @@ _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
@@ -61,11 +66,14 @@ _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
@@ -88,8 +96,10 @@ AUTO_FLAGS := \
gen/flags/Wshadow.mk \
gen/flags/Wsign-compare.mk \
gen/flags/Wstrict-prototypes.mk \
+ gen/flags/Wundef-prefix.mk \
gen/flags/bind-now.mk \
- gen/flags/deps.mk
+ gen/flags/deps.mk \
+ gen/flags/pthread.mk
gen/flags.mk: ${AUTO_FLAGS}
${MSG} "[ GEN] $@"
@@ -100,8 +110,8 @@ 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
+ @cat $^ >>$@
+ @cat ${^:%=%.log} >gen/flags.log
${VCAT} $@
.PHONY: gen/flags.mk
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/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..f15829a 100644
--- a/build/header.mk
+++ b/build/header.mk
@@ -18,9 +18,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 +34,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 +56,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 +70,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
diff --git a/build/pkgs.mk b/build/pkgs.mk
index 5de9ac2..f692739 100644
--- a/build/pkgs.mk
+++ b/build/pkgs.mk
@@ -19,7 +19,7 @@ gen/pkgs.mk: ${HEADERS}
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..ec0663a 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.0.8"
fi