build: fix symlink selection
[sox.git] / mingwbuild
blob60b1f00526d71d44156e2e2869bb133c523b32e7
1 #!/bin/sh
3 # This script will automates the steps used to producing a win32 package
4 # of SoX.
6 # It is used on a Fedora box with mingw32 cross compiler and wine to
7 # test.
9 # It will optionally package up VC++ version of wget if found in
10 # ../wget-1.11.4.
12 # Various notes:
14 # The following command lines were used to generate the external libraries
15 # SoX ships with.
17 # Needed for libltdl support.
18 # FIXME: Install
19 # cd libtool-2.4.2
20 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
22 # yum install ming32-libpng mingw32-libpng-static
23 # or
24 # cd libpng-1.6.15
25 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
27 # yum install mingw32-wavpack
28 # or
29 # cd ../wavpack-4.70.0
30 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
32 # yum install mingw32-flac
33 # or
34 # Need to disable optional ogg support to prevent duplicate symbols during
35 # link.
36 # Edited Makefile and removed "examples" from SUBDIRS.
37 # cd ../flac-1.3.1
38 # mingw32-configure --disable-ogg --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
40 # yum install mingw32-libogg
41 # or
42 # cd ../libogg-1.3.2
43 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
45 # yum install mingw32-libvorbis
46 # or
47 # cd ../libvorbis-1.3.4
48 # mingw32-configure --disable-shared --enable-static;mingw-32-make;sudo mingw32-make install
50 # FIXME: Install libsndfile
51 # Compile libsndfile after FLAC and ogg vorbis so that it will include
52 # support for that.
53 # MINGW work around: Can either add -lwsock32 to end of *_LDADD for any
54 # failed program links or modify top leve Makefile and remove
55 # "programs", "examples", "regtests", and "tests" from SUBDIRS.
56 # cd ../libsndfile-1.0.25
57 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
59 # yum install mingw32-libid3tag
60 # or
61 # libid3tag does not like to be compiled shared on mingw32 cross compiler.
62 # cd ../libid3tag-0.15.1b
63 # mingw32-configure --disable-shared --enable-static;mingw32-make;sudo mingw32-make install
65 # To get MP3 header files used to enable MP3 support (no libraries used):
67 # yum install mingw32-libmad
68 # or
69 # MINGW work around: Edit Makefile and remove -fforce-mem from CFLAGS
70 # cd ../libmad-0.15.1b
71 # mingw32-configure --enable-shared --disable-static;mingw32-make;sudo mingw32-make install
73 [ ! -x configure ] && autoreconf -i
75 SYS_ROOT="/usr/i686-w64-mingw32/sys-root"
76 CONFIGURE=mingw32-configure
77 DOC_TARGETS="pdf"
78 DOCS="sox.pdf soxformat.pdf soxi.pdf"
79 TMP_SNDFILE_LIBS="-lsndfile -lFLAC -lvorbisenc -lvorbisfile -lvorbis -logg"
80 STRIP=i686-pc-mingw32-strip
82 # Some versions of autoconf (2.63?) seem to get easily confused about
83 # CPP variable. If you see warning messages about header files
84 # rejected by preprocessor then its most likely from that.
85 # Force the value of CPP=cpp works around that bug.
86 # static versions of libsndfile do not advertise when they have
87 # FLAC or ogg vorbis support. Need to force the link ourselves.
88 if [ $# -ne 0 -o ! -r Makefile ]; then
89 $CONFIGURE \
90 --with-libltdl \
91 --enable-dl-lame --enable-dl-mad --enable-dl-amrnb --enable-dl-amrwb \
92 LDFLAGS="-L/usr/local/lib" CPPFLAGS=-I/usr/local/include \
93 SNDFILE_LIBS="${TMP_SNDFILE_LIBS}" \
97 # Reduce total size of sox.exe by over half.
98 make -s all txt $DOC_TARGETS || exit 1
100 ${STRIP} src/.libs/sox.exe
102 dir=sox-`grep Version: sox.pc | cut -d ' ' -f 2`
103 rm -rf $dir $dir-win32.zip
104 mkdir -p $dir
106 for f in ChangeLog LICENSE.GPL README README.win32; do
107 cp -p $f $dir/$f.txt
108 unix2dos $dir/$f.txt
109 done
111 binaries=src/.libs/sox.exe
113 dlls=`/usr/i686-w64-mingw32/bin/objdump -p src/.libs/libsox-3.dll | grep "DLL Name:" | sed "s|DLL Name: |${SYS_ROOT}/mingw/bin/|" | grep -v KERNEL32.dll | grep -v msvcrt.dll | grep -v USER32.dll | grep -v WINMM.DLL`
114 dlls="$dlls src/.libs/libsox-3.dll"
115 dlls="$dlls ${SYS_ROOT}/mingw/bin/libwinpthread-1.dll"
117 cp -p \
118 $binaries \
119 $dlls \
120 $DOCS \
121 scripts/batch-example.bat \
122 $dir
124 # Special case fixup for nsiswrapper. Rename libFLAC-8.dll to libflac-8.dll.
125 mv $dir/libFLAC-8.dll $dir/libflac-8.dll
127 unix2dos $dir/batch-example.bat
129 if test -r "../wget-1.11.4/wget.exe"; then
130 cp ../wget-1.11.4/wget.exe $dir
131 cp ../wget-1.11.4/wget.ini $dir
134 zip -r $dir-win32.zip $dir
136 # Optionally, create windows installer if nsiswrapper exists.
137 if test -r "/usr/bin/nsiswrapper"; then
138 cd ${dir}
139 export PATH=$PATH:.
140 nsiswrapper --run --name $dir --outfile ../${dir}-win32.exe *.exe *.dll *.ini *.txt *.pdf *.bat
141 cd ..
144 rm -rf $dir