Skip to content

Commit d3c83cf

Browse files
committed
Added makefile for building 32 bit Windows version of JyNI.
1 parent 0511a32 commit d3c83cf

File tree

2 files changed

+161
-1
lines changed

2 files changed

+161
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ To run tests and demos, see section [Test Example](#test-example)
243243
- for Linux/GCC type `make`
244244
- for Linux/CLANG type `make -f makefile.clang`
245245
- for OS-X type `make -f makefile.osx`
246-
- for Windows type `make -f makefile.win64`
246+
- for Windows (64 bit) type `make -f makefile.win64`
247+
- for Windows (32 bit) type `make -f makefile.win32` (not tested)
247248

248249
Optionally run `make clean` or e.g. `make -f makefile.osx clean` respectively.
249250
The resulting binaries are placed in the subfolder named `build`.

makefile.win32

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Copyright of JyNI:
2+
# Copyright (c) 2013, 2014, 2015, 2016, 2017 Stefan Richthofer.
3+
# All rights reserved.
4+
#
5+
#
6+
# Copyright of Python and Jython:
7+
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
8+
# 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
9+
# Python Software Foundation.
10+
# All rights reserved.
11+
#
12+
#
13+
# This file is part of JyNI.
14+
#
15+
# JyNI is free software: you can redistribute it and/or modify
16+
# it under the terms of the GNU Lesser General Public License as
17+
# published by the Free Software Foundation, either version 3 of
18+
# the License, or (at your option) any later version.
19+
#
20+
# JyNI is distributed in the hope that it will be useful,
21+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
# GNU Lesser General Public License for more details.
24+
#
25+
# You should have received a copy of the GNU Lesser General Public
26+
# License along with JyNI. If not, see <http://www.gnu.org/licenses/>.
27+
#
28+
#
29+
#
30+
# makefile for JyNI on Windows
31+
#
32+
# Author: Stefan Richthofer
33+
#
34+
35+
# These variables might need adjustment by the user:
36+
# PYTHON_HOME, JYTHON, JAVA_HOME, VC_Python, JAVA, JC
37+
38+
# PYTHON_HOME = "C:\Program Files\Python\Python2.7.13"
39+
# With Python 2.7: python -c "import os, sys; print os.path.dirname(sys.executable)"
40+
PYTHON_HOME = "$(shell python JyNI-Lib\python_home_winreg.py)"
41+
42+
# Adjust the following line to point to Jython >=2.7.1
43+
JYTHON = jython.jar
44+
# for instance, if you extracted it to your home folder:
45+
# JYTHON = /home/your_name/jython.jar
46+
47+
SHELL = cmd
48+
49+
# You can explicitly set JAVA_HOME here.
50+
# By default it will be guessed via "where javac", see lower line.
51+
# Note that predefined JAVA_HOME might not be quoted, which is required for whitespaces.
52+
# JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_121"
53+
JAVA_HOME = $(subst \bin\javac.exe,, "$(shell where javac)")
54+
55+
# (get the compiler from https://www.microsoft.com/en-us/download/details.aspx?id=44266)
56+
# We set VC_Python to the default install location for a user-install.
57+
# This might need adjustment in some cases.
58+
USER = $(shell echo %username%)
59+
VC_Python = "C:\Users\$(USER)\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0"
60+
61+
CC = $(VC_Python)\VC\bin\cl
62+
LK = $(VC_Python)\VC\bin\link
63+
MT = $(VC_Python)\WinSDK\Bin\mt
64+
JC = javac
65+
JAVA = java
66+
OUTPUTDIR = build
67+
68+
PLATFORM = win32
69+
70+
JYNI = JyNI-Java\src
71+
JYNIBIN = JyNI-Java\bin
72+
JYNIBIN2 = JyNI-Java\\bin
73+
74+
JYNI_INCLUDES = /I./JyNI-C/include /I./JyNI-C/include/Python_JyNI /I./JyNI-Java/include /I./JyNI-C/src/PC /I $(JAVA_HOME)/include /I $(JAVA_HOME)/include/$(PLATFORM)
75+
INCLUDES = /I$(VC_Python)/VC/Include /I$(VC_Python)/WinSDK/Include $(JYNI_INCLUDES) /I$(PYTHON_HOME)/include
76+
77+
LIBS = $(VC_Python)/VC/lib/msvcrt.lib $(VC_Python)/VC/lib/libcmt.lib $(VC_Python)/VC/lib/OLDNAMES.lib $(VC_Python)/WinSDK/lib/Kernel32.lib $(VC_Python)/WinSDK/lib/uuid.lib $(VC_Python)/WinSDK/lib/User32.lib $(VC_Python)/WinSDK/lib/Dbghelp.lib $(VC_Python)/WinSDK/lib/AdvAPI32.lib
78+
79+
CFLAGS = /w $(INCLUDES) /DPy_BUILD_CORE /MD /nologo /Ox /GS- /DNDEBUG
80+
81+
# You can optionally remove -source 1.7 -target 1.7. It's purpose is to achieve maximal compatibility by default.
82+
JFLAGS= -cp $(JYTHON);$(JYNI) -d $(JYNIBIN) -source 1.7 -target 1.7
83+
84+
SOURCES = $(wildcard JyNI-C/src/*.c) $(wildcard JyNI-C/src/Python/*.c) $(wildcard JyNI-C/src/Objects/*.c) $(wildcard JyNI-C/src/Modules/*.c) $(wildcard JyNI-C/src/PC/*.c)
85+
OBJECTS = $(SOURCES:.c=.obj)
86+
JSOURCES = $(wildcard JyNI-Java/src/JyNI/*.java) $(wildcard JyNI-Java/src/JyNI/gc/*.java)
87+
88+
all: $(OUTPUTDIR) libJyNI JyNI
89+
@echo.
90+
@echo Build successful.
91+
92+
$(OUTPUTDIR):
93+
mkdir $(OUTPUTDIR)
94+
95+
$(OUTPUTDIR)/JyNI.dll:
96+
mkdir $(OUTPUTDIR)\JyNI.dll
97+
98+
%.obj: %.c
99+
$(CC) /c /Fo./$@ $(CFLAGS) $<
100+
101+
JyNI-C/src/Python/dynload_win.obj:
102+
$(CC) /c /Fo./JyNI-C/src/Python/dynload_win.obj $(CFLAGS) JyNI-C/src/Python/dynload/dynload_win.c
103+
104+
$(JYTHON):
105+
@echo.
106+
@echo ------------------------------------------------
107+
@echo Fatal error: Could not find jython.jar.
108+
@echo Either put jython.jar into the JyNI base folder,
109+
@echo or adjust the JYTHON-variable at the top of
110+
@echo makefile to point to your installed jython.jar.
111+
@echo Be sure to use Jython 2.7.1 or newer.
112+
@echo ------------------------------------------------
113+
@echo.
114+
@false
115+
116+
libJyNI: $(OUTPUTDIR)/JyNI.dll $(OBJECTS) JyNI-C/src/Python/dynload_win.obj
117+
$(LK) /DLL /OUT:$(OUTPUTDIR)/JyNI.dll/python27.dll $(OBJECTS) JyNI-C/src/Python/dynload_win.obj $(LIBS)
118+
$(MT) -nologo -manifest JyNI-C/python27.dll.manifest -outputresource:$(OUTPUTDIR)/JyNI.dll/python27.dll;2
119+
del $(OUTPUTDIR)\JyNI.dll\python27.lib
120+
del $(OUTPUTDIR)\JyNI.dll\python27.exp
121+
del $(OUTPUTDIR)\JyNI.dll\python27.dll.manifest
122+
# We delete JyNI.dll\python27.lib here, because in any case one should link against original python27.lib.
123+
# So this is a useless file and we avoid confusion and invalid linking.
124+
125+
$(JYNIBIN):
126+
mkdir $(JYNIBIN)
127+
mkdir $(JYNIBIN)\ctypes
128+
mkdir $(JYNIBIN)\ctypes\macholib
129+
mkdir $(JYNIBIN)\sqlite3
130+
mkdir $(JYNIBIN)\META-INF\services
131+
132+
$(JYNIBIN)/JyNI: $(JYNIBIN)
133+
$(JC) $(JFLAGS) $(JSOURCES)
134+
135+
$(JYNIBIN)/Lib: $(JYTHON) $(JYNIBIN)
136+
copy JyNI-Lib\*.py $(JYNIBIN)
137+
copy JyNI-Lib\ctypes\*.py $(JYNIBIN)\ctypes
138+
copy JyNI-Lib\ctypes\macholib\*.py $(JYNIBIN)\ctypes\macholib
139+
copy JyNI-Lib\sqlite3\*.py $(JYNIBIN)\sqlite3
140+
$(JAVA) -cp $(JYTHON) org.python.util.jython -c "import compileall; compileall.compile_dir('$(JYNIBIN2)')"
141+
142+
JyNI: $(JYTHON) $(JYNIBIN)/JyNI $(JYNIBIN)/Lib
143+
copy JyNI-Java\META-INF\services\org.python.core.JythonInitializer $(JYNIBIN)\META-INF\services
144+
jar cvf $(OUTPUTDIR)\JyNI.jar -C $(JYNIBIN) .
145+
146+
cleanJ:
147+
RD /S /Q $(JYNIBIN)
148+
149+
clean:
150+
del JyNI-C\src\*.obj
151+
del JyNI-C\src\Python\*.obj
152+
del JyNI-C\src\Objects\*.obj
153+
del JyNI-C\src\Modules\*.obj
154+
del JyNI-C\src\PC\*.obj
155+
RD /S /Q $(JYNIBIN)
156+
157+
#.PHONY: JyNI libJyNI libJyNI-Loader clean cleanJ JAVA_HOME_hint all
158+
.PHONY: all
159+

0 commit comments

Comments
 (0)