forked from ryanwoodsmall/osxwinebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osxwinebuild.sh
executable file
·3059 lines (2937 loc) · 97.5 KB
/
osxwinebuild.sh
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
#!/bin/bash
#
# Compile and install Wine and many prerequisites in a self-contained directory.
#
# Copyright (C) 2009,2010,2011,2012,2013,2014 Ryan Woodsmall <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# fail_and_exit
# first function defined since it will be called if there are failures
function fail_and_exit {
echo "${@} - exiting"
exit 1
}
# usage
# defined early; may be called if "--help" or a bunk option is passed
function usage {
echo "usage: $(basename ${0}) [--help] [--stable] [--devel] [--crossover] [--no-clean-prefix] [--no-clean-source] [--no-rebuild] [--no-reconfigure]"
echo ""
echo " Informational option(s):"
echo " --help: display this help message"
echo ""
echo " Build type options (mutually exclusive):"
echo " --devel: build the development version of Wine (default)"
echo " --stable: build the stable version of Wine"
echo " --crossover: build Wine using CrossOver sources"
echo ""
echo " Common build options:"
echo " --no-clean-prefix: do not move and create a new prefix if one already exists"
echo " --no-clean-source: do not remove/extract source if already done"
echo " --no-rebuild: do not rebuild packages, just reinstall"
echo " --no-reconfigure: do not re-run 'configure' for any packages"
echo ""
}
# options
# XXX - build gcc, patches, etc. flags
# TODO - update crossover
# set Wine build type to zero, handle below using flags
BUILDSTABLE=0
BUILDDEVEL=0
BUILDCROSSOVER=0
# use this flag to track which Wine we're building
BUILDFLAG=0
# we remove and rebuild everything in a new prefix by default
NOCLEANPREFIX=0
NOCLEANSOURCE=0
NOREBUILD=0
NORECONFIGURE=0
# cycle through options and set appropriate vars
if [ ${#} -gt 0 ] ; then
until [ -z ${1} ] ; do
case ${1} in
--stable)
if [ ${BUILDFLAG} -ne 1 ] ; then
BUILDFLAG=$((${BUILDFLAG}+1))
fi
shift ;;
--devel)
if [ ${BUILDFLAG} -ne 10 ] ; then
BUILDFLAG=$((${BUILDFLAG}+10))
fi
shift ;;
--crossover)
if [ ${BUILDFLAG} -ne 100 ] ; then
BUILDFLAG=$((${BUILDFLAG}+100))
fi
shift ;;
--no-clean-prefix)
NOCLEANPREFIX=1
echo "found --no-clean-prefix option, will install to existing prefix if it exists"
shift ;;
--no-clean-source)
NOCLEANSOURCE=1
echo "found --no-clean-source option, will not remove/rextract existing source directories"
shift ;;
--no-rebuild)
NOREBUILD=1
echo "found --no-rebuild option, will not re-run 'make' on existing source directories"
shift ;;
--no-reconfigure)
NORECONFIGURE=1
echo "found --no-reconfigure option, will not re-run 'configure' on existing source directories"
shift ;;
--help)
usage ; exit 0 ;;
*)
usage ; exit 1 ;;
esac
done
fi
# wine version
# a tag we'll use later
WINETAG=""
# stable
WINESTABLEVERSION="1.6.2"
WINESTABLESHA1SUM="574b9ccedbf213622b7ee55f715764673fc27692"
# devel
WINEDEVELVERSION="1.7.38"
WINEDEVELSHA1SUM="36d246716aa0d052ce2debb4ce8e63b517f9e297"
# CrossOver Wine
CROSSOVERVERSION="14.0.3"
CROSSOVERSHA1SUM="99016a8e8846e9eebd5020e81279e7e56ea1cd9a"
# check our build flag and pick the right version
if [ ${BUILDFLAG} -eq 1 ] ; then
BUILDSTABLE=1
WINEVERSION="${WINESTABLEVERSION}"
WINESHA1SUM="${WINESTABLESHA1SUM}"
WINETAG="Wine ${WINEVERSION}"
echo "found --stable option, will build Wine stable version"
elif [ ${BUILDFLAG} -eq 10 ] || [ ${BUILDFLAG} -eq 0 ] ; then
BUILDDEVEL=1
WINEVERSION="${WINEDEVELVERSION}"
WINESHA1SUM="${WINEDEVELSHA1SUM}"
WINETAG="Wine ${WINEVERSION}"
echo "found --devel option or no build options, will build Wine devel version"
elif [ ${BUILDFLAG} -eq 100 ] ; then
BUILDCROSSOVER=1
WINEVERSION="${CROSSOVERVERSION}"
WINESHA1SUM="${CROSSOVERSHA1SUM}"
WINETAG="CrossOver Wine ${WINEVERSION}"
echo "found --crossover option, will build Wine from CrossOver sources"
else
BUILDSTABLE=0
BUILDDEVEL=1
BUILDCROSSOVER=0
WINEVERSION="${WINEDEVELVERSION}"
WINESHA1SUM="${WINEDEVELSHA1SUM}"
WINETAG="Wine ${WINEVERSION}"
echo "found multiple build types or no specified build type, defaulting to Wine devel"
fi
# what are we building?
echo "building ${WINETAG}"
# set our file name, Wine source directory name and URL correctly
if [ ${BUILDSTABLE} -eq 1 ] || [ ${BUILDDEVEL} -eq 1 ] ; then
WINEFILE="wine-${WINEVERSION}.tar.bz2"
WINEURL="http://downloads.sourceforge.net/wine/${WINEFILE}"
WINEDIR="wine-${WINEVERSION}"
elif [ ${BUILDCROSSOVER} -eq 1 ] ; then
WINEFILE="crossover-sources-${WINEVERSION}.tar.gz"
WINEURL="http://media.codeweavers.com/pub/crossover/source/${WINEFILE}"
WINEDIR="sources/wine"
fi
# timestamp
export TIMESTAMP=$(date '+%Y%m%d%H%M%S')
# wine dir
# where everything lives - ~/wine by default
export WINEBASEDIR="${HOME}/wine"
# make the base dir if it doesn't exist
if [ ! -d ${WINEBASEDIR} ] ; then
mkdir -p ${WINEBASEDIR} || fail_and_exit "could not create ${WINEBASEDIR}"
fi
# installation path
# ~/wine/wine-X.Y.Z for standard Wine
# if we're doing a CrossOver build, set the proper directory name
WINEINSTALLDIRPREPEND=""
if [ ${BUILDCROSSOVER} -eq 1 ] ; then
WINEINSTALLDIRPREPEND="crossover-"
fi
export WINEINSTALLPATH="${WINEBASEDIR}/${WINEINSTALLDIRPREPEND+${WINEINSTALLDIRPREPEND}}wine-${WINEVERSION}"
# tools path
# ccache, gcc, etc.
export WINETOOLSINSTALLPATH="${WINEBASEDIR}/tools"
echo "${WINETAG} will be installed into ${WINEINSTALLPATH}"
# wine source path
# ~/wine/source
export WINESOURCEPATH="${WINEBASEDIR}/source"
if [ ! -d ${WINESOURCEPATH} ] ; then
mkdir -p ${WINESOURCEPATH} || fail_and_exit "could not create ${WINESOURCEPATH}"
fi
# build path
# ~/wine/build
export WINEBUILDPATH="${WINEBASEDIR}/build"
if [ ! -d ${WINEBUILDPATH} ] ; then
mkdir -p ${WINEBUILDPATH} || fail_and_exit "could not create ${WINEBUILDPATH}"
fi
# binary path
# ~/wine/wine-X.Y.Z/bin
export WINEBINPATH="${WINEINSTALLPATH}/bin"
# tools binary path
export WINETOOLSBINPATH="${WINETOOLSINSTALLPATH}/bin"
# include path
# ~/wine/wine-X.Y.Z/include
export WINEINCLUDEPATH="${WINEINSTALLPATH}/include"
# lib path
# ~/wine/wine-X.Y.Z/lib
export WINELIBPATH="${WINEINSTALLPATH}/lib"
# darwin/os x major version
# 10.9 = Darwin 13
# 10.8 = Darwin 12
# 10.7 = Darwin 11
# 10.6 = Darwin 10
# 10.5 = Darwin 9
# ...
export DARWINMAJ=$(uname -r | awk -F. '{print $1}')
echo "your OS reports itself as:" $(uname -a)
# 16-bit code flag
# enable by default, disable on 10.5
# XXX - should be checking Xcode version
# 2.x can build 16-bit code, works on 10.4, 10.5, 10.6
# 3.0,3.1 CANNOT build 16-bit code, work on 10.5+
# XXX - patched ld/ld64 on 10.5 can be used
# 3.2 can build 16-bit code, works only on 10.6
export WIN16FLAG="enable"
if [ ${DARWINMAJ} -eq 9 ] ; then
export WIN16FLAG="disable"
fi
# os x min version and sdk settings
# Mac OS X Tiger/10.4
#export OSXVERSIONMIN="10.4"
# Mac OS X Leopard/10.5
#export OSXVERSIONMIN="10.5"
# Mac OS X Snow Leopard/10.6
#export OSXVERSIONMIN="10.6"
# only set SDK version and deployment target env vars if a min version is set
if [ ! -z "${OSXVERSIONMIN}" ] ; then
if [ ${OSXVERSIONMIN} == "10.4" ] ; then
export SDKADDITION="u"
fi
export OSXSDK="/Developer/SDKs/MacOSX${OSXVERSIONMIN}${SDKADDITION+${SDKADDITION}}.sdk"
export MACOSX_DEPLOYMENT_TARGET=${OSXVERSIONMIN}
fi
# x11
# these need to be changed for Xquartz and the like...
# default is to use OS-provided /usr/X11
export DEFAULTX11DIR="/usr/X11"
export X11DIR="${DEFAULTX11DIR}"
# check for XQuartz in /opt/X11 on 10.6+
if [ ${DARWINMAJ} -ge 10 ] ; then
# check for the XQuartz launchd entry
launchctl list | grep -i startx | grep -i xquartz >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "XQuartz launchd startup found, checking for installation"
# check that directory /opt/X11 exists and use it
if [ -d /opt/X11 ] ; then
echo "using XQuartz installed in /opt/X11"
export X11DIR="/opt/X11"
else
echo "XQuartz launchd startup found, but no /opt/X11; reinstall XQuartz?"
fi
else
echo "no XQuartz launchd startup found, assuming system X11 in ${DEFAULTX11DIR}"
fi
fi
echo "X11 installation set to: \$X11DIR = ${X11DIR}"
export X11BIN="${X11DIR}/bin"
export X11INC="${X11DIR}/include"
export X11LIB="${X11DIR}/lib"
# path
# pull out fink, macports, gentoo - what about homebrew?
# set our Wine install dir's bin and X11 bin before everything else
export PATH=$(echo $PATH | tr ":" "\n" | egrep -v ^"(/opt/local|/sw|/opt/gentoo)" | xargs echo | tr " " ":")
export PATH="${WINEBINPATH}:${WINETOOLSBINPATH}:${X11BIN}:${PATH}"
echo "your path is set to: \${PATH} = ${PATH}"
# compiler and preprocessor flags
# default - set to GCC
: ${CC:="gcc"}
: ${CXX:="g++"}
export CC
export CXX
echo "C compiler set to: \$CC = \"${CC}\""
echo "full path to ${CC} is:" $(which ${CC})
echo "C++ compiler set to: \$CXX = \"${CXX}\""
echo "full path to ${CXX} is:" $(which ${CXX})
# preprocessor/compiler flags
export CPPFLAGS="-I${WINEINCLUDEPATH} ${OSXSDK+-isysroot $OSXSDK} -I${X11INC}"
# some extra flags based on CPU features
export CPUFLAGS="-mmmx -msse -msse2 -msse3 -mfpmath=sse"
# set our CFLAGS to something useful, and specify we should be using 32-bit
export CFLAGS="-g -O2 -arch i386 -m32 -pipe ${CPUFLAGS} ${OSXSDK+-isysroot $OSXSDK} ${OSXVERSIONMIN+-mmacosx-version-min=$OSXVERSIONMIN} ${CPPFLAGS}"
export CXXFLAGS=${CFLAGS}
echo "CFLAGS and CXXFLAGS set to: ${CFLAGS}"
# linker flags
# always prefer our Wine install path's lib dir
# set the sysroot if need be
export LDFLAGS="-L${WINELIBPATH} ${OSXSDK+-isysroot $OSXSDK} -L${X11LIB} -framework CoreServices -lz -L${X11LIB} -lGL -lGLU"
echo "LDFLAGS set to: ${LDFLAGS}"
# pkg-config config
# system and stuff we build only
export PKG_CONFIG_PATH="${WINELIBPATH}/pkgconfig:/usr/lib/pkgconfig:${X11LIB}/pkgconfig"
# aclocal/automake
# include custom, X11, other system stuff
export ACLOCAL="aclocal -I ${WINEINSTALLPATH}/share/aclocal -I ${X11DIR}/share/aclocal -I /usr/share/aclocal"
# make
# how many jobs do we run concurrently?
# core count + 1
export MAKE="make"
export MAKEJOBS=$((`sysctl -n machdep.cpu.core_count | tr -d " "`+1))
export CONCURRENTMAKE="${MAKE} -j${MAKEJOBS}"
# configure
# use a common prefix
# disable static libs by default
export CONFIGURE="./configure"
export CONFIGURECOMMONPREFIX="--prefix=${WINEINSTALLPATH}"
export CONFIGURECOMMONLIBOPTS="--enable-shared=yes --enable-static=no"
# configure - tools prefix
export CONFIGURETOOLSPREFIX="--prefix=${WINETOOLSINSTALLPATH}"
# SHA-1 sum program
# openssl is available everywhere
export SHA1SUM="openssl dgst -sha1"
# downloader program
# curl's avail everywhere!
export CURL="curl"
export CURLOPTS="-kL"
echo "base downloader command: ${CURL} ${CURLOPTS}"
# extract commands
# currently we only have gzip/bzip2 tar files
export TARGZ="tar -zxvf"
export TARBZ2="tar -jxvf"
export TARXZ="tarxz"
export XZ="xz"
# git needs these?
# not using Git yet, but we will in the future
# apparently these have to be set or Git will try to use Fink/MacPorts
# so much smarter than us, Git
export NO_FINK=1
export NO_DARWIN_PORTS=1
#
# helpers
#
#
# compiler_check
# output a binary and run it
#
function compiler_check {
if [ ! -d ${WINEBUILDPATH} ] ; then
mkdir -p ${WINEBUILDPATH} || fail_and_exit "build directory ${WINEBUILDPATH} doesn't exist and cannot be created"
fi
# check C compiler
echo "checking compiler '${CC}'"
cat > ${WINEBUILDPATH}/$$_compiler_check_c.c <<- EOF
#include <stdio.h>
int main(void)
{
printf("hello\n");
return(0);
}
EOF
${CC} ${CFLAGS} ${WINEBUILDPATH}/$$_compiler_check_c.c -o ${WINEBUILDPATH}/$$_compiler_check_c || fail_and_exit "compiler '${CC}' cannot output executables; please make sure Xcode command line tools/Unix development bits are installed"
${WINEBUILDPATH}/$$_compiler_check_c | grep hello >/dev/null 2>&1 || fail_and_exit "C source compiled fine, but unexpected output was encountered"
echo "compiler '${CC}' works fine for a simple test"
rm -rf ${WINEBUILDPATH}/$$_compiler_check_c.c ${WINEBUILDPATH}/$$_compiler_check_c ${WINEBUILDPATH}/$$_compiler_check_c.dSYM
# check C++ compiler
echo "checking compiler '${CXX}'"
cat > ${WINEBUILDPATH}/$$_compiler_check_cc.cc <<- EOF
#include <iostream>
using namespace std;
int main(void)
{
cout << "hello" << endl;
return(0);
}
EOF
${CXX} ${CXXFLAGS} ${WINEBUILDPATH}/$$_compiler_check_cc.cc -o ${WINEBUILDPATH}/$$_compiler_check_cc || fail_and_exit "compiler '${CXX}' cannot output executables; please make sure Xcode command line tools/Unix development bits are installed"
${WINEBUILDPATH}/$$_compiler_check_cc | grep hello >/dev/null 2>&1 || fail_and_exit "C++ source compiled fine, but unexpected output was encountered"
echo "compiler '${CXX}' works fine for a simple test"
rm -rf ${WINEBUILDPATH}/$$_compiler_check_cc.cc ${WINEBUILDPATH}/$$_compiler_check_cc ${WINEBUILDPATH}/$$_compiler_check_cc.dSYM
}
#
# get_file
# receives a filename, directory and url
#
function get_file {
FILE=${1}
DIRECTORY=${2}
URL=${3}
if [ ! -d ${DIRECTORY} ] ; then
mkdir -p ${DIRECTORY} || fail_and_exit "could not create directory ${DIRECTORY}"
fi
pushd . >/dev/null 2>&1
cd ${DIRECTORY} || fail_and_exit "could not cd to ${DIRECTORY}"
if [ ! -f ${FILE} ] ; then
echo "downloading file ${URL} to ${DIRECTORY}/${FILE}"
${CURL} ${CURLOPTS} -o ${FILE} "${URL}"
else
echo "${DIRECTORY}/${FILE} already exists - not fetching"
popd >/dev/null 2>&1
return
fi
if [ $? != 0 ] ; then
fail_and_exit "could not download ${URL}"
else
echo "successfully downloaded ${URL} to ${DIRECTORY}/${FILE}"
fi
popd >/dev/null 2>&1
}
#
# check_sha1sum
# receives a filename a SHA sum to compare
#
function check_sha1sum {
FILE=${1}
SHASUM=${2}
if [ ! -e ${FILE} ] ; then
fail_and_exit "${FILE} doesn't seem to exist"
fi
FILESUM=$(${SHA1SUM} < ${FILE})
if [ "${SHASUM}x" != "${FILESUM}x" ] ; then
fail_and_exit "failed to verify ${FILE}"
else
echo "successfully verified ${FILE}"
fi
}
#
# clean_source_dir
# cleans up a source directory - receives base dir + source dir
#
function clean_source_dir {
SOURCEDIR=${1}
BASEDIR=${2}
if [ ${NOCLEANSOURCE} -eq 1 ] ; then
echo "--no-clean-source set, not cleaning ${BASEDIR}/${SOURCEDIR}"
return
fi
if [ -d ${BASEDIR}/${SOURCEDIR} ] ; then
pushd . >/dev/null 2>&1
echo "cleaning up ${BASEDIR}/${SOURCEDIR} for fresh compile"
cd ${BASEDIR} || fail_and_exit "could not cd into ${BASEDIR}"
rm -rf ${SOURCEDIR} || fail_and_exit "could not clean up ${BASEDIR}/${SOURCEDIR}"
popd >/dev/null 2>&1
fi
}
#
# extract_file
# receives an extract command, a file and a directory
#
function extract_file {
EXTRACTCMD=${1}
EXTRACTFILE=${2}
EXTRACTDIR=${3}
SOURCEDIR=${4}
if [ ${NOCLEANSOURCE} -eq 1 ] ; then
if [ -d ${EXTRACTDIR}/${SOURCEDIR} ] ; then
echo "--no-clean-source set, not extracting ${EXTRACTFILE}"
return
fi
fi
echo "extracting ${EXTRACTFILE} to ${EXTRACTDIR} with '${EXTRACTCMD}'"
if [ ! -d ${EXTRACTDIR} ] ; then
mkdir -p ${EXTRACTDIR} || fail_and_exit "could not create ${EXTRACTDIR}"
fi
pushd . >/dev/null 2>&1
cd ${EXTRACTDIR} || fail_and_exit "could not cd into ${EXTRACTDIR}"
if [ "${EXTRACTCMD}" == "tarxz" ] ; then
xzcat ${EXTRACTFILE} | tar -xvf - || fail_and_exit "could not extract ${EXTRACTFILE}"
else
${EXTRACTCMD} ${EXTRACTFILE} || fail_and_exit "could not extract ${EXTRACTFILE}"
fi
echo "successfully extracted ${EXTRACTFILE}"
popd >/dev/null 2>&1
}
#
# configure_package
# receives a configure command and a directory in which to run it.
#
function configure_package {
CONFIGURECMD=${1}
SOURCEDIR=${2}
CONFIGUREDFILE="${SOURCEDIR}/.$(basename ${0})-configured"
if [ ! -d ${SOURCEDIR} ] ; then
fail_and_exit "could not find ${SOURCEDIR}"
fi
if [ ${NORECONFIGURE} -eq 1 ] ; then
if [ -f ${CONFIGUREDFILE} ] ; then
echo "--no-reconfigure set, not reconfiguring in ${SOURCEDIR}"
return
fi
fi
echo "running '${CONFIGURECMD}' in ${SOURCEDIR}"
pushd . >/dev/null 2>&1
cd ${SOURCEDIR} || fail_and_exit "source directory ${SOURCEDIR} does not seem to exist"
${CONFIGURECMD} || fail_and_exit "could not run configure command '${CONFIGURECMD}' in ${SOURCEDIR}"
touch ${CONFIGUREDFILE} || fail_and_exit "could not touch ${CONFIGUREDFILE}"
echo "successfully ran configure in ${SOURCEDIR}"
popd >/dev/null 2>&1
}
#
# build_package
# receives a build command line and a directory
#
function build_package {
BUILDCMD=${1}
BUILDDIR=${2}
BUILTFILE="${BUILDDIR}/.$(basename ${0})-built"
if [ ! -d ${BUILDDIR} ] ; then
fail_and_exit "${BUILDDIR} does not exist"
fi
if [ ${NOREBUILD} -eq 1 ] ; then
if [ -f ${BUILTFILE} ] ; then
echo "--no-rebuild set, not rebuilding in ${BUILDDIR}"
return
fi
fi
pushd . >/dev/null 2>&1
cd ${BUILDDIR} || fail_and_exit "build directory ${BUILDDIR} does not seem to exist"
${BUILDCMD} || fail_and_exit "could not run '${BUILDCMD}' in ${BUILDDIR}"
touch ${BUILTFILE} || fail_and_exit "could not touch ${BUILTFILE}"
echo "successfully ran '${BUILDCMD}' in ${BUILDDIR}"
popd >/dev/null 2>&1
}
#
# install_package
# receives an install command line and a directory to run it in
#
function install_package {
INSTALLCMD=${1}
INSTALLDIR=${2}
if [ ! -d ${INSTALLDIR} ] ; then
fail_and_exit "${INSTALLDIR} does not exist"
fi
echo "installing with '${INSTALLCMD}' in ${INSTALLDIR}"
pushd . >/dev/null 2>&1
cd ${INSTALLDIR} || fail_and_exit "directory ${INSTALLDIR} does not seem to exist"
${INSTALLCMD}
if [ $? != 0 ] ; then
echo "some items may have failed to install! check above for errors."
else
echo "succesfully ran '${INSTALLCMD}' in ${INSTALLDIR}'"
fi
popd >/dev/null 2>&1
}
#
# package functions
# common steps for (pretty much) each source build
# clean
# get
# check
# extract
# configure
# build
# install
#
#
# ccache
#
CCACHEVER="3.1.10"
CCACHEFILE="ccache-${CCACHEVER}.tar.bz2"
CCACHEURL="http://samba.org/ftp/ccache/${CCACHEFILE}"
CCACHESHA1SUM="f78154d526b98546c27e5ef480354f3ce021abe2"
CCACHEDIR="ccache-${CCACHEVER}"
function clean_ccache {
clean_source_dir "${CCACHEDIR}" "${WINEBUILDPATH}"
}
function get_ccache {
get_file "${CCACHEFILE}" "${WINESOURCEPATH}" "${CCACHEURL}"
}
function check_ccache {
check_sha1sum "${WINESOURCEPATH}/${CCACHEFILE}" "${CCACHESHA1SUM}"
}
function extract_ccache {
extract_file "${TARBZ2}" "${WINESOURCEPATH}/${CCACHEFILE}" "${WINEBUILDPATH}" "${CCACHEDIR}"
}
function configure_ccache {
configure_package "${CONFIGURE} ${CONFIGURETOOLSPREFIX}" "${WINEBUILDPATH}/${CCACHEDIR}"
}
function build_ccache {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${CCACHEDIR}"
}
function install_ccache {
clean_ccache
extract_ccache
configure_ccache
build_ccache
install_package "${MAKE} install" "${WINEBUILDPATH}/${CCACHEDIR}"
CCACHECOUNT=$(which ccache | wc -l | tr -d ' ')
if [ ${CCACHECOUNT} -ge 1 ] ; then
echo "ccache found in path at: `which ccache | xargs echo`"
echo "ccache installed, setting CC and C++ variables"
echo ${CC} | grep -i ccache >/dev/null 2>&1
if [ $? -ne 0 ] ; then
export CC="ccache ${CC}"
fi
echo ${CXX} | grep -i ccache >/dev/null 2>&1
if [ $? -ne 0 ] ; then
export CXX="ccache ${CXX}"
fi
echo "C compiler set to: \$CC = \"${CC}\""
echo "C++ compiler set to: \$CXX = \"${CXX}\""
# recheck compiler
compiler_check
fi
}
#
# apple-gcc
# 4.2.1 build 5666 dot 3
#
APPLEGCCVER="5666.3"
APPLEGCCFILE="20120601014516_gcc-${APPLEGCCVER}_patched.tar.bz2"
APPLEGCCURL="http://osxwinebuilder.googlecode.com/files/${APPLEGCCFILE}"
APPLEGCCSHA1SUM="5af0a9a1c90f876f92e5e0569d4bfbf0b8ee27b6"
APPLEGCCDIR="gcc-${APPLEGCCVER}"
function clean_applegcc {
clean_source_dir "${APPLEGCCDIR}" "${WINEBUILDPATH}"
}
function get_applegcc {
get_file "${APPLEGCCFILE}" "${WINESOURCEPATH}" "${APPLEGCCURL}"
}
function check_applegcc {
check_sha1sum "${WINESOURCEPATH}/${APPLEGCCFILE}" "${APPLEGCCSHA1SUM}"
}
function extract_applegcc {
extract_file "${TARBZ2}" "${WINESOURCEPATH}/${APPLEGCCFILE}" "${WINEBUILDPATH}" "${APPLEGCCDIR}"
}
function install_applegcc {
# only build gcc if our default CC is LLVM/CLANG
${CC} --version | egrep -i '(llvm|clang)' >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "installing Apple-patched GCC 4.2.1 for i386 only"
clean_applegcc
extract_applegcc
pushd . >/dev/null 2>&1
GCCBASEDIR="${WINEBUILDPATH}/${APPLEGCCDIR}"
cd ${GCCBASEDIR} || fail_and_exit "could not cd into ${GCCBASEDIR}"
# env vars
OLDCC=${CC}
export LANGUAGES="c,c++,objc,obj-c++"
# make install/build_gcc arguments
export CC="${CC} -m32 -std=gnu89"
export PREFIX="${WINETOOLSINSTALLPATH}"
export SRCROOT="${GCCBASEDIR}"
export OBJROOT="${SRCROOT}/obj"
export SYMROOT="${SRCROOT}/sym"
export DSTROOT="${SRCROOT}/dst"
export RC_NONARCH_CFLAGS="-pipe -std=gnu89"
export RC_OS="macos"
export RC_ARCHS="i386"
export TARGETS="i386"
make install CC="${CC}" PREFIX="${PREFIX}" SRCROOT="${SRCROOT}" OBJROOT="${OBJROOT}" SYMROOT="${SYMROOT}" DSTROOT="${DSTROOT}" RC_NONARCH_CFLAGS="${RC_NONARCH_CFLAGS}" RC_OS="${RC_OS}" RC_ARCHS="${RC_ARCHS}" TARGETS="${TARGETS}" || fail_and_exit "failed to build GCC"
echo "copying compiler from '${DSTROOT}${PREFIX}' into place in '${WINETOOLSINSTALLPATH}'"
rsync -avHS ${DSTROOT}${PREFIX}/. ${WINETOOLSINSTALLPATH}/. || fail_and_exit "could not copy compiler from '${DSTROOT}${PREFIX}' into '${WINETOOLSINSTALLPATH}'"
unset TARGETS
unset RC_ARCHS
unset RC_OS
unset RC_NONARCH_CFLAGS
unset DSTROOT
unset SYMROOT
unset OBJROOT
unset SRCROOT
unset PREFIX
unset LANGUAGES
export CC=${OLDCC}
popd >/dev/null 2>&1
echo "compiler installed, setting up symlinks"
pushd . >/dev/null 2>&1
cd ${WINETOOLSBINPATH} || fail_and_exit "could not cd into ${WINETOOLSBINPATH} to fix compiler symlinks"
ln -Ffs gcc-apple-4.2 cc || fail_and_exit "could not setup 'cc' symlink in ${WINETOOLSBINPATH}"
ln -Ffs c++-apple-4.2 c++ || fail_and_exit "could not setup 'c++' symlink in ${WINETOOLSBINPATH}"
ln -Ffs cpp-apple-4.2 cpp || fail_and_exit "could not setup 'cpp' symlink in ${WINETOOLSBINPATH}"
ln -Ffs gcc-apple-4.2 gcc || fail_and_exit "could not setup 'gcc' symlink in ${WINETOOLSBINPATH}"
ln -Ffs g++-apple-4.2 g++ || fail_and_exit "could not setup 'g++' symlink in ${WINETOOLSBINPATH}"
ln -Ffs gcov-apple-4.2 gcov || fail_and_exit "could not setup 'gcov' symlink in ${WINETOOLSBINPATH}"
popd >/dev/null 2>&1
echo "compiler symlinks created"
# XXX - recheck compiler here
else
echo "it doesn't look like LLVM or clang are in use - assuming GCC is working"
fi
}
#
# libtool
# XXX - needed for libltdl on (mountain) lion
#
LTOOLVER="2.4.2"
LTOOLFILE="libtool-${LTOOLVER}.tar.gz"
LTOOLURL="http://ftpmirror.gnu.org/libtool/${LTOOLFILE}"
LTOOLDIR="libtool-${LTOOLVER}"
LTOOLSHA1SUM="22b71a8b5ce3ad86e1094e7285981cae10e6ff88"
function clean_libtool {
clean_source_dir "${LTOOLDIR}" "${WINEBUILDPATH}"
}
function get_libtool {
get_file "${LTOOLFILE}" "${WINESOURCEPATH}" "${LTOOLURL}"
}
function check_libtool {
check_sha1sum "${WINESOURCEPATH}/${LTOOLFILE}" "${LTOOLSHA1SUM}"
}
function extract_libtool {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${LTOOLFILE}" "${WINEBUILDPATH}" "${LTOOLDIR}"
}
function configure_libtool {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS}" "${WINEBUILDPATH}/${LTOOLDIR}"
}
function build_libtool {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${LTOOLDIR}"
}
function install_libtool {
clean_libtool
extract_libtool
configure_libtool
build_libtool
install_package "${MAKE} install" "${WINEBUILDPATH}/${LTOOLDIR}"
pushd . >/dev/null 2>&1
#cd "${WINEBUILDPATH}/${LTOOLDIR}/libltdl/.libs"
#if [ ! -e ${WINELIBPATH} ] ; then
# mkdir -p ${WINELIBPATH} || fail_and_exit "could not create '${WINELIBPATH}' directory for libtool files"
#fi
#cp libltdl*.dylib libltdl*.la ${WINELIBPATH}/
cd ${WINEBINPATH}
for LTBIN in libtool libtoolize ; do
mv ${LTBIN}{,.DISABLED}
done
popd >/dev/null 2>&1
}
#
# xz
#
XZVER="5.0.3"
XZFILE="xz-${XZVER}.tar.bz2"
XZURL="http://tukaani.org/xz/${XZFILE}"
XZSHA1SUM="79661fd1c24603437e325d76732046b1da683b32"
XZDIR="xz-${XZVER}"
function clean_xz {
clean_source_dir "${XZDIR}" "${WINEBUILDPATH}"
}
function get_xz {
get_file "${XZFILE}" "${WINESOURCEPATH}" "${XZURL}"
}
function check_xz {
check_sha1sum "${WINESOURCEPATH}/${XZFILE}" "${XZSHA1SUM}"
}
function extract_xz {
extract_file "${TARBZ2}" "${WINESOURCEPATH}/${XZFILE}" "${WINEBUILDPATH}" "${XZDIR}"
}
function configure_xz {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS} --enable-small --disable-assembler" "${WINEBUILDPATH}/${XZDIR}"
}
function build_xz {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${XZDIR}"
}
function install_xz {
clean_xz
extract_xz
configure_xz
build_xz
install_package "${MAKE} install" "${WINEBUILDPATH}/${XZDIR}"
}
#
# libffi
#
LIBFFIVER="3.0.11"
LIBFFIFILE="libffi-${LIBFFIVER}.tar.gz"
LIBFFIURL="ftp://sourceware.org/pub/libffi/${LIBFFIFILE}"
LIBFFISHA1SUM="bff6a6c886f90ad5e30dee0b46676e8e0297d81d"
LIBFFIDIR="libffi-${LIBFFIVER}"
function clean_libffi {
clean_source_dir "${LIBFFIDIR}" "${WINEBUILDPATH}"
}
function get_libffi {
get_file "${LIBFFIFILE}" "${WINESOURCEPATH}" "${LIBFFIURL}"
}
function check_libffi {
check_sha1sum "${WINESOURCEPATH}/${LIBFFIFILE}" "${LIBFFISHA1SUM}"
}
function extract_libffi {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${LIBFFIFILE}" "${WINEBUILDPATH}" "${LIBFFIDIR}"
}
function configure_libffi {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS}" "${WINEBUILDPATH}/${LIBFFIDIR}"
}
function build_libffi {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${LIBFFIDIR}"
}
function install_libffi {
clean_libffi
extract_libffi
configure_libffi
build_libffi
install_package "${MAKE} install" "${WINEBUILDPATH}/${LIBFFIDIR}"
}
#
# pkg-config
#
PKGCONFIGVER="0.25"
PKGCONFIGFILE="pkg-config-${PKGCONFIGVER}.tar.gz"
PKGCONFIGURL="http://pkgconfig.freedesktop.org/releases/${PKGCONFIGFILE}"
PKGCONFIGSHA1SUM="8922aeb4edeff7ed554cc1969cbb4ad5a4e6b26e"
PKGCONFIGDIR="pkg-config-${PKGCONFIGVER}"
function clean_pkgconfig {
clean_source_dir "${PKGCONFIGDIR}" "${WINEBUILDPATH}"
}
function get_pkgconfig {
get_file "${PKGCONFIGFILE}" "${WINESOURCEPATH}" "${PKGCONFIGURL}"
}
function check_pkgconfig {
check_sha1sum "${WINESOURCEPATH}/${PKGCONFIGFILE}" "${PKGCONFIGSHA1SUM}"
}
function extract_pkgconfig {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${PKGCONFIGFILE}" "${WINEBUILDPATH}" "${PKGCONFIGDIR}"
}
function configure_pkgconfig {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS}" "${WINEBUILDPATH}/${PKGCONFIGDIR}"
}
function build_pkgconfig {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${PKGCONFIGDIR}"
}
function install_pkgconfig {
clean_pkgconfig
extract_pkgconfig
configure_pkgconfig
build_pkgconfig
install_package "${MAKE} install" "${WINEBUILDPATH}/${PKGCONFIGDIR}"
}
#
# pkgconfig026
#
PKGCONFIG026VER="0.26"
PKGCONFIG026FILE="pkg-config-${PKGCONFIG026VER}.tar.gz"
PKGCONFIG026URL="http://pkgconfig.freedesktop.org/releases/${PKGCONFIG026FILE}"
PKGCONFIG026SHA1SUM="fd71a70b023b9087c8a7bb76a0dc135a61059652"
PKGCONFIG026DIR="pkg-config-${PKGCONFIG026VER}"
function clean_pkgconfig026 {
clean_source_dir "${PKGCONFIG026DIR}" "${WINEBUILDPATH}"
}
function get_pkgconfig026 {
get_file "${PKGCONFIG026FILE}" "${WINESOURCEPATH}" "${PKGCONFIG026URL}"
}
function check_pkgconfig026 {
check_sha1sum "${WINESOURCEPATH}/${PKGCONFIG026FILE}" "${PKGCONFIG026SHA1SUM}"
}
function extract_pkgconfig026 {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${PKGCONFIG026FILE}" "${WINEBUILDPATH}" "${PKGCONFIG026DIR}"
}
function configure_pkgconfig026 {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS}" "${WINEBUILDPATH}/${PKGCONFIG026DIR}"
}
function build_pkgconfig026 {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${PKGCONFIG026DIR}"
}
function install_pkgconfig026 {
clean_pkgconfig026
extract_pkgconfig026
configure_pkgconfig026
build_pkgconfig026
install_package "${MAKE} install" "${WINEBUILDPATH}/${PKGCONFIG026DIR}"
}
#
# gettext
#
GETTEXTVER="0.18.1.1"
GETTEXTFILE="gettext-${GETTEXTVER}.tar.gz"
GETTEXTURL="http://ftp.gnu.org/pub/gnu/gettext/${GETTEXTFILE}"
GETTEXTSHA1SUM="5009deb02f67fc3c59c8ce6b82408d1d35d4e38f"
GETTEXTDIR="gettext-${GETTEXTVER}"
function clean_gettext {
clean_source_dir "${GETTEXTDIR}" "${WINEBUILDPATH}"
}
function get_gettext {
get_file "${GETTEXTFILE}" "${WINESOURCEPATH}" "${GETTEXTURL}"
}
function check_gettext {
check_sha1sum "${WINESOURCEPATH}/${GETTEXTFILE}" "${GETTEXTSHA1SUM}"
}
function extract_gettext {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${GETTEXTFILE}" "${WINEBUILDPATH}" "${GETTEXTDIR}"
}
function configure_gettext {
echo "attempting to fixup gettext"
pushd . >/dev/null 2>&1
cd "${WINEBUILDPATH}/${GETTEXTDIR}" || fail_and_exit "could not cd into gettext dir ${WINEBUILDPATH}/${GETTEXTDIR}"
# turn off examples subdir manually
sed -i.ORIG 's# gnulib-tests examples# gnulib-tests#g' gettext-tools/Makefile.in || fail_and_exit "in place sed for gettext-tools/Makefile.in failed"
# stpncpy broken/defined on Lion?
if [ ${DARWINMAJ} -ge 11 ] ; then
echo "attempting to fixup gettext for Darwin 11+"
sed -i.ORIG 's#^extern char \*stpncpy#//extern char *stpncpy#g' gettext-tools/configure || fail_and_exit "in place sed for gettext-tools/configure"
echo "successfully changed gettext-tools/configure for Darwin 11+"
fi
echo "successfully changed gettext-tools/Makefile.in"
popd >/dev/null 2>&1
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS} --disable-java --disable-native-java --without-emacs --without-git --without-cvs --disable-csharp --disable-native-java --with-included-gettext --with-included-glib --with-included-libcroco --with-included-libxml" "${WINEBUILDPATH}/${GETTEXTDIR}"
}
function build_gettext {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${GETTEXTDIR}"
}
function install_gettext {
clean_gettext
extract_gettext
configure_gettext
build_gettext
install_package "${MAKE} install" "${WINEBUILDPATH}/${GETTEXTDIR}"
}
#
# jpeg
#
JPEGVER="8d"
JPEGFILE="jpegsrc.v${JPEGVER}.tar.gz"
JPEGURL="http://www.ijg.org/files/${JPEGFILE}"
JPEGSHA1SUM="f080b2fffc7581f7d19b968092ba9ebc234556ff"
JPEGDIR="jpeg-${JPEGVER}"
function clean_jpeg {
clean_source_dir "${JPEGDIR}" "${WINEBUILDPATH}"
}
function get_jpeg {
get_file "${JPEGFILE}" "${WINESOURCEPATH}" "${JPEGURL}"
}
function check_jpeg {
check_sha1sum "${WINESOURCEPATH}/${JPEGFILE}" "${JPEGSHA1SUM}"
}
function extract_jpeg {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${JPEGFILE}" "${WINEBUILDPATH}" "${JPEGDIR}"
}
function configure_jpeg {
configure_package "${CONFIGURE} ${CONFIGURECOMMONPREFIX} ${CONFIGURECOMMONLIBOPTS}" "${WINEBUILDPATH}/${JPEGDIR}"
}
function build_jpeg {
build_package "${CONCURRENTMAKE}" "${WINEBUILDPATH}/${JPEGDIR}"
}
function install_jpeg {
clean_jpeg
extract_jpeg
configure_jpeg
build_jpeg
install_package "${MAKE} install" "${WINEBUILDPATH}/${JPEGDIR}"
}
#
# jbigkit
#
JBIGKITVER="2.0"
JBIGKITMAJOR=$(echo ${JBIGKITVER} | awk -F\. '{print $1}')
JBIGKITFILE="jbigkit-${JBIGKITVER}.tar.gz"
JBIGKITURL="http://www.cl.cam.ac.uk/~mgk25/download/${JBIGKITFILE}"
JBIGKITSHA1SUM="cfb7d3121f02a74bfb229217858a0d149b6589ef"
JBIGKITDIR="jbigkit"
function clean_jbigkit {
clean_source_dir "${JBIGKITDIR}" "${WINEBUILDPATH}"
}
function get_jbigkit {
get_file "${JBIGKITFILE}" "${WINESOURCEPATH}" "${JBIGKITURL}"
}
function check_jbigkit {
check_sha1sum "${WINESOURCEPATH}/${JBIGKITFILE}" "${JBIGKITSHA1SUM}"
}
function extract_jbigkit {
extract_file "${TARGZ}" "${WINESOURCEPATH}/${JBIGKITFILE}" "${WINEBUILDPATH}" "${JBIGKITDIR}"