1#!/bin/sh
2#
3# This script will automates the steps used to producing a static osx
4# package of SoX.
5#
6# It requires to already have several external libraries already installed
7# under /usr/local/10.9.  The external libraries must be static only or else
8# it will expect dylib versions to already exist on external boxes.
9#
10# This goes out of its way to use the oldest available SDK for greater
11# compatibility.
12#
13# Various notes:
14#
15# The following command lines were used to generate the static external
16# libraries SoX ships with.
17#
18# brew install libtool
19#
20# cd libpng-1.6.15
21# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --disable-shared --enable-static;make;sudo make install
22#
23# cd ../wavpack-4.70.0
24# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --disable-shared --enable-static;make;sudo make install
25#
26# cd ../flac-1.3.1
27# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" CXXFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9" --disable-shared --enable-static;make;sudo make install
28#
29# cd ../libogg-1.3.2
30# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --disable-shared --enable-static;make;sudo make install
31#
32# cd ../libvorbis-1.3.4
33# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --disable-shared --enable-static;make;sudo make install
34#
35# When compiling with newer versions of OS X, Carbon.h does not exist and
36# doesn't need to be included by app.  Edit programs/sndfile-play.c and
37# delete/comment out line 61.
38# cd ../libsndfile-1.0.25
39# ./configure --disable-sqlite --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" CXXFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9" --disable-shared --enable-static;make;sudo make install
40#
41# cd ../libid3tag-0.15.1b
42# ./configure --prefix=/usr/local/10.9 CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --disable-shared --enable-static;make;sudo make install
43#
44# To get MP3 header files used to enable MP3 support (no libraries used):
45#
46# brew install mad
47#
48# or compile and install:
49#
50# cd ../libmad-0.15.1b
51# ./configure CFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" --enable-shared --disable-static;make;sudo make install
52#
53
54MacOSXSDK=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
55
56[ ! -x configure ] && autoreconf -i
57
58# Some versions of autoconf (2.63?) seem to get easily confused about
59# CPP variable. If you see warning messages about header files
60# rejected by preprocessor then its most likely from that.
61# Force the value of CPP=cpp works around that bug.
62if [ $# -ne 0 -o ! -r Makefile ]; then
63  ./configure \
64    --disable-shared \
65    --with-libltdl \
66    --enable-dl-lame --enable-dl-mad \
67    --enable-dl-amrnb --enable-dl-amrwb \
68    CPP=cpp\
69    CPPFLAGS="-I/usr/local/10.9/include -I/usr/local/include" \
70    CFLAGS="-isysroot ${MacOSXSDK}" \
71    LDFLAGS="-L/usr/local/10.9/lib -isysroot ${MacOSXSDK}" \
72    $*
73fi
74
75make -s all txt || exit 1
76
77dylib_need_to_ship=`otool -L src/sox | grep -v CoreAudio.framework | grep -v libz | grep -v libiconv | grep -v libSystem | grep -v libgcc_s | grep -v src/sox`
78
79# Make sure we are only relying on OS dynamic libraries.  If not
80# then app won't run unless user's box looks just like this one
81# (unlikely).  We could ship some dylibs but that would require
82# using rpath just right (@loader_path) and thats not easy to
83# get right.
84if [ ! "${dylib_need_to_ship}x" = "x" ]; then
85    echo "Non-OS dylib's detected:${dylib_need_to_ship}"
86    exit 1
87fi
88
89dir=sox-`grep Version: sox.pc | cut -d ' ' -f 2`
90rm -rf $dir $dir-macosx.zip
91mkdir -p $dir
92
93# Judgement call.  If filename ends in .txt then user can view
94# by double clicking in Finder.
95for f in LICENSE.GPL README.osx; do
96  cp -p $f $dir/$f.txt
97done
98
99for f in ChangeLog README; do
100  cp -p $f $dir/$f
101done
102
103binaries=src/sox
104
105# TODO: Distribute wget binary
106#[ -r "../wget-1.11.4/wget" ] && binaries+=" ../wget-1.11.4/wget"
107
108cp -p \
109  $binaries \
110  sox.txt \
111  soxformat.txt \
112  soxi.txt \
113  libsox.txt \
114  $dir
115
116(cd $dir; ln -s sox soxi; ln -s sox play; ln -s sox rec)
117
118#if test -r "../wget-1.11.4/wget"; then
119#  cp ../wget-1.11.4/wget.ini $dir
120#fi
121
122zip --symlinks -r $dir-macosx.zip $dir
123rm -rf $dir
124