diff options
| author | Julian Blake Kongslie | 2022-06-25 19:19:01 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-06-25 19:23:33 -0700 |
| commit | e5f30c2294b31b9042b43ea876b6063fea4dec29 (patch) | |
| tree | f8dd2b5c2fadc3a04d566753eedcbf539a57406f /Makefile | |
| parent | Support header-only components. (diff) | |
| download | issim-e5f30c2294b31b9042b43ea876b6063fea4dec29.tar.xz | |
Reorganize Makefile.
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 40 |
1 files changed, 23 insertions, 17 deletions
| @@ -6,38 +6,46 @@ CXX ?= g++ | |||
| 6 | 6 | ||
| 7 | CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} | 7 | CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} |
| 8 | 8 | ||
| 9 | libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1))) | 9 | .DEFAULT: issim |
| 10 | |||
| 11 | PARTS := $(shell find * -type d -\( -name build -prune -o -name tools -prune -o -print -\)) | ||
| 12 | PARTARS := | ||
| 13 | PARTSOS := | ||
| 14 | 10 | ||
| 15 | MAINOBJS := $(patsubst %.cpp, build/%.o, $(wildcard *.cpp)) | 11 | libname = $(shell realpath --canonicalize-missing --relative-to . build/$(dir $(1))/lib$(notdir $(1))) |
| 16 | MAINOBJS += build/git-tag.o | ||
| 17 | |||
| 18 | HEADERS := $(find -type f -name \*.h) | ||
| 19 | |||
| 20 | .DEFAULT: issim issim-static | ||
| 21 | 12 | ||
| 22 | define mklib = | 13 | define mklib = |
| 23 | 14 | ||
| 24 | ifneq ($(wildcard $(1)/*.cpp),) | 15 | ifneq ($(wildcard $(1)/*.cpp),) |
| 25 | 16 | ||
| 26 | $(call libname, $(1).a): $(patsubst %.cpp, build/%.o, $(wildcard $(1)/*.cpp)) | 17 | $$(info Component $(call libname,$(1))) |
| 18 | |||
| 19 | $(call libname,$(1).a): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp)) | ||
| 27 | @mkdir -p $$(dir $$@) | 20 | @mkdir -p $$(dir $$@) |
| 28 | $${AR} cr $$@ $$+ | 21 | $${AR} cr $$@ $$+ |
| 29 | 22 | ||
| 30 | $(call libname, $(1).so): $(patsubst %.cpp, build/%.o, $(wildcard $(1)/*.cpp)) | 23 | $(call libname,$(1).so): $(patsubst %.cpp,build/%.o,$(wildcard $(1)/*.cpp)) |
| 31 | @mkdir -p $$(dir $$@) | 24 | @mkdir -p $$(dir $$@) |
| 32 | $${CXX} $${CXXFLAGS} -shared -o $$@ $$+ | 25 | $${CXX} $${CXXFLAGS} -shared -o $$@ $$+ |
| 33 | 26 | ||
| 34 | PARTARS += $(call libname, $(1).a) | 27 | PARTARS += $(call libname,$(1).a) |
| 35 | PARTSOS += $(call libname, $(1).so) | 28 | PARTSOS += $(call libname,$(1).so) |
| 29 | |||
| 30 | else | ||
| 31 | |||
| 32 | $$(info Header-only component $(1)) | ||
| 36 | 33 | ||
| 37 | endif | 34 | endif |
| 38 | 35 | ||
| 39 | endef | 36 | endef |
| 40 | 37 | ||
| 38 | PARTS := $(shell find * -type d -\( -name build -prune -o -name tools -prune -o -print -\)) | ||
| 39 | PARTARS := | ||
| 40 | PARTSOS := | ||
| 41 | |||
| 42 | $(foreach part,${PARTS},$(eval $(call mklib,${part}))) | ||
| 43 | |||
| 44 | MAINOBJS := $(patsubst %.cpp,build/%.o,$(wildcard *.cpp)) | ||
| 45 | MAINOBJS += build/git-tag.o | ||
| 46 | |||
| 47 | $(info ) | ||
| 48 | |||
| 41 | issim: build/issim-dynamic | 49 | issim: build/issim-dynamic |
| 42 | @ln -sf $< $@ | 50 | @ln -sf $< $@ |
| 43 | .PHONY: issim | 51 | .PHONY: issim |
| @@ -73,7 +81,5 @@ build/%.o: build/%.cpp | |||
| 73 | @mkdir -p $(dir $@) | 81 | @mkdir -p $(dir $@) |
| 74 | ${CXX} ${CXXFLAGS} -MMD -c -o $@ $< | 82 | ${CXX} ${CXXFLAGS} -MMD -c -o $@ $< |
| 75 | 83 | ||
| 76 | $(foreach part, ${PARTS}, $(eval $(call mklib, ${part}))) | ||
| 77 | |||
| 78 | .SUFFIXES: | 84 | .SUFFIXES: |
| 79 | .SECONDARY: | 85 | .SECONDARY: |
