|
| 1 | +# Makefile for PythonNET |
| 2 | +# usage: |
| 3 | +# make PYTHON=/path/to/python |
| 4 | +# make PYTHON=C:/Python25/python.exe |
| 5 | +# make PYTHON=/path/to/python DEFINE=additional,defines CSCARGS=additional_args |
| 6 | +# make clean |
| 7 | + |
| 8 | +RELEASE = pythonnet-2.0-alpha3 |
| 9 | + |
| 10 | +PYTHON ?= python |
| 11 | +PYTHONVER ?= $(shell $(PYTHON) -c "import sys; print 'PYTHON%i%i' % sys.version_info[:2]") |
| 12 | +UCS ?= $(shell $(PYTHON) -c "from distutils.sysconfig import get_config_var; \ |
| 13 | + print 'UCS%i' % (get_config_var('Py_UNICODE_SIZE') or 2)") |
| 14 | + |
| 15 | +ifeq ($(origin WINDIR), undefined) |
| 16 | + RUNNER = mono |
| 17 | + ILDASM = monodis |
| 18 | + ILASM = ilasm |
| 19 | + CSC = gmcs |
| 20 | + RUNTIME_REF = /reference:Mono.Posix.dll |
| 21 | + ALL = clr.so monoclr |
| 22 | +else |
| 23 | + RUNNER = |
| 24 | + ILDASM = ildasm.exe |
| 25 | + ILASM = ilasm.exe |
| 26 | + CSC = csc.exe |
| 27 | + RUNTIME_REF = |
| 28 | + ALL = clr.pyd |
| 29 | +endif |
| 30 | + |
| 31 | +ifeq ($(origin DEFINE), undefined) |
| 32 | + _DEFINE = $(PYTHONVER),$(UCS) |
| 33 | +else |
| 34 | + _DEFINE = $(DEFINE),$(PYTHONVER),$(UCS) |
| 35 | +endif |
| 36 | + |
| 37 | +CSC += /define:$(_DEFINE) /nologo $(CSCARGS) |
| 38 | + |
| 39 | +BASEDIR = $(shell pwd) |
| 40 | + |
| 41 | +PYTHON_CS = $(wildcard $(BASEDIR)/src/console/*.cs) |
| 42 | +RUNTIME_CS = $(wildcard $(BASEDIR)/src/runtime/*.cs) |
| 43 | +TESTING_CS = $(wildcard $(BASEDIR)/src/testing/*.cs) |
| 44 | +EMBED_CS = $(wildcard $(BASEDIR)/src/embed_tests/*.cs) |
| 45 | + |
| 46 | +all: Python.Runtime.dll python.exe Python.Test.dll $(ALL) |
| 47 | + |
| 48 | +cleanall: clean all |
| 49 | + |
| 50 | +python.exe: Python.Runtime.dll $(PYTHON_CS) |
| 51 | + cd $(BASEDIR)/src/console; \ |
| 52 | + $(CSC) /target:exe /out:../../python.exe \ |
| 53 | + /reference:../../Python.Runtime.dll /recurse:*.cs |
| 54 | + |
| 55 | +Python.Runtime.dll: $(RUNTIME_CS) |
| 56 | + cd $(BASEDIR)/src/runtime; \ |
| 57 | + $(CSC) /unsafe /target:library \ |
| 58 | + $(RUNTIME_REF) /out:../../Python.Runtime.dll /recurse:*.cs |
| 59 | + |
| 60 | + |
| 61 | +clr.pyd: Python.Runtime.dll src/runtime/clrmodule.il |
| 62 | + $(ILASM) /nologo /dll /quiet /output=clr.pyd \ |
| 63 | + src/runtime/clrmodule.il |
| 64 | + |
| 65 | + |
| 66 | +clr.so: Python.Runtime.dll src/monoclr/clrmod.c src/monoclr/pynetclr.h \ |
| 67 | + src/monoclr/pynetinit.c |
| 68 | + $(PYTHON) setup.py build_ext -i |
| 69 | + |
| 70 | + |
| 71 | +Python.Test.dll: Python.Runtime.dll |
| 72 | + cd $(BASEDIR)/src/testing; \ |
| 73 | + $(CSC) /target:library /out:../../Python.Test.dll \ |
| 74 | + /reference:../../Python.Runtime.dll,System.Windows.Forms.dll \ |
| 75 | + /recurse:*.cs |
| 76 | + |
| 77 | +.PHONY=clean |
| 78 | +clean: |
| 79 | + find . \( -name \*.o -o -name \*.so -o -name \*.py[co] -o -name \ |
| 80 | + \*.dll -o -name \*.exe -o -name \*.pdb -o -name \*.mdb \ |
| 81 | + -o -name \*.pyd -o -name \*~ \) -exec rm -f {} \; |
| 82 | + rm -f Python*.il Python*.il2 Python*.res |
| 83 | + rm -rf build/ |
| 84 | + cd src/console; rm -rf bin; rm -rf obj; cd ../..; |
| 85 | + cd src/runtime; rm -rf bin; rm -rf obj; cd ../..; |
| 86 | + cd src/testing; rm -rf bin; rm -rf obj; cd ../..; |
| 87 | + cd src/embed_tests; rm -rf bin; rm -rf obj; rm -f TestResult.xml; cd ../..; |
| 88 | + cd src/monoclr; make clean; cd ../.. |
| 89 | + |
| 90 | +.PHONY=test |
| 91 | +test: all |
| 92 | + rm -f ./src/tests/*.pyc |
| 93 | + $(RUNNER) ./python.exe ./src/tests/runtests.py |
| 94 | + |
| 95 | +.PHONY=dist |
| 96 | +dist: clean all |
| 97 | + rm -rf ./$(RELEASE) |
| 98 | + mkdir ./$(RELEASE) |
| 99 | + mkdir -p ./release |
| 100 | + cp ./makefile ./$(RELEASE)/ |
| 101 | + cp ./*.sln ./$(RELEASE)/ |
| 102 | + cp ./*.txt ./$(RELEASE)/ |
| 103 | + svn export ./demo ./$(RELEASE)/demo/ |
| 104 | + svn export ./doc ./$(RELEASE)/doc/ |
| 105 | + svn export ./src ./$(RELEASE)/src/ |
| 106 | + cp ./python.exe ./$(RELEASE)/ |
| 107 | + cp ./*.dll ./$(RELEASE)/ |
| 108 | + cp ./*.pyd ./$(RELEASE)/ |
| 109 | + tar czf $(RELEASE).tgz ./$(RELEASE)/ |
| 110 | + mv $(RELEASE).tgz ./release/ |
| 111 | + rm -rf ./$(RELEASE)/ |
| 112 | + |
| 113 | +dis: |
| 114 | + $(ILDASM) Python.Runtime.dll /out=Python.Runtime.il |
| 115 | + |
| 116 | +asm: |
| 117 | + $(ILASM) /dll /quiet \ |
| 118 | + /resource=Python.Runtime.res /output=Python.Runtime.dll \ |
| 119 | + Python.Runtime.il |
| 120 | + |
| 121 | +monoclr: |
| 122 | + make -C $(BASEDIR)/src/monoclr PYTHON=$(PYTHON) |
| 123 | + |
| 124 | +run: python.exe |
| 125 | + $(RUNNER) python.exe |
| 126 | + |
0 commit comments