summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-04-02 15:30:34 +0200
committerAlejandro Colomar <alx@kernel.org>2023-04-02 15:30:36 +0200
commitb0058fa6658ad2499b928a25c65ee017eda7a85a (patch)
tree220f2b6f94b56c53905a5c6366da84f307e254b8
parent437a0ad8283d29ef2c8f59d08388c9aa4170b567 (diff)
*.mk: Simplify build tree
Reuse $_MANDIR (.tmp/man/) for most stuff we build (with the exception of `make dist`). Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--lib/build-src.mk16
-rw-r--r--lib/build.mk7
-rw-r--r--lib/lint-man.mk8
-rw-r--r--lib/lint.mk17
4 files changed, 16 insertions, 32 deletions
diff --git a/lib/build-src.mk b/lib/build-src.mk
index 410af3abd..15382c6be 100644
--- a/lib/build-src.mk
+++ b/lib/build-src.mk
@@ -1,6 +1,6 @@
########################################################################
-# Copyright (C) 2021, 2022 Alejandro Colomar <alx@kernel.org>
-# SPDX-License-Identifier: GPL-2.0 OR LGPL-2.0
+# Copyright (C) 2021 - 2023 Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later OR LGPL-3.0-or-later
########################################################################
@@ -55,9 +55,9 @@ LD := $(CC) $(CFLAGS)
MAN := man
-_SRCPAGEDIRS := $(patsubst $(MANDIR)/%,$(_SRCDIR)/%.d,$(NONSO_MAN))
+_SRCPAGEDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d,$(NONSO_MAN))
-_UNITS_src_src := $(patsubst $(MANDIR)/%,$(_SRCDIR)/%,$(shell \
+_UNITS_src_src := $(patsubst $(MANDIR)/%,$(_MANDIR)/%,$(shell \
$(FIND) $(MANDIR)/man*/ -type f \
| $(GREP) '$(MANEXT)' \
| $(XARGS) $(GREP) -l '^\.TH ' \
@@ -72,12 +72,12 @@ _UNITS_src_o := $(patsubst %.c,%.o,$(_UNITS_src_c))
_UNITS_src_bin := $(patsubst %.c,%,$(_UNITS_src_c))
-$(_SRCPAGEDIRS): $(_SRCDIR)/%.d: $(MANDIR)/% | $$(@D)/
+$(_SRCPAGEDIRS): $(_MANDIR)/%.d: $(MANDIR)/% | $$(@D)/
+$(info MKDIR $@)
+$(MKDIR) $@
+touch $@
-$(_UNITS_src_src): $$(patsubst $(_SRCDIR)/%.d,$(MANDIR)/%,$$(@D)) | $$(@D)
+$(_UNITS_src_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) | $$(@D)
$(_UNITS_src_c): $$(filter $$(@D)/%.h,$(_UNITS_src_h))
$(_UNITS_src_src):
$(info SED $@)
@@ -91,11 +91,11 @@ $(_UNITS_src_src):
| $(SED) 's/^ //' \
>$@
-$(_UNITS_src_o): $(_SRCDIR)/%.o: $(_SRCDIR)/%.c
+$(_UNITS_src_o): %.o: %.c
$(info CC $@)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-$(_UNITS_src_bin): $(_SRCDIR)/%: $(_SRCDIR)/%.o
+$(_UNITS_src_bin): %: %.o
$(info LD $@)
$(LD) $(LDFLAGS) -o $@ $< $(LDLIBS)
diff --git a/lib/build.mk b/lib/build.mk
index aab086981..6c7493c58 100644
--- a/lib/build.mk
+++ b/lib/build.mk
@@ -1,6 +1,6 @@
########################################################################
-# Copyright (C) 2021, 2022 Alejandro Colomar <alx@kernel.org>
-# SPDX-License-Identifier: GPL-2.0 OR LGPL-2.0
+# Copyright (C) 2021 - 2023 Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later OR LGPL-3.0-or-later
########################################################################
@@ -16,7 +16,6 @@ builddir := .tmp
SYSCONFDIR := $(srcdir)/etc
-_SRCDIR := $(builddir)/src
_MANDIR := $(builddir)/man
@@ -29,11 +28,9 @@ NONSO_MAN := $(shell $(FIND) $(MANDIR)/man*/ -type f \
| $(XARGS) $(GREP) -l '^\.TH ' \
| $(SORT))
_MANDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%/,$(MANDIRS))
-_SRCDIRS := $(patsubst $(MANDIR)/%,$(_SRCDIR)/%/,$(MANDIRS))
$(_MANDIRS): %/: | $$(dir %) $(_MANDIR)/
-$(_SRCDIRS): %/: | $$(dir %) $(_SRCDIR)/
$(builddir)/%/:
diff --git a/lib/lint-man.mk b/lib/lint-man.mk
index 92fec7ef8..b896eb0e9 100644
--- a/lib/lint-man.mk
+++ b/lib/lint-man.mk
@@ -21,15 +21,15 @@ MANDOCFLAGS := $(DEFAULT_MANDOCFLAGS) $(EXTRA_MANDOCFLAGS)
MANDOC := mandoc
-_LINT_man_mandoc:=$(patsubst $(MANDIR)/%,$(_LINTDIR)/%.lint-man.mandoc.touch,$(NONSO_MAN))
-_LINT_man_tbl :=$(patsubst $(MANDIR)/%,$(_LINTDIR)/%.lint-man.tbl.touch,$(NONSO_MAN))
+_LINT_man_mandoc:=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.mandoc.touch,$(NONSO_MAN))
+_LINT_man_tbl :=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.tbl.touch,$(NONSO_MAN))
linters_man := mandoc tbl
lint_man := $(foreach x,$(linters_man),lint-man-$(x))
-$(_LINT_man_mandoc): $(_LINTDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% | $$(@D)/
+$(_LINT_man_mandoc): $(_MANDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% | $$(@D)/
$(info LINT (mandoc) $@)
! ($(MANDOC) $(MANDOCFLAGS) $< 2>&1 \
| $(GREP) -v 'STYLE: lower case character in document title:' \
@@ -43,7 +43,7 @@ $(_LINT_man_mandoc): $(_LINTDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% | $$(@D)/
| $(GREP) '.' >&2
touch $@
-$(_LINT_man_tbl): $(_LINTDIR)/%.lint-man.tbl.touch: $(MANDIR)/% | $$(@D)/
+$(_LINT_man_tbl): $(_MANDIR)/%.lint-man.tbl.touch: $(MANDIR)/% | $$(@D)/
$(info LINT (tbl comment) $@)
if $(GREP) -q '^\.TS$$' $< && ! $(HEAD) -n1 $< | $(GREP) -q '\\" t$$'; \
then \
diff --git a/lib/lint.mk b/lib/lint.mk
index 347e8d12c..c81f283da 100644
--- a/lib/lint.mk
+++ b/lib/lint.mk
@@ -1,6 +1,6 @@
########################################################################
-# Copyright (C) 2021, 2022 Alejandro Colomar <alx@kernel.org>
-# SPDX-License-Identifier: GPL-2.0 OR LGPL-2.0
+# Copyright (C) 2021 - 2023 Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later OR LGPL-3.0-or-later
########################################################################
@@ -8,22 +8,9 @@ ifndef MAKEFILE_LINT_INCLUDED
MAKEFILE_LINT_INCLUDED := 1
-include $(srcdir)/lib/build.mk
-include $(srcdir)/lib/src.mk
-
-
-_LINTDIR := $(builddir)/lint
-
-
-_LINTDIRS := $(patsubst $(MANDIR)/%,$(_LINTDIR)/%/,$(MANDIRS))
-
-
lint := lint-c lint-man
-$(_LINTDIRS): %/: | $$(dir %) $(_LINTDIR)/
-
-
.PHONY: lint
lint: $(lint)
@: