Makefile
changeset 6 862080d48ef2
parent 5 6dec159540ee
child 8 b7e0285edfa8
child 10 b4cadeffabe4
equal deleted inserted replaced
5:6dec159540ee 6:862080d48ef2
     1 #! gmake
     1 #! gmake
     2 
     2 
     3 # This is Makefile for Beremiz installer
     3 # This is Makefile for Beremiz installer
     4 #
     4 #
     5 # invoke with "make" on a linux box having those packages installed :
     5 # Invoke with "make -f path/to/Makefile" on a linux box 
     6 #  - wine
     6 # in directory where build should happen.
       
     7 #
       
     8 # All those dependencies have to be installed :
       
     9 #
       
    10 #  Windows installer :
       
    11 #  - wine (tested with 1.2 and 1.6. Fail with 1.4)
     7 #  - mingw32
    12 #  - mingw32
       
    13 #  - flex
       
    14 #  - bison
     8 #  - tar
    15 #  - tar
     9 #  - unrar
    16 #  - unrar
    10 #  - wget
    17 #  - wget
    11 #  - nsis
    18 #  - nsis
       
    19 #  - libtool
       
    20 #  - xmlstarlet
       
    21 #  - xsltproc
       
    22 #  - python-lxml
       
    23 #
       
    24 #  Linux RootFS and packages
       
    25 #  - reprepro 
       
    26 #  - multistrap
       
    27 #  - germinate
       
    28 #  - user-mode-linux
       
    29 #  - ddpt
    12 #
    30 #
    13 # WARNING : DISPLAY variable have to be defined to a valid X server
    31 # WARNING : DISPLAY variable have to be defined to a valid X server
    14 #           in case it would be a problem, run :
    32 #           in case it would be a problem, run :
    15 #           xvfb-run make -f /path/to/this/Makefile
    33 #           xvfb-run make -f /path/to/this/Makefile
    16 
    34 
    17 version = 1.03
    35 version = 1.1
    18 
    36 
    19 HGROOT := ~/src
    37 HGROOT := ~/src
       
    38 GITROOT := $(HGROOT)
       
    39 HGPULL = 0
       
    40 DIST =
    20 CPUS = 8
    41 CPUS = 8
       
    42 BLKDEV=/dev/null
    21 
    43 
    22 src := $(shell dirname $(lastword $(MAKEFILE_LIST)))
    44 src := $(shell dirname $(lastword $(MAKEFILE_LIST)))
    23 distfiles = $(src)/distfiles
    45 distfiles = $(src)/distfiles
    24 sfmirror = ovh
    46 sfmirror = downloads
    25 tmp := $(shell mktemp -d)
    47 tmp := $(shell mktemp -d)
    26 
    48 
       
    49 ifeq ("$(HGPULL)","1")
       
    50 define hg_get_archive
       
    51 hg -R $(HGROOT)/`basename $(1)` pull
       
    52 hg -R $(HGROOT)/`basename $(1)` update $(2)
       
    53 hg -R $(HGROOT)/`basename $(1)` archive $(1)
       
    54 endef
       
    55 else
       
    56 define hg_get_archive
       
    57 hg -R $(HGROOT)/`basename $(1)` archive $(2) $(1)
       
    58 endef
       
    59 endif
       
    60 
    27 define get_src_hg
    61 define get_src_hg
    28 hg -R $(HGROOT)/`basename $(1)` archive $(tmp)/`basename $(1)`.tar.bz2
    62 rm -rf $(1)
       
    63 $(call hg_get_archive, $(1), $(2))
       
    64 endef
       
    65 
       
    66 define get_src_git
       
    67 rm -rf $(1)
    29 mkdir $(1)
    68 mkdir $(1)
    30 tar --strip-components=1 -C $(1) -xvjf $(tmp)/`basename $(1)`.tar.bz2
    69 (cd $(GITROOT)/`basename $(1)`; git archive --format=tar $(2)) | tar -C $(1) -x
    31 endef
    70 endef
    32 
    71 
    33 define get_src_http
    72 define get_src_http
    34 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`) ) ) &&
    73 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`) ) ) &&
    35 endef
    74 endef
    37 define get_src_pypi
    76 define get_src_pypi
    38 $(call get_src_http,http://pypi.python.org/packages/$(1),$(2))
    77 $(call get_src_http,http://pypi.python.org/packages/$(1),$(2))
    39 endef
    78 endef
    40 
    79 
    41 define get_src_sf
    80 define get_src_sf
    42 $(call get_src_http,http://$(sfmirror).dl.sourceforge.net/project/$(1),$(2))
    81 $(call get_src_http,http://$(sfmirror).sourceforge.net/project/$(1),$(2))
    43 endef
    82 endef
    44 
    83 
    45 all: Beremiz-$(version).exe
    84 all: Beremiz-$(version).exe $(targets_add)
    46 
    85 
       
    86 
       
    87 ifneq ("$(DIST)","")
       
    88 include $(src)/$(DIST).mk
       
    89 endif
       
    90 
       
    91 CUSTOM := public
       
    92 CUSTOM_DIR := $(src)
       
    93 
       
    94 include $(CUSTOM_DIR)/$(CUSTOM).mk
       
    95 
       
    96 build:
       
    97 	rm -rf build
       
    98 	mkdir -p build
       
    99 
       
   100 # native toolchain, pre-built
    47 mingwdir=build/mingw
   101 mingwdir=build/mingw
    48 mingw: 
   102 mingw: |build
    49 	rm -rf $(mingwdir)
   103 	rm -rf $(mingwdir)
    50 	mkdir -p $(mingwdir)
   104 	mkdir -p $(mingwdir)
    51 	# windows.h
   105 	# windows.h
    52 	$(call get_src_sf,mingw/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-3.17,w32api-3.17-2-mingw32-dev.tar.lzma)\
   106 	$(call get_src_sf,mingw/MinGW/Base/w32api/w32api-3.17,w32api-3.17-2-mingw32-dev.tar.lzma)\
    53 	tar -C $(mingwdir) --lzma -xvf $$dld
   107 	tar -C $(mingwdir) --lzma -xf $$dld
    54 	# mingw runtime
   108 	# mingw runtime
    55 	$(call get_src_sf,mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.20,mingwrt-3.20-mingw32-dll.tar.gz)\
   109 	$(call get_src_sf,mingw/MinGW/Base/mingw-rt/mingwrt-3.20,mingwrt-3.20-mingw32-dll.tar.gz)\
    56 	tar -C $(mingwdir) -xvzf $$dld
   110 	tar -C $(mingwdir) -xzf $$dld
    57 	# mingw headers and lib
   111 	# mingw headers and lib
    58 	$(call get_src_sf,mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-3.20,mingwrt-3.20-mingw32-dev.tar.gz)\
   112 	$(call get_src_sf,mingw/MinGW/Base/mingw-rt/mingwrt-3.20,mingwrt-3.20-mingw32-dev.tar.gz)\
    59 	tar -C $(mingwdir) -xvzf $$dld
   113 	tar -C $(mingwdir) -xzf $$dld
    60 	# binutils
   114 	# binutils
    61 	$(call get_src_sf,mingw/MinGW/BaseSystem/GNU-Binutils/binutils-2.21.53,binutils-2.21.53-1-mingw32-bin.tar.lzma)\
   115 	$(call get_src_sf,mingw/MinGW/Base/binutils/binutils-2.21.53,binutils-2.21.53-1-mingw32-bin.tar.lzma)\
    62 	tar -C $(mingwdir) --lzma -xvf $$dld
   116 	tar -C $(mingwdir) --lzma -xf $$dld
    63 	# C compiler
   117 	# C compiler
    64 	$(call get_src_sf,mingw/MinGW/BaseSystem/GCC/Version4/gcc-4.6.1-2,gcc-core-4.6.1-2-mingw32-bin.tar.lzma)\
   118 	$(call get_src_sf,mingw/MinGW/Base/gcc/Version4/gcc-4.6.1-2,gcc-core-4.6.1-2-mingw32-bin.tar.lzma)\
    65 	tar -C $(mingwdir) --lzma -xvf $$dld
   119 	tar -C $(mingwdir) --lzma -xf $$dld
    66 	# C++ compiler
       
    67 	#$(call get_src_sf,mingw/MinGW/BaseSystem/GCC/Version4/gcc-4.6.1-2,gcc-c++-4.6.1-2-mingw32-bin.tar.lzma)\
       
    68 	#tar -C $(mingwdir) --lzma -xvf $$dld
       
    69 	# dependencies
   120 	# dependencies
    70 	$(call get_src_sf,mingw/MinGW/gmp/gmp-5.0.1-1,libgmp-5.0.1-1-mingw32-dll-10.tar.lzma)\
   121 	$(call get_src_sf,mingw/MinGW/Base/gmp/gmp-5.0.1-1,libgmp-5.0.1-1-mingw32-dll-10.tar.lzma)\
    71 	tar -C $(mingwdir) --lzma -xvf $$dld
   122 	tar -C $(mingwdir) --lzma -xf $$dld
    72 	$(call get_src_sf,mingw/MinGW/mpc/mpc-0.8.1-1,libmpc-0.8.1-1-mingw32-dll-2.tar.lzma)\
   123 	$(call get_src_sf,mingw/MinGW/Base/mpc/mpc-0.8.1-1,libmpc-0.8.1-1-mingw32-dll-2.tar.lzma)\
    73 	tar -C $(mingwdir) --lzma -xvf $$dld
   124 	tar -C $(mingwdir) --lzma -xf $$dld
    74 	$(call get_src_sf,mingw/MinGW/mpfr/mpfr-2.4.1-1,libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma)\
   125 	$(call get_src_sf,mingw/MinGW/Base/mpfr/mpfr-2.4.1-1,libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma)\
    75 	tar -C $(mingwdir) --lzma -xvf $$dld
   126 	tar -C $(mingwdir) --lzma -xf $$dld
    76 	#$(call get_src_sf,mingw/MinGW/pthreads-w32/pthreads-w32-2.9.0-pre-20110507-2,libpthreadgc-2.9.0-mingw32-pre-20110507-2-dll-2.tar.lzma)\
   127 	$(call get_src_sf,mingw/MinGW/Base/gettext/gettext-0.17-1,libintl-0.17-1-mingw32-dll-8.tar.lzma)\
    77 	#tar -C $(mingwdir) --lzma -xvf $$dld
   128 	tar -C $(mingwdir) --lzma -xf $$dld
    78 	#$(call get_src_sf,mingw/MinGW/pthreads-w32/pthreads-w32-2.9.0-pre-20110507-2,pthreads-w32-2.9.0-mingw32-pre-20110507-2-dev.tar.lzma)\
   129 	$(call get_src_sf,mingw/MinGW/Base/gettext/gettext-0.17-1,libgettextpo-0.17-1-mingw32-dll-0.tar.lzma)\
    79 	#tar -C $(mingwdir) --lzma -xvf $$dld
   130 	tar -C $(mingwdir) --lzma -xf $$dld
    80 	$(call get_src_sf,mingw/MinGW/gettext/gettext-0.17-1,libintl-0.17-1-mingw32-dll-8.tar.lzma)\
   131 	$(call get_src_sf,mingw/MinGW/Base/libiconv/libiconv-1.13.1-1,libiconv-1.13.1-1-mingw32-dll-2.tar.lzma)\
    81 	tar -C $(mingwdir) --lzma -xvf $$dld
   132 	tar -C $(mingwdir) --lzma -xf $$dld
    82 	$(call get_src_sf,mingw/MinGW/gettext/gettext-0.17-1,libgettextpo-0.17-1-mingw32-dll-0.tar.lzma)\
   133 	
    83 	tar -C $(mingwdir) --lzma -xvf $$dld
   134 	touch $@
    84 	$(call get_src_sf,mingw/MinGW/libiconv/libiconv-1.13.1-1,libiconv-1.13.1-1-mingw32-dll-2.tar.lzma)\
       
    85 	tar -C $(mingwdir) --lzma -xvf $$dld
       
    86 	
       
    87 	touch mingw
       
    88 
       
    89 # a directory to collect binaries that must be in the path
       
    90 
   135 
    91 msiexec = WINEPREFIX=$(tmp) msiexec
   136 msiexec = WINEPREFIX=$(tmp) msiexec
    92 wine = WINEPREFIX=$(tmp) wine
   137 wine = WINEPREFIX=$(tmp) wine
    93 pydir = build/python
   138 pydir = build/python
    94 pysite = $(pydir)/Lib/site-packages
   139 pysite = $(pydir)/Lib/site-packages
    95 
   140 
    96 python:
   141 python: |build
    97 	rm -rf $(pydir)
   142 	rm -rf $(pydir)
    98 	mkdir -p $(pydir)
   143 	mkdir -p $(pydir)
    99 	# Python
   144 	# Python
   100 	$(call get_src_http,http://www.python.org/ftp/python/2.7.2,python-2.7.2.msi)\
   145 	$(call get_src_http,http://www.python.org/ftp/python/2.7.2,python-2.7.2.msi)\
   101 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   146 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   111 	# wxPython fails if VC9.0 bullshit is not fully here.
   156 	# wxPython fails if VC9.0 bullshit is not fully here.
   112 	$(call get_src_http,http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140,vcredist_x86.exe)\
   157 	$(call get_src_http,http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140,vcredist_x86.exe)\
   113 	cp $$dld $(tmp)
   158 	cp $$dld $(tmp)
   114 	$(wine) $(tmp)/vcredist_x86.exe /qn /a
   159 	$(wine) $(tmp)/vcredist_x86.exe /qn /a
   115 	cp $(tmp)/drive_c/windows/winsxs/x86_Microsoft.VC90.CRT*/* $(pydir)
   160 	cp $(tmp)/drive_c/windows/winsxs/x86_Microsoft.VC90.CRT*/* $(pydir)
       
   161 
       
   162 	# MathPlotLib
       
   163 	$(call get_src_http,https://github.com/downloads/matplotlib/matplotlib,matplotlib-1.2.0.win32-py2.7.exe)\
       
   164 	unzip -d $(tmp)/mathplotlib $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
       
   165 	cp -R $(tmp)/mathplotlib/PLATLIB/* $(pysite)
   116 	
   166 	
   117 	# pywin32
   167 	# pywin32
   118 	$(call get_src_sf,pywin32/pywin32/Build216,pywin32-216.win32-py2.7.exe)\
   168 	$(call get_src_sf,pywin32/pywin32/Build216,pywin32-216.win32-py2.7.exe)\
   119 	unzip -d $(tmp)/pw32 $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   169 	unzip -d $(tmp)/pw32 $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   120 	cp -R $(tmp)/pw32/PLATLIB/* $(pysite)
   170 	cp -R $(tmp)/pw32/PLATLIB/* $(pysite)
   128 	$(call get_src_pypi,2.7/T/Twisted,Twisted-11.0.0.winxp32-py2.7.msi)\
   178 	$(call get_src_pypi,2.7/T/Twisted,Twisted-11.0.0.winxp32-py2.7.msi)\
   129 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   179 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   130 	
   180 	
   131 	# Nevow
   181 	# Nevow
   132 	$(call get_src_pypi,source/N/Nevow,Nevow-0.10.0.tar.gz)\
   182 	$(call get_src_pypi,source/N/Nevow,Nevow-0.10.0.tar.gz)\
   133 	tar -C $(tmp) -xvzf $$dld
   183 	tar -C $(tmp) -xzf $$dld
   134 	for i in nevow formless twisted; do cp -R $(tmp)/Nevow-0.10.0/$$i $(pysite); done
   184 	for i in nevow formless twisted; do cp -R $(tmp)/Nevow-0.10.0/$$i $(pysite); done
   135 	
   185 	
   136 	# Numpy
   186 	# Numpy
   137 	$(call get_src_pypi,2.7/n/numpy,numpy-1.6.1.win32-py2.7.exe)\
   187 	$(call get_src_pypi,2.7/n/numpy,numpy-1.6.1.win32-py2.7.exe)\
   138 	unzip -d $(tmp)/np $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   188 	unzip -d $(tmp)/np $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   139 	cp -R $(tmp)/np/PLATLIB/* $(pysite)
   189 	cp -R $(tmp)/np/PLATLIB/* $(pysite)
   140 	
   190 	
   141 	# SimpleJson
   191 	# SimpleJson
   142 	$(call get_src_pypi,source/s/simplejson,simplejson-2.2.1.tar.gz)\
   192 	$(call get_src_pypi,source/s/simplejson,simplejson-2.2.1.tar.gz)\
   143 	tar -C $(tmp) -xvzf $$dld
   193 	tar -C $(tmp) -xzf $$dld
   144 	cp -R $(tmp)/simplejson-2.2.1/simplejson/ $(pysite)
   194 	cp -R $(tmp)/simplejson-2.2.1/simplejson/ $(pysite)
   145 	
   195 	
   146 	# WxGlade
   196 	# WxGlade
   147 	$(call get_src_http,https://bitbucket.org/agriggio/wxglade/get,b0247325407e.zip)\
   197 	$(call get_src_http,https://bitbucket.org/agriggio/wxglade/get,b0247325407e.zip)\
   148 	unzip -d $(tmp) $$dld 
   198 	unzip -d $(tmp) $$dld 
   149 	mv $(tmp)/agriggio-wxglade-b0247325407e $(pysite)/wxglade
   199 	mv $(tmp)/agriggio-wxglade-b0247325407e $(pysite)/wxglade
   150 	
   200 	
   151 	# Pyro
   201 	# Pyro
   152 	$(call get_src_pypi,source/P/Pyro,Pyro-3.15.tar.gz)\
   202 	$(call get_src_pypi,source/P/Pyro,Pyro-3.9.1.tar.gz)\
   153 	tar -C $(tmp) -xvzf $$dld
   203 	tar -C $(tmp) -xzf $$dld
   154 	mv $(tmp)/Pyro-3.15/Pyro $(pysite)
   204 	mv $(tmp)/Pyro-3.9.1/Pyro $(pysite)
   155 	
   205 	
   156 	touch python
   206 	# Lxml
       
   207 	$(call get_src_pypi,2.7/l/lxml,lxml-3.2.3.win32-py2.7.exe)\
       
   208 	unzip -d $(tmp)/lxml $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
       
   209 	cp -R $(tmp)/lxml/PLATLIB/* $(pysite)
       
   210 
       
   211 	touch $@
   157 
   212 
   158 matiecdir = build/matiec
   213 matiecdir = build/matiec
   159 matiec: 
   214 matiec: |build
   160 	$(call get_src_hg,$(tmp)/matiec)
   215 	$(call get_src_hg,$(tmp)/matiec)
   161 	cd $(tmp)/matiec ;\
   216 	cd $(tmp)/matiec ;\
       
   217 	autoreconf;\
   162 	./configure --host=i586-mingw32msvc;\
   218 	./configure --host=i586-mingw32msvc;\
   163 	make -j$(CPUS);
   219 	make -j$(CPUS);
   164 	mkdir $(matiecdir)
   220 	rm -rf $(matiecdir)
       
   221 	mkdir -p $(matiecdir)
   165 	mv $(tmp)/matiec/*.exe $(matiecdir)
   222 	mv $(tmp)/matiec/*.exe $(matiecdir)
   166 	mv $(tmp)/matiec/lib $(matiecdir)
   223 	mv $(tmp)/matiec/lib $(matiecdir)
   167 	touch matiec
   224 	touch $@
   168 	
   225 
   169 plcopeneditor:
   226 examples: |build
   170 	$(call get_src_hg,build/plcopeneditor)
   227 	rm -rf  examples
   171 	touch plcopeneditor
   228 	mkdir -p examples
   172 
   229 
   173 beremiz:
   230 beremiz: | build examples 
   174 	$(call get_src_hg,build/beremiz)
   231 	$(call get_src_hg,build/beremiz)
   175 	touch beremiz
   232 	$(call tweak_beremiz_targets)
   176 
   233 	rm -rf examples/canopen_tests
   177 Beremiz-$(version).exe: python mingw matiec plcopeneditor beremiz $(src)/license.txt $(src)/install.nsi
   234 	mkdir -p examples/canopen_tests
       
   235 	mv build/beremiz/tests/canopen_* examples/canopen_tests
       
   236 	rm -rf examples/base_tests
       
   237 	mkdir -p examples/base_tests
       
   238 	mv build/beremiz/tests/* examples/base_tests
       
   239 	touch $@
       
   240 
       
   241 beremiz_etherlab_plugin: beremiz | examples
       
   242 	$(call get_src_hg,$(tmp)/beremiz_etherlab_plugin)
       
   243 	rm -rf examples/ethercat_tests
       
   244 	mv $(tmp)/beremiz_etherlab_plugin/ethercat_tests examples/
       
   245 	rm -rf build/EthercatMaster
       
   246 	mv $(tmp)/beremiz_etherlab_plugin/etherlab build/EthercatMaster
       
   247 	touch $@
       
   248 
       
   249 CFbuild = build/CanFestival-3
       
   250 CFconfig = $(CFbuild)/objdictgen/canfestival_config.py
       
   251 canfestival: mingw
       
   252 	rm -rf $(CFbuild)
       
   253 	$(call get_src_hg,$(CFbuild))
       
   254 	cd $(CFbuild); \
       
   255 	./configure --can=tcp_win32 \
       
   256 				--cc=i586-mingw32msvc-gcc \
       
   257 				--cxx=i586-mingw32msvc-g++ \
       
   258 				--target=win32 \
       
   259 				--wx=0
       
   260 	$(MAKE) -C $(CFbuild)
       
   261 	cd $(CFbuild); find . -name "*.o" -exec rm {} ';' #remove object files only
       
   262 	touch $@
       
   263 
       
   264 targets=python mingw matiec beremiz
       
   265 Beremiz-$(version).exe: $(targets) $(src)/license.txt $(src)/install.nsi $(targets_ex)
   178 	sed -e 's/\$$BVERSION/$(version)/g' $(src)/license.txt > build/license.txt
   266 	sed -e 's/\$$BVERSION/$(version)/g' $(src)/license.txt > build/license.txt
   179 	sed -e 's/\$$BVERSION/$(version)/g' $(src)/install.nsi | makensis - 
   267 	sed -e 's/\$$BVERSION/$(version)/g' $(src)/install.nsi |\
   180 	
   268     sed -e 's/\$$BEXTENSIONS/$(extensions)/g' |\
   181 
   269     makensis - 
       
   270 	
       
   271 clean_installer:
       
   272 	rm -rf build Beremiz-$(version).exe $(targets) $(targets_ex)
       
   273 
       
   274