Makefile
changeset 22 07ad3ba42d39
parent 21 5c0a6affeafa
child 27 e7c278de2e20
equal deleted inserted replaced
21:5c0a6affeafa 22:07ad3ba42d39
    25 #           in case it would be a problem, run :
    25 #           in case it would be a problem, run :
    26 #           xvfb-run make -f /path/to/this/Makefile
    26 #           xvfb-run make -f /path/to/this/Makefile
    27 
    27 
    28 version = 1.2-rc1
    28 version = 1.2-rc1
    29 
    29 
    30 HGROOT := ~/src
    30 HGREMOTE ?= https://hg.beremiz.org/
       
    31 HGROOT ?= $(abspath $(CURDIR)/..)
    31 GITROOT := $(HGROOT)
    32 GITROOT := $(HGROOT)
    32 HGPULL = 0
       
    33 DIST =
    33 DIST =
    34 CPUS = 8
    34 CPUS = 8
    35 BLKDEV=/dev/null
    35 BLKDEV=/dev/null
    36 
    36 
    37 
    37 
    48 src := $(shell dirname $(lastword $(MAKEFILE_LIST)))
    48 src := $(shell dirname $(lastword $(MAKEFILE_LIST)))
    49 distfiles = $(src)/distfiles
    49 distfiles = $(src)/distfiles
    50 sfmirror = downloads
    50 sfmirror = downloads
    51 tmp := $(shell mktemp -d)
    51 tmp := $(shell mktemp -d)
    52 
    52 
    53 ifeq ("$(HGPULL)","1")
       
    54 define hg_get_archive
    53 define hg_get_archive
    55 hg -R $(HGROOT)/`basename $(1)` pull
    54 test -d $(HGROOT)/`basename $(1)` || hg --cwd $(HGROOT) clone $(HGREMOTE)`basename $(1)`
    56 hg -R $(HGROOT)/`basename $(1)` update $(2)
       
    57 hg -R $(HGROOT)/`basename $(1)` archive $(1)
       
    58 endef
       
    59 else
       
    60 define hg_get_archive
       
    61 hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1)
    55 hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1)
    62 endef
    56 hg -R $(HGROOT)/`basename $(1)` id -i | sed 's/\+//' > $(1)/revision
    63 endif
       
    64 
       
    65 define hg_get_rev_num
       
    66 hg -R $(HGROOT)/`basename $(1)` id -i | sed 's/\+//' > $(2)
       
    67 endef
    57 endef
    68 
    58 
    69 define get_src_hg
    59 define get_src_hg
    70 rm -rf $(1)
    60 rm -rf $(1)
    71 $(call hg_get_archive, $(1), $(2))
    61 $(call hg_get_archive, $(1), $(2))
    80 define get_src_http
    70 define get_src_http
    81 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`) ) ) &&
    71 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`) ) ) &&
    82 endef
    72 endef
    83 
    73 
    84 define get_src_pypi
    74 define get_src_pypi
    85 $(call get_src_http,http://pypi.python.org/packages/$(1),$(2))
    75 $(call get_src_http,https://pypi.python.org/packages/$(1),$(2))
    86 endef
    76 endef
    87 
    77 
    88 define get_src_sf
    78 define get_src_sf
    89 $(call get_src_http,http://$(sfmirror).sourceforge.net/project/$(1),$(2))
    79 $(call get_src_http,https://$(sfmirror).sourceforge.net/project/$(1),$(2))
    90 endef
    80 endef
    91 
    81 
    92 all: Beremiz-$(version).exe $(targets_add)
    82 all: Beremiz-$(version).exe $(targets_add)
    93 
    83 
    94 
    84 
   107 
    97 
   108 # native toolchain, pre-built
    98 # native toolchain, pre-built
   109 mingwdir=build/mingw
    99 mingwdir=build/mingw
   110 
   100 
   111 define get_mingw
   101 define get_mingw
   112 $(call get_src_sf,mingw/MinGW/Base/$(1),$(2)) tar -C $(mingwdir) --lzma -xf $$dld
   102 $(call get_src_sf,mingw/MinGW/Base/$(1),$(2)) tar -C $(mingwdir) -xf $$dld
   113 endef
   103 endef
   114 define get_msys
   104 define get_msys
   115 $(call get_src_sf,mingw/MSYS/Base/$(1),$(2)) tar -C $(mingwdir) --lzma -xf $$dld
   105 $(call get_src_sf,mingw/MSYS/Base/$(1),$(2)) tar -C $(mingwdir) -xf $$dld
   116 endef
   106 endef
   117 mingw: |build
   107 mingw: |build
   118 	rm -rf $(mingwdir)
   108 	rm -rf $(mingwdir)
   119 	mkdir -p $(mingwdir)
   109 	mkdir -p $(mingwdir)
   120 	# windows.h
   110 	# windows.h
   121 	$(call get_mingw,w32api/w32api-3.17,w32api-3.17-2-mingw32-dev.tar.lzma)
   111 	$(call get_mingw,w32api/w32api-5.0.1,w32api-5.0.1-mingw32-dev.tar.xz)
   122 	# mingw runtime
   112 	# mingw runtime
   123 	$(call get_mingw,mingwrt/mingwrt-3.20,mingwrt-3.20-2-mingw32-dll.tar.lzma)
   113 	$(call get_mingw,mingwrt/mingwrt-5.0.1,mingwrt-5.0.1-mingw32-dll.tar.xz)
   124 	# mingw headers and lib
   114 	# mingw headers and lib
   125 	$(call get_mingw,mingwrt/mingwrt-3.20,mingwrt-3.20-2-mingw32-dev.tar.lzma)
   115 	$(call get_mingw,mingwrt/mingwrt-5.0.1,mingwrt-5.0.1-mingw32-dev.tar.xz)
   126 	# binutils
   116 	# binutils
   127 	$(call get_mingw,binutils/binutils-2.21.53,binutils-2.21.53-1-mingw32-bin.tar.lzma)
   117 	$(call get_mingw,binutils/binutils-2.28,binutils-2.28-1-mingw32-bin.tar.xz)
   128 	# C compiler
   118 	# C compiler
   129 	$(call get_mingw,gcc/Version4/gcc-4.6.1-2,gcc-core-4.6.1-2-mingw32-bin.tar.lzma)
   119 	$(call get_mingw,gcc/Version6/gcc-6.3.0,gcc-core-6.3.0-1-mingw32-bin.tar.xz)
   130 	# dependencies
   120 	# dependencies
   131 	$(call get_mingw,gmp/gmp-5.0.1-1,libgmp-5.0.1-1-mingw32-dll-10.tar.lzma)
   121 	$(call get_mingw,gmp/gmp-6.1.2,libgmp-6.1.2-2-mingw32-dll-10.tar.xz)
   132 	$(call get_mingw,mpc/mpc-0.8.1-1,libmpc-0.8.1-1-mingw32-dll-2.tar.lzma)
   122 	$(call get_mingw,mpc/mpc-1.0.3,libmpc-1.0.3-1-mingw32-dll-3.tar.xz)
   133 	$(call get_mingw,mpfr/mpfr-2.4.1-1,libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma)
   123 	$(call get_mingw,mpfr/mpfr-3.1.5,libmpfr-3.1.5-1-mingw32-dll-4.tar.xz)
   134 	$(call get_mingw,gettext/gettext-0.17-1,libintl-0.17-1-mingw32-dll-8.tar.lzma)
   124 	$(call get_mingw,gettext/gettext-0.18.3.2-2,libintl-0.18.3.2-2-mingw32-dll-8.tar.xz)
   135 	$(call get_mingw,gettext/gettext-0.17-1,libgettextpo-0.17-1-mingw32-dll-0.tar.lzma)
   125 	$(call get_mingw,gettext/gettext-0.18.3.2-2,libgettextpo-0.18.3.2-2-mingw32-dll-0.tar.xz)
   136 	$(call get_mingw,libiconv/libiconv-1.13.1-1,libiconv-1.13.1-1-mingw32-dll-2.tar.lzma)
   126 	$(call get_mingw,libiconv/libiconv-1.14-3,libiconv-1.14-3-mingw32-dll.tar.lzma)
       
   127 
   137 	# make, bash, and dependencies
   128 	# make, bash, and dependencies
   138 	$(call get_msys,bash/bash-3.1.17-3,bash-3.1.17-3-msys-1.0.13-bin.tar.lzma)
   129 	$(call get_msys,bash/bash-3.1.23-1,bash-3.1.23-1-msys-1.0.18-bin.tar.xz)
   139 	$(call get_msys,coreutils/coreutils-5.97-3,coreutils-5.97-3-msys-1.0.13-bin.tar.lzma)
   130 	$(call get_msys,coreutils/coreutils-5.97-3,coreutils-5.97-3-msys-1.0.13-bin.tar.lzma)
   140 	$(call get_msys,libiconv/libiconv-1.13.1-2,libiconv-1.13.1-2-msys-1.0.13-bin.tar.lzma)
   131 	$(call get_msys,libiconv/libiconv-1.14-1,libiconv-1.14-1-msys-1.0.17-bin.tar.lzma)
   141 	$(call get_msys,libiconv/libiconv-1.13.1-2,libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma)
   132 	$(call get_msys,libiconv/libiconv-1.14-1,libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma)
   142 	$(call get_msys,gettext/gettext-0.17-2,libintl-0.17-2-msys-dll-8.tar.lzma)
   133 	$(call get_msys,gettext/gettext-0.18.1.1-1,libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma)
   143 	$(call get_msys,regex/regex-1.20090805-2,libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma)
   134 	$(call get_msys,regex/regex-1.20090805-2,libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma)
   144 	$(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma)
   135 	$(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma)
   145 	$(call get_msys,make/make-3.81-3,make-3.81-3-msys-1.0.13-bin.tar.lzma) 
   136 	$(call get_msys,make/make-3.81-3,make-3.81-3-msys-1.0.13-bin.tar.lzma) 
   146 	$(call get_msys,msys-core/msys-1.0.13-2,msysCORE-1.0.13-2-msys-1.0.13-bin.tar.lzma)
   137 	$(call get_msys,msys-core/msys-1.0.19-1,msysCORE-1.0.19-1-msys-1.0.19-bin.tar.xz)
   147 	$(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma)
   138 	$(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma)
   148 	touch $@
   139 	touch $@
   149 
   140 
   150 msiexec = WINEPREFIX=$(tmp) msiexec
   141 msiexec = WINEPREFIX=$(tmp) msiexec
   151 wine = WINEPREFIX=$(tmp) wine
   142 wine = WINEPREFIX=$(tmp) wine
   268 	rm -rf  examples
   259 	rm -rf  examples
   269 	mkdir -p examples
   260 	mkdir -p examples
   270 
   261 
   271 beremiz: | build examples
   262 beremiz: | build examples
   272 	$(call get_src_hg,build/beremiz)
   263 	$(call get_src_hg,build/beremiz)
   273 	$(call hg_get_rev_num,beremiz,build/beremiz/revision)
       
   274 	$(call tweak_beremiz_targets)
   264 	$(call tweak_beremiz_targets)
   275 	rm -rf examples/canopen_tests
   265 	rm -rf examples/canopen_tests
   276 	mkdir -p examples/canopen_tests
   266 	mkdir -p examples/canopen_tests
   277 	mv build/beremiz/tests/canopen_* examples/canopen_tests
   267 	mv build/beremiz/tests/canopen_* examples/canopen_tests
   278 	rm -rf examples/base_tests
   268 	rm -rf examples/base_tests