forked from chirlu/sox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mingwbuild
executable file
·166 lines (150 loc) · 5.58 KB
/
mingwbuild
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
#!/bin/sh
#
# This script will automates the steps used to producing a static win32
# package of SoX.
#
# It is used on a Fedora box with mingw cross compiler and wine to
# test. It can also be used under MSYS but will not generate PDF docs.
#
# It will optionally package up VC++ version of wget if found in
# ../wget-1.11.4.
#
# Various notes:
#
# Script makes use of "-static" option to tell compiler to prefer static
# external libraries so that we do not need to distribute DLL's.
#
# Libtool will get confused with this flag for external libraries
# that have a libtool lib*.la file and support shared libraries as
# well as static libraries (but usually only if that library
# further depends on other external libraries with lib*.la files).
# Libtool may ignore -static option or it may link first external
# library as static but other dependent libraries as shared (usually
# because it follows $dependency_libs and that ignores -static option).
#
# Work arounds include to only install static libraries, delete the lib*.la
# file, or edit the lib*.la file and set dlnames and library_names variables
# to empty string ("").
#
# The following command lines were used to generate the static external
# libraries SoX ships with.
#
# cd libtool-2.4.2
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# libpng.la will have libtool issue because depends on libz
# which has a libz.la file. Must edit libpng.la to
# prevent needing to distribute zlib1.dll.
# cd libpng-1.5.7
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# cd ../wavpack-4.60.1
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# Need to disable optional ogg support to prevent duplicate symbols during
# link.
# Edited Makefile and removed "examples" from SUBDIRS.
# cd ../flac-1.2.1
# mingw32-configure --disable-ogg --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# cd ../libogg-1.3.0
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# cd ../libvorbis-1.3.2
# mingw32-configure --disable-shared --enable-static;mingw-32-make;sudo mingw32-make install
#
# Compile libsndfile after FLAC and ogg vorbis so that it will include
# support for that.
# MINGW work around: Can either add -lwsock32 to end of *_LDADD for any
# failed program links or modify top leve Makefile and remove
# "programs", "examples", "regtests", and "tests" from SUBDIRS.
# cd ../libsndfile-1.0.25
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# libid3tag does not like to be compiled shared on mingw32 cross compiler.
# cd ../libid3tag-0.15.1b
# mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
#
# To get MP3 header files used to enable MP3 support (no libraries used):
#
# MINGW work around: Edit Makefile and remove -fforce-mem from CFLAGS
# cd ../libmad-0.15.1b
# mingw32-configure --enable-shared --disable-static;mingw32-make;sudo mingw32-make install
[ ! -x configure ] && autoreconf -i
case `uname` in
MINGW32*)
CONFIGURE=configure
SYS_ROOT=""
# Can't build PDF's on MSYS unless ghostscript is installed.
DOC_TARGETS=""
DOCS=""
TMP_SNDFILE_LIBS=""
TMP_FLAC_LIBS=""
STRIP=strip
;;
*)
SYS_ROOT="/usr/i686-w64-mingw32/sys-root"
CONFIGURE=mingw32-configure
DOC_TARGETS="pdf"
DOCS="sox.pdf soxformat.pdf soxi.pdf"
TMP_SNDFILE_LIBS="-lsndfile -lFLAC -lvorbisenc -lvorbisfile -lvorbis -logg"
# TODO: libFLAC is referencing ntohl() but not defining it in their
# flac.pc. Its not obvious how upstream is going to fix this issue
# so work around in script for now.
#TMP_FLAC_LIBS="-lwsock32"
STRIP=i686-pc-mingw32-strip
esac
# Some versions of autoconf (2.63?) seem to get easily confused about
# CPP variable. If you see warning messages about header files
# rejected by preprocessor then its most likely from that.
# Force the value of CPP=cpp works around that bug.
# static versions of libsndfile do not advertise when they have
# FLAC or ogg vorbis support. Need to force the link ourselves.
if [ $# -ne 0 -o ! -r Makefile ]; then
$CONFIGURE \
--disable-shared \
--with-libltdl \
--enable-dl-lame --enable-dl-mad --enable-dl-amrnb --enable-dl-amrwb \
LDFLAGS="-static -L/usr/local/lib" CPPFLAGS=-I/usr/local/include \
SNDFILE_LIBS="${TMP_SNDFILE_LIBS}" FLAC_LIBS="${TMP_FLAC_LIBS}"\
$*
fi
# Reduce total size of sox.exe by over half.
make -s all txt $DOC_TARGETS || exit 1
${STRIP} src/sox.exe
dir=sox-`grep Version: sox.pc | cut -d ' ' -f 2`
rm -rf $dir $dir-win32.zip
mkdir -p $dir
for f in ChangeLog LICENSE.GPL README README.win32; do
cp -p $f $dir/$f.txt
unix2dos $dir/$f.txt
done
binaries=src/sox.exe
# If you do not edit libpng.la to comment out shared libraries
# then you'll need to distribute zlib1.dll.
dlls=""
dlls="$dlls ${SYS_ROOT}/mingw/bin/zlib1.dll"
dlls="$dlls ${SYS_ROOT}/mingw/bin/libgomp-1.dll"
cp -p \
$binaries \
$dlls \
$DOCS \
scripts/batch-example.bat \
$dir
# Special case copy to work around some case sensitivity bugs with
# nsiswrapper under linux.
cp -p ${SYS_ROOT}/mingw/bin/pthreadGC2.dll ${dir}/pthreadgc2.dll
unix2dos $dir/batch-example.bat
if test -r "../wget-1.11.4/wget.exe"; then
cp ../wget-1.11.4/wget.exe $dir
cp ../wget-1.11.4/wget.ini $dir
fi
zip -r $dir-win32.zip $dir
# Optionally, create windows installer if nsiswrapper exists.
if test -r "/usr/bin/nsiswrapper"; then
cd ${dir}
export PATH=$PATH:.
nsiswrapper --run --name $dir --outfile ../${dir}-win32.exe *.exe *.ini *.txt *.pdf *.bat
cd ..
fi
rm -rf $dir