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