13
13
import os, sys, platform, subprocess
16
16
machine = platform.machine()
18
18
if machine.startswith("iPod") or machine.startswith("iPhone"):
20
elif sys.platform == "win32" and "--compiler=mingw32" in sys.argv:
21
23
platform = sys.platform
33
35
# JCC_LFLAGS and JCC_JAVAC environment variables using os.pathsep as value
38
if platform in ("win32", "mingw32"):
40
from helpers.windows import JAVAHOME
37
47
'darwin': '/System/Library/Frameworks/JavaVM.framework/Versions/Current',
38
48
'ipod': '/usr/include/gcc',
39
49
'linux2': '/usr/lib/jvm/java-6-openjdk',
40
50
'sunos5': '/usr/jdk/instances/jdk1.6.0',
41
'win32': 'o:/Java/jdk1.6.0_02',
42
'freebsd7': '/usr/local/diablo-jdk1.6.0',
53
'freebsd7': '/usr/local/diablo-jdk1.6.0'
44
55
if 'JCC_JDK' in os.environ:
45
56
JDK[platform] = os.environ['JCC_JDK']
60
raise RuntimeError('''
62
Can't determine where the Java JDK has been installed on this machine.
64
Please set the environment variable JCC_JDK to that location before
68
elif not os.path.isdir(JDK[platform]):
69
raise RuntimeError('''
71
Java JDK directory '%s' does not exist.
73
Please set the environment variable JCC_JDK to the correct location before
48
79
'darwin': ['%(darwin)s/Headers' %(JDK)],
49
80
'ipod': ['%(ipod)s/darwin/default' %(JDK)],
53
84
'%(sunos5)s/include/solaris' %(JDK)],
54
85
'win32': ['%(win32)s/include' %(JDK),
55
86
'%(win32)s/include/win32' %(JDK)],
87
'mingw32': ['%(mingw32)s/include' %(JDK),
88
'%(mingw32)s/include/win32' %(JDK)],
56
89
'freebsd7': ['%(freebsd7)s/include' %(JDK),
57
90
'%(freebsd7)s/include/freebsd' %(JDK)],
64
97
'sunos5': ['-features=iddollar',
65
98
'-erroff=badargtypel2w,wbadinitl,wvarhidemem'],
100
'mingw32': ['-fno-strict-aliasing', '-Wno-write-strings'],
67
101
'freebsd7': ['-fno-strict-aliasing', '-Wno-write-strings'],
74
108
'linux2': ['-O0', '-g', '-DDEBUG'],
75
109
'sunos5': ['-DDEBUG'],
76
110
'win32': ['/Od', '/DDEBUG'],
111
'mingw32': ['-O0', '-g', '-DDEBUG'],
77
112
'freebsd7': ['-O0', '-g', '-DDEBUG'],
94
129
'-L%(sunos5)s/jre/lib/i386/client' %(JDK), '-ljvm',
95
130
'-R%(sunos5)s/jre/lib/i386:%(sunos5)s/jre/lib/i386/client' %(JDK)],
96
131
'win32': ['/LIBPATH:%(win32)s/lib' %(JDK), 'jvm.lib'],
132
'mingw32': ['-L%(mingw32)s/lib' %(JDK), '-ljvm'],
97
133
'freebsd7': ['-L%(freebsd7)s/jre/lib/i386' %(JDK), '-ljava', '-lverify',
98
134
'-L%(freebsd7)s/jre/lib/i386/client' %(JDK), '-ljvm',
99
135
'-Wl,-rpath=%(freebsd7)s/jre/lib/i386:%(freebsd7)s/jre/lib/i386/client' %(JDK)],
139
'win32': ["/IMPLIB:%s"],
140
'mingw32': ["-Wl,--out-implib,%s"]
102
143
if platform == 'linux2':
103
144
LFLAGS['linux2'] = LFLAGS['linux2/%s' %(machine)]
122
164
enable_shared = False
123
165
with_setuptools_c7 = ('00000000', '00000006', '*c', '00000007', '*final')
124
with_setuptools_c11 = ('00000000', '00000006', '*c', '00000011', '*final')
125
167
if with_setuptools >= with_setuptools_c7 and 'NO_SHARED' not in os.environ:
126
168
if platform in ('darwin', 'ipod', 'win32'):
127
169
enable_shared = True
128
170
elif platform == 'linux2':
130
from setuptools.command.build_ext import sh_link_shared_object
131
enable_shared = True # jcc/patches/patch.43 was applied
134
jccdir = os.path.dirname(os.path.abspath(__file__))
135
st_egg = os.path.dirname(setuptools.__path__[0])
136
if with_setuptools < with_setuptools_c11:
137
patch_version = '0.6c7'
139
patch_version = '0.6c11'
144
Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
145
or the NO_SHARED environment variable must be set to turn off this error.
147
sudo patch -d %s -Nup0 < %s/jcc/patches/patch.43.%s
149
See %s/INSTALL for more information about shared mode.
150
''' %(patch_version, st_egg, jccdir, patch_version, jccdir)
155
Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
156
or the NO_SHARED environment variable must be set to turn off this error.
161
patch -Nup0 < %s/jcc/patches/patch.43.%s
166
See %s/INSTALL for more information about shared mode.
167
''' %(patch_version, st_egg, jccdir, patch_version, st_egg, jccdir)
169
if os.path.isdir(st_egg):
170
raise NotImplementedError, patch_st_dir()
172
raise NotImplementedError, patch_st_zip()
171
from helpers.linux import patch_setuptools
172
enable_shared = patch_setuptools(with_setuptools)
173
elif platform == 'mingw32':
175
# need to monkeypatch the CygwinCCompiler class to generate
176
# jcc.lib in the correct place
177
from helpers.mingw32 import JCCMinGW32CCompiler
178
import distutils.cygwinccompiler
179
distutils.cygwinccompiler.Mingw32CCompiler = JCCMinGW32CCompiler
174
181
except ImportError:
175
182
if sys.version_info < (2, 4):
205
212
_lflags = LFLAGS[platform]
214
if 'JCC_IMPLIB_LFLAGS' in os.environ:
215
_implib_lflags = os.environ['JCC_IMPLIB_LFLAGS'].split(_jcc_argsep)
217
_implib_lflags = IMPLIB_LFLAGS.get(platform, [])
207
219
if 'JCC_JAVAC' in os.environ:
208
220
_javac = os.environ['JCC_JAVAC'].split(_jcc_argsep)
210
222
_javac = JAVAC[platform]
212
config = file(os.path.join(os.path.dirname(os.path.abspath(__file__)),
213
'jcc', 'config.py'), 'w')
215
print >>config, 'INCLUDES=%s' %(_includes)
216
print >>config, 'CFLAGS=%s' %(_cflags)
217
print >>config, 'DEBUG_CFLAGS=%s' %(_debug_cflags)
218
print >>config, 'LFLAGS=%s' %(_lflags)
219
print >>config, 'SHARED=%s' %(enable_shared)
224
from helpers.build import jcc_build_py
226
jcc_build_py.config_file = \
227
os.path.join(os.path.dirname(os.path.abspath(__file__)),
229
jcc_build_py.config_text = \
231
'INCLUDES=%s' %(_includes),
232
'CFLAGS=%s' %(_cflags),
233
'DEBUG_CFLAGS=%s' %(_debug_cflags),
234
'LFLAGS=%s' %(_lflags),
235
'IMPLIB_LFLAGS=%s' %(_implib_lflags),
236
'SHARED=%s' %(enable_shared),
237
'VERSION="%s"' %(jcc_ver),
256
273
kwds = { "extra_compile_args": cflags,
257
274
"include_dirs": includes,
258
"define_macros": [('_jcc_lib', None)],
275
"define_macros": [('_jcc_lib', None),
276
('JCC_VER', '"%s"' %(jcc_ver))],
259
277
"sources": sources[0:2] }
261
279
if platform in ('darwin', 'ipod'):
297
315
extra_compile_args=cflags,
298
316
extra_link_args=lflags,
299
317
include_dirs=includes,
300
define_macros=[('_java_generics', None)],
318
define_macros=[('_java_generics', None),
319
('JCC_VER', '"%s"' %(jcc_ver))],
301
320
sources=sources))
320
339
'packages': ['jcc'],
321
340
'package_dir': {'jcc': 'jcc'},
322
341
'package_data': {'jcc': package_data},
323
'ext_modules': extensions
342
'ext_modules': extensions,
343
"cmdclass": {"build_py": jcc_build_py},
325
345
if with_setuptools:
326
346
args['zip_safe'] = False