User:Jacek Antonelli/Mac Notes

Configure & Build Helper Functions
Since many of the libraries can be configured with the same command, and I keep having to update that command when it becomes apparent certain flags need to be added for all commands, I've made bash functions to aid with configuration and compilation of the libraries:

BASE_CFLAGS="-Z -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/ \             -I/usr/local/include/ \              -I/Developer/SDKs/MacOSX10.4u.sdk/usr/include/" BASE_LDFLAGS="-Z -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/ \              -L/usr/local/lib/ \               -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/ \               -headerpad_max_install_names" export BASE_CFLAGS export BASE_LDFLAGS function CONFIG {  ./configure\ CFLAGS="$BASE_CFLAGS $EXTRA_CFLAGS" \ LDFLAGS="$BASE_LDFLAGS $EXTRA_LDFLAGS" \ "$@" } function MAKE {  make\ CFLAGS="$BASE_CFLAGS $EXTRA_CFLAGS" \ LDFLAGS="$BASE_LDFLAGS $EXTRA_LDFLAGS" \ "$@" } function BUILD {  CONFIG "$@" && make if [ $? = 0 ]  then echo "Installing..." sudo make install fi }

You can call them just like regular commands, after you enter them in bash (or put them in your bash profile and . ~/.bash_profile, or whatever).

Xcode tools
Installed from the Mac OS X installer disk.

git
Download and install git

openal-soft
git clone git://repo.or.cz/openal-soft.git openal-soft

Edit openal-soft/CMakeLists.txt to change this: SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_BUILD_VERSION}") to this: SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")

Then, in the openal-soft directory:

cmake. && make && sudo make install

Installed to /usr/local.

freealut
freealut-1.1.0.tar.gz.

To compile against openal-soft: ./configure && make && sudo make install

Or, to compile against the standard OpenAL framework: FRAMEWORKS=/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks EXTRA_CFLAGS="-std=gnu99 -I${FRAMEWORKS}/OpenAL.framework/Headers/" CONFIG make LIBS="" LDFLAGS="-syslibroot /Developer/SDKs/MacOSX10.4u.sdk/ \                      -framework OpenAL -headerpath_max_install_name" pushd test_suite; make;  popd sudo make install

fink
Fink is for installing other stuff. Download fink package and install it.

Then to get package listings: sudo fink scanpackages sudo fink index Then to update fink, maybe not necessary: sudo apt-get update sudo apt-get install fink

pkgconfig
This helps configure scripts find the other installed libraries.

pkg-config-0.23.tar.gz ./configure make sudo make install

gettext
Provides libintl (needed by glib2) and gettext (needed by gst-plugins-good?)

gettext-0.14.5.tar.gz BUILD

glib2
Needed by gstreamer.

glib-2.12.0.tar.bz2 patch -p1 < /sw/fink/10.5/stable/main/finkinfo/gnome/glib2.patch # maybe not necessary? BUILD

libxml2
Needed by gstreamer. OS X comes with libxml2, but the version seems to be too low for gstreamer's liking.

libxml2-2.6.27.tar.bz2 BUILD

gstreamer
gstreamer-0.10.22.tar.bz2

BUILD

liboil
Needed by gst-plugins-base.

liboil-0.3.15.tar.gz

BUILD

libogg
Optionally used by gst-plugins-base.

libogg-1.1.3.tar.gz patch -p1 < /sw/fink/10.5/stable/main/finkinfo/sound/libogg.patch BUILD

libvorbis
Optionally used by gst-plugins-base.

libvorbis-1.1.0.tar.gz patch -p1 < /sw/fink/10.5/stable/main/finkinfo/sound/libvorbis0.patch BUILD

libtheora
libtheora-1.0alpha5.tar.bz2 patch -p1 < /sw/fink/10.5/stable/main/finkinfo/graphics/libtheora0.patch BUILD

pango
Not using pango after all.

Optionally used by gst-plugins-base. sudo fink install pango1 pango1-dev

Second try, based on fink:

pango-1.10.1.tar.bz2 patch -p1 < /sw/fink/10.5/stable/main/finkinfo/gnome/pango1-xft2.patch BUILD

XQuartz
X11-2.3.2.1.dmg

I needed it for gst-plugins-base to find the libfontconfig.la

gst-plugins-base
gst-plugins-base-0.10.22.tar.bz2 BUILD --disable-pango --disable-x --disable-xvideo

libjpeg
Optionally used by gst-plugins-good. sudo fink install libjpeg

Second try, based on how fink does it (but it doesn't work, see below):

jpegsrc.v6b.tar.gz patch -p1 < /sw/fink/10.5/stable/main/finkinfo/graphics/libjpeg.patch cp /usr/share/libtool/config.*. CONFIG --enable-shared --enable-static perl -pi.bak -e 's,-undefined suppress,,g; s,-flat_namespace,,g' libtool make sudo make install
 * 1) Update configure stuff, libjpeg's is from 1998 and doesn't work on Mac OS X
 * 1) Remove some problematic compile flags? Dunno exactly what's going on, but fink does it.

This doesn't work right though, doesn't make shared libs. Configure says libtool doesn't support shared libs, for some reason. Anyway, the fink version will do, since it doesn't have any dependencies to change with install_name.

libpng
libpng-1.2.35.tar.bz2

Optionally used by gst-plugins-good. BUILD

flac
Optionally used by gst-plugins-good.

flac-1.2.1.tar.gz BUILD --disable-asm-optimizations

gst-plugins-good
gst-plugins-good-0.10.14.tar.bz2 CONFIG pushd sys/osxaudio/ make LDFLAGS="-Wl,-syslibroot -Wl,/Developer/SDKs/MacOSX10.4u.sdk/ -L/usr/local/lib -headerpad_max_install_names" cd ../osxvideo/ make LDFLAGS="-Wl,-syslibroot -Wl,/Developer/SDKs/MacOSX10.4u.sdk/ -L/usr/local/lib -headerpad_max_install_names" popd make sudo make install

neon
OSX 10.5 comes with neon, but 10.4 doesn't seem to. Optionally used by gst-plugins-bad (but we need it).

neon-0.28.4.tar.gz BUILD --with-libxml2 --enable-shared

gst-plugins-bad
gst-plugins-bad-0.10.10.tar.bz2 CONFIG --disable-oss4 pushd sys/qtwrapper EXTRA_LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk/" MAKE popd make sudo make install

gst-ffmpeg
gst-ffmpeg-0.10.6.tar.bz2 CONFIG pushd gst-libs/ext/ffmpeg/ ./configure --extra-cflags="-Z -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/ -I/usr/local/include/ -I/Developer/SDKs/MacOSX10.4u.sdk/usr/include/" \ --extra-ldflags="-Z -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/ -L/usr/local/lib/ -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/ -headerpad_max_install_names" \ --disable-vhook --disable-ffserver --disable-ffplay --enable-postproc \ --enable-swscale --enable-gpl --enable-static --enable-shared \ --disable-encoder=flac --disable-decoder=cavs --disable-protocols \ --disable-devices --disable-network --disable-mmx --disable-altivec popd make sudo make install
 * 1) Configure the included ffmpeg separately because it doesn't like CFLAGS/LDFLAGS.

Symlinking Headers
We need to link (or copy, if you want) some directories of headers so that Imprudence will find them. From the imprudence directory: pushd linden/libraries/universal-darwin/include/ ln -s /usr/local/include/AL. ln -s /usr/local/include/glib-2.0. ln -s /usr/local/lib/glib-2.0/include/glibconfig.h. ln -s /usr/local/include/libxml2. popd

Copying Libraries
Put this in a shell script (e.g. ~/copy_libs.sh), and run it from the imprudence directory: pushd linden/libraries/universal-darwin/lib_release/ # Glib for g in glib \ gmodule \ gobject \ gthread do    echo "cp /usr/local/lib/lib${g}-2.0.0.dylib  ./lib${g}-2.0.dylib" cp /usr/local/lib/lib${g}-2.0.0.dylib ./lib${g}-2.0.dylib done # Gstreamer for lib in libgstapp-0.10.dylib \ libgstaudio-0.10.dylib \ libgstbase-0.10.dylib \ libgstcdda-0.10.dylib \ libgstcontroller-0.10.dylib \ libgstdataprotocol-0.10.dylib \ libgstfft-0.10.dylib \ libgstinterfaces-0.10.dylib \ libgstnet-0.10.dylib \ libgstnetbuffer-0.10.dylib \ libgstpbutils-0.10.dylib \ libgstreamer-0.10.dylib \ libgstriff-0.10.dylib \ libgstrtp-0.10.dylib \ libgstrtsp-0.10.dylib \ libgstsdp-0.10.dylib \ libgsttag-0.10.dylib \ libgstvideo-0.10.dylib do    echo "cp /usr/local/lib/$lib ." cp /usr/local/lib/$lib. done # Misc for lib in libalut.0.dylib \ libFLAC.8.dylib \ libintl.3.dylib \ libneon.27.dylib \ libogg.0.dylib \ liboil-0.3.0.dylib \ libtheora.0.dylib \ libvorbis.0.dylib \ libvorbisenc.2.dylib \ libxml2.2.dylib do    echo "cp /usr/local/lib/$lib ." cp /usr/local/lib/$lib. done # libjpeg was compiled by fink, so far. cp /sw/lib/libjpeg.62.dylib. # Gstreamer plugins pushd gstreamer-plugins/ for plugin in libgstaacparse.so \ libgstadder.so \ libgstaiffparse.so \ libgstamrparse.so \ libgstapp.so \ libgstaudioconvert.so \ libgstaudiorate.so \ libgstaudioresample.so \ libgstautodetect.so \ libgstavi.so \ libgstcoreelements.so \ libgstcoreindexers.so \ libgstdebug.so \ libgstdecodebin.so \ libgstdecodebin2.so \ libgstdeinterlace2.so \ libgstequalizer.so \ libgstffmpeg.so \ libgstffmpegcolorspace.so \ libgstffmpegscale.so \ libgstflac.so \ libgstflv.so \ libgstgdp.so \ libgsth264parse.so \ libgsticydemux.so \ libgstid3demux.so \ libgstinterleave.so \ libgstjpeg.so \ libgstlevel.so \ libgstmetadata.so \ libgstmpeg4videoparse.so \ libgstmpegdemux.so \ libgstmpegvideoparse.so \ libgstmultipart.so \ libgstneonhttpsrc.so \ libgstogg.so \ libgstosxaudio.so \ libgstosxvideosink.so \ libgstplaybin.so \ libgstpng.so \ libgstpostproc.so \ libgstqtdemux.so \ libgstqtwrapper.so \ libgstqueue2.so \ libgstreal.so \ libgstrtp.so \ libgstrtpmanager.so \ libgstrtsp.so \ libgstsdpelem.so \ libgstselector.so \ libgsttcp.so \ libgsttheora.so \ libgsttypefindfunctions.so \ libgstudp.so \ libgstvideoscale.so \ libgstvolume.so \ libgstvorbis.so \ libgstwavparse.so    do       echo "cp /usr/local/lib/gstreamer-0.10/$plugin ." cp /usr/local/lib/gstreamer-0.10/$plugin. done popd popd

fix_libs.rb
I made a ruby script to help fix the install_names on the libs (and later, the Imprudence binary). Make a new file called ~/bin/fix_libs.rb with these contents: rules = { /\/usr\/local\/lib\//    => "@executable_path/", /(libg.+).2.0.0.dylib/   => "\\1-2.0.dylib", /(libgst.+).0.10.0.dylib/ => "\\1-0.10.dylib", /.+\/libiconv.2.dylib/   => "/usr/lib/libiconv.2.dylib", /.+\/libbz2.1.dylib/     => "/usr/lib/libbz2.1.0.dylib", /.+\/libneon.26.dylib/   => "/usr/lib/libneon.26.dylib", } ARGV.each do |lib| puts "" `install_name_tool -id @executable_path/#{File.basename(lib)} #{lib}` deps = `otool -L #{lib} | egrep "dylib|so"`.split("\n") deps = deps.collect { |dep| dep.strip! dep.gsub!(/ \(compatibility.*/, "")  }   unchanged = 0   deps.each { |old|     if old       new = old.dup       rules.each_pair { |regexp, result|         new.gsub!( regexp, result )       }       if( new == old )         #puts "[#{File.basename(lib)}]  #{old}  (no change)"         unchanged += 1       else         puts "[#{File.basename(lib)}]  #{old}  ->  #{new}"       end       `install_name_tool -change #{old} #{new} #{lib}`     end   }   puts "[#{File.basename(lib)}] (#{unchanged} unchanged)"   puts "" end
 * 1) !/usr/bin/env ruby

Then chmod u+x ~/bin/fix_libs.rb so you can execute it.

Running the script
Now we need to run the script over the libraries and plugins to fix them. From the imprudence directory: pushd linden/libraries/universal-darwin/lib_release ~/bin/fix_libs.rb *.dylib ~/bin/fix_libs.rb gstreamer-plugins/*.so popd

Configuring & Compiling
In imprudence/linden/indra: ./develop.py

Open imprudence/linden/indra/build-darwin-i386/Imprudence.xcodeproj in Xcode.

For a Universal build, go to Project menu -> Edit Project Settings, and change "Architectures" to "Standard (32-bit Universal)". However, the new libs for OpenAL and GStreamer have not (yet) been compiled as Universal, so there's no point in compilinng Imprudence as Universal, unless you disable OpenAL and GStreamer support before compiling.

Command-B to start compiling, Command-Shift-B to watch the build progress and results.

Fixing the Imprudence Executable
Most of the lib path references in Imprudence should be good, but sometimes a few are bad (like libalut; need to fix that). So we have to run the fix_libs.rb script over the Imprudence executable.

From the imprudence directory (if compiling for release, change RelWithDebInfo to Release): pushd linden/indra/build-darwin-i386/newview/RelWithDebInfo/Imprudence.app/Contents/MacOS/ ~/bin/fix_libs.rb Imprudence popd