summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile29
1 files changed, 18 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 9e84cc8..ed96817 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,11 @@ CXX ?= g++
6IWYU ?= iwyu 6IWYU ?= iwyu
7CHRONIC ?= chronic 7CHRONIC ?= chronic
8 8
9CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} 9PKGS := fmt
10PKG_FLAGS := $(shell pkg-config --cflags ${PKGS})
11PKG_LIBS := -Wl,--push-state,--as-needed $(shell pkg-config --libs ${PKGS}) -Wl,--pop-state
12
13CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${PKG_FLAGS} ${OPTIMIZE} ${DEBUG}
10 14
11.DEFAULT_GOAL := all 15.DEFAULT_GOAL := all
12 16
@@ -24,7 +28,7 @@ endef
24export GITTAGCPP 28export GITTAGCPP
25 29
26ifneq ($(shell which ${IWYU}),) 30ifneq ($(shell which ${IWYU}),)
27iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error ${CXXFLAGS} $(1) 31iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error -Xiwyu --mapping_file=tools/iwyu.imp ${CXXFLAGS} $(1)
28else 32else
29$(warning Not using IWYU) 33$(warning Not using IWYU)
30iwyu = 34iwyu =
@@ -42,29 +46,32 @@ $(call libname,$(1).a): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp))
42 46
43$(call libname,$(1).so): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp)) 47$(call libname,$(1).so): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp))
44 @mkdir -p $$(dir $$@) 48 @mkdir -p $$(dir $$@)
45 $${CXX} $${CXXFLAGS} -shared -o $$@ $$+ 49 $${CXX} $${CXXFLAGS} -shared -o $$@ $$+ ${PKG_LIBS}
46 50
47PARTARS += $(call libname,$(1).a) 51PARTARS += $(call libname,$(1).a)
48PARTSOS += $(call libname,$(1).so) 52PARTSOS += $(call libname,$(1).so)
49 53
50else 54endif
51 55
52$(call libname,$(1).cpp): 56ifdef iwyu
57
58build/$(1)/iwyu.cpp:
53 @mkdir -p $$(dir $$@) 59 @mkdir -p $$(dir $$@)
54 @tools/iwyu-header $$(wildcard $(1)/*.h) > $$@ 60 @tools/iwyu-header $$(wildcard $(1)/*.h) > $$@
55 @$$(call iwyu,$$@) 61 @$$(call iwyu,$$@)
56.PHONY: $(call libname,$(1).cpp) 62.PHONY: build/$(1)/iwyu.cpp
57 63
58EXTRA_TARGETS += $(call libname,$(1).cpp) 64IWYU_CPPS += build/$(1)/iwyu.cpp
59 65
60endif 66endif
61 67
62endef 68endef
63 69
64PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -name tools -prune -o -print -\))) 70PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -name tools -prune -o -print -\)))
71
65PARTARS := 72PARTARS :=
66PARTSOS := 73PARTSOS :=
67EXTRA_TARGETS := 74IWYU_CPPS :=
68 75
69$(foreach part,${PARTS},$(eval $(call mklib,${part}))) 76$(foreach part,${PARTS},$(eval $(call mklib,${part})))
70 77
@@ -73,7 +80,7 @@ MAINOBJS += build/git-tag.o
73 80
74$(info ) 81$(info )
75 82
76all: ${EXTRA_TARGETS} issim issim-static 83all: ${IWYU_CPPS} issim issim-static
77 84
78issim: build/issim-dynamic 85issim: build/issim-dynamic
79 @ln -sf $< $@ 86 @ln -sf $< $@
@@ -85,11 +92,11 @@ issim-static: build/issim-static
85 92
86build/issim-dynamic: ${MAINOBJS} ${PARTSOS} 93build/issim-dynamic: ${MAINOBJS} ${PARTSOS}
87 @mkdir -p $(dir $@) 94 @mkdir -p $(dir $@)
88 ${CXX} ${CXXFLAGS} -o $@ $+ 95 ${CXX} ${CXXFLAGS} -o $@ $+ ${PKG_LIBS}
89 96
90build/issim-static: ${MAINOBJS} ${PARTARS} 97build/issim-static: ${MAINOBJS} ${PARTARS}
91 @mkdir -p $(dir $@) 98 @mkdir -p $(dir $@)
92 ${CXX} ${CXXFLAGS} -o $@ $+ 99 ${CXX} ${CXXFLAGS} -o $@ $+ ${PKG_LIBS}
93 100
94clean: 101clean:
95 rm -rf build issim issim-static 102 rm -rf build issim issim-static