-
Notifications
You must be signed in to change notification settings - Fork 70
/
msys_build_deps.py
1717 lines (1455 loc) · 52.3 KB
/
msys_build_deps.py
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# -*- coding: ascii -*-
# Program msys_build_deps.py
# Requires Python 2.5 or later and win32api.
"""Build Pygame dependencies using MinGW and MSYS
Configured for Pygame 1.9.2 and Python 2.5 and up.
By default the libraries are installed in the MSYS directory /usr/local unless
a diffrent directory is specified by the --prefix command line argument.
This program can be run from a Windows cmd.exe or MSYS terminal. The current
directory and its outer directory are searched for the library source
directories. Run the program from the pygame trunk directory. The Windows
file path cannot have spaces in it.
The recognized, and optional, environment variables are:
PREFIX - Destination directory
MSYS_ROOT_DIRECTORY - MSYS home directory (may omit 1.0 subdirectory)
CPPFLAGS - preprocessor options, appended to options set by the program
CFLAGS - compiler flags, appended to options set by the program
LDFLAGS - linker options, prepended to flags set by the program
To get a list of command line options run
python build_deps.py --help
This program has been tested against the following libraries:
SDL 1.2.15
SDL_image 1.2(.10+) hg changset 45748e6e2f81
SDL_mixer 1.2.12 hg changeset b455bc681654
SDL_ttf 2.0.11 hg changeset d9a600fa3c4a
smpeg SVN revision 391 (built separately with MSVC++)
freetype 2.4.8
libogg 1.3.0
libvorbis 1.3.2
FLAC 1.2.1
mikmod 3.1.12 patched (included with SDL_mixer 1.2.12)
tiff 4.0b7
libpng 1.6.0b1
jpeg 8c
zlib 1.2.5
PortMidi revision 217 from SVN
untested with GCC 4.6.1: ffmpeg revision 24482 from SVN (swscale revision 31785)
The build environment used:
GCC 4.6.1
MSYS 1.0.17
dx7 headers
yasm 1.2.0
The build has been performed on Windows XP, SP3.
Build issues:
An intermitent problem was noted with SDL's configure involving locking of
conftest.exe resulting in various C library functions being reported unavailable
when in fact they are present. This does not appear to be a problem with the
configure script itself but rather Msys. If it happens then just rerun
msys_build_deps.py.
"""
import msys
from optparse import OptionParser
import os
import sys
from glob import glob
import time
# For Python 2.x/3.x compatibility
def geterror():
return sys.exc_info()[1]
#
# Generic declarations
#
hunt_paths = ['.', '..']
default_prefix_mp = '/usr/local'
def prompt(p=None):
"""MSYS friendly raw_input
This provides a hook that can be replaced for testing.
"""
msys.msys_raw_input(p)
def print_(*args, **kwds):
msys.msys_print(*args, **kwds)
def confirm(message):
"""Ask a yes/no question, return result"""
reply = prompt("\n%s [Y/n]:" % message)
if reply and reply[0].lower() == 'n':
return 0
return 1
def as_flag(b):
"""Return bool b as a shell script flag '1' or '0'"""
if b:
return '1'
return '0'
def as_linker_lib_path(p):
"""Return as an ld library path argument"""
if p:
return '-L' + p
return ''
def as_linker_option(p):
"""Return as an ld library path argument"""
if p:
return '-Wl,' + p
return ''
def as_preprocessor_header_path(p):
"""Return as a C preprocessor header include path argument"""
if p:
return '-I' + p
return ''
def as_macro_define(m, v):
"""Return as a C preprocessor command line macro definition"""
if v:
return '-D%s=%s' % (m, v)
return '-D%s' % (m,)
def merge_strings(*args, **kwds):
"""Returns non empty string joined by sep
The default separator is an empty string.
"""
sep = kwds.get('sep', '')
return sep.join([s for s in args if s])
def get_python_msvcrt_version():
"""Return the Visual C runtime version Python is linked to, as an int"""
python_version = sys.version_info[0:2]
if python_version < (2.4):
return 60
if python_version < (2.6):
return 71
return 90
class BuildError(Exception):
"""Raised for missing source paths and failed script runs"""
pass
class Dependency(object):
"""Builds a library"""
def __init__(self, name, wildcards, libs, shell_script):
self.name = name
self.wildcards = wildcards
self.shell_script = shell_script
self.libs = libs
def configure(self, hunt_paths):
self.path = None
self.paths = []
self.hunt(hunt_paths)
self.choosepath()
def hunt(self, hunt_paths):
parent = os.path.abspath('..')
for p in hunt_paths:
for w in self.wildcards:
found = glob(os.path.join(p, w))
found.sort() or found.reverse() #reverse sort
for f in found:
if f[:5] == '..'+os.sep+'..' and \
os.path.abspath(f)[:len(parent)] == parent:
continue
if os.path.isdir(f):
self.paths.append(f)
def choosepath(self):
path = None
if not self.paths:
raise BuildError("Path for %s: not found" % self.name)
if len(self.paths) == 1:
path = self.paths[0]
else:
print_("Select path for %s:" % self.name)
for i in range(len(self.paths)):
print_(" %d = %s" % (i+1, self.paths[i]))
print_(" 0 = <Nothing>")
choice = prompt("Select 0-%d (1=default):" % len(self.paths))
if not choice:
choice = 1
else:
choice = int(choice)
if choice > 0:
path = self.paths[choice-1]
if path is not None:
self.path = os.path.abspath(path)
def build(self, msys):
if self.path is not None:
env_home = msys.environ.get('HOME', None)
msys.environ['HOME'] = self.path
try:
return_code = msys.run_shell_script(self.shell_script)
finally:
if env_home is not None:
msys.environ['HOME'] = env_home
else:
del msys.environ['HOME']
if return_code != 0:
raise BuildError("The build for %s failed with code %d" %
(self.name, return_code))
else:
raise BuildError("No source directory for %s" % self.name)
class Preparation(object):
"""Perform necessary build environment preperations"""
def __init__(self, name, shell_script):
self.name = name
self.path = ''
self.paths = []
self.libs = []
self.shell_script = shell_script
def configure(self, hunt_paths):
pass
def build(self, msys):
return_code = msys.run_shell_script(self.shell_script)
if return_code != 0:
raise BuildError("Preparation '%s' failed with code %d" %
(self.name, return_code))
def configure(dependencies, hunt_paths):
"""Find source directories of all dependencies"""
success = True
print_("Hunting for source directories...")
for dep in dependencies:
try:
dep.configure(hunt_paths)
except BuildError:
print_(geterror())
success = False
else:
if dep.path:
print_("Source directory for", dep.name, ":", dep.path)
if not success:
raise BuildError("Not all source directories were found")
def build(dependencies, msys):
"""Execute the shell scripts for all dependencies"""
for dep in dependencies:
print_("\n\n----", dep.name, "----")
dep.build(msys)
def command_line():
"""Process the command line and return the options"""
usage = ("usage: %prog [options] --all\n"
" %prog [options] [args]\n"
"\n"
"Build the Pygame dependencies. The args, if given, are\n"
"libraries to include or exclude.\n"
"\n"
"At startup this program may prompt for missing information.\n"
"Be aware of this before redirecting output or leaving the\n"
"program unattended. Once the 'Starting build' message appears\n"
"no more user input is required. The build process will"
"abort on the first error, as library build order is important.\n"
"\n"
"See --help-args.\n"
"\n"
"For more details see the program's document string\n")
parser = OptionParser(usage)
parser.add_option('-a', '--all', action='store_true', dest='build_all',
help="Include all libraries in the build")
parser.set_defaults(build_all=False)
parser.add_option('--msvcr-version', action='store', dest='msvcrt_version',
type='choice', choices=['60', '71', '90'],
help="Visual C runtime library version")
parser.set_defaults(msvcrt_version=get_python_msvcrt_version())
parser.add_option('--no-configure', action='store_false', dest='configure',
help="Do not prepare the makefiles")
parser.set_defaults(configure=True)
parser.add_option('--no-compile', action='store_false', dest='compile',
help="Do not compile or install the libraries")
parser.set_defaults(compile=True)
parser.add_option('--no-install', action='store_false', dest='install',
help="Do not install the libraries")
parser.add_option('--no-strip', action='store_false', dest='strip',
help="Do not strip the library")
parser.set_defaults(strip=True)
parser.set_defaults(install=True)
parser.add_option('--clean', action='store_true', dest='clean',
help="Remove generated files (make clean)"
" as a last step")
parser.set_defaults(clean=False)
parser.add_option('--clean-only', action='store_true', dest='clean_only',
help="Perform only a clean")
parser.set_defaults(clean_only=False)
parser.add_option('-e', '--exclude', action='store_true', dest='exclude',
help="Exclude the specified libraries")
parser.set_defaults(exclude=False)
parser.add_option('-m', '--msys-root', action='store',
dest='msys_directory',
help="MSYS directory path, which may include"
" the 1.x subdirectory")
parser.set_defaults(msys_directory='')
parser.add_option('-s', '--sources', action='store',
dest='sources',
help="Paths to search for library source directories"
" as a semicolon ';' separated list: defaults to %s"
% (';'.join(hunt_paths),))
parser.add_option('-p', '--prefix', action='store',
dest='prefix',
help="Destination directory of the build: defaults to MSYS %s"
% (default_prefix_mp,))
parser.set_defaults(prefix='')
parser.add_option('--help-args', action='store_true', dest='arg_help',
help="Show a list of recognised libraries,"
" in build order, and exit")
parser.set_defaults(arg_help=False)
parser.add_option('--subsystem-noforce', action='store_true', dest='subsystem_noforce',
help="Do not force the dlls to build with the GUI subsystem type")
parser.set_defaults(subsystem_noforce=False)
parser.add_option('-b', '--beep', action='store_true', dest='finish_alert',
help="Beep the computer speaker when finished.")
parser.set_defaults(finish_alert=False)
parser.add_option('-n', '--beep-ntimes', type='int', action='store', dest='finish_alert_ntimes',
help="Beep the computer speaker n times when finished")
parser.set_defaults(finish_alert_ntimes=0)
return parser.parse_args()
def set_environment_variables(msys, options):
"""Set the environment variables used by the scripts"""
environ = msys.environ
msys_root_wp = msys.msys_root
prefix_wp = options.prefix
if not prefix_wp:
prefix_wp = environ.get('PREFIX', '')
if prefix_wp:
prefix_mp = msys.windows_to_msys(prefix_wp)
else:
prefix_mp = default_prefix_mp
prefix_wp = msys.msys_to_windows(prefix_mp)
include_mp = prefix_mp + '/include'
lib_mp = prefix_mp + '/lib'
subsystem = ''
if not options.subsystem_noforce:
subsystem = '-mwindows'
msvcrt_mp = ''
resources_mp = ''
if options.msvcrt_version == 71:
# Hide the msvcrt.dll import libraries with those for msvcr71.dll.
# Their subdirectory is in the same directory as the SDL library.
msvcrt_mp = lib_mp + '/msvcr71'
elif options.msvcrt_version == 90:
# Hide the msvcrt.dll import libraries with those for msvcr90.dll.
# Their subdirectory is in the same directory as the SDL library.
msvcrt_mp = lib_mp + '/msvcr90'
resources_mp = msvcrt_mp + '/resources.o'
environ['PREFIX'] = prefix_mp
environ.pop('INCLUDE', None) # INCLUDE causes problems with MIXER.
environ['CPPFLAGS'] = merge_strings(as_macro_define('__MSVCRT_VERSION__',
'0x0%02i0' % (options.msvcrt_version,)),
as_preprocessor_header_path(include_mp),
environ.get('CPPFLAGS', ''),
sep=' ')
# Need to make the resources object file an explicit linker option to
# bypass libtool (freetype).
environ['LDFLAGS'] = merge_strings(as_linker_lib_path(msvcrt_mp),
environ.get('LDFLAGS', ''),
as_linker_lib_path(lib_mp),
as_linker_option(resources_mp),
subsystem,
sep=' ')
environ['BDCONF'] = as_flag(options.configure and
not options.clean_only)
environ['BDCOMP'] = as_flag(options.compile and
not options.clean_only)
environ['BDINST'] = as_flag(options.install and
options.compile and
not options.clean_only)
environ['BDSTRIP'] = as_flag(options.compile and
options.install and
options.strip and
not options.clean_only)
environ['BDCLEAN'] = as_flag(options.clean or options.clean_only)
environ['BDRESOURCES'] = resources_mp
environ['BDMSVCRT_VERSION'] = '%i' % (options.msvcrt_version,)
environ['BDMSVCRT'] = msvcrt_mp
class ChooseError(Exception):
"""Failer to select dependencies"""
pass
def choose_dependencies(dependencies, options, args):
"""Return the dependencies to actually build"""
if options.build_all:
if args:
raise ChooseError("No library names are accepted"
" for the --all option.")
if options.exclude:
return []
else:
return dependencies
if args:
names = [d.name for d in dependencies]
args = [a.upper() for a in args]
for a in args:
if a not in names:
msg = ["%s is an unknown library; valid choices are:" % a]
msg.extend(names)
raise ChooseError('\n'.join(msg))
if options.exclude:
return [d for d in dependencies if d.name not in args]
return [d for d in dependencies if d.name in args]
return []
def summary(dependencies, msys, start_time, chosen_deps):
"""Display a summary report of new, existing and missing libraries"""
import datetime
print_("\n\n=== Summary ===")
if start_time is not None:
print_(" Elapse time:",
datetime.timedelta(seconds=time.time()-start_time))
print_()
for dep in chosen_deps:
if dep.path is None:
print_(" ** No source directory found for", dep.name)
elif dep.path:
print_(" Source directory for", dep.name, ":", dep.path)
print_()
prefix = msys.msys_to_windows(msys.environ['PREFIX']).replace('/', os.sep)
bin_dir = os.path.join(prefix, 'bin')
lib_dir = os.path.join(prefix, 'lib')
for d in dependencies:
for lib in d.libs:
if lib.endswith('.dll'):
lib_path = os.path.join(bin_dir, lib)
try:
mod_time = os.path.getmtime(lib_path)
except:
msg = "No DLL"
else:
if mod_time >= start_time:
msg = "Installed new DLL %s" % (lib_path,)
else:
msg = "-- (old DLL %s)" % (lib_path,)
elif lib.endswith('.a'):
lib_path = os.path.join(lib_dir, lib)
try:
mod_time = os.path.getmtime(lib_path)
except:
msg = "No static library"
else:
if mod_time >= start_time:
msg = "Installed new static library %s" % (lib_path,)
else:
msg = "-- (old static library %s)" % (lib_path,)
else:
msg = "Internal error: unknown library type %s" % (lib,)
print_(" %-10s: %s" % (d.name, msg))
def main(dependencies, msvcr71_preparation, msvcr90_preparation, msys_preparation):
"""Build the dependencies according to the command line options."""
options, args = command_line()
if options.arg_help:
print_("These are the Pygame library dependencies:")
for dep in dependencies:
print_(" ", dep.name)
return 0
try:
chosen_deps = choose_dependencies(dependencies, options, args)
except ChooseError:
print_(geterror())
return 1
if not chosen_deps:
if not args:
print_("No libraries specified.")
elif options.build_all:
print_("All libraries excluded")
if options.msvcrt_version == 71 and not options.clean_only:
chosen_deps.insert(0, msvcr71_preparation)
print_("Linking to msvcr71.dll.")
elif options.msvcrt_version == 90 and not options.clean_only:
chosen_deps.insert(0, msvcr90_preparation)
else:
print_("Linking to C runtime library msvcrt.dll.")
if chosen_deps and not options.clean_only:
chosen_deps.insert(0, msys_preparation)
try:
m = msys.Msys(options.msys_directory)
except msys.MsysException:
print_(geterror())
return 1
print_("Using MSYS in directory:", m.msys_root)
print_("MinGW directory:", m.mingw_root)
start_time = None
return_code = 1
set_environment_variables(m, options)
if not options.clean_only:
print_("Destination directory:",
m.msys_to_windows(m.environ['PREFIX']).replace('/', os.sep))
print_("common CPPFLAGS:", m.environ.get('CPPFLAGS', ''))
print_("common CFLAGS:", m.environ.get('CFLAGS', ''))
print_("common LDFLAGS:", m.environ.get('LDFLAGS', ''))
sources = hunt_paths
if options.sources:
sources = options.sources.split(';')
print_("library source directories search paths: %s" % (';'.join(sources),))
try:
configure(chosen_deps, sources)
except BuildError:
print_("Build aborted:", geterror())
else:
if options.clean_only:
print_("\n=== Performing clean ===")
else:
print_("\n=== Starting build ===")
start_time = time.time() # For file timestamp checks.
try:
build(chosen_deps, m)
except BuildError:
print_("Build aborted:", geterror())
else:
# A successful build!
return_code = 0
if not options.clean_only:
summary(dependencies, m, start_time, chosen_deps)
# MinGW configure file for setup.py (optional).
try:
import mingwcfg
except ImportError:
pass
else:
mingwcfg.write(m.mingw_root)
if options.finish_alert or options.finish_alert_ntimes > 0:
if options.finish_alert_ntimes > 0:
m.environ['BDNTIMES'] = "%i" % (options.finish_alert_ntimes,)
alert.build(m)
return return_code
#
# Build specific code
#
# This list includes the MSYS shell scripts to build each library. Each script
# runs in an environment where MINGW_ROOT_DIRECTORY is defined and the MinGW
# bin directory is in PATH. Four build control environment variables are
# defined: BDCONF, BDCOMP, BDINST and BDCLEAN. They are either '0' or '1'. They
# represent configure, compile, install and clean respectively. When '1' the
# corresponding action is performed. When '0' it is skipped. The installation
# directory is given by PREFIX. The script needs to prepend it to PATH. The
# script's HOME directory is the source code root directory. The msvcrt version
# is given as BDMSVCRT_VERSION. BDMSVCRT is where to place a shadow libraries
# which hide the normal MinGW C runtime export libraries. Various gcc flags are
# in CPPFLAGS, CFLAGS, and LDFLAGS. INCLUDE is undefined.
#
# None of these scripts end with an "exit". Exit, possibly, leads to Msys
# freezing on some versions of Windows (98).
#
# The list order corresponds to build order. It is critical.
dependencies = [
Dependency('SDL', ['SDL-[1-9].*'], ['SDL.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
# Remove NONAMELESSUNION from directx.h headers.
for d in video audio; do
BDDXHDR=src/$d/windx5/directx.h
cp -f $BDDXHDR $BDDXHDR'_'
sed 's/^\\(#define NONAMELESSUNION\\)/\\/*\\1*\\//' $BDDXHDR'_' >$BDDXHDR
if [ x$? != x0 ]; then exit $?; fi
rm $BDDXHDR'_'
BDDXHDR=
done
# If this comes from the repository it has no configure script
if [ ! -f "./configure" ]; then
./autogen.sh
fi
./configure --prefix="$PREFIX" --disable-static --disable-stdio-redirect \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install-bin install-hdrs install-lib
# Make SDL_config_win32.h available for prebuilt and MSVC
cp -f "$HOME/include/SDL_config_win32.h" "$PREFIX/include/SDL"
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/SDL.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean
fi
"""),
Dependency('Z', ['zlib-[1-9].*'], ['zlib1.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
cp -fp win32/Makefile.gcc .
# Will use contributed asm code.
cp -fp contrib/asm686/match.S .
fi
if [ x$BDCOMP == x1 ]; then
# Build with the import library renamed, using asm code, our CPPFLAGS,
# CFLAGS, and LDFLAGS (passed in as LOC).
make IMPLIB=libz.dll.a OBJA=match.o -fMakefile.gcc
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LOC="-DASMV $LDFLAGS"
fi
if [ x$BDINST == x1 ]; then
# Make sure everything is installed in the correct places
make install LIBRARY_PATH="$PREFIX/lib" INCLUDE_PATH="$PREFIX/include" \
BINARY_PATH="$PREFIX/bin" SHARED_MODE=1 IMPLIB=libz.dll.a -fMakefile.gcc
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/zlib1.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean -fMakefile.gcc
fi
"""),
Dependency('FREETYPE', ['freetype-[2-9].*'], ['libfreetype-6.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' builds/unix/config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/libfreetype-6.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean
fi
"""),
Dependency('FONT', ['SDL_ttf-[2-9].*'], ['SDL_ttf.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
# If this comes from the repository it has no configure script
if [ ! -f "./configure" ]; then
./autogen.sh
fi
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/SDL_ttf.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean
fi
"""),
Dependency('PNG', ['l*png*[1-9][1-9.]*'], ['libpng16-16.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/libpng16-16.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean -fMakefile.mingw prefix="$PREFIX"
fi
"""),
Dependency('JPEG', ['jpeg-[6-9]*'], ['libjpeg-8.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
# This will only build a static library.
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
cp jconfig.vc jconfig.h
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
# Only install the headers and import library, otherwise SDL_image will
# statically link to jpeg.
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/libjpeg-8.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean
fi
"""),
Dependency('TIFF', ['tiff-[3-9].*'], ['libtiff-5.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
# Only build the library; the tools can be built, but do not install
# for msvcr90.dll because of a strange linker error.
bd_subdirs="port libtiff"
if [ x$BDCONF == x1 ]; then
./configure --disable-cxx --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make SUBDIRS="$bd_subdirs"
fi
if [ x$BDINST == x1 ]; then
make install SUBDIRS="$bd_subdirs"
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/libtiff-5.dll"
fi
if [ x$BDCLEAN == x1 ]; then
set +e
make clean SUBDIRS="$bd_subdirs"
rm -f libtiff.dll.a
rm -f libtiff.dll
fi
"""),
Dependency('IMAGE', ['SDL_image-[1-9].*'], ['SDL_image.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
# If this comes from the repository it has no configure script
if [ ! -f "./configure" ]; then
./autogen.sh
fi
# configure searches for the JPEG dll. Unfortunately it uses the wrong file
# name. Correct this.
mv configure configure~
sed -e 's|jpeg\.dll|libjpeg-*.dll|' configure~ >configure
# Add the destination bin directory to the library search path so
# configure can find its precious DLL files.
export LDFLAGS="$LDFLAGS -L$PREFIX/bin"
# Add path to PNG headers
CPPFLAGS="$CPPFLAGS `$PREFIX/bin/libpng-config --I_opts`"
# Disable dynamic loading of image libraries as it uses the wrong DLL
# search path: does not check in the same directory.
# --disable-libtool-lock: Prevent libtool deadlocks (maybe).
./configure --disable-jpg-shared --disable-png-shared --disable-tif-shared \
--disable-libtool-lock --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/SDL_image.dll"
fi
if [[ x$BDCLEAN == x1 && -f Makefile ]]; then
set +e
make clean
fi
"""),
Dependency('SMPEG', ['smpeg-[0-9].*', 'smpeg'], ['smpeg.dll'], """
if (( $BDMSVCRT_VERSION != 60 )); then
echo The smpeg build has been disabled\\.
exit 0
fi
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
# This comes straight from SVN so has no configure script
if [ ! -f "./configure" ]; then
./autogen.sh
fi
# Don't need the toys. Disable dynamic linking of libgcc and libstdc++
./configure --disable-gtk-player --disable-opengl-player --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
# Leave out undefined symbols so a dll will build.
make CXXLD='$(CXX) -no-undefined'
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/smpeg.dll"
fi
if [[ x$BDCLEAN == x1 && -f Makefile ]]; then
set +e
make clean
fi
"""),
Dependency('OGG', ['libogg-[1-9].*'], ['libogg-0.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
# check for MSYS permission errors
if [ x"`grep 'Permission denied' config.log`" != x ]; then
echo '**** MSYS problems; build aborted.'
exit 1
fi
fi
if [ x$BDCOMP == x1 ]; then
make
fi
if [ x$BDINST == x1 ]; then
make install
fi
if [ x$BDSTRIP == x1 ]; then
strip --strip-all "$PREFIX/bin/libogg-0.dll"
fi
if [[ x$BDCLEAN == x1 && -f Makefile ]]; then
set +e
make clean
fi
"""),
Dependency('VORBIS',
['libvorbis-[1-9].*'],
['libvorbis-0.dll', 'libvorbisfile-3.dll'], """
set -e
export PATH="$PREFIX/bin:$PATH"
if [ x$BDCONF == x1 ]; then
./configure --prefix="$PREFIX" \
CPPFLAGS="$CPPFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" LIBS='-logg'
# check for MSYS permission errors