summaryrefslogtreecommitdiffstats
path: root/share/mk/build/examples
diff options
context:
space:
mode:
Diffstat (limited to 'share/mk/build/examples')
-rw-r--r--share/mk/build/examples/_.mk28
-rw-r--r--share/mk/build/examples/cc.mk54
-rw-r--r--share/mk/build/examples/ld.mk51
-rw-r--r--share/mk/build/examples/src.mk55
4 files changed, 188 insertions, 0 deletions
diff --git a/share/mk/build/examples/_.mk b/share/mk/build/examples/_.mk
new file mode 100644
index 0000000..c01a952
--- /dev/null
+++ b/share/mk/build/examples/_.mk
@@ -0,0 +1,28 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_DIR_INCLUDED
+MAKEFILE_BUILD_EX_DIR_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_PAGEEXDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d/,$(NONSO_MAN))
+
+
+$(_PAGEEXDIRS):
+ +$(info $(INFO_)MKDIR $@)
+ +$(MKDIR) -p $@
+ +$(TOUCH) $@
+
+
+.PHONY: build-ex
+build-ex: build-ex-ld;
+
+
+endif # include guard
diff --git a/share/mk/build/examples/cc.mk b/share/mk/build/examples/cc.mk
new file mode 100644
index 0000000..6513fbe
--- /dev/null
+++ b/share/mk/build/examples/cc.mk
@@ -0,0 +1,54 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_CC_INCLUDED
+MAKEFILE_BUILD_EX_CC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/examples/src.mk
+include $(MAKEFILEDIR)/configure/build-depends/cc.mk
+include $(MAKEFILEDIR)/configure/build-depends/cpp.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+
+
+_XFAIL_UNITS_ex_o := \
+ $(_MANDIR)/man2/bpf.2.d/bpf.o \
+ $(_MANDIR)/man2/seccomp.2.d/seccomp.o \
+ $(_MANDIR)/man2/sigaction.2.d/sigaction.o \
+ $(_MANDIR)/man2/spu_run.2.d/spu_run.o \
+ $(_MANDIR)/man2/_syscall.2.d/_syscall.o \
+ $(_MANDIR)/man3/circleq.3.d/circleq.o \
+ $(_MANDIR)/man3/encrypt.3.d/encrypt.o \
+ $(_MANDIR)/man3/getsubopt.3.d/getsubopt.o \
+ $(_MANDIR)/man3/hsearch.3.d/hsearch.o \
+ $(_MANDIR)/man3/malloc_info.3.d/malloc_info.o \
+ $(_MANDIR)/man3/mallopt.3.d/mallopt.o \
+ $(_MANDIR)/man3/matherr.3.d/matherr.o \
+ $(_MANDIR)/man3/mcheck.3.d/mcheck.o \
+ $(_MANDIR)/man3/mtrace.3.d/t_mtrace.o \
+ $(_MANDIR)/man3/__ppc_get_timebase.3.d/__ppc_get_timebase.o \
+ $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.o \
+ $(_MANDIR)/man3/rtime.3.d/rtime.o \
+ $(_MANDIR)/man3/setbuf.3.d/setbuf.o \
+ $(_MANDIR)/man3/stpncpy.3.d/stpncpy.o \
+ $(_MANDIR)/man3head/printf.h.3head.d/register_printf_specifier.o
+
+
+_UNITS_ex_o := $(patsubst %.c,%.o,$(_UNITS_ex_c))
+ifeq ($(SKIP_XFAIL),yes)
+_UNITS_ex_o := $(filter-out $(_XFAIL_UNITS_ex_o), $(_UNITS_ex_o))
+endif
+
+
+$(_UNITS_ex_o): %.o: %.c $(MK)
+ $(info $(INFO_)CC $@)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+
+.PHONY: build-ex-cc
+build-ex-cc: $(_UNITS_ex_o);
+
+
+endif # include guard
diff --git a/share/mk/build/examples/ld.mk b/share/mk/build/examples/ld.mk
new file mode 100644
index 0000000..9d5535d
--- /dev/null
+++ b/share/mk/build/examples/ld.mk
@@ -0,0 +1,51 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_LD_INCLUDED
+MAKEFILE_BUILD_EX_LD_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/examples/cc.mk
+include $(MAKEFILEDIR)/configure/build-depends/ld.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+
+
+_XFAIL_UNITS_ex_bin := \
+ $(_MANDIR)/man2/add_key.2.d/add_key \
+ $(_MANDIR)/man2/keyctl.2.d/key_instantiate \
+ $(_MANDIR)/man2/request_key.2.d/t_request_key \
+ $(_MANDIR)/man2/select_tut.2.d/select \
+ $(_MANDIR)/man2/shmop.2.d/svshm_string_read \
+ $(_MANDIR)/man3/cacos.3.d/cacos \
+ $(_MANDIR)/man3/cacosh.3.d/cacosh \
+ $(_MANDIR)/man3/catan.3.d/catan \
+ $(_MANDIR)/man3/catanh.3.d/catanh \
+ $(_MANDIR)/man3/getaddrinfo_a.3.d/async \
+ $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton \
+ $(_MANDIR)/man3/list.3.d/list \
+ $(_MANDIR)/man3/mallinfo.3.d/mallinfo \
+ $(_MANDIR)/man3/slist.3.d/slist \
+ $(_MANDIR)/man3/stailq.3.d/stailq \
+ $(_MANDIR)/man3/strncat.3.d/strncat \
+ $(_MANDIR)/man3/tailq.3.d/tailq \
+ $(_MANDIR)/man3/tsearch.3.d/tsearch
+
+
+_UNITS_ex_bin := $(patsubst %.o,%,$(_UNITS_ex_o))
+ifeq ($(SKIP_XFAIL),yes)
+_UNITS_ex_bin := $(filter-out $(_XFAIL_UNITS_ex_bin), $(_UNITS_ex_bin))
+endif
+
+
+$(_UNITS_ex_bin): %: %.o $(MK)
+ $(info $(INFO_)LD $@)
+ $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+
+.PHONY: build-ex-ld
+build-ex-ld: $(_UNITS_ex_bin);
+
+
+endif # include guard
diff --git a/share/mk/build/examples/src.mk b/share/mk/build/examples/src.mk
new file mode 100644
index 0000000..f47a713
--- /dev/null
+++ b/share/mk/build/examples/src.mk
@@ -0,0 +1,55 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_SRC_INCLUDED
+MAKEFILE_BUILD_EX_SRC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/findutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/mandoc.mk
+include $(MAKEFILEDIR)/configure/build-depends/sed.mk
+include $(MAKEFILEDIR)/configure/directory_variables.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_UNITS_ex_src := \
+ $(patsubst $(MANDIR)/%, $(_MANDIR)/%, \
+ $(shell \
+ $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \
+ | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \
+ | $(SED) 's/)//' \
+ | $(SORTMAN) \
+ | $(SED) 's,:,\\:,g' \
+ ) \
+ )
+_UNITS_ex_h := $(filter %.h,$(_UNITS_ex_src))
+_UNITS_ex_c := $(filter %.c,$(_UNITS_ex_src))
+
+
+$(_UNITS_ex_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) $(MK) | $$(@D)/
+$(_UNITS_ex_c): $$(filter $$(@D)/%.h,$(_UNITS_ex_h))
+$(_UNITS_ex_src):
+ $(info $(INFO_)SED $@)
+ <$< \
+ $(SED) -n \
+ -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
+ -e '/^\.SH EXAMPLES/p' \
+ -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \
+ | $(MANDOC) -Tutf8 \
+ | $(HEAD) -n-2 \
+ | $(SED) '/^[^ ]/d' \
+ | $(SED) 's/^ //' \
+ >$@
+
+
+.PHONY: build-ex-src
+build-ex-src: $(_UNITS_ex_src);
+
+
+endif # include guard