2020-03-28 18:46:24 +01:00
|
|
|
# parameters:
|
|
|
|
# $(1): lowercase package name
|
|
|
|
# $(2): uppercase package name
|
|
|
|
# $(3): 32/64, build type
|
|
|
|
define create-rules-common
|
|
|
|
$(2)_OBJ$(3) := $$(OBJ)/obj-$(1)$(3)
|
2021-01-21 10:30:21 +01:00
|
|
|
$(2)_DST$(3) := $$(OBJ)/dst-$(1)$(3)
|
2020-03-28 18:46:24 +01:00
|
|
|
$(2)_DEPS$(3) := $$(call toupper,$$($(2)_DEPENDS)) $$(call toupper,$$($(2)_DEPENDS$(3)))
|
|
|
|
|
|
|
|
$(2)_BINDIR$(3) ?= $$($(2)_DST$(3))/bin
|
|
|
|
$(2)_LIBDIR$(3) ?= $$($(2)_DST$(3))/lib$(subst 32,,$(3))
|
|
|
|
$(2)_INCDIR$(3) ?= $$($(2)_DST$(3))/include
|
|
|
|
|
|
|
|
$$(OBJ)/.$(1)-configure$(3): $$(shell mkdir -p $$($(2)_OBJ$(3)))
|
|
|
|
$$(OBJ)/.$(1)-configure$(3): CCACHE_BASEDIR = $$($(2)_SRC)
|
|
|
|
$$(OBJ)/.$(1)-configure$(3): $$(patsubst %,%-build$(3),$$($(2)_DEPENDS) $$($(2)_DEPENDS$(3)))
|
|
|
|
|
|
|
|
$(1)-configure$(3): $$(OBJ)/.$(1)-configure$(3)
|
|
|
|
.INTERMEDIATE: $(1)-configure$(3)
|
|
|
|
|
|
|
|
all-configure$(3) $(1)-configure: $(1)-configure$(3)
|
|
|
|
.PHONY: all-configure$(3) $(1)-configure
|
|
|
|
|
|
|
|
all-configure: $(1)-configure
|
|
|
|
.PHONY: all-configure
|
|
|
|
|
|
|
|
|
|
|
|
$$(OBJ)/.$(1)-build$(3): CCACHE_BASEDIR = $$($(2)_SRC)
|
|
|
|
$$(OBJ)/.$(1)-build$(3): $$(OBJ)/.$(1)-source
|
|
|
|
$$(OBJ)/.$(1)-build$(3): $$(OBJ)/.$(1)-configure$(3)
|
|
|
|
|
|
|
|
ifeq ($(CONTAINER),)
|
|
|
|
$$(OBJ)/.$(1)-build$(3): container-build
|
|
|
|
$$(OBJ)/.$(1)-post-build$(3): container-build
|
2021-01-21 10:30:21 +01:00
|
|
|
$$(OBJ)/.$(1)-dist$(3): container-build
|
2020-03-28 18:46:24 +01:00
|
|
|
else
|
|
|
|
$$(OBJ)/.$(1)-post-build$(3): $$(OBJ)/.$(1)-build$(3)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(1)-build$(3): $$(OBJ)/.$(1)-build$(3)
|
|
|
|
.INTERMEDIATE: $(1)-build$(3)
|
|
|
|
|
|
|
|
all-build$(3) $(1)-build: $(1)-build$(3)
|
|
|
|
.PHONY: all-build$(3) $(1)-build
|
|
|
|
|
|
|
|
all-build: $(1)-build
|
|
|
|
.PHONY: all-build
|
|
|
|
|
|
|
|
|
2021-01-21 10:30:21 +01:00
|
|
|
ifeq ($(CONTAINER),1)
|
|
|
|
$$(OBJ)/.$(1)-dist$(3): $$(OBJ)/.$(1)-build$(3)
|
|
|
|
$$(OBJ)/.$(1)-dist$(3): $$(OBJ)/.$(1)-post-build$(3)
|
|
|
|
|
|
|
|
ifneq ($(UNSTRIPPED_BUILD),)
|
|
|
|
$$(OBJ)/.$(1)-dist$(3):
|
|
|
|
@echo ":: installing $(3)bit $(1)..." >&2
|
|
|
|
mkdir -p $$($(2)_LIBDIR$(3))/ $$(DST_LIBDIR$(3))/
|
2021-05-28 10:50:59 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -printf '$$(DST_LIBDIR$(3))/%h\0' | sort -z | uniq -z | xargs $(--verbose?) -0 -r -P$$(J) mkdir -p
|
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type l -printf '%p\0$$(DST_LIBDIR$(3))/%p\0' | xargs $(--verbose?) -0 -r -P$$(J) -n2 cp -a
|
2021-09-04 00:42:35 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -not '(' -iname '*.pc' -or -iname '*.cmake' -or -iname '*.a' -or -iname '*.la' -or -iname '*.def' ')' \
|
2021-01-21 10:30:21 +01:00
|
|
|
-printf '--only-keep-debug\0%p\0$$(DST_LIBDIR$(3))/%p.debug\0' | \
|
2021-05-28 10:50:59 +02:00
|
|
|
xargs $(--verbose?) -0 -r -P$$(J) -n3 objcopy --file-alignment=4096
|
2021-09-04 00:42:35 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -not '(' -iname '*.pc' -or -iname '*.cmake' -or -iname '*.a' -or -iname '*.la' -or -iname '*.def' ')' \
|
2021-01-21 10:30:21 +01:00
|
|
|
-printf '--add-gnu-debuglink=$$(DST_LIBDIR$(3))/%p.debug\0--strip-debug\0%p\0$$(DST_LIBDIR$(3))/%p\0' | \
|
2021-05-28 10:50:59 +02:00
|
|
|
xargs $(--verbose?) -0 -r -P$$(J) -n4 objcopy --file-alignment=4096
|
2021-05-28 10:29:12 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -name '*.dll' \
|
|
|
|
-printf '$$(DST_LIBDIR$(3))/%p\0' | \
|
2021-05-28 10:50:59 +02:00
|
|
|
xargs $(--verbose?) -0 -r -P$$(J) -n1 $$(SRC)/make/pefixup.py
|
2021-01-21 10:30:21 +01:00
|
|
|
touch $$@
|
|
|
|
else
|
|
|
|
$$(OBJ)/.$(1)-dist$(3):
|
|
|
|
@echo ":: installing $(3)bit $(1)..." >&2
|
|
|
|
mkdir -p $$($(2)_LIBDIR$(3))/ $$(DST_LIBDIR$(3))/
|
2021-05-28 10:50:59 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -printf '$$(DST_LIBDIR$(3))/%h\0' | sort -z | uniq -z | xargs $(--verbose?) -0 -r -P$$(J) mkdir -p
|
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type l -printf '%p\0$$(DST_LIBDIR$(3))/%p\0' | xargs $(--verbose?) -0 -r -P$$(J) -n2 cp -a
|
2021-09-04 00:42:35 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -not '(' -iname '*.pc' -or -iname '*.cmake' -or -iname '*.a' -or -iname '*.la' -or -iname '*.def' ')' \
|
2021-05-28 10:50:59 +02:00
|
|
|
-printf '$$(DST_LIBDIR$(3))/%p.debug\0' | xargs $(--verbose?) -0 -r -P$$(J) rm -f
|
2021-09-04 00:42:35 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -not '(' -iname '*.pc' -or -iname '*.cmake' -or -iname '*.a' -or -iname '*.la' -or -iname '*.def' ')' \
|
2021-01-21 10:30:21 +01:00
|
|
|
-printf '--strip-debug\0%p\0$$(DST_LIBDIR$(3))/%p\0' | \
|
2021-05-28 10:50:59 +02:00
|
|
|
xargs $(--verbose?) -0 -r -P$$(J) -n3 objcopy --file-alignment=4096
|
2021-05-28 10:29:12 +02:00
|
|
|
cd $$($(2)_LIBDIR$(3)) && find -type f -name '*.dll' \
|
|
|
|
-printf '$$(DST_LIBDIR$(3))/%p\0' | \
|
2021-05-28 10:50:59 +02:00
|
|
|
xargs $(--verbose?) -0 -r -P$$(J) -n1 $$(SRC)/make/pefixup.py
|
2021-01-21 10:30:21 +01:00
|
|
|
touch $$@
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(1)-dist$(3): $$(OBJ)/.$(1)-dist$(3)
|
|
|
|
.INTERMEDIATE: $(1)-dist$(3)
|
|
|
|
|
|
|
|
all-dist$(3) $(1)-dist: $(1)-dist$(3)
|
|
|
|
.PHONY: all-dist$(3) $(1)-dist
|
|
|
|
|
|
|
|
all-dist: $(1)-dist
|
|
|
|
.PHONY: all-dist
|
|
|
|
|
|
|
|
|
|
|
|
$(1)$(3): $(1)-configure$(3) $(1)-build$(3) $(1)-dist$(3)
|
2020-03-28 18:46:24 +01:00
|
|
|
.INTERMEDIATE: $(1)$(3)
|
|
|
|
|
|
|
|
all$(3) $(1): $(1)$(3)
|
|
|
|
.PHONY: all$(3) $(1)
|
|
|
|
|
|
|
|
all: $(1)
|
|
|
|
.PHONY: all
|
|
|
|
|
2021-04-02 12:40:30 +02:00
|
|
|
CONTAINERGOALS := $(CONTAINERGOALS) $(filter $(1),$(MAKECMDGOALS))
|
|
|
|
|
2020-03-28 18:46:24 +01:00
|
|
|
|
|
|
|
$(2)_ENV$(3) = \
|
2020-05-28 12:24:12 +02:00
|
|
|
CARGO_HOME=$$(OBJ)/.cargo \
|
|
|
|
CARGO_TARGET_$$(call toupper,$$(ARCH$(3))-unknown-linux-gnu)_LINKER="$$(ARCH$(3))-linux-gnu-gcc" \
|
2020-03-28 18:46:24 +01:00
|
|
|
CCACHE_BASEDIR="$$(CCACHE_BASEDIR)" \
|
|
|
|
STRIP="$$(STRIP)" \
|
|
|
|
CC="$$(CCACHE_BIN) $$(ARCH$(3))-linux-gnu-gcc" \
|
|
|
|
CXX="$$(CCACHE_BIN) $$(ARCH$(3))-linux-gnu-g++" \
|
|
|
|
LD="$$(ARCH$(3))-linux-gnu-ld" \
|
|
|
|
PKG_CONFIG="$$(ARCH$(3))-linux-gnu-pkg-config" \
|
|
|
|
CROSSCC="$$(CCACHE_BIN) $$(ARCH$(3))-w64-mingw32-gcc" \
|
|
|
|
CROSSCXX="$$(CCACHE_BIN) $$(ARCH$(3))-w64-mingw32-g++" \
|
|
|
|
CROSSLD="$$(ARCH$(3))-w64-mingw32-ld" \
|
|
|
|
CROSSPKG_CONFIG="$$(ARCH$(3))-linux-gnu-pkg-config" \
|
2021-01-21 10:30:21 +01:00
|
|
|
PATH="$$(call list-join,:,$$(foreach d,$$($(2)_DEPS$(3)),$$($$(d)_BINDIR$(3))),,:):$$(SRC)/glslang/bin:$$$$PATH" \
|
|
|
|
LD_LIBRARY_PATH="$$(call list-join,:,$$(foreach d,$$($(2)_DEPS$(3)),$$($$(d)_LIBDIR$(3))),,:)$$$$LD_LIBRARY_PATH" \
|
|
|
|
PKG_CONFIG_PATH="$$(call list-join,:,$$(foreach d,$$($(2)_DEPS$(3)),$$($$(d)_LIBDIR$(3))/pkgconfig))" \
|
|
|
|
CFLAGS="$$(foreach d,$$($(2)_DEPS$(3)),-I$$($$(d)_INCDIR$(3))) $$($(2)_CFLAGS) $$(COMMON_FLAGS) $$(COMMON_FLAGS$(3))" \
|
2021-09-04 00:42:35 +02:00
|
|
|
CPPFLAGS="$$(foreach d,$$($(2)_DEPS$(3)),-I$$($$(d)_INCDIR$(3))) $$($(2)_CPPFLAGS) $$(COMMON_FLAGS) $$(COMMON_FLAGS$(3))" \
|
2021-01-21 10:30:21 +01:00
|
|
|
CXXFLAGS="$$(foreach d,$$($(2)_DEPS$(3)),-I$$($$(d)_INCDIR$(3))) $$($(2)_CXXFLAGS) $$(COMMON_FLAGS) $$(COMMON_FLAGS$(3)) -std=c++17" \
|
|
|
|
LDFLAGS="$$(foreach d,$$($(2)_DEPS$(3)),-L$$($$(d)_LIBDIR$(3))) \
|
|
|
|
$$(foreach d,$$($(2)_DEPS$(3)),-Wl,-rpath-link=$$($$(d)_LIBDIR$(3))) \
|
2021-09-04 00:42:35 +02:00
|
|
|
$$($(2)_LDFLAGS$(3)) $$($(2)_LDFLAGS) $$(LDFLAGS)"
|
2020-03-28 18:46:24 +01:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
2021-01-21 10:30:21 +01:00
|
|
|
ifneq ($(UNSTRIPPED_BUILD),)
|
|
|
|
install-strip = objcopy --file-alignment=4096 --only-keep-debug $(1) $(2)/$(notdir $(1)).debug && \
|
|
|
|
objcopy --file-alignment=4096 --add-gnu-debuglink=$(2)/$(notdir $(1)).debug --strip-debug $(1) $(2)/$(notdir $(1))
|
|
|
|
else
|
|
|
|
install-strip = objcopy --file-alignment=4096 --strip-debug $(1) $(2)/$(notdir $(1)) && rm -f $(2)/$(notdir $(1)).debug
|
|
|
|
endif
|
|
|
|
|
2020-03-28 18:46:24 +01:00
|
|
|
ARCH32 := i686
|
|
|
|
ARCH64 := x86_64
|
|
|
|
|
|
|
|
$(OBJ)/.%-post-build32:
|
|
|
|
touch $@
|
|
|
|
$(OBJ)/.%-post-build64:
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
rules-common = $(call create-rules-common,$(1),$(call toupper,$(1)),$(2))
|