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@37: all: Beremiz-installer edouard@37: edouard@37: DIST ?= win32 Edouard@0: Edouard@29: src := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) edouard@37: HGREMOTE ?= REMOTE_HG_DISABLED edouard@28: HGROOT ?= $(abspath $(src)/..) Edouard@6: GITROOT := $(HGROOT) Edouard@29: CPUS := `cat /proc/cpuinfo | grep -e 'processor\W*:\W*[[:digit:]]*' | nl -n ln | tail -n1 | cut -f1` Edouard@6: BLKDEV=/dev/null Edouard@0: edouard@37: XVFBRUN ?= xvfb-run andrej@12: 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@37: test -d $(HGROOT)/`basename $(1)` || hg --cwd $(HGROOT) clone $(HGREMOTE)`basename $(1)`;\ edouard@37: hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1);\ edouard@37: hg -R $(HGROOT)/`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@37: rm -rf $(1) edouard@37: test -d $(GITROOT)/`basename $(1)` || git clone $(3) $(GITROOT)/`basename $(1)` edouard@37: mkdir $(1) edouard@37: (cd $(GITROOT)/`basename $(1)`; git archive --format=tar $(2)) | tar -C $(1) -x 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@37: get_src_pypi=$(call get_src_http,https://pypi.python.org/packages/$(1),$(2)) Edouard@0: edouard@37: get_src_sf=$(call get_src_http,https://$(sfmirror).sourceforge.net/project/$(1),$(2)) Edouard@6: edouard@37: include $(src)/windows_installer.mk Edouard@6: Edouard@6: ifneq ("$(DIST)","") Edouard@6: include $(src)/$(DIST).mk Edouard@6: endif Edouard@6: edouard@37: OWN_PROJECTS=beremiz matiec $(OWN_PROJECTS_EX) Edouard@6: edouard@37: define get_revision edouard@37: $(1)_revision?=$(lastword $(shell grep $(1) $(src)/revisions.txt)) edouard@37: endef edouard@37: $(foreach project,$(OWN_PROJECTS),$(eval $(call get_revision,$(project)))) Edouard@8: edouard@37: define get_revisionid edouard@45: $(1)_revisionid?=$(shell hg -R $(HGROOT)/$(1) id -i -r $($(1)_revision)) Edouard@8: endef edouard@37: $(foreach project,$(OWN_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@57: echo "Checkout HG source $(1)_$($(1)_revisionid)" edouard@57: env edouard@37: rm -rf sources/$(1)* edouard@37: $(call get_src_hg,sources/$(1),-r $($(1)_revisionid)) edouard@37: touch $$@ Edouard@8: endef edouard@37: $(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project)))) edouard@22: edouard@37: own_sources: $(foreach project,$(OWN_PROJECTS), sources/$(project)_src) Edouard@8: touch $@ Edouard@0: edouard@37: define show_revision_details edouard@37: echo -n $(1) "revision is: "; hg -R $(HGROOT)/$(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@37: (echo -n "beremiz_dist revision is: "; hg -R $(src) id;) >> revisions.txt edouard@37: ($(foreach project,$(OWN_PROJECTS),$(call show_revision_details,$(project)))) >> revisions.txt edouard@37: bash -c 'hg -R $(src) st | ( if read ; then echo -e "\n******* MODIFIED LPCDISTRO ********\n" ; hg -R $(src) st ; fi ) >> revisions.txt' Edouard@6: Edouard@6: edouard@37: