41
51
def choosepath(self):
43
print 'Path for ', self.name, 'not found.'
44
if self.required: print 'Too bad that is a requirement! Hand-fix the "Setup"'
53
print ("Path for %s not found." % self.name)
55
print ('Too bad that is a requirement! Hand-fix the "Setup"')
45
56
elif len(self.paths) == 1:
46
57
self.path = self.paths[0]
47
print 'Path for '+self.name+':', self.path
58
print ("Path for %s:' % self.name")
49
print 'Select path for '+self.name+':'
60
print ("Select path for %s:" % self.name)
50
61
for i in range(len(self.paths)):
51
print ' ', i+1, '=', self.paths[i]
52
print ' ', 0, '= <Nothing>'
53
choice = raw_input('Select 0-'+`len(self.paths)`+' (1=default):')
62
print (" %i=%s" % (i + 1, self.paths[i]))
63
print (" %i = <Nothing>" % 0)
64
choice = raw_input("Select 0-%i (1=default):" % len(self.paths))
54
65
if not choice: choice = 1
55
66
else: choice = int(choice)
142
146
if self.test(e) and os.path.isfile(os.path.join(path, e)):
144
148
self.lib_dir = os.path.join(path, e).replace('\\', '/')
145
print "DLL for %s is %s" % (self.lib_name, self.lib_dir)
149
print ("DLL for %s is %s" % (self.lib_name, self.lib_dir))
147
print "DLL for %s not found" % self.lib_name
151
print ("DLL for %s not found" % self.lib_name)
150
153
class DependencyWin(object):
151
def __init__(self, name, libs):
154
def __init__(self, name, cflags):
153
156
self.inc_dir = None
154
157
self.lib_dir = None
159
162
def configure(self):
164
Dependency('SDL', ['SDL-[1-9].*'], required=1),
165
Dependency('FONT', ['SDL_ttf-[2-9].*']),
166
Dependency('IMAGE', ['SDL_image-[1-9].*']),
167
Dependency('MIXER', ['SDL_mixer-[1-9].*']),
168
Dependency('SMPEG', ['smpeg-[0-9].*', 'smpeg']),
169
DependencyWin('SCRAP', ['user32', 'gdi32']),
170
Dependency('JPEG', ['jpeg-[6-9]*']),
171
Dependency('PNG', ['libpng-[1-9].*']),
172
DependencyDLL('TIFF', ['tiff-[3-9].*']),
173
DependencyDLL('VORBIS', ['libvorbis-[1-9].*']),
174
DependencyDLL('OGG', ['libogg-[1-9].*']),
175
DependencyDLL('Z', ['zlib-[1-9].*']),
178
DEPS += [DependencyDLL(link=dep) for dep in DEPS[:] if type(dep) is Dependency]
179
DEPS += [DependencyDLL('VORBISFILE', link=DEPS[9])]
165
class DependencyGroup(object):
167
self.dependencies =[]
170
def add(self, name, lib, wildcards, dll_regex, libs=None, required=0):
173
dep = Dependency(name, wildcards, [lib], required)
174
self.dependencies.append(dep)
175
self.dlls.append(DependencyDLL(dll_regex, link=dep, libs=libs))
177
def add_win(self, name, cflags):
178
self.dependencies.append(DependencyWin(name, cflags))
180
def add_dll(self, dll_regex, lib=None, wildcards=None, libs=None, link_lib=None):
182
if link_lib is not None:
183
name = 'COPYLIB_' + link_lib
189
raise KeyError("Link lib %s not found" % link_lib)
190
self.dlls.append(DependencyDLL(dll_regex, lib, wildcards, libs, link))
197
for d in self.dependencies:
202
DEPS = DependencyGroup()
203
DEPS.add('SDL', 'SDL', ['SDL-[1-9].*'], r'(lib){0,1}SDL\.dll$', required=1)
204
DEPS.add('FONT', 'SDL_ttf', ['SDL_ttf-[2-9].*'], r'(lib){0,1}SDL_ttf\.dll$', ['SDL', 'z'])
205
DEPS.add('IMAGE', 'SDL_image', ['SDL_image-[1-9].*'], r'(lib){0,1}SDL_image\.dll$',
206
['SDL', 'jpeg', 'png', 'tiff'], 0),
207
DEPS.add('MIXER', 'SDL_mixer', ['SDL_mixer-[1-9].*'], r'(lib){0,1}SDL_mixer\.dll$',
208
['SDL', 'vorbisfile', 'smpeg'])
209
DEPS.add('SMPEG', 'smpeg', ['smpeg-[0-9].*', 'smpeg'], r'smpeg\.dll$', ['SDL'])
210
DEPS.add('PNG', 'png', ['libpng-[1-9].*'], r'(png|libpng13)\.dll$', ['z'])
211
DEPS.add('JPEG', 'jpeg', ['jpeg-[6-9]*'], r'(lib){0,1}jpeg\.dll$')
212
DEPS.add('PORTMIDI', 'portmidi', ['portmidi'], r'portmidi\.dll$')
213
#DEPS.add('PORTTIME', 'porttime', ['porttime'], r'porttime\.dll$')
214
DEPS.add_dll(r'(lib){0,1}tiff\.dll$', 'tiff', ['tiff-[3-9].*'], ['jpeg', 'z'])
215
DEPS.add_dll(r'(z|zlib1)\.dll$', 'z', ['zlib-[1-9].*'])
216
DEPS.add_dll(r'(libvorbis-0|vorbis)\.dll$', 'vorbis', ['libvorbis-[1-9].*'],
218
DEPS.add_dll(r'(libvorbisfile-3|vorbisfile)\.dll$', 'vorbisfile',
219
link_lib='vorbis', libs=['vorbis'])
220
DEPS.add_dll(r'(libogg-0|ogg)\.dll$', 'ogg', ['libogg-[1-9].*'])
221
for d in get_definitions():
222
DEPS.add_win(d.name, d.value)
181
225
def setup_prebuilt():
182
226
setup = open('Setup', 'w')
183
for line in open('Setup.in').readlines():
184
if line[:3] == '#--': continue
185
if line[:6] == 'SDL = ':
186
line = 'SDL = -Iprebuilt/include -Iprebuilt/include/SDL -Lprebuilt/lib -lSDL\n'
187
if line[:8] == 'SMPEG = ':
188
line = 'SMPEG = -Iprebuilt/include/smpeg -lsmpeg\n'
189
if line[:8] == 'SCRAP = ':
190
line = 'SCRAP = -luser32 -lgdi32\n'
229
setup_win_in = open(os.path.join('prebuilt', 'Setup_Win.in'))
231
raise IOError("prebuilt missing required Setup_Win.in")
233
# Copy Setup.in to Setup, replacing the BeginConfig/EndConfig
234
# block with prebuilt\Setup_Win.in .
235
setup_in = open('Setup.in')
238
for line in setup_in:
239
if line.startswith('#--StartConfig'):
241
setup.write(setup_win_in.read())
243
setup_win_common_in = open('Setup_Win_Common.in')
248
setup.write(setup_win_common_in.read())
250
setup_win_common_in.close()
251
elif line.startswith('#--EndConfig'):