Skip to content

Commit fcd3817

Browse files
committed
Removed old makefiles
Added a one size fits all Makefile for Windows and Mono including support for autodetection of UCS 2/3 and Python version
1 parent 035b7ad commit fcd3817

4 files changed

Lines changed: 145 additions & 230 deletions

File tree

pythonnet/Makefile

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+

pythonnet/makefile

Lines changed: 0 additions & 111 deletions
This file was deleted.

pythonnet/makefile.mono

Lines changed: 0 additions & 112 deletions
This file was deleted.

pythonnet/src/monoclr/Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
# Author: Christian Heimes
22

3-
PYTHON=python2.5
3+
PYTHON = python2.5
4+
BASENAME = $(shell basename $(PYTHON))
5+
GCC = gcc
6+
7+
PY_LIBS = $(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \
8+
print get_config_vars('BLDLIBRARY')[0]")
9+
PY_CFLAGS = -I$(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \
10+
print get_config_vars('CFLAGS')[0] + ' -I' + get_config_vars('CONFINCLUDEPY')[0]")
11+
12+
MONO_LIBS = $(shell pkg-config --libs mono)
13+
MONO_CFLAGS = $(shell pkg-config --cflags mono)
14+
15+
LIBS = $(MONO_LIBS) $(PY_LIBS)
16+
CFLAGS = $(MONO_CFLAGS) $(PY_CFLAGS)
417

518
all: clrpython python
619

720
clrpython: clrpython.o pynetinit.o
8-
gcc `pkg-config --libs mono` -I/usr/include/$(PYTHON) -l$(PYTHON) \
9-
clrpython.o pynetinit.o -o clr$(PYTHON)
21+
$(GCC) $(LIBS) clrpython.o pynetinit.o -o clr$(BASENAME)
1022

1123
clrpython.o: pynetclr.h clrpython.c
12-
gcc `pkg-config --cflags mono` -I/usr/include/$(PYTHON) -c clrpython.c -o clrpython.o
24+
$(GCC) $(CFLAGS) -c clrpython.c -o clrpython.o
25+
1326
pynetinit.o: pynetclr.h pynetinit.c
14-
gcc `pkg-config --cflags mono` -I/usr/include/$(PYTHON) -c pynetinit.c -o pynetinit.o
27+
$(GCC) $(CFLAGS) -c pynetinit.c -o pynetinit.o
1528

1629
python: python.c
17-
gcc -I/usr/include/$(PYTHON) -l$(PYTHON) python.c -o $(PYTHON)
30+
$(GCC) $(PY_CFLAGS) $(PY_LIBS) python.c -o $(BASENAME)
1831

1932
clean:
2033
rm -f *.o
2134
rm -f *.so
2235
rm -f clr$(PYTHON)
2336
rm -f $(PYTHON)
2437
rm -rf build/
25-

0 commit comments

Comments
 (0)