Makefile
changeset 29 503b0ef635cc
parent 28 950f79385de7
child 30 1def008491ba
equal deleted inserted replaced
28:950f79385de7 29:503b0ef635cc
    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 src := $(shell dirname $(lastword $(MAKEFILE_LIST)))
    30 src := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
    31 HGREMOTE ?= https://hg.beremiz.org/
    31 HGREMOTE ?= https://hg.beremiz.org/
    32 HGROOT ?= $(abspath $(src)/..)
    32 HGROOT ?= $(abspath $(src)/..)
    33 GITROOT := $(HGROOT)
    33 GITROOT := $(HGROOT)
    34 DIST =
    34 DIST =
    35 CPUS = 8
    35 CPUS := `cat /proc/cpuinfo | grep -e 'processor\W*:\W*[[:digit:]]*' | nl -n ln | tail -n1 | cut -f1`
    36 BLKDEV=/dev/null
    36 BLKDEV=/dev/null
    37 
    37 
    38 
    38 
    39 CROSS_COMPILE=i686-w64-mingw32
    39 CROSS_COMPILE=i686-w64-mingw32
    40 CROSS_COMPILE_LIBS_DIR=$(shell dirname $(shell $(CROSS_COMPILE)-gcc -print-libgcc-file-name))
    40 CROSS_COMPILE_LIBS_DIR=$(shell dirname $(shell $(CROSS_COMPILE)-gcc -print-libgcc-file-name))
    83 
    83 
    84 
    84 
    85 ifneq ("$(DIST)","")
    85 ifneq ("$(DIST)","")
    86 include $(src)/$(DIST).mk
    86 include $(src)/$(DIST).mk
    87 endif
    87 endif
    88 
       
    89 CUSTOM := public
       
    90 CUSTOM_DIR := $(src)
       
    91 
       
    92 include $(CUSTOM_DIR)/$(CUSTOM).mk
       
    93 
    88 
    94 build:
    89 build:
    95 	rm -rf build
    90 	rm -rf build
    96 	mkdir -p build
    91 	mkdir -p build
    97 
    92 
   141 msiexec = WINEPREFIX=$(tmp) msiexec
   136 msiexec = WINEPREFIX=$(tmp) msiexec
   142 wine = WINEPREFIX=$(tmp) wine
   137 wine = WINEPREFIX=$(tmp) wine
   143 pydir = build/python
   138 pydir = build/python
   144 pysite = $(pydir)/Lib/site-packages
   139 pysite = $(pydir)/Lib/site-packages
   145 
   140 
       
   141 OSSLVER=openssl-1.0.1p
       
   142 M2CRVER=M2Crypto-0.22.6rc2
       
   143 MINGPFX=i686-w64-mingw32-
       
   144 
   146 python: |build
   145 python: |build
   147 	rm -rf $(pydir)
   146 	rm -rf $(pydir)
   148 	mkdir -p $(pydir)
   147 	mkdir -p $(pydir)
   149 
   148 	
   150 	# Python
   149 	# Python
   151 	$(call get_src_http,http://www.python.org/ftp/python/2.7.2,python-2.7.2.msi)\
   150 	$(call get_src_http,http://www.python.org/ftp/python/2.7.3,python-2.7.3.msi)\
   152 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   151 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   153 
   152 	
   154 	# WxPython (needs running inno unpacker in wine)
   153 	# WxPython 2.8 (needs running inno unpacker in wine)
   155 	$(call get_src_sf,innounp/innounp/innounp%200.36,innounp036.rar)\
   154 	$(call get_src_sf,innounp/innounp/innounp%200.36,innounp036.rar)\
   156 	unrar e $$dld innounp.exe $(tmp)
   155 	unrar e $$dld innounp.exe $(tmp)
   157 	$(call get_src_sf,wxpython/wxPython/2.8.12.1,wxPython2.8-win32-unicode-2.8.12.1-py27.exe)\
   156 	$(call get_src_sf,wxpython/wxPython/2.8.12.1,wxPython2.8-win32-unicode-2.8.12.1-py27.exe)\
   158 	$(wine) $(tmp)/innounp.exe -d$(tmp) -x $$dld
   157 	$(wine) $(tmp)/innounp.exe -d$(tmp) -x $$dld
   159 	cp -R $(tmp)/\{code_GetPythonDir\}/* $(pydir)
   158 	cp -R $(tmp)/\{code_GetPythonDir\}/* $(pydir)
   160 	cp -R $(tmp)/\{app\}/* $(pysite)
   159 	cp -R $(tmp)/\{app\}/* $(pysite)
   161 
   160 	
       
   161 	# WxPython 3.0 (needs running inno unpacker in wine)
       
   162 	$(call get_src_sf,wxpython/wxPython/3.0.2.0,wxPython3.0-win32-3.0.2.0-py27.exe)\
       
   163 	$(wine) $(tmp)/innounp.exe -d$(tmp) -x $$dld
       
   164 	cp -R $(tmp)/\{code_GetPythonDir\}/* $(pydir)
       
   165 	cp -R $(tmp)/\{app\}/* $(pysite)
       
   166 	
   162 	# wxPython fails if VC9.0 bullshit is not fully here.
   167 	# wxPython fails if VC9.0 bullshit is not fully here.
   163 	$(call get_src_http,http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140,vcredist_x86.exe)\
   168 	$(call get_src_http,http://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140,vcredist_x86.exe)\
   164 	cp $$dld $(tmp)
   169 	cp $$dld $(tmp)
   165 	$(wine) $(tmp)/vcredist_x86.exe /qn /a
   170 	$(wine) $(tmp)/vcredist_x86.exe /qn /a
   166 	cp $(tmp)/drive_c/windows/winsxs/x86_Microsoft.VC90.CRT*/* $(pydir)
   171 	cp $(tmp)/drive_c/windows/winsxs/x86_Microsoft.VC90.CRT*/* $(pydir)
   167 
   172 	
   168 	# MathPlotLib
   173 	# MathPlotLib
   169 	$(call get_src_http,https://github.com/downloads/matplotlib/matplotlib,matplotlib-1.2.0.win32-py2.7.exe)\
   174 	$(call get_src_http,https://github.com/downloads/matplotlib/matplotlib,matplotlib-1.2.0.win32-py2.7.exe)\
   170 	unzip -d $(tmp)/mathplotlib $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   175 	unzip -d $(tmp)/mathplotlib $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   171 	cp -R $(tmp)/mathplotlib/PLATLIB/* $(pysite)
   176 	cp -R $(tmp)/mathplotlib/PLATLIB/* $(pysite)
   172 
   177 	
   173 	# pywin32
   178 	# pywin32
   174 	$(call get_src_sf,pywin32/pywin32/Build216,pywin32-216.win32-py2.7.exe)\
   179 	$(call get_src_sf,pywin32/pywin32/Build216,pywin32-216.win32-py2.7.exe)\
   175 	unzip -d $(tmp)/pw32 $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   180 	unzip -d $(tmp)/pw32 $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   176 	cp -R $(tmp)/pw32/PLATLIB/* $(pysite)
   181 	cp -R $(tmp)/pw32/PLATLIB/* $(pysite)
   177 
   182 	
   178 	# zope.interface
   183 	# zope.interface (twisted prereq)
   179 	$(call get_src_pypi,9d/2d/beb32519c0bd19bda4ac38c34db417d563ee698518e582f951d0b9e5898b,zope.interface-4.3.2-py2.7-win32.egg)\
   184 	$(call get_src_pypi,2.7/z/zope.interface,zope.interface-4.3.2-py2.7-win32.egg)\
   180 	unzip -d $(tmp) $$dld
   185 	unzip -d $(tmp) $$dld
   181 	cp -R $(tmp)/zope $(pysite)
   186 	cp -R $(tmp)/zope $(pysite)
   182 
   187 	
       
   188 	# six (pyopenssl prereq)
       
   189 	$(call get_src_pypi,py2.py3/s/six,six-1.11.0-py2.py3-none-any.whl)\
       
   190 	unzip -d $(tmp) $$dld 
       
   191 	cp -R $(tmp)/six.py $(pysite)
       
   192 	
       
   193 	# enum34 (cryptography prereq)
       
   194 	$(call get_src_pypi,source/e/enum34,enum34-1.1.6.tar.gz)\
       
   195 	tar -C $(tmp) -xzf $$dld
       
   196 	cp -R $(tmp)/enum34-1.1.6/enum $(pysite)
       
   197 	
       
   198 	# cryptography (pyopenssl prereq)
       
   199 	$(call get_src_pypi,cp27/c/cryptography,cryptography-1.0.2-cp27-none-win32.whl)\
       
   200 	unzip -d $(tmp) $$dld 
       
   201 	cp -R $(tmp)/cryptography $(pysite)
       
   202 	
       
   203 	# pyopenssl (twisted/ssl prereq)
       
   204 	$(call get_src_pypi,py2.py3/p/pyOpenSSL,pyOpenSSL-0.15.1-py2.py3-none-any.whl)\
       
   205 	unzip -d $(tmp) $$dld 
       
   206 	cp -R $(tmp)/OpenSSL $(pysite)
       
   207 	
       
   208 	# pyasn1 (service identity prereq)
       
   209 	$(call get_src_pypi,source/p/pyasn1,pyasn1-0.1.9.tar.gz)\
       
   210 	tar -C $(tmp) -xzf $$dld
       
   211 	cp -R $(tmp)/pyasn1-0.1.9/pyasn1 $(pysite)
       
   212 	
       
   213 	# pyasn1-modules (service identity prereq)
       
   214 	$(call get_src_pypi,source/p/pyasn1-modules,pyasn1-modules-0.0.8.tar.gz)\
       
   215 	tar -C $(tmp) -xzf $$dld
       
   216 	cp -R $(tmp)/pyasn1-modules-0.0.8/pyasn1_modules $(pysite)
       
   217 	
       
   218 	# characteristic (service identity prereq)
       
   219 	$(call get_src_pypi,source/c/characteristic,characteristic-14.3.0.tar.gz)\
       
   220 	tar -C $(tmp) -xzf $$dld
       
   221 	cp -R $(tmp)/characteristic-14.3.0/characteristic.py $(pysite)
       
   222 	
       
   223 	# service identity (twisted prereq)
       
   224 	$(call get_src_pypi,source/s/service_identity,service_identity-14.0.0.tar.gz)\
       
   225 	tar -C $(tmp) -xzf $$dld
       
   226 	cp -R $(tmp)/service_identity-14.0.0/service_identity $(pysite)
       
   227 	
       
   228 	# txaio (autobahn prereq)
       
   229 	$(call get_src_pypi,source/t/txaio,txaio-2.6.0.tar.gz)\
       
   230 	tar -C $(tmp) -xzf $$dld
       
   231 	cp -R $(tmp)/txaio-2.6.0/txaio $(pysite)
       
   232 	
       
   233 	# python-msgpack (autobahn prereq)
       
   234 	$(call get_src_pypi,cp27/m/msgpack-python,msgpack_python-0.4.8-cp27-cp27m-win32.whl)\
       
   235 	unzip -d $(tmp) $$dld 
       
   236 	cp -R $(tmp)/msgpack $(pysite)
       
   237 	
       
   238 	# u-msgpack-python (autobahn prereq)
       
   239 	$(call get_src_pypi,source/u/u-msgpack-python,u-msgpack-python-2.3.0.tar.gz)\
       
   240 	tar -C $(tmp) -xzf $$dld
       
   241 	cp -R $(tmp)/u-msgpack-python-2.3.0/umsgpack.py $(pysite)
       
   242 	
       
   243 	# cffi (cryptography prereq)
       
   244 	$(call get_src_pypi,cp27/c/cffi,cffi-1.2.1-cp27-none-win32.whl)\
       
   245 	unzip -d $(tmp) $$dld 
       
   246 	cp -R $(tmp)/cffi $(tmp)/_cffi_backend.pyd $(pysite)
       
   247 	
   183 	# Twisted
   248 	# Twisted
   184 	$(call get_src_pypi,2.7/T/Twisted,Twisted-11.0.0.winxp32-py2.7.msi)\
   249 	$(call get_src_pypi,cp27/T/Twisted,Twisted-15.4.0-cp27-none-win32.whl)\
   185 	$(msiexec) /qn /a $$dld TARGETDIR=.\\$(pydir)
   250 	unzip -d $(tmp) $$dld 
   186 
   251 	cp -R $(tmp)/twisted $(pysite)
       
   252 	
       
   253 	# Autobahn
       
   254 	$(call get_src_pypi,source/a/autobahn,autobahn-17.6.1.tar.gz)\
       
   255 	tar -C $(tmp) -xzf $$dld
       
   256 	for i in autobahn twisted; do cp -R $(tmp)/autobahn-17.6.1/$$i $(pysite); done
       
   257 	
   187 	# Nevow
   258 	# Nevow
   188 	$(call get_src_pypi,source/N/Nevow,Nevow-0.10.0.tar.gz)\
   259 	$(call get_src_pypi,source/N/Nevow,Nevow-0.10.0.tar.gz)\
   189 	tar -C $(tmp) -xzf $$dld
   260 	tar -C $(tmp) -xzf $$dld
   190 	for i in nevow formless twisted; do cp -R $(tmp)/Nevow-0.10.0/$$i $(pysite); done
   261 	for i in nevow formless twisted; do cp -R $(tmp)/Nevow-0.10.0/$$i $(pysite); done
   191 
   262 	
   192 	# Numpy
   263 	# Numpy
   193 	$(call get_src_pypi,2.7/n/numpy,numpy-1.6.1.win32-py2.7.exe)\
   264 	$(call get_src_pypi,2.7/n/numpy,numpy-1.6.1.win32-py2.7.exe)\
   194 	unzip -d $(tmp)/np $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   265 	unzip -d $(tmp)/np $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   195 	cp -R $(tmp)/np/PLATLIB/* $(pysite)
   266 	cp -R $(tmp)/np/PLATLIB/* $(pysite)
   196 
   267 	
   197 	# SimpleJson
   268 	# SimpleJson
   198 	$(call get_src_pypi,source/s/simplejson,simplejson-2.2.1.tar.gz)\
   269 	$(call get_src_pypi,source/s/simplejson,simplejson-2.2.1.tar.gz)\
   199 	tar -C $(tmp) -xzf $$dld
   270 	tar -C $(tmp) -xzf $$dld
   200 	cp -R $(tmp)/simplejson-2.2.1/simplejson/ $(pysite)
   271 	cp -R $(tmp)/simplejson-2.2.1/simplejson/ $(pysite)
   201 
   272 	
   202 	# Zeroconf
   273 	# Zeroconf
   203 	$(call get_src_pypi,6b/88/48dbe88b10098f98acef33218763c5630b0081c7fd0849ab4793b1e9b6d3,zeroconf-0.19.1-py2.py3-none-any.whl)\
   274 	$(call get_src_pypi,6b/88/48dbe88b10098f98acef33218763c5630b0081c7fd0849ab4793b1e9b6d3,zeroconf-0.19.1-py2.py3-none-any.whl)\
   204 	unzip -d $(tmp)/zeroconf $$dld
   275 	unzip -d $(tmp)/zeroconf $$dld
   205 	cp -R $(tmp)/zeroconf/* $(pysite)
   276 	cp -R $(tmp)/zeroconf/* $(pysite)
   206 
   277 	
   207 	# Enum34
       
   208 	$(call get_src_pypi,c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050,enum34-1.1.6-py2-none-any.whl)\
       
   209 	unzip -d $(tmp)/enum34 $$dld
       
   210 	cp -R $(tmp)/enum34/* $(pysite)	
       
   211 
       
   212 	# netifaces
   278 	# netifaces
   213 	$(call get_src_pypi,05/00/c719457bcb8f14f9a7b9244c3c5e203c40d041a364cf784cf554aaef8129,netifaces-0.10.6-py2.7-win32.egg)\
   279 	$(call get_src_pypi,05/00/c719457bcb8f14f9a7b9244c3c5e203c40d041a364cf784cf554aaef8129,netifaces-0.10.6-py2.7-win32.egg)\
   214 	unzip -d $(tmp)/netifaces $$dld
   280 	unzip -d $(tmp)/netifaces $$dld
   215 	cp -R $(tmp)/netifaces/* $(pysite)	
   281 	cp -R $(tmp)/netifaces/* $(pysite)	
   216 
   282 	
   217 	# Six
       
   218 	$(call get_src_pypi,67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a,six-1.11.0-py2.py3-none-any.whl)\
       
   219 	unzip -d $(tmp)/six $$dld
       
   220 	cp -R $(tmp)/six/* $(pysite)	
       
   221 
       
   222 
       
   223 	# WxGlade
   283 	# WxGlade
   224 	$(call get_src_http,https://bitbucket.org/wxglade/wxglade/get,034d891cc947.zip)\
   284 	$(call get_src_http,https://bitbucket.org/wxglade/wxglade/get,034d891cc947.zip)\
   225 	unzip -d $(tmp) $$dld
   285 	unzip -d $(tmp) $$dld
   226 	mv $(tmp)/wxglade-wxglade-034d891cc947 $(pysite)/wxglade
   286 	mv $(tmp)/wxglade-wxglade-034d891cc947 $(pysite)/wxglade
   227 
   287 	
   228 	# Pyro
   288 	# Pyro
   229 	$(call get_src_pypi,source/P/Pyro,Pyro-3.9.1.tar.gz)\
   289 	$(call get_src_pypi,source/P/Pyro,Pyro-3.9.1.tar.gz)\
   230 	tar -C $(tmp) -xzf $$dld
   290 	tar -C $(tmp) -xzf $$dld
   231 	mv $(tmp)/Pyro-3.9.1/Pyro $(pysite)
   291 	mv $(tmp)/Pyro-3.9.1/Pyro $(pysite)
   232 
   292 	
       
   293 	# Build Openssl
       
   294 	$(call get_src_http,https://openssl.org/source,$(OSSLVER).tar.gz)\
       
   295 	tar -C $(tmp) -xzf $$dld
       
   296 	cd $(tmp)/$(OSSLVER); \
       
   297 	CC=$(MINGPFX)gcc ./Configure mingw && \
       
   298 	make all build-shared CROSS_COMPILE=$(MINGPFX) SHARED_LDFLAGS=-static-libgcc
       
   299 	
       
   300 	# Build M2crypto
       
   301 	$(call get_src_pypi,source/M/M2Crypto,$(M2CRVER).tar.gz)\
       
   302 	tar -C $(tmp) -xzf $$dld
       
   303 	cd $(tmp)/$(M2CRVER); \
       
   304 	patch -p1 < $(src)/M2Crypto-mingw-cross-compile-fix.patch && \
       
   305 	PYTHONLIB=$(abspath $(pydir))/libs \
       
   306 	PYTHONINC=$(abspath $(pydir))/include/ \
       
   307 	MINGCCPREFIX=$(MINGPFX) \
       
   308 	    python setup.py build build_ext \
       
   309 	        --openssl=$(tmp)/$(OSSLVER) -cmingw32
       
   310 	
       
   311 	# Copy openssl dlls directly in M2Crypto package directory
       
   312 	cp -a $(tmp)/$(OSSLVER)/*.dll $(tmp)/$(M2CRVER)/build/lib.win32-2.7/M2Crypto 
       
   313 	
       
   314 	# Move result into python site packages
       
   315 	mv $(tmp)/$(M2CRVER)/build/lib.win32-2.7/M2Crypto $(pysite)
       
   316 	
   233 	# Lxml
   317 	# Lxml
   234 	$(call get_src_pypi,2.7/l/lxml,lxml-3.2.3.win32-py2.7.exe)\
   318 	$(call get_src_pypi,2.7/l/lxml,lxml-3.2.3.win32-py2.7.exe)\
   235 	unzip -d $(tmp)/lxml $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   319 	unzip -d $(tmp)/lxml $$dld ; [ $$? -eq 1 ] #silence error unziping .exe
   236 	cp -R $(tmp)/lxml/PLATLIB/* $(pysite)
   320 	cp -R $(tmp)/lxml/PLATLIB/* $(pysite)
   237 
   321 	
   238 	touch $@
   322 	touch $@
   239 
   323 
   240 matiecdir = build/matiec
   324 matiecdir = build/matiec
   241 matiec: |build
   325 matiec: |build
   242 	$(call get_src_hg,$(tmp)/matiec)
   326 	$(call get_src_hg,$(tmp)/matiec)
   246 	./configure --host=$(CROSS_COMPILE);\
   330 	./configure --host=$(CROSS_COMPILE);\
   247 	make -j$(CPUS);
   331 	make -j$(CPUS);
   248 	rm -rf $(matiecdir)
   332 	rm -rf $(matiecdir)
   249 	mkdir -p $(matiecdir)
   333 	mkdir -p $(matiecdir)
   250 	mv $(tmp)/matiec/*.exe $(matiecdir)
   334 	mv $(tmp)/matiec/*.exe $(matiecdir)
   251 
   335 	
   252 	# install necessary shared libraries from local cross-compiler
   336 	# install necessary shared libraries from local cross-compiler
   253 	$(call get_runtime_libs,$(matiecdir))
   337 	$(call get_runtime_libs,$(matiecdir))
   254 
   338 	
   255 	mv $(tmp)/matiec/lib $(matiecdir)
   339 	mv $(tmp)/matiec/lib $(matiecdir)
   256 	touch $@
   340 	touch $@
   257 
   341 
   258 examples: |build
   342 examples: |build
   259 	rm -rf  examples
   343 	rm -rf  examples
   260 	mkdir -p examples
   344 	mkdir -p examples
   261 
   345 
   262 beremiz: | build examples
   346 beremiz: | build examples
   263 	$(call get_src_hg,build/beremiz)
   347 	$(call get_src_hg,build/beremiz)
   264 	$(call tweak_beremiz_targets)
   348 	$(call tweak_beremiz_source)
   265 	rm -rf examples/canopen_tests
   349 	rm -rf examples/canopen_tests
   266 	mkdir -p examples/canopen_tests
   350 	mkdir -p examples/canopen_tests
   267 	mv build/beremiz/tests/canopen_* examples/canopen_tests
   351 	mv build/beremiz/tests/canopen_* examples/canopen_tests
   268 	rm -rf examples/base_tests
   352 	rm -rf examples/base_tests
   269 	mkdir -p examples/base_tests
   353 	mkdir -p examples/base_tests