1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/build/mkdocker/cmake.mk
nosamad 979ff1e689 refactor(mkdockerbuild): extracts common parts (#24)
* fixes mount of project in wrapper scripts, when not running in container

* refactors makefile in preparation to extract common parts

* refactors makefiles and scripts

* fix git ignore matches

* adds support to disable fetch

* update

* fixes docker warning about unused build argument

* adds support to force offline build

fixes shell escaping
changes paths to relative where possible

* moves make docker builder support files

* removes unnecessary configuration elements

* fixes initial download directory creation

* adds missing rule for initial download directory creation

* fixes docker error: unable to prepare context

copies dockerfile to build context, in order to remove dependency to
unsupported/new docker feature
2019-04-17 17:25:56 +02:00

114 lines
4.3 KiB
Makefile

CURRENT_MAKEFILE := $(lastword $(MAKEFILE_LIST)))
#######################################################################################################################
# Overridable CMake defaults
filter_targets ?= $2
CMAKE_BUILD_TYPE ?= $(BUILDTYPE)
CMAKE_MEMCHECK_FILTER ?= $(MEMCHECK_FILTER)
CMAKE_PROJECTDIR ?= $(CONTAINER_PROJECTDIR)
CMAKE_SCRIPTDIR ?= $(CONTAINER_SCRIPTDIR)
ifndef _INCLUDE_DEFAULTS
include $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE)))/defaults.mk
endif
#######################################################################################################################
# CMake macros
cmake_configure_rule = \
$$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt: $$(PROJECTDIR)/CMakeLists.txt $$(OUTDIR)/docker/$1 | $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/gdbserver; \
$$(SILENT)$$(call cmake_configure,$1)
cmake_configure = \
$(call run,$1,sh -c 'cmake $(CMAKEFLAGS) $(CMAKE_PROJECTDIR) && $(CMAKE_SCRIPTDIR)/bin/cmake_discover_cc_settings.sh $(notdir $@) "$(realpath $(dir $@))"') \
&& touch $(addprefix $(dir $@)/,include_dirs.txt) $@
cmake_discover_cc_settings_rule = \
$$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/include_dirs.txt: $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt; \
$$(SILENT)$$(call cmake_discover_cc_settings,$1)
cmake_discover_cc_settings = \
$(call run,$1,$(CMAKE_SCRIPTDIR)/bin/cmake_discover_cc_settings.sh $(notdir $<) '$(realpath $(dir $<))')
ninja_build_rule = \
build-$1: $$(OUTDIR)/$1/$$(CMAKE_BUILD_TYPE)/CMakeCache.txt; \
$$(SILENT)$$(call ninja_build,$1)
ninja_build = $(call run,$1,ninja $(_PARALLELMFLAGS) $(NINJAFLAGS) $(GOALS))
ctest_memcheck_rule = \
memcheck-$1: build-$1; \
$$(SILENT)$$(call ctest_memcheck,$1)
ctest_memcheck = $(call run,$1,ctest -T memcheck $(CTESTFLAGS))
#######################################################################################################################
# CMake rule target configuration
$(BUILDSILENT)NINJAFLAGS += -v
DOCKER_RUNFLAGS += --env NINJA_STATUS
CMAKEFLAGS += '-GNinja'
CMAKEFLAGS += '-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)'
CMAKE_TARGETS := $(CMAKE_TARGETS)
CMAKE_TARGET := $(filter $(BUILDTARGET),$(CMAKE_TARGETS))
$(CMAKE_TARGET)CMAKE_ACTIVE_TARGETS += $(CMAKE_TARGETS)
CMAKE_ACTIVE_TARGETS += $(CMAKE_TARGET)
CMAKE_ACTIVE_TARGETS := $(call filter_targets,$(FILTER),$(CMAKE_ACTIVE_TARGETS))
CMAKE_BUILD_TARGETS += $(addprefix build-,$(CMAKE_ACTIVE_TARGETS))
CMAKE_CLEAN_TARGETS += $(addprefix clean-,$(CMAKE_ACTIVE_TARGETS))
CMAKE_CHECK_TARGETS += $(addprefix check-,$(CMAKE_ACTIVE_TARGETS))
CMAKE_MEMCHECK_TARGETS += $(addprefix memcheck-,$(call filter_targets,$(CMAKE_MEMCHECK_FILTER),$(CMAKE_ACTIVE_TARGETS)))
CMAKE_RUN_TARGETS += $(addprefix run-,$(firstword $(CMAKE_ACTIVE_TARGETS)))
CMAKE_DISCOVER_CC_TARGETS += $(addprefix discover-cc-,$(firstword $(CMAKE_ACTIVE_TARGETS)))
CMAKE_OUTDIRS += $(addsuffix /$(CMAKE_BUILD_TYPE),$(addprefix $(OUTDIR)/,$(CMAKE_ACTIVE_TARGETS)))
CMAKE_RULE_TARGETS += $(addsuffix /cmakerules.mk,$(OUTDIR))
BUILD_TARGETS += $(CMAKE_BUILD_TARGETS)
CHECK_TARGETS += $(CMAKE_CHECK_TARGETS)
MEMCHECK_TARGETS += $(CMAKE_MEMCHECK_TARGETS)
CLEAN_TARGETS += $(CMAKE_CLEAN_TARGETS)
RUN_TARGETS += $(CMAKE_RUN_TARGETS)
DISCOVER_CC_TARGETS += $(CMAKE_DISCOVER_CC_TARGETS)
RULE_TARGETS += $(CMAKE_RULE_TARGETS)
TARGETS += $(CMAKE_ACTIVE_TARGETS)
OUTDIRS += $(CMAKE_OUTDIRS)
#######################################################################################################################
# Makefile dependencies
MAKEFILE_DEPS += touch
MAKEFILE_DEPS += echo
#######################################################################################################################
# CMake rules
$(CMAKE_RULE_TARGETS):
$(SILENT) \
{ \
$(foreach TARGET,$(CMAKE_TARGETS),\
echo; \
echo '$(call image_rule,$(TARGET))'; \
echo; \
echo '$(call cmake_configure_rule,$(TARGET))'; \
echo; \
echo '$(call ninja_build_rule,$(TARGET))'; \
echo; \
echo '$(call check_rule,$(TARGET))'; \
echo; \
echo '$(call ctest_memcheck_rule,$(TARGET))'; \
echo; \
echo '$(call run_rule,$(TARGET))'; \
echo; \
echo '$(call clean_rule,$(TARGET))'; \
echo; \
echo '$(call cmake_discover_cc_settings_rule,$(TARGET))'; \
echo; \
echo '$(call discover_cc_rule,$(TARGET))'; \
echo; \
echo '$(call wrapper_rule,$(TARGET))'; \
) \
} > $@