2022-10-04 20:02:18 +00:00
|
|
|
export lsproj = $(bin)/lsproj$(exe)
|
|
|
|
export flags += "-I$(inc)" -D$(OS) -DPPC_VERSION_MAJOR=$(version-major) -DPPC_VERSION_MINOR=$(version-minor) -DPPC_VERSION_BUILD=$(version-build)
|
2022-09-19 07:34:19 +00:00
|
|
|
|
2022-10-09 11:18:38 +00:00
|
|
|
$(shell make -f scripts/lsproj.mak lsproj=$(lsproj) src=$(src) $(lsproj))
|
|
|
|
|
2022-10-04 20:45:08 +00:00
|
|
|
rwildcard=$(foreach d, $(wildcard $(1:=/*)),\
|
|
|
|
$(call rwildcard,$d,$2)\
|
|
|
|
$(filter $(subst *,%,$2),$d)\
|
|
|
|
)
|
2022-09-19 07:34:19 +00:00
|
|
|
|
|
|
|
uniq=$(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
2022-10-04 20:02:18 +00:00
|
|
|
modoutput=$(shell ./$(lsproj) $(src) $1 output)
|
2022-09-19 07:34:19 +00:00
|
|
|
deps=$(strip \
|
2022-10-04 20:02:18 +00:00
|
|
|
$(foreach dep, $(shell ./$(lsproj) $(src) $1 deps),\
|
2022-10-04 20:45:08 +00:00
|
|
|
$(if $(wildcard src/$(dep)), $(dep),\
|
2022-09-19 07:34:19 +00:00
|
|
|
$(error The module '$(dep)' (dependency of '$1') doesn't exist)\
|
|
|
|
)\
|
|
|
|
)\
|
|
|
|
)
|
|
|
|
rdeps=$(call uniq,$(strip \
|
|
|
|
$(foreach dep, $(call deps,$1),\
|
|
|
|
$(call rdeps,$(dep))\
|
|
|
|
$(dep)\
|
|
|
|
)\
|
|
|
|
))
|
|
|
|
|
|
|
|
fdeps=$(foreach dep,$(call deps,$1),$(bin)/lib$(lib)$(call modoutput,$(dep))$(so))
|
|
|
|
frdeps=$(foreach dep,$(call rdeps,$1),$(bin)/lib$(lib)$(call modoutput,$(dep))$(so))
|
|
|
|
|
|
|
|
ldeps=$(foreach dep,$(call deps,$1),-l$(lib)$(call modoutput,$(dep)))
|
|
|
|
lrdeps=$(foreach dep,$(call rdeps,$1),-l$(lib)$(call modoutput,$(dep)))
|
|
|
|
|
|
|
|
modules = $(patsubst $(src)/%/,$(bin)/lib$(lib)%$(so),$(filter-out $(src)/$(mainmodule)/,$(wildcard $(src)/*/)))
|
|
|
|
sources = $(call rwildcard,$(src)/$1,*.cc)
|
2022-10-09 11:18:38 +00:00
|
|
|
headers = $(call rwildcard,$(inc),*.hh)
|
2022-10-04 20:45:08 +00:00
|
|
|
binaries = $(patsubst $(src)/%.cc,$(bin)/tmp/%.o,$(call sources,$1))
|
2022-09-19 07:34:19 +00:00
|
|
|
|
|
|
|
.PHONY: build
|
2022-10-04 20:45:08 +00:00
|
|
|
.PRECIOUS: $(bin)/tmp/%.o
|
2022-09-19 07:34:19 +00:00
|
|
|
|
|
|
|
build: $(binary)
|
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
2022-10-03 14:22:21 +00:00
|
|
|
$(binary): $$(call frdeps,$(mainmodule)) $$(call binaries,$(mainmodule))
|
2022-09-19 07:34:19 +00:00
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
echo Compiling executable '$(notdir $(binary))'...
|
2022-10-03 14:22:21 +00:00
|
|
|
$(CXX) $(flags) $(call binaries,$(mainmodule)) -o $@ $(ldflags) $(call ldeps,$(mainmodule)) -L$(bin) "-I$(inc)"
|
2022-09-19 07:34:19 +00:00
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
2022-10-03 14:22:21 +00:00
|
|
|
$(bin)/lib$(lib)%$(so): $$(call frdeps,$$*) $$(call binaries,$$*)
|
2022-09-19 07:34:19 +00:00
|
|
|
$(call mkdir,$(bin))
|
|
|
|
echo Compiling library '$(notdir $@)'...
|
2022-10-03 14:22:21 +00:00
|
|
|
$(CXX) -shared -fPIC $(flags) $(call binaries,$*) -o $@ $(ldflags) $(call ldeps,$*) -L$(bin) "-I$(inc)"
|
2022-09-19 07:34:19 +00:00
|
|
|
|
2022-10-04 20:45:08 +00:00
|
|
|
$(bin)/tmp/%.o: $(src)/%.cc $(headers)
|
2022-10-03 14:22:21 +00:00
|
|
|
echo - Compiling '$*.cc'...
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(CXX) -fPIC -c $(flags) $< -o $@
|