mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-14 15:48:11 +03:00
build: Introduce rules-common macro.
This commit is contained in:
parent
49cfbe9870
commit
dcb0f60cb7
@ -37,6 +37,7 @@ endif
|
||||
|
||||
include $(SRC)/make/utility.mk
|
||||
include $(SRC)/make/rules-source.mk
|
||||
include $(SRC)/make/rules-common.mk
|
||||
|
||||
# If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment.
|
||||
ifeq ($(ENABLE_CCACHE),1)
|
||||
@ -162,9 +163,11 @@ else
|
||||
MESON_STRIP_ARG := --strip
|
||||
endif
|
||||
|
||||
CROSSLDFLAGS += -Wl,--file-alignment,4096
|
||||
OPTIMIZE_FLAGS := -O2 -march=nocona $(call cc-option,$(CC),-mtune=core-avx2,) -mfpmath=sse
|
||||
SANITY_FLAGS := -fwrapv -fno-strict-aliasing
|
||||
COMMON_FLAGS := $(OPTIMIZE_FLAGS) $(SANITY_FLAGS)
|
||||
COMMON_FLAGS = $(OPTIMIZE_FLAGS) $(SANITY_FLAGS) -ffile-prefix-map=$(CCACHE_BASEDIR)=.
|
||||
COMMON_FLAGS32 := -mstackrealign
|
||||
CARGO_BUILD_ARG := --release
|
||||
|
||||
# These variables might need to be quoted, but might not
|
||||
|
89
make/rules-common.mk
Normal file
89
make/rules-common.mk
Normal file
@ -0,0 +1,89 @@
|
||||
# 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)
|
||||
$(2)_DST$(3) := $$(abspath $$(TOOLS_DIR$(3)))
|
||||
$(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
|
||||
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
|
||||
|
||||
|
||||
$(1)$(3): $(1)-configure$(3) $(1)-build$(3)
|
||||
.INTERMEDIATE: $(1)$(3)
|
||||
|
||||
all$(3) $(1): $(1)$(3)
|
||||
.PHONY: all$(3) $(1)
|
||||
|
||||
all: $(1)
|
||||
.PHONY: all
|
||||
|
||||
|
||||
$(2)_ENV$(3) = \
|
||||
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" \
|
||||
PATH="$$($(2)_BINDIR$(3)):$$(SRC)/glslang/bin:$$$$PATH" \
|
||||
LD_LIBRARY_PATH="$$($(2)_LIBDIR$(3)):$$$$LD_LIBRARY_PATH" \
|
||||
PKG_CONFIG_PATH="$$($(2)_LIBDIR$(3))/pkgconfig" \
|
||||
CFLAGS="-I$$($(2)_INCDIR$(3)) $$($(2)_CFLAGS) $$(COMMON_FLAGS) $$(COMMON_FLAGS$(3))" \
|
||||
CXXFLAGS="-I$$($(2)_INCDIR$(3)) $$($(2)_CXXFLAGS) $$(COMMON_FLAGS) $$(COMMON_FLAGS$(3)) -std=c++17" \
|
||||
LDFLAGS="-L$$($(2)_LIBDIR$(3)) \
|
||||
-Wl,-rpath-link=$$($(2)_LIBDIR$(3)) \
|
||||
$$($(2)_LDFLAGS) $$(LDFLAGS)"
|
||||
|
||||
endef
|
||||
|
||||
ARCH32 := i686
|
||||
ARCH64 := x86_64
|
||||
|
||||
$(OBJ)/.%-post-build32:
|
||||
touch $@
|
||||
$(OBJ)/.%-post-build64:
|
||||
touch $@
|
||||
|
||||
rules-common = $(call create-rules-common,$(1),$(call toupper,$(1)),$(2))
|
Loading…
x
Reference in New Issue
Block a user