build: Introduce rules-cmake macro.

This commit is contained in:
Rémi Bernon 2020-03-28 16:35:00 +01:00 committed by Andrew Eikum
parent 05480be5b9
commit 94fd711e2b
2 changed files with 35 additions and 0 deletions

View file

@ -39,6 +39,7 @@ include $(SRC)/make/utility.mk
include $(SRC)/make/rules-source.mk include $(SRC)/make/rules-source.mk
include $(SRC)/make/rules-common.mk include $(SRC)/make/rules-common.mk
include $(SRC)/make/rules-meson.mk include $(SRC)/make/rules-meson.mk
include $(SRC)/make/rules-cmake.mk
# If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment. # If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment.
ifeq ($(ENABLE_CCACHE),1) ifeq ($(ENABLE_CCACHE),1)

34
make/rules-cmake.mk Normal file
View file

@ -0,0 +1,34 @@
# parameters:
# $(1): lowercase package name
# $(2): uppercase package name
# $(3): 32/64, build type
#
define create-rules-cmake
$(call create-rules-common,$(1),$(2),$(3))
ifeq ($(CONTAINER),1)
$$(OBJ)/.$(1)-configure$(3): $$($(2)_SRC)/CMakeLists.txt
@echo ":: configuring $(3)bit $(1)..." >&2
rm -rf "$$($(2)_OBJ$(3))/CMakeCache.txt"
cd "$$($(2)_OBJ$(3))" && env $$($(2)_ENV$(3)) \
cmake "$$($(2)_SRC)" \
-DCMAKE_INSTALL_PREFIX="$$($(2)_DST$(3))" \
-DCMAKE_INSTALL_LIBDIR="lib$(subst 32,,$(3))" \
-DCMAKE_BUILD_TYPE=plain \
$$($(2)_CMAKE_ARGS) \
$$($(2)_CMAKE_ARGS$(3))
touch $$@
$$(OBJ)/.$(1)-build$(3):
@echo ":: building $(3)bit $(1)..." >&2
cd "$$($(2)_OBJ$(3))" && env $$($(2)_ENV$(3)) \
$$(MAKE)
cd "$$($(2)_OBJ$(3))" && env $$($(2)_ENV$(3)) \
$$(MAKE) install
touch $$@
endif
endef
rules-cmake = $(call create-rules-cmake,$(1),$(call toupper,$(1)),$(2))