Makefile
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 31 Jul 2022 16:43:25 +0200
changeset 79 a8b434605895
parent 62 d545546e8735
child 81 a95b2fa896e9
permissions -rw-r--r--
Add Snap Package.

For now :
- using makefile :
$ cd ~/build; make -f ~/src/beremiz_public_dist/Makefile DIST=snap
- build and run of python exemple was tested
- no fieldbus support yet.
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
     1
#! gmake
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
     2
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
     3
# This is top level Makefile for beremiz_public_dist
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
     4
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
     5
# see also: 
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
     6
#   build_in_docker.sh : use case example
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
     7
#   provision_bionic64.sh : prerequisites
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
     8
79
a8b434605895 Add Snap Package.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 62
diff changeset
     9
all: main_target
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    10
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    11
DIST ?= win32
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    12
29
503b0ef635cc Upgrade Makefile
Edouard Tisserant
parents: 28
diff changeset
    13
src := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    14
HGREMOTE ?= REMOTE_HG_DISABLED
28
950f79385de7 HGROOT now default to parent of directory containing makefile. Added more instruction in Dockerfile
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 27
diff changeset
    15
HGROOT ?= $(abspath $(src)/..)
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    16
GITROOT := $(HGROOT)
29
503b0ef635cc Upgrade Makefile
Edouard Tisserant
parents: 28
diff changeset
    17
CPUS := `cat /proc/cpuinfo | grep -e 'processor\W*:\W*[[:digit:]]*' | nl -n ln | tail -n1 | cut -f1`
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    18
BLKDEV=/dev/null
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    19
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    20
distfiles = $(src)/distfiles
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    21
sfmirror = downloads
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    22
tmp := $(shell rm -rf $${TMPDIR:-/tmp}/beremiz_dist_build_tmp.* ; mktemp -d -t beremiz_dist_build_tmp.XXXXXXXXXX)
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    23
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    24
define hg_get_archive
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    25
	test -d $(HGROOT)/`basename $(1)` || hg --cwd $(HGROOT) clone $(HGREMOTE)`basename $(1)`;\
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    26
	hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1);\
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    27
	hg -R $(HGROOT)/`basename $(1)` id -i | sed 's/\+//' > $(1)/revision;
15
db66054a2ff3 create and add file with revision information for Beremiz
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 14
diff changeset
    28
endef
db66054a2ff3 create and add file with revision information for Beremiz
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 14
diff changeset
    29
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    30
define get_src_hg
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    31
	rm -rf $(1);\
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    32
	$(call hg_get_archive, $(1), $(2))
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    33
endef
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    34
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    35
define get_src_git
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    36
	rm -rf $(1)
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    37
	test -d $(GITROOT)/`basename $(1)` || git clone $(3) $(GITROOT)/`basename $(1)`
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    38
	mkdir $(1)
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    39
	(cd $(GITROOT)/`basename $(1)`; git archive --format=tar $(2)) | tar -C $(1) -x
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    40
endef
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    41
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    42
define get_src_http
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    43
	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`) ) ) &&
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    44
endef
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    45
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    46
get_src_pypi=$(call get_src_http,https://pypi.python.org/packages/$(1),$(2))
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    47
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    48
get_src_sf=$(call get_src_http,https://$(sfmirror).sourceforge.net/project/$(1),$(2))
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    49
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    50
ifneq ("$(DIST)","")
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    51
include $(src)/$(DIST).mk
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    52
endif
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    53
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    54
OWN_PROJECTS=beremiz matiec $(OWN_PROJECTS_EX)
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    55
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    56
define get_revision
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    57
$(1)_revision?=$(lastword $(shell grep $(1) $(src)/revisions.txt))
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    58
endef
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    59
$(foreach project,$(OWN_PROJECTS),$(eval $(call get_revision,$(project))))
8
b7e0285edfa8 Added msys' make, bash and coreutils with mingw binaries
Edouard Tisserant
parents: 6
diff changeset
    60
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    61
define get_revisionid
62
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 59
diff changeset
    62
ifeq ($(origin $(1)_revisionid), undefined)
45
20c1c8a59eab Makefile: Allow overriding revisions IDs through environment, to make it possible to build code comming from non HG repos.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 37
diff changeset
    63
$(1)_revisionid?=$(shell hg -R $(HGROOT)/$(1) id -i -r $($(1)_revision))
62
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 59
diff changeset
    64
endif
8
b7e0285edfa8 Added msys' make, bash and coreutils with mingw binaries
Edouard Tisserant
parents: 6
diff changeset
    65
endef
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    66
$(foreach project,$(OWN_PROJECTS),$(eval $(call get_revisionid,$(project))))
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    67
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    68
sources:
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    69
	mkdir -p sources
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    70
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    71
define make_src_rule
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    72
sources/$(1)_src: sources/$(1)_$($(1)_revisionid)
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    73
	touch $$@
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    74
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    75
sources/$(1)_$($(1)_revisionid): | sources
57
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 45
diff changeset
    76
	echo "Checkout HG source $(1)_$($(1)_revisionid)"
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    77
	rm -rf sources/$(1)*
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    78
	$(call get_src_hg,sources/$(1),-r $($(1)_revisionid))
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    79
	touch $$@
8
b7e0285edfa8 Added msys' make, bash and coreutils with mingw binaries
Edouard Tisserant
parents: 6
diff changeset
    80
endef
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    81
$(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project))))
22
07ad3ba42d39 Experimental docker based installer build, + update of mingw binaries - builds, untested
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 21
diff changeset
    82
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    83
own_sources: $(foreach project,$(OWN_PROJECTS), sources/$(project)_src)
8
b7e0285edfa8 Added msys' make, bash and coreutils with mingw binaries
Edouard Tisserant
parents: 6
diff changeset
    84
	touch $@
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    85
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    86
define show_revision_details
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    87
echo -n $(1) "revision is: "; hg -R $(HGROOT)/$(1) id -r $($(1)_revisionid);
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    88
endef
0
7bc9d95b92bc initial commit, 1.03 installs on WinXP, python test builds and works
Edouard Tisserant
parents:
diff changeset
    89
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    90
revisions.txt: $(src)/revisions.txt own_sources
57
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 45
diff changeset
    91
	echo "Generate revisions.txt"
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    92
	echo "\n******* PACKAGE REVISIONS ********\n" > revisions.txt
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    93
	(echo -n "beremiz_dist revision is: "; hg -R $(src) id;) >> revisions.txt
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    94
	($(foreach project,$(OWN_PROJECTS),$(call show_revision_details,$(project)))) >> revisions.txt
79
a8b434605895 Add Snap Package.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 62
diff changeset
    95
	bash -c 'hg -R $(src) st | ( if read ; then echo -e "\n******* beremiz_public_dist IS MODIFIED ********\n" ; hg -R $(src) st ; fi ) >> revisions.txt'
6
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    96
862080d48ef2 Various updates and enhancement in installer build system, including support for specialized distributions, existing in other branches
Edouard Tisserant
parents: 5
diff changeset
    97
37
fd09116d3537 New windows installer cross build, using patched pacman to get MSYS2's packages and PIP over Wine to get PyPI packages. Work in progress.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 36
diff changeset
    98