diff options
Diffstat (limited to 'share/tests/libc-str-len/Makefile')
-rwxr-xr-x | share/tests/libc-str-len/Makefile | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/share/tests/libc-str-len/Makefile b/share/tests/libc-str-len/Makefile new file mode 100755 index 0000000..223cb8a --- /dev/null +++ b/share/tests/libc-str-len/Makefile @@ -0,0 +1,63 @@ +# Copyright 2022 Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception + + +SHELL := /usr/bin/env bash -Eeuo pipefail + + +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-builtin-variables +MAKEFLAGS += --no-print-directory + + +CC := cc +FIND := find +GREP := grep +PKGCONF := pkgconf +SORT := sort + + +libname := libc-str-len + + +PKGCONFFLAGS := + +CPPFLAGS := + +CFLAGS := -Wall -Wextra -Werror +CFLAGS += -std=gnu2x +CFLAGS += $(shell $(PKGCONF) $(PKGCONFFLAGS) --cflags $(libname)) + +LDFLAGS := -Wl,--as-needed +LDFLAGS += -Wl,--no-allow-shlib-undefined +LDFLAGS += -Wl,--no-copy-dt-needed-entries +LDFLAGS += -Wl,--no-undefined +LDFLAGS += $(shell $(PKGCONF) $(PKGCONFFLAGS) --libs-only-L $(libname)) +LDFLAGS += $(shell $(PKGCONF) $(PKGCONFFLAGS) --libs-only-other $(libname)) + +LDLIBS := $(shell $(PKGCONF) $(PKGCONFFLAGS) --libs-only-l $(libname)) + + +TESTDIR := . + + +TESTS_c := $(shell $(FIND) $(TESTDIR) -type f | $(GREP) '\.c$$' | $(SORT)) +TESTS := $(patsubst %.c,%,$(TESTS_c)) + + +.PHONY: all +all: $(TESTS) + + +$(TESTS): %: %.c FORCE + $(info TEST $(dir $@)) + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -o $@ + cd $(dir $@) && ./test.sh + + +V := +$(V).SILENT: + + +FORCE: |