6
6
import sys, os, imp, re, optparse
7
7
from glob import glob
8
from platform import machine as platform_machine
9
10
from distutils import log
10
11
from distutils import sysconfig
247
248
'WARNING: skipping import check for Carbon-based "%s"' %
252
if self.get_platform() == 'darwin' and (
253
sys.maxint > 2**32 and '-arch' in ext.extra_link_args):
254
# Don't bother doing an import check when an extension was
255
# build with an explicit '-arch' flag on OSX. That's currently
256
# only used to build 32-bit only extensions in a 4-way
257
# universal build and loading 32-bit code into a 64-bit
260
'WARNING: skipping import check for "%s"' %
250
264
# Workaround for Cygwin: Cygwin currently has fork issues when many
251
265
# modules have been imported
252
266
if self.get_platform() == 'cygwin':
542
556
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
543
if platform == 'darwin':
557
if platform == 'darwin': # and os.uname()[2] < '9.':
544
558
# MacOSX 10.4 has a broken readline. Don't try to build
545
559
# the readline module unless the user has installed a fixed
546
560
# readline package
561
# FIXME: The readline emulation on 10.5 is better, but the
562
# readline module doesn't compile out of the box.
547
563
if find_file('readline/rlconf.h', inc_dirs, []) is None:
548
564
do_readline = False
687
703
# a release. Most open source OSes come with one or more
688
704
# versions of BerkeleyDB already installed.
690
max_db_ver = (4, 5) # XXX(gregory.p.smith): 4.6 "works" but seems to
691
# have issues on many platforms. I've temporarily
692
# disabled 4.6 to see what the odd platform
694
707
min_db_ver = (3, 3)
695
708
db_setup_debug = False # verbose debug prints from this script?
710
def allow_db_ver(db_ver):
711
"""Returns a boolean if the given BerkeleyDB version is acceptable.
714
db_ver: A tuple of the version to verify.
716
if not (min_db_ver <= db_ver <= max_db_ver):
718
# Use this function to filter out known bad configurations.
719
if (4, 6) == db_ver[:2]:
720
# BerkeleyDB 4.6.x is not stable on many architectures.
721
arch = platform_machine()
722
if arch not in ('i386', 'i486', 'i586', 'i686',
727
def gen_db_minor_ver_nums(major):
729
for x in range(max_db_ver[1]+1):
730
if allow_db_ver((4, x)):
734
if allow_db_ver((3, x)):
737
raise ValueError("unknown major BerkeleyDB version", major)
697
739
# construct a list of paths to look for the header file in on
698
740
# top of the normal inc_dirs.
708
750
'/sw/include/db3',
710
752
# 4.x minor number specific paths
711
for x in range(max_db_ver[1]+1):
753
for x in gen_db_minor_ver_nums(4):
712
754
db_inc_paths.append('/usr/include/db4%d' % x)
713
755
db_inc_paths.append('/usr/include/db4.%d' % x)
714
756
db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
718
760
# MacPorts default (http://www.macports.org/)
719
761
db_inc_paths.append('/opt/local/include/db4%d' % x)
720
762
# 3.x minor number specific paths
763
for x in gen_db_minor_ver_nums(3):
722
764
db_inc_paths.append('/usr/include/db3%d' % x)
723
765
db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
724
766
db_inc_paths.append('/usr/local/include/db3%d' % x)
733
775
for dn in inc_dirs:
734
776
std_variants.append(os.path.join(dn, 'db3'))
735
777
std_variants.append(os.path.join(dn, 'db4'))
736
for x in range(max_db_ver[1]+1):
778
for x in gen_db_minor_ver_nums(4):
737
779
std_variants.append(os.path.join(dn, "db4%d"%x))
738
780
std_variants.append(os.path.join(dn, "db4.%d"%x))
781
for x in gen_db_minor_ver_nums(3):
740
782
std_variants.append(os.path.join(dn, "db3%d"%x))
741
783
std_variants.append(os.path.join(dn, "db3.%d"%x))
773
815
if ( (not db_ver_inc_map.has_key(db_ver)) and
774
(db_ver <= max_db_ver and db_ver >= min_db_ver) ):
816
allow_db_ver(db_ver) ):
775
817
# save the include directory with the db.h version
776
818
# (first occurrence only)
777
819
db_ver_inc_map[db_ver] = d
818
860
if db_setup_debug:
819
print "db lib: using", db_ver, dblib
820
print "db: lib dir", dblib_dir, "inc dir", db_incdir
861
print "bsddb using BerkeleyDB lib:", db_ver, dblib
862
print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
821
863
db_incs = [db_incdir]
823
865
# We add the runtime_library_dirs argument because the
1277
1319
'_Dlg', '_Drag', '_Evt', '_File', '_Folder', '_Fm',
1278
1320
'_Help', '_Icn', '_IBCarbon', '_List',
1279
1321
'_Menu', '_Mlte', '_OSA', '_Res', '_Qd', '_Qdoffs',
1280
'_Scrap', '_Snd', '_TE', '_Win',
1322
'_Scrap', '_Snd', '_TE',
1282
1324
for name in CARBON_EXTS:
1283
1325
addMacExtension(name, carbon_kwds)
1327
# Workaround for a bug in the version of gcc shipped with Xcode 3.
1328
# The _Win extension should build just like the other Carbon extensions, but
1329
# this actually results in a hard crash of the linker.
1331
if '-arch ppc64' in cflags and '-arch ppc' in cflags:
1332
win_kwds = {'extra_compile_args': carbon_extra_compile_args + ['-arch', 'i386', '-arch', 'ppc'],
1333
'extra_link_args': ['-framework', 'Carbon', '-arch', 'i386', '-arch', 'ppc'],
1335
addMacExtension('_Win', win_kwds)
1337
addMacExtension('_Win', carbon_kwds)
1285
1340
# Application Services & QuickTime
1286
1341
app_kwds = {'extra_compile_args': carbon_extra_compile_args,
1287
1342
'extra_link_args': ['-framework','ApplicationServices'],
1348
1403
include_dirs.append('/usr/X11R6/include')
1349
1404
frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
1406
# All existing framework builds of Tcl/Tk don't support 64-bit
1408
cflags = sysconfig.get_config_vars('CFLAGS')[0]
1409
archs = re.findall('-arch\s+(\w+)', cflags)
1410
if 'x86_64' in archs or 'ppc64' in archs:
1412
archs.remove('x86_64')
1416
archs.remove('ppc64')
1421
frameworks.append('-arch')
1422
frameworks.append(a)
1351
1424
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1352
1425
define_macros=[('WITH_APPINIT', 1)],
1353
1426
include_dirs = include_dirs,
1354
1427
libraries = [],
1355
extra_compile_args = frameworks,
1428
extra_compile_args = frameworks[2:],
1356
1429
extra_link_args = frameworks,
1358
1431
self.extensions.append(ext)
1580
1654
# finding some -z option for the Sun compiler.
1581
1655
extra_link_args.append('-mimpure-text')
1583
elif sys.platform.startswith('hpux'):
1657
elif sys.platform.startswith('hp-ux'):
1584
1658
extra_link_args.append('-fPIC')
1586
1660
ext = Extension('_ctypes',