Compiling libgig for Mac OS X with XCode ======================================== Requirements ------------ The XCode project uses autotools build files. On Mac OS 10.4, you need to install pkg-config (available at http://pkgconfig.freedesktop.org/wiki/). If you are to build the CVS snapshot, then you need to do the following steps to make autotools work correctly: $ sudo ln -sf /usr/bin/glibtoolize /usr/local/bin/libtoolize $ sudo cat >/usr/local/bin/aclocal <<'EOF' #!/bin/sh /usr/bin/aclocal -I /usr/local/share/aclocal $@ EOF $ sudo chmod +x /usr/local/bin/aclocal Layout of the Directories ------------------------- The XCode project for libgig creates a temporary build directory as "$LIBGIG/../temp_build/$BUILD_STYLE" (where $LIBGIG is the libgig directory, and $BUILD_STYLE is the build style defined in the XCode project). In this directory, the following subdirectories are created and used: $BASEGIG.build: Intermediate build directory. Symbolic links to the original source files are placed and "configure && make" is performed in this directory. ($BASEGIG is the basename of the libgig directory.) local: The products are "installed" in this directory. libgig.a is in local/lib, and gigdump, gigextract, dlsdump, rifftree are in local/bin. Such a layout allows you to build binaries of different architectures (and build options) independently. On the other hand, you will need to link libgig.a statically because you cannot expect other users to place libgig.a at the same path. The XCode project takes care of this by giving "--disable-shared" to configure. Also note that this temporary directory is outside the libgig directory and will be shared with the Xcode projects for other linuxsampler subproducts. So it is best to create a common directory for all linuxsampler subproducts and place the libgig directory (and the directories of other linuxsampler subproducts) in it. Universal Binaries ------------------ Universal Binaries are not automatically created by the XCode project. However, it is easy to create them by hands as follows: $ cd $LIBGIG # Move to the libgig directory $ mkdir -p ../temp_build/UB/bin ../temp_build/UB/lib $ cd ../temp_build/Deployment_ppc $ for i in bin/* lib/*.a; do lipo -create $i ../Deployment_i386/$i -output ../UB/$i done The libgig project is dependent on libsndfile, but you may not have a Universal Binary version of libsndfile. Don't worry, you can still create UB of libgig products. Follow these steps: - Get the sources of libsndfile and extract in $LIBGIG/.. - cd to $LIBGIG/../libsndfile-* - env BUILD_STYLE=Deployment_ppc \ WITH_INSTALL=1 \ CONFIG_OPTIONS="--disable-shared" \ BUILD_BASE_DIR="$PWD/../temp_build" \ SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk" \ /bin/sh $LIBGIG/osx/autoconf_builder.sh - env BUILD_STYLE=Deployment_i386 \ WITH_INSTALL=1 \ CONFIG_OPTIONS="--disable-shared" \ BUILD_BASE_DIR="$PWD/../temp_build" \ SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk" \ /bin/sh $LIBGIG/osx/autoconf_builder.sh After these steps, the i386 and ppc versions of libsndfile.a are created in $LIBGIG/../temp_build/Deployment_$ARCH/local/lib ($ARCH is either i386 or ppc). Now you can double-click on libgig.xcodeproj and build libgig with Deployment_i386 and Deployment_ppc build styles. pkg-config will find the correct version of libsndfile.a in $LIBGIG/../temp_build/$BUILD_STYLES/ local/lib. Additional Information ---------------------- The XCode project just invokes autoconf_builder.sh with after setting relevant environmental variables. If you are interested (or feel suspicious), please examine autoconf_builder.sh. 6 May 2007 Written by Toshi Nagata