-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmakefile.wine64
161 lines (130 loc) · 5.82 KB
/
makefile.wine64
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
160
161
# 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 Wine
#
# Author: Stefan Richthofer
#
# This is an experimental makefile to build JyNI's Windows version using Wine.
#
# Note:
# Using Wine 1.6.2 it is currently not possible to successfully build JyNI
# with this makefile. This might change with a future Wine release.
#
# More specifically the manifest tool mt.exe seems not to run properly.
# However, this makefile is still helpful to check MSVC compatibility of
# source files while working on Linux or OS-X.
# These lines must be configured by the user specifically for current wine setup:
# (get the compiler from https://www.microsoft.com/en-us/download/details.aspx?id=44266)
VC_PYTHON_HOME_WINE = "/windows/Users/Stefan/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0"
PYTHON_HOME_WINE = "/windows/Program Files/Python/Python2.7.13"
JAVA_HOME_WINE = "/windows/Program Files/Java/jdk1.8.0_121"
# 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
PYTHON_HOME = ./Python_wine
VC_Python = ./VCPython_wine
JAVA_HOME = ./Java_wine
CC = wine $(VC_Python)/VC/bin/x86_amd64/cl
LK = wine $(VC_Python)/VC/bin/x86_amd64/link
MT = wine $(VC_Python)/WinSDK/Bin/x64/mt
JC = javac
JAVA = java
OUTPUTDIR = build
PLATFORM = win32
JYNI = ./JyNI-Java/src
JYNIBIN = ./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
LIBS64 = $(VC_Python)/VC/lib/amd64/msvcrt.lib $(VC_Python)/VC/lib/amd64/libcmt.lib $(VC_Python)/VC/lib/amd64/OLDNAMES.lib $(VC_Python)/WinSDK/lib/x64/Kernel32.lib $(VC_Python)/WinSDK/lib/x64/uuid.lib $(VC_Python)/WinSDK/lib/x64/User32.lib $(VC_Python)/WinSDK/lib/x64/Dbghelp.lib $(VC_Python)/WinSDK/lib/x64/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
$(JAVA_HOME): $(JYTHON)
ln -s $(JAVA_HOME_WINE) $(JAVA_HOME)
$(PYTHON_HOME):
ln -s $(PYTHON_HOME_WINE) $(PYTHON_HOME)
$(VC_Python):
ln -s $(VC_PYTHON_HOME_WINE) $(VC_Python)
libJyNI: $(VC_Python) $(PYTHON_HOME) $(JAVA_HOME) $(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 $(LIBS64)
$(MT) -nologo -manifest JyNI-C/dll.manifest_amd64/python27.dll.manifest -outputresource:$(OUTPUTDIR)/JyNI.dll/python27.dll;2
rm $(OUTPUTDIR)/JyNI.dll/python27.lib
rm $(OUTPUTDIR)/JyNI.dll/python27.exp
rm $(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)
$(JYNIBIN)/JyNI: $(JYNIBIN)
$(JC) $(JFLAGS) $(JSOURCES)
$(JYNIBIN)/Lib: $(JYTHON) $(JYNIBIN)
cp -r JyNI-Lib/* $(JYNIBIN)
$(JAVA) -cp $(JYTHON) org.python.util.jython -c "import compileall; compileall.compile_dir('$(JYNIBIN)')"
JyNI: $(JYTHON) $(JYNIBIN)/JyNI $(JYNIBIN)/Lib
cp -r JyNI-Java/META-INF $(JYNIBIN)
jar cvf $(OUTPUTDIR)/JyNI.jar -C $(JYNIBIN) .
cleanJ:
rm -rf $(JYNIBIN)
clean:
rm -rf $(JYNIBIN)
rm -f ./JyNI-C/src/Python/*.obj
rm -f ./JyNI-C/src/Objects/*.obj
rm -f ./JyNI-C/src/Modules/*.obj
rm -f ./JyNI-C/src/PC/*.obj
rm $(VC_Python)
rm $(JAVA_HOME)
rm $(PYTHON_HOME)
.PHONY: JyNI libJyNI clean cleanJ all