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
|
|
|
|
|
|
|
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
|
|
|
|
|
|
|
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-09-19 07:34:19 +00:00
|
|
|
$(if $(wildcard src/$(dep)),\
|
|
|
|
$(dep),\
|
|
|
|
$(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)
|
|
|
|
headers = $(call rwildcard,$(inc),*.h)
|
|
|
|
binaries = $(patsubst $(src)/%.cc,$(bin)/%.o,$(call sources,$1))
|
|
|
|
|
2022-10-04 20:02:18 +00:00
|
|
|
ifneq ($(nolsproj),yes)
|
|
|
|
$(shell make -f scripts/lsproj.mak $(lsproj))
|
|
|
|
endif
|
|
|
|
|
2022-09-19 07:34:19 +00:00
|
|
|
|
|
|
|
.PHONY: build
|
2022-10-04 16:34:27 +00:00
|
|
|
.PRECIOUS: $(bin)/%.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-03 14:22:21 +00:00
|
|
|
$(bin)/%.o: $(src)/%.cc $(headers)
|
|
|
|
echo - Compiling '$*.cc'...
|
|
|
|
$(call mkdir,$(dir $@))
|
|
|
|
$(CXX) -fPIC -c $(flags) $< -o $@
|