1
"""Config on Darwin w/ frameworks"""
3
import os, sys, shutil, string
6
configcommand = os.environ.get('SDL_CONFIG', 'sdl-config')
7
configcommand = configcommand + ' --version --cflags --libs'
11
def __init__(self, name, checkhead, checklib, lib):
17
self.checklib = checklib+self.libext
18
self.checkhead = checkhead
21
def configure(self, incdirs, libdirs):
22
incname = self.checkhead
23
libnames = self.checklib, string.lower(self.name)
25
path = os.path.join(dir, incname)
26
if os.path.isfile(path):
31
path = os.path.join(dir, name)
32
if os.path.isfile(path):
35
if self.lib_dir and self.inc_dir:
36
print self.name + ' '[len(self.name):] + ': found'
39
print self.name + ' '[len(self.name):] + ': not found'
41
class FrameworkDependency(Dependency):
42
def configure(self, incdirs, libdirs):
43
for n in '/Library/Frameworks/','~/Library/Frameworks/','/System/Library/Frameworks/':
44
if os.path.isfile(n+self.lib+'.framework/Versions/Current/'+self.lib):
45
print 'Framework '+self.lib+' found'
47
self.inc_dir = n+self.lib+'.framework/Versions/Current/Headers'
48
self.cflags = '-Ddarwin -Xlinker "-F'+n+self.lib+'.framework" -Xlinker "-framework" -Xlinker "'+self.lib+'"'
49
self.origlib = self.lib
52
print 'Framework '+self.lib+' not found'
55
if sys.platform.find('bsd') != -1:
56
sdl_lib_name = 'SDL-1.2'
59
FrameworkDependency('SDL', 'SDL.h', 'lib'+sdl_lib_name, 'SDL'),
60
FrameworkDependency('FONT', 'SDL_ttf.h', 'libSDL_ttf', 'SDL_ttf'),
61
FrameworkDependency('IMAGE', 'SDL_image.h', 'libSDL_image', 'SDL_image'),
62
FrameworkDependency('MIXER', 'SDL_mixer.h', 'libSDL_mixer', 'SDL_mixer'),
63
Dependency('SMPEG', 'smpeg.h', 'libsmpeg', 'smpeg'),
67
from distutils.util import split_quoted
71
print 'calling "sdl-config"'
72
configinfo = "-I/usr/local/include/SDL -L/usr/local/lib -D_REENTRANT -lSDL"
74
configinfo = os.popen(configcommand).readlines()
75
print 'Found SDL version:', configinfo[0]
76
configinfo = ' '.join(configinfo[1:])
77
configinfo = configinfo.split()
78
for w in configinfo[:]:
79
if ',' in w: configinfo.remove(w)
80
configinfo = ' '.join(configinfo)
81
#print 'Flags:', configinfo
83
raise SystemExit, """Cannot locate command, "sdl-config". Default SDL compile
84
flags have been used, which will likely require a little editing."""
86
print 'Hunting dependencies...'
87
incdirs = ['/usr/local/include/smpeg']
92
for arg in split_quoted(configinfo):
98
incdirs.append(arg[2:])
100
elif arg[:2] == '-L':
101
libdirs.append(arg[2:])
102
newconfig.append(arg)
103
elif arg[:2] == '-F':
105
elif arg == '-framework':
109
d.configure(incdirs, libdirs)
111
newconfig.extend(map(lambda x:'-Xlinker "%s"'%x,extralib))
112
if sys.platform.find('darwin') != -1:
113
newconfig.append('-Ddarwin')
114
configinfo = ' '.join(newconfig)
115
DEPS[0].inc_dirs = []
116
DEPS[0].lib_dirs = []
117
DEPS[0].cflags = configinfo
121
if __name__ == '__main__':
122
print """This is the configuration subscript for Unix.
123
Please run "config.py" for full configuration."""