Edouard@0: #! gmake Edouard@0: edouard@37: # This is top level Makefile for beremiz_public_dist Edouard@0: edouard@37: # see also: edouard@37: # build_in_docker.sh : use case example edouard@37: # provision_bionic64.sh : prerequisites edouard@37: edouard@79: all: main_target edouard@37: edouard@37: DIST ?= win32 Edouard@0: Edouard@29: src := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) edouard@120: WORKSPACE ?= $(abspath $(src)/..) Edouard@29: CPUS := `cat /proc/cpuinfo | grep -e 'processor\W*:\W*[[:digit:]]*' | nl -n ln | tail -n1 | cut -f1` edouard@101: Edouard@0: distfiles = $(src)/distfiles Edouard@6: sfmirror = downloads edouard@37: tmp := $(shell rm -rf $${TMPDIR:-/tmp}/beremiz_dist_build_tmp.* ; mktemp -d -t beremiz_dist_build_tmp.XXXXXXXXXX) Edouard@0: Edouard@6: define hg_get_archive edouard@120: hg -R $(WORKSPACE)/`basename $(1)` archive $(2) $(1);\ edouard@120: hg -R $(WORKSPACE)/`basename $(1)` id -i | sed 's/\+//' > $(1)/revision; andrej@15: endef andrej@15: Edouard@0: define get_src_hg edouard@37: rm -rf $(1);\ edouard@37: $(call hg_get_archive, $(1), $(2)) Edouard@6: endef Edouard@6: Edouard@6: define get_src_git Edouard@0: endef Edouard@0: Edouard@0: define get_src_http edouard@37: dld=$(distfiles)/`echo $(2) | tr ' ()' '___'`;( ( [ -f $$dld ] || wget $(1)/$(2) -O $$dld ) && ( [ ! -f $$dld.md5 ] && (cd $(distfiles);md5sum `basename $$dld`) > $$dld.md5 || (cd $(distfiles);md5sum -c `basename $$dld.md5`) ) ) && Edouard@0: endef Edouard@0: Edouard@6: ifneq ("$(DIST)","") Edouard@6: include $(src)/$(DIST).mk Edouard@6: endif Edouard@6: edouard@120: FROM_SOURCE_PROJECTS=beremiz matiec $(DIST_FROM_SOURCE_PROJECTS) Edouard@6: edouard@37: define get_revision edouard@37: $(1)_revision?=$(lastword $(shell grep $(1) $(src)/revisions.txt)) edouard@37: endef edouard@120: $(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call get_revision,$(project)))) edouard@120: edouard@120: tar_opts=--absolute-names --exclude=.hg --exclude=.git --exclude=.*.pyc --exclude=.*.swp --exclude=__pycache__ Edouard@8: edouard@37: define get_revisionid edouard@120: $(1)_revisionid ?=\ edouard@120: $(if $(filter local, $($(1)_revision)),\ edouard@120: $(shell tar $(tar_opts) -P -c $(WORKSPACE)/$(1) | sha1sum | cut -d ' ' -f 1),\ edouard@120: $(1)_revisionid?=$$(shell hg -R $(WORKSPACE)/$(1) id -i -r $($(1)_revision))) Edouard@8: endef edouard@120: $(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call get_revisionid,$(project)))) edouard@37: edouard@37: sources: edouard@37: mkdir -p sources edouard@37: edouard@37: define make_src_rule edouard@37: sources/$(1)_src: sources/$(1)_$($(1)_revisionid) edouard@37: touch $$@ edouard@37: edouard@37: sources/$(1)_$($(1)_revisionid): | sources edouard@120: rm -rf sources/$(1)* edouard@120: ifeq ($($(1)_revision),local) edouard@120: echo "Copy local source code for $(1)_$($(1)_revisionid)" edouard@120: tar -C $(WORKSPACE) $(tar_opts) -P -c $(1) | tar -C sources -x edouard@120: else edouard@57: echo "Checkout HG source $(1)_$($(1)_revisionid)" edouard@37: $(call get_src_hg,sources/$(1),-r $($(1)_revisionid)) edouard@120: endif edouard@37: touch $$@ Edouard@8: endef edouard@120: $(foreach project,$(FROM_SOURCE_PROJECTS),$(eval $(call make_src_rule,$(project)))) edouard@22: edouard@120: own_sources: $(foreach project,$(FROM_SOURCE_PROJECTS), sources/$(project)_src) Edouard@8: touch $@ Edouard@0: edouard@81: all_sources: own_sources sources/open62541_src edouard@81: touch $@ edouard@81: edouard@87: sources/open62541_src: | sources edouard@81: rm -rf sources/open62541 edouard@123: $(call get_src_http,https://github.com/open62541/open62541/archive/refs/tags,v1.3.7.tar.gz)\ edouard@81: tar -xzf $$dld edouard@123: mv open62541-1.3.7 sources/open62541 edouard@81: edouard@81: edouard@37: define show_revision_details edouard@120: $(if $(filter local, $($(1)_revision)),\ edouard@120: echo -n $(1) "state is: "; test -d .hg \ edouard@120: && (hg -R $(WORKSPACE)/$(1) id; echo; hg -R $(WORKSPACE)/$(1) st) \ edouard@120: || (git -C $(WORKSPACE)/$(1) show --pretty=format:'%P' -s; echo; git -C $(WORKSPACE)/$(1) status --porcelain);,\ edouard@120: echo -n $(1) "revision is: "; hg -R $(WORKSPACE)/$(1) id -r $($(1)_revisionid); ) edouard@37: endef Edouard@0: edouard@37: revisions.txt: $(src)/revisions.txt own_sources edouard@57: echo "Generate revisions.txt" edouard@37: echo "\n******* PACKAGE REVISIONS ********\n" > revisions.txt edouard@120: (echo -n "beremiz_public_dist revision is: "; test -d .hg && (hg -R $(src) id ; echo; hg -R $(src) st) || (git -C $(src) show --pretty=format:'%P' -s; echo; git -C $(src) status --porcelain)) >> revisions.txt edouard@120: ($(foreach project,$(FROM_SOURCE_PROJECTS),$(call show_revision_details,$(project)))) >> revisions.txt Edouard@6: Edouard@6: edouard@37: