Edouard@0: #! gmake Edouard@0: Edouard@0: # This is Makefile for Beremiz installer Edouard@2: # andrej@14: # Invoke with "make -f path/to/Makefile" on a linux box Edouard@6: # in directory where build should happen. Edouard@6: # Edouard@6: # All those dependencies have to be installed : Edouard@6: # Edouard@6: # Windows installer : Edouard@6: # - wine (tested with 1.2 and 1.6. Fail with 1.4) Edouard@0: # - mingw32 Edouard@6: # - flex Edouard@6: # - bison Edouard@0: # - tar Edouard@0: # - unrar Edouard@0: # - wget Edouard@0: # - nsis Edouard@6: # - libtool Edouard@6: # - xmlstarlet Edouard@6: # - xsltproc Edouard@6: # - python-lxml Edouard@6: # Edouard@2: # WARNING : DISPLAY variable have to be defined to a valid X server Edouard@2: # in case it would be a problem, run : Edouard@2: # xvfb-run make -f /path/to/this/Makefile Edouard@0: andrej@16: version = 1.2-rc1 Edouard@0: Edouard@0: HGROOT := ~/src Edouard@6: GITROOT := $(HGROOT) Edouard@6: HGPULL = 0 Edouard@6: DIST = Edouard@0: CPUS = 8 Edouard@6: BLKDEV=/dev/null Edouard@0: andrej@12: andrej@12: CROSS_COMPILE=i686-w64-mingw32 edouard@19: CROSS_COMPILE_LIBS_DIR=$(shell dirname $(shell $(CROSS_COMPILE)-gcc -print-libgcc-file-name)) andrej@12: CC=$(CROSS_COMPILE)-gcc andrej@12: CXX=$(CROSS_COMPILE)-g++ andrej@12: andrej@12: define get_runtime_libs andrej@12: cp $(CROSS_COMPILE_LIBS_DIR)/libgcc_s_sjlj-1.dll $(1) andrej@12: cp $(CROSS_COMPILE_LIBS_DIR)/libstdc++-6.dll $(1) andrej@12: endef andrej@12: Edouard@0: src := $(shell dirname $(lastword $(MAKEFILE_LIST))) Edouard@0: distfiles = $(src)/distfiles Edouard@6: sfmirror = downloads Edouard@0: tmp := $(shell mktemp -d) Edouard@0: Edouard@6: ifeq ("$(HGPULL)","1") Edouard@6: define hg_get_archive Edouard@6: hg -R $(HGROOT)/`basename $(1)` pull Edouard@6: hg -R $(HGROOT)/`basename $(1)` update $(2) Edouard@6: hg -R $(HGROOT)/`basename $(1)` archive $(1) Edouard@6: endef Edouard@6: else Edouard@6: define hg_get_archive Edouard@6: hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1) Edouard@6: endef Edouard@6: endif Edouard@6: andrej@15: define hg_get_rev_num andrej@15: hg -R $(HGROOT)/`basename $(1)` id -i | sed 's/\+//' > $(2) andrej@15: endef andrej@15: Edouard@0: define get_src_hg Edouard@6: rm -rf $(1) Edouard@6: $(call hg_get_archive, $(1), $(2)) Edouard@6: endef Edouard@6: Edouard@6: define get_src_git Edouard@6: rm -rf $(1) Edouard@0: mkdir $(1) Edouard@6: (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@5: 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@0: define get_src_pypi Edouard@0: $(call get_src_http,http://pypi.python.org/packages/$(1),$(2)) Edouard@0: endef Edouard@0: Edouard@0: define get_src_sf Edouard@6: $(call get_src_http,http://$(sfmirror).sourceforge.net/project/$(1),$(2)) Edouard@6: endef Edouard@6: Edouard@6: all: Beremiz-$(version).exe $(targets_add) Edouard@6: Edouard@6: Edouard@6: ifneq ("$(DIST)","") Edouard@6: include $(src)/$(DIST).mk Edouard@6: endif Edouard@6: Edouard@6: CUSTOM := public Edouard@6: CUSTOM_DIR := $(src) Edouard@6: Edouard@6: include $(CUSTOM_DIR)/$(CUSTOM).mk Edouard@6: Edouard@6: build: Edouard@6: rm -rf build Edouard@6: mkdir -p build Edouard@6: Edouard@6: # native toolchain, pre-built Edouard@0: mingwdir=build/mingw Edouard@8: Edouard@8: define get_mingw Edouard@8: $(call get_src_sf,mingw/MinGW/Base/$(1),$(2)) tar -C $(mingwdir) --lzma -xf $$dld Edouard@8: endef Edouard@8: define get_msys Edouard@8: $(call get_src_sf,mingw/MSYS/Base/$(1),$(2)) tar -C $(mingwdir) --lzma -xf $$dld Edouard@8: endef Edouard@6: mingw: |build Edouard@5: rm -rf $(mingwdir) Edouard@0: mkdir -p $(mingwdir) Edouard@0: # windows.h Edouard@8: $(call get_mingw,w32api/w32api-3.17,w32api-3.17-2-mingw32-dev.tar.lzma) Edouard@0: # mingw runtime edouard@18: $(call get_mingw,mingwrt/mingwrt-3.20,mingwrt-3.20-2-mingw32-dll.tar.lzma) Edouard@0: # mingw headers and lib edouard@18: $(call get_mingw,mingwrt/mingwrt-3.20,mingwrt-3.20-2-mingw32-dev.tar.lzma) Edouard@0: # binutils Edouard@8: $(call get_mingw,binutils/binutils-2.21.53,binutils-2.21.53-1-mingw32-bin.tar.lzma) Edouard@0: # C compiler Edouard@8: $(call get_mingw,gcc/Version4/gcc-4.6.1-2,gcc-core-4.6.1-2-mingw32-bin.tar.lzma) Edouard@0: # dependencies Edouard@8: $(call get_mingw,gmp/gmp-5.0.1-1,libgmp-5.0.1-1-mingw32-dll-10.tar.lzma) Edouard@8: $(call get_mingw,mpc/mpc-0.8.1-1,libmpc-0.8.1-1-mingw32-dll-2.tar.lzma) Edouard@8: $(call get_mingw,mpfr/mpfr-2.4.1-1,libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma) Edouard@8: $(call get_mingw,gettext/gettext-0.17-1,libintl-0.17-1-mingw32-dll-8.tar.lzma) Edouard@8: $(call get_mingw,gettext/gettext-0.17-1,libgettextpo-0.17-1-mingw32-dll-0.tar.lzma) Edouard@8: $(call get_mingw,libiconv/libiconv-1.13.1-1,libiconv-1.13.1-1-mingw32-dll-2.tar.lzma) Edouard@8: # make, bash, and dependencies Edouard@8: $(call get_msys,bash/bash-3.1.17-3,bash-3.1.17-3-msys-1.0.13-bin.tar.lzma) Edouard@8: $(call get_msys,coreutils/coreutils-5.97-3,coreutils-5.97-3-msys-1.0.13-bin.tar.lzma) Edouard@8: $(call get_msys,libiconv/libiconv-1.13.1-2,libiconv-1.13.1-2-msys-1.0.13-bin.tar.lzma) Edouard@8: $(call get_msys,libiconv/libiconv-1.13.1-2,libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma) Edouard@8: $(call get_msys,gettext/gettext-0.17-2,libintl-0.17-2-msys-dll-8.tar.lzma) Edouard@8: $(call get_msys,regex/regex-1.20090805-2,libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma) Edouard@8: $(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma) Edouard@8: $(call get_msys,make/make-3.81-3,make-3.81-3-msys-1.0.13-bin.tar.lzma) Edouard@8: $(call get_msys,msys-core/msys-1.0.13-2,msysCORE-1.0.13-2-msys-1.0.13-bin.tar.lzma) Edouard@8: $(call get_msys,termcap/termcap-0.20050421_1-2,libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma) Edouard@8: touch $@ Edouard@0: Edouard@0: msiexec = WINEPREFIX=$(tmp) msiexec Edouard@0: wine = WINEPREFIX=$(tmp) wine Edouard@0: pydir = build/python Edouard@0: pysite = $(pydir)/Lib/site-packages Edouard@0: Edouard@6: python: |build Edouard@5: rm -rf $(pydir) Edouard@2: mkdir -p $(pydir) Edouard@0: # Python Edouard@0: $(call get_src_http,http://www.python.org/ftp/python/2.7.2,python-2.7.2.msi)\ Edouard@0: $(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir) Edouard@0: Edouard@0: # WxPython (needs running inno unpacker in wine) Edouard@0: $(call get_src_sf,innounp/innounp/innounp%200.36,innounp036.rar)\ Edouard@0: unrar e $$dld innounp.exe $(tmp) Edouard@0: $(call get_src_sf,wxpython/wxPython/2.8.12.1,wxPython2.8-win32-unicode-2.8.12.1-py27.exe)\ Edouard@0: $(wine) $(tmp)/innounp.exe -d$(tmp) -x $$dld Edouard@0: cp -R $(tmp)/\{code_GetPythonDir\}/* $(pydir) Edouard@0: cp -R $(tmp)/\{app\}/* $(pysite) Edouard@2: Edouard@2: # wxPython fails if VC9.0 bullshit is not fully here. Edouard@2: $(call get_src_http,http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140,vcredist_x86.exe)\ Edouard@2: cp $$dld $(tmp) Edouard@2: $(wine) $(tmp)/vcredist_x86.exe /qn /a Edouard@2: cp $(tmp)/drive_c/windows/winsxs/x86_Microsoft.VC90.CRT*/* $(pydir) Edouard@6: Edouard@6: # MathPlotLib Edouard@6: $(call get_src_http,https://github.com/downloads/matplotlib/matplotlib,matplotlib-1.2.0.win32-py2.7.exe)\ Edouard@6: unzip -d $(tmp)/mathplotlib $$dld ; [ $$? -eq 1 ] #silence error unziping .exe Edouard@6: cp -R $(tmp)/mathplotlib/PLATLIB/* $(pysite) Edouard@0: Edouard@0: # pywin32 Edouard@0: $(call get_src_sf,pywin32/pywin32/Build216,pywin32-216.win32-py2.7.exe)\ Edouard@0: unzip -d $(tmp)/pw32 $$dld ; [ $$? -eq 1 ] #silence error unziping .exe Edouard@0: cp -R $(tmp)/pw32/PLATLIB/* $(pysite) Edouard@0: andrej@11: # zope.interface andrej@11: $(call get_src_pypi,9d/2d/beb32519c0bd19bda4ac38c34db417d563ee698518e582f951d0b9e5898b,zope.interface-4.3.2-py2.7-win32.egg)\ andrej@14: unzip -d $(tmp) $$dld Edouard@3: cp -R $(tmp)/zope $(pysite) Edouard@3: Edouard@0: # Twisted Edouard@0: $(call get_src_pypi,2.7/T/Twisted,Twisted-11.0.0.winxp32-py2.7.msi)\ Edouard@0: $(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir) Edouard@0: Edouard@0: # Nevow Edouard@0: $(call get_src_pypi,source/N/Nevow,Nevow-0.10.0.tar.gz)\ Edouard@6: tar -C $(tmp) -xzf $$dld Edouard@0: for i in nevow formless twisted; do cp -R $(tmp)/Nevow-0.10.0/$$i $(pysite); done Edouard@0: Edouard@0: # Numpy Edouard@0: $(call get_src_pypi,2.7/n/numpy,numpy-1.6.1.win32-py2.7.exe)\ Edouard@0: unzip -d $(tmp)/np $$dld ; [ $$? -eq 1 ] #silence error unziping .exe Edouard@0: cp -R $(tmp)/np/PLATLIB/* $(pysite) Edouard@0: Edouard@0: # SimpleJson Edouard@0: $(call get_src_pypi,source/s/simplejson,simplejson-2.2.1.tar.gz)\ Edouard@6: tar -C $(tmp) -xzf $$dld Edouard@0: cp -R $(tmp)/simplejson-2.2.1/simplejson/ $(pysite) Edouard@0: Edouard@0: # WxGlade andrej@10: andrej@10: $(call get_src_http,https://bitbucket.org/wxglade/wxglade/get,034d891cc947.zip)\ andrej@14: unzip -d $(tmp) $$dld andrej@10: mv $(tmp)/wxglade-wxglade-034d891cc947 $(pysite)/wxglade Edouard@0: Edouard@0: # Pyro Edouard@6: $(call get_src_pypi,source/P/Pyro,Pyro-3.9.1.tar.gz)\ Edouard@6: tar -C $(tmp) -xzf $$dld Edouard@6: mv $(tmp)/Pyro-3.9.1/Pyro $(pysite) Edouard@6: Edouard@6: # Lxml Edouard@6: $(call get_src_pypi,2.7/l/lxml,lxml-3.2.3.win32-py2.7.exe)\ Edouard@6: unzip -d $(tmp)/lxml $$dld ; [ $$? -eq 1 ] #silence error unziping .exe Edouard@6: cp -R $(tmp)/lxml/PLATLIB/* $(pysite) Edouard@6: Edouard@6: touch $@ Edouard@0: Edouard@0: matiecdir = build/matiec Edouard@6: matiec: |build Edouard@0: $(call get_src_hg,$(tmp)/matiec) Edouard@0: cd $(tmp)/matiec ;\ Edouard@6: autoreconf;\ andrej@12: automake --add-missing;\ andrej@12: ./configure --host=$(CROSS_COMPILE);\ Edouard@0: make -j$(CPUS); Edouard@6: rm -rf $(matiecdir) Edouard@6: mkdir -p $(matiecdir) Edouard@0: mv $(tmp)/matiec/*.exe $(matiecdir) andrej@12: andrej@12: # install necessary shared libraries from local cross-compiler andrej@12: $(call get_runtime_libs,$(matiecdir)) andrej@12: Edouard@0: mv $(tmp)/matiec/lib $(matiecdir) Edouard@6: touch $@ Edouard@6: Edouard@6: examples: |build Edouard@6: rm -rf examples Edouard@6: mkdir -p examples Edouard@6: andrej@14: beremiz: | build examples Edouard@0: $(call get_src_hg,build/beremiz) andrej@15: $(call hg_get_rev_num,beremiz,build/beremiz/revision) Edouard@6: $(call tweak_beremiz_targets) Edouard@6: rm -rf examples/canopen_tests Edouard@6: mkdir -p examples/canopen_tests Edouard@6: mv build/beremiz/tests/canopen_* examples/canopen_tests Edouard@6: rm -rf examples/base_tests Edouard@6: mkdir -p examples/base_tests Edouard@6: mv build/beremiz/tests/* examples/base_tests Edouard@6: touch $@ Edouard@6: Edouard@6: CFbuild = build/CanFestival-3 Edouard@6: CFconfig = $(CFbuild)/objdictgen/canfestival_config.py Edouard@6: canfestival: mingw Edouard@6: rm -rf $(CFbuild) Edouard@6: $(call get_src_hg,$(CFbuild)) Edouard@6: cd $(CFbuild); \ Edouard@6: ./configure --can=tcp_win32 \ andrej@12: --cc=$(CC) \ andrej@12: --cxx=$(CXX) \ Edouard@6: --target=win32 \ Edouard@6: --wx=0 Edouard@6: $(MAKE) -C $(CFbuild) Edouard@6: cd $(CFbuild); find . -name "*.o" -exec rm {} ';' #remove object files only Edouard@6: touch $@ Edouard@6: Edouard@6: targets=python mingw matiec beremiz Edouard@6: Beremiz-$(version).exe: $(targets) $(src)/license.txt $(src)/install.nsi $(targets_ex) Edouard@0: sed -e 's/\$$BVERSION/$(version)/g' $(src)/license.txt > build/license.txt Edouard@6: sed -e 's/\$$BVERSION/$(version)/g' $(src)/install.nsi |\ andrej@14: sed -e 's/\$$BEXTENSIONS/$(extensions)/g' |\ andrej@14: makensis - andrej@14: Edouard@6: clean_installer: Edouard@6: rm -rf build Beremiz-$(version).exe $(targets) $(targets_ex) Edouard@6: Edouard@6: