2019-03-03 12:42:46 +00:00
|
|
|
.PHONY: default
|
|
|
|
default: all
|
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
# Overridable defaults
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 02:48:15 +00:00
|
|
|
export SOURCE_DATE_EPOCH ?= $(shell $(PROJECT_ROOT)/build/get_source_date_epoch.sh)
|
|
|
|
export BUILDTIME ?= $(shell date -u -d '@$(SOURCE_DATE_EPOCH)' --rfc-3339 ns 2>/dev/null | sed -e 's/ /T/')
|
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
VERBOSE ?=
|
2019-03-23 03:07:47 +00:00
|
|
|
MARCH ?= amd64
|
2019-03-23 02:48:15 +00:00
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
PROJECT_NAME ?= webfs
|
2019-03-03 12:42:46 +00:00
|
|
|
PROJECT_ROOT ?= .
|
|
|
|
VERSION ?= $(shell cat $(PROJECT_ROOT)/VERSION)
|
2019-03-23 02:48:15 +00:00
|
|
|
OUT ?= $(PROJECT_ROOT)/.build
|
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
PARALLELMFLAGS ?= -j$(shell nproc)
|
2019-03-20 00:32:55 +00:00
|
|
|
UID ?= $(shell id -u)
|
2019-03-23 02:48:15 +00:00
|
|
|
|
2019-03-03 12:42:46 +00:00
|
|
|
DOCKER ?= docker
|
2019-03-23 01:31:32 +00:00
|
|
|
DOCKER_BUILDKIT ?=
|
2019-03-23 02:48:15 +00:00
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
CONTAINER_USER ?= $(UID)
|
|
|
|
CONTAINER_GROUP ?= $(shell id -g)
|
|
|
|
CONTAINER_WORKSPACE ?= /workspace
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
UBUNTU_CODENAME ?= bionic
|
2019-03-20 23:43:53 +00:00
|
|
|
|
2019-03-23 03:07:47 +00:00
|
|
|
# Dependencies
|
2019-03-23 01:17:44 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
GTEST_VERSION ?= 1.8.1
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDARGS += GTEST_VERSION=$(GTEST_VERSION)
|
2019-03-23 03:07:47 +00:00
|
|
|
FETCH_TARGETS += $(OUT)/googletest-release-$(GTEST_VERSION).tar.gz
|
|
|
|
$(OUT)/googletest-release-$(GTEST_VERSION).tar.gz: URL := https://github.com/google/googletest/archive/release-$(GTEST_VERSION).tar.gz
|
2019-03-23 01:17:44 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
FUSE_VERSION ?= 3.1.1
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDARGS += FUSE_VERSION=$(FUSE_VERSION)
|
2019-03-23 03:07:47 +00:00
|
|
|
FETCH_TARGETS += $(OUT)/libfuse-fuse-$(FUSE_VERSION).tar.gz
|
|
|
|
$(OUT)/libfuse-fuse-$(FUSE_VERSION).tar.gz: URL := https://github.com/libfuse/libfuse/archive/fuse-$(FUSE_VERSION).tar.gz
|
2019-03-23 01:17:44 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
WEBSOCKETS_VERSION ?= 3.1.0
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDARGS += WEBSOCKETS_VERSION=$(WEBSOCKETS_VERSION)
|
2019-03-23 03:07:47 +00:00
|
|
|
FETCH_TARGETS += $(OUT)/libwebsockets-$(WEBSOCKETS_VERSION).tar.gz
|
|
|
|
$(OUT)/libwebsockets-$(WEBSOCKETS_VERSION).tar.gz: URL := https://github.com/warmcat/libwebsockets/archive/v$(WEBSOCKETS_VERSION).tar.gz
|
2019-03-23 01:17:44 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
JANSSON_VERSION ?= 2.12
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDARGS += JANSSON_VERSION=$(JANSSON_VERSION)
|
2019-03-23 03:07:47 +00:00
|
|
|
FETCH_TARGETS += $(OUT)/jansson-$(JANSSON_VERSION).tar.gz
|
|
|
|
$(OUT)/jansson-$(JANSSON_VERSION).tar.gz: URL := https://github.com/akheron/jansson/archive/v$(JANSSON_VERSION).tar.gz
|
2019-03-20 23:43:53 +00:00
|
|
|
|
2019-03-23 03:07:47 +00:00
|
|
|
QEMU_VERSION ?= v3.1.0-2
|
|
|
|
FETCH_TARGETS += $(OUT)/docker/qemu-arm-static-$(QEMU_VERSION)
|
|
|
|
$(OUT)/docker/qemu-arm-static-$(QEMU_VERSION): URL := https://github.com/multiarch/qemu-user-static/releases/download/$(QEMU_VERSION)/qemu-arm-static
|
|
|
|
|
|
|
|
# Architecture-specific rule target configuration
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
MARCH_AMD64 := $(filter-out amd64,$(MARCH))
|
2019-03-23 01:17:44 +00:00
|
|
|
$(MARCH_AMD64)MARCHS += amd64
|
|
|
|
$(MARCH_AMD64)TARGETS += amd64-ubuntu-builder
|
|
|
|
|
2019-03-03 12:42:46 +00:00
|
|
|
MARCH_ARM32V7 := $(filter-out arm32v7,$(MARCH))
|
2019-03-23 01:17:44 +00:00
|
|
|
$(MARCH_ARM32V7)MARCHS += arm32v7
|
|
|
|
$(MARCH_ARM32V7)TARGETS += arm32v7-ubuntu-builder
|
|
|
|
|
|
|
|
ARM_TARGETS = $(filter arm%,$(TARGETS))
|
2019-03-23 03:07:47 +00:00
|
|
|
$(addprefix $(OUT)/docker/,$(ARM_TARGETS)): $(OUT)/docker/qemu-arm-static-$(QEMU_VERSION)
|
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
UBUNTU_TARGETS = $(filter $(addsuffix -ubuntu%,$(MARCHS)),$(TARGETS))
|
2019-03-23 03:07:47 +00:00
|
|
|
$(addprefix $(OUT)/docker/,$(UBUNTU_TARGETS)): CODENAME := $(UBUNTU_CODENAME)
|
|
|
|
|
|
|
|
# Common rule target configuration
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
MAKEFLAGS += $(PARALLELMFLAGS) --no-builtin-rules
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
CMAKEFLAGS += -GNinja
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
DOCKER_RUNFLAGS += --interactive
|
|
|
|
DOCKER_RUNFLAGS += --rm
|
|
|
|
DOCKER_RUNFLAGS += --tty
|
2019-03-20 00:32:55 +00:00
|
|
|
DOCKER_RUNFLAGS += --init
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_RUNFLAGS += --user $(CONTAINER_USER):$(CONTAINER_GROUP)
|
2019-03-03 12:42:46 +00:00
|
|
|
DOCKER_RUNFLAGS += --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined
|
|
|
|
DOCKER_RUNFLAGS += --env SOURCE_DATE_EPOCH
|
2019-03-23 02:48:15 +00:00
|
|
|
DOCKER_RUNFLAGS += --env BUILDTIME
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
DOCKER_BUILDARGS += CODENAME=$(CODENAME)
|
2019-03-20 23:43:53 +00:00
|
|
|
DOCKER_BUILDARGS += PARALLELMFLAGS=$(PARALLELMFLAGS)
|
2019-03-20 00:32:55 +00:00
|
|
|
DOCKER_BUILDARGS += USERID=$(UID)
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDARGS += WORKSPACE=$(CONTAINER_WORKSPACE)
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
DOCKER_BUILDFLAGS += --rm
|
2019-03-03 12:42:46 +00:00
|
|
|
DOCKER_BUILDFLAGS += $(addprefix --build-arg ,$(DOCKER_BUILDARGS))
|
|
|
|
|
|
|
|
OUT_DIRS += $(OUT)
|
|
|
|
OUT_DIRS += $(OUT)/docker
|
2019-03-20 23:43:53 +00:00
|
|
|
OUT_DIRS += $(OUT)/src
|
2019-03-03 12:42:46 +00:00
|
|
|
OUT_DIRS += $(addprefix $(OUT)/,$(TARGETS))
|
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
BUILD_TARGETS += $(addprefix build-,$(TARGETS))
|
2019-03-03 12:42:46 +00:00
|
|
|
CHECK_TARGETS += $(addprefix check-,$(TARGETS))
|
2019-03-20 23:43:53 +00:00
|
|
|
EXTRACT_TARGETS += $(patsubst $(OUT)/%.tar.gz,$(OUT)/src/%,$(FETCH_TARGETS))
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
echo_if_silent = VERBOSE=1
|
|
|
|
$(VERBOSE)echo_if_silent = echo $1
|
|
|
|
$(VERBOSE)SILENT := @
|
|
|
|
|
2019-03-23 01:38:52 +00:00
|
|
|
BUILD_TARGETS := $(BUILD_TARGETS)
|
|
|
|
CHECK_TARGETS := $(CHECK_TARGETS)
|
2019-03-23 01:17:44 +00:00
|
|
|
CONTAINER_GROUP := $(CONTAINER_GROUP)
|
2019-03-03 12:42:46 +00:00
|
|
|
VERSION := $(VERSION)
|
|
|
|
PROJECT_ROOT := $(PROJECT_ROOT)
|
|
|
|
OUT := $(OUT)
|
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
# Rules
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 01:38:52 +00:00
|
|
|
$(CHECK_TARGETS):
|
|
|
|
|
|
|
|
$(BUILD_TARGETS):
|
|
|
|
|
2019-03-03 12:42:46 +00:00
|
|
|
.PHONY: all
|
2019-03-23 01:17:44 +00:00
|
|
|
all: $(BUILD_TARGETS)
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
.PHONY: check
|
|
|
|
check: $(CHECK_TARGETS)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean: $(CLEAN_TARGETS)
|
|
|
|
$(SILENT)-rm -rf $(OUT_DIRS)
|
|
|
|
|
2019-03-23 01:17:44 +00:00
|
|
|
.PHONY: check-%
|
|
|
|
check-%: build-%;
|
|
|
|
|
|
|
|
.PHONY: build-%
|
|
|
|
build-%: $(OUT)/%/CMakeCache.txt
|
|
|
|
$(SILENT) \
|
|
|
|
$(call echo_if_silent,ninja $(PARALLELMFLAGS) $(GLOAS)) \
|
|
|
|
&& $(DOCKER) run $(DOCKER_RUNFLAGS) \
|
|
|
|
--volume '$(realpath $(PROJECT_ROOT)):$(CONTAINER_WORKSPACE)' \
|
|
|
|
--volume '$(realpath $(dir $<)):$(CONTAINER_WORKSPACE)/$(notdir $(OUT))' \
|
|
|
|
--workdir '$(CONTAINER_WORKSPACE)/$(notdir $(OUT))' \
|
|
|
|
$(PROJECT_NAME)-$*:$(VERSION) \
|
|
|
|
ninja $(PARALLELMFLAGS) $(GLOAS)
|
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
.PHONY: get-deps
|
|
|
|
get-deps: $(EXTRACT_TARGETS)
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
.PHONY: debug-print-%
|
|
|
|
debug-print-%:
|
|
|
|
@printf '%s\n' '$*:' $($*)
|
2019-03-19 23:58:06 +00:00
|
|
|
|
2019-03-03 12:42:46 +00:00
|
|
|
$(CHECK_TARGETS): GLOAS := test
|
2019-03-23 01:17:44 +00:00
|
|
|
$(CHECK_TARGETS): CONTAINER_USER := user
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
$(OUT)/docker/qemu-arm-static-$(QEMU_VERSION):
|
|
|
|
$(SILENT) \
|
2019-03-23 01:17:44 +00:00
|
|
|
$(call echo_if_silent,curl -fsSL -o $@ $(URL)) \
|
|
|
|
&& curl -fsSL -o $@ $(URL) \
|
2019-03-20 23:43:53 +00:00
|
|
|
&& chmod +x $@
|
2019-03-03 12:42:46 +00:00
|
|
|
|
2019-03-23 02:48:15 +00:00
|
|
|
$(OUT)/docker/% : $(PROJECT_ROOT)/build/% | $(OUT_DIRS)
|
2019-03-20 23:43:53 +00:00
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
$(OUT)/docker/%: $(OUT)/docker/%.dockerfile $(EXTRACT_TARGETS) $(PROJECT_ROOT)/Makefile | $(OUT_DIRS)
|
2019-03-23 01:17:44 +00:00
|
|
|
$(SILENT) \
|
|
|
|
$(call echo_if_silent,docker build $(PROJECT_NAME)-$*:$(VERSION) $(OUT)) \
|
|
|
|
&& $(DOCKER) build $(DOCKER_BUILDFLAGS) --iidfile $@ --file $< --tag $(PROJECT_NAME)-$*:$(VERSION) $(OUT)
|
2019-03-20 23:43:53 +00:00
|
|
|
|
|
|
|
$(OUT)/%.tar.gz: | $(OUT_DIRS)
|
|
|
|
curl -fsSL -o $@ $(URL)
|
|
|
|
|
|
|
|
$(OUT)/src/%: $(OUT)/%.tar.gz | $(OUT_DIRS)
|
|
|
|
$(SILENT) \
|
2019-03-23 01:17:44 +00:00
|
|
|
$(call echo_if_silent,tar -C $(dir $@) -xf $<) \
|
|
|
|
&& tar -C $(dir $@) -xf $< \
|
2019-03-20 23:43:53 +00:00
|
|
|
&& touch $@
|
|
|
|
|
|
|
|
$(OUT)/%/CMakeCache.txt: $(PROJECT_ROOT)/CMakeLists.txt $(OUT)/docker/% | $(OUT_DIRS)
|
2019-03-23 01:17:44 +00:00
|
|
|
$(SILENT) \
|
|
|
|
$(call echo_if_silent,cmake $(CMAKEFLAGS) ..) \
|
|
|
|
&& $(DOCKER) run $(DOCKER_RUNFLAGS) \
|
|
|
|
--volume '$(realpath $(PROJECT_ROOT)):$(CONTAINER_WORKSPACE)' \
|
|
|
|
--volume '$(realpath $(dir $@)):$(CONTAINER_WORKSPACE)/$(notdir $(OUT))' \
|
|
|
|
--workdir '$(CONTAINER_WORKSPACE)/$(notdir $(OUT))' \
|
|
|
|
$(PROJECT_NAME)-$*:$(VERSION) \
|
2019-03-23 01:31:32 +00:00
|
|
|
cmake $(CMAKEFLAGS) .. \
|
|
|
|
&& touch $@
|
2019-03-03 12:42:46 +00:00
|
|
|
|
|
|
|
$(OUT_DIRS):
|
|
|
|
$(SILENT)mkdir -p $@
|
|
|
|
|
2019-03-20 23:43:53 +00:00
|
|
|
.PRECIOUS: $(OUT)/docker/% $(OUT)/%/CMakeCache.txt
|
|
|
|
.DELETE_ON_ERROR: $(OUT)/%/CMakeCache.txt
|
2019-03-03 12:42:46 +00:00
|
|
|
|