summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile27
1 files changed, 22 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index debe4b5..9e84cc8 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,12 @@ DEBUG ?= -g
3 3
4AR ?= ar 4AR ?= ar
5CXX ?= g++ 5CXX ?= g++
6IWYU ?= iwyu
7CHRONIC ?= chronic
6 8
7CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} 9CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG}
8 10
9.DEFAULT: issim 11.DEFAULT_GOAL := all
10 12
11VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null) 13VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null)
12ifndef VERSION 14ifndef VERSION
@@ -21,14 +23,19 @@ std::string GIT_TAG = "$(subst ",\",${VERSION})";
21endef 23endef
22export GITTAGCPP 24export GITTAGCPP
23 25
26ifneq ($(shell which ${IWYU}),)
27iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error ${CXXFLAGS} $(1)
28else
29$(warning Not using IWYU)
30iwyu =
31endif
32
24libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1))) 33libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1)))
25 34
26define mklib = 35define mklib =
27 36
28ifneq ($(wildcard $(1)/*.cpp),) 37ifneq ($(wildcard $(1)/*.cpp),)
29 38
30$$(info Component $(call libname,$(1)))
31
32$(call libname,$(1).a): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp)) 39$(call libname,$(1).a): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp))
33 @mkdir -p $$(dir $$@) 40 @mkdir -p $$(dir $$@)
34 $${AR} cr $$@ $$+ 41 $${AR} cr $$@ $$+
@@ -42,15 +49,22 @@ PARTSOS += $(call libname,$(1).so)
42 49
43else 50else
44 51
45$$(info Header-only component $(1)) 52$(call libname,$(1).cpp):
53 @mkdir -p $$(dir $$@)
54 @tools/iwyu-header $$(wildcard $(1)/*.h) > $$@
55 @$$(call iwyu,$$@)
56.PHONY: $(call libname,$(1).cpp)
57
58EXTRA_TARGETS += $(call libname,$(1).cpp)
46 59
47endif 60endif
48 61
49endef 62endef
50 63
51PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -print -\))) 64PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -name tools -prune -o -print -\)))
52PARTARS := 65PARTARS :=
53PARTSOS := 66PARTSOS :=
67EXTRA_TARGETS :=
54 68
55$(foreach part,${PARTS},$(eval $(call mklib,${part}))) 69$(foreach part,${PARTS},$(eval $(call mklib,${part})))
56 70
@@ -59,6 +73,8 @@ MAINOBJS += build/git-tag.o
59 73
60$(info ) 74$(info )
61 75
76all: ${EXTRA_TARGETS} issim issim-static
77
62issim: build/issim-dynamic 78issim: build/issim-dynamic
63 @ln -sf $< $@ 79 @ln -sf $< $@
64.PHONY: issim 80.PHONY: issim
@@ -88,6 +104,7 @@ include $(shell find -type f -name \*.d)
88 104
89build/%.o: %.cpp 105build/%.o: %.cpp
90 @mkdir -p $(dir $@) 106 @mkdir -p $(dir $@)
107 @$(call iwyu,$<)
91 ${CXX} ${CXXFLAGS} -MMD -c -o $@ $< 108 ${CXX} ${CXXFLAGS} -MMD -c -o $@ $<
92 109
93build/%.o: build/%.cpp 110build/%.o: build/%.cpp