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