diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 27 |
1 files changed, 22 insertions, 5 deletions
| @@ -3,10 +3,12 @@ DEBUG ?= -g | |||
| 3 | 3 | ||
| 4 | AR ?= ar | 4 | AR ?= ar |
| 5 | CXX ?= g++ | 5 | CXX ?= g++ |
| 6 | IWYU ?= iwyu | ||
| 7 | CHRONIC ?= chronic | ||
| 6 | 8 | ||
| 7 | CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} | 9 | CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} |
| 8 | 10 | ||
| 9 | .DEFAULT: issim | 11 | .DEFAULT_GOAL := all |
| 10 | 12 | ||
| 11 | VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null) | 13 | VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null) |
| 12 | ifndef VERSION | 14 | ifndef VERSION |
| @@ -21,14 +23,19 @@ std::string GIT_TAG = "$(subst ",\",${VERSION})"; | |||
| 21 | endef | 23 | endef |
| 22 | export GITTAGCPP | 24 | export GITTAGCPP |
| 23 | 25 | ||
| 26 | ifneq ($(shell which ${IWYU}),) | ||
| 27 | iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error ${CXXFLAGS} $(1) | ||
| 28 | else | ||
| 29 | $(warning Not using IWYU) | ||
| 30 | iwyu = | ||
| 31 | endif | ||
| 32 | |||
| 24 | libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1))) | 33 | libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1))) |
| 25 | 34 | ||
| 26 | define mklib = | 35 | define mklib = |
| 27 | 36 | ||
| 28 | ifneq ($(wildcard $(1)/*.cpp),) | 37 | ifneq ($(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 | ||
| 43 | else | 50 | else |
| 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 | |||
| 58 | EXTRA_TARGETS += $(call libname,$(1).cpp) | ||
| 46 | 59 | ||
| 47 | endif | 60 | endif |
| 48 | 61 | ||
| 49 | endef | 62 | endef |
| 50 | 63 | ||
| 51 | PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -print -\))) | 64 | PARTS := $(patsubst ./%,%,$(shell find -mindepth 1 -type d -\( -name .\* -prune -o -name build -prune -o -name tools -prune -o -print -\))) |
| 52 | PARTARS := | 65 | PARTARS := |
| 53 | PARTSOS := | 66 | PARTSOS := |
| 67 | EXTRA_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 | ||
| 76 | all: ${EXTRA_TARGETS} issim issim-static | ||
| 77 | |||
| 62 | issim: build/issim-dynamic | 78 | issim: 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 | ||
| 89 | build/%.o: %.cpp | 105 | build/%.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 | ||
| 93 | build/%.o: build/%.cpp | 110 | build/%.o: build/%.cpp |
