1*880b10faSchristos#!/bin/sh 2*880b10faSchristos 3*880b10faSchristos############################################################################### 4*880b10faSchristos# Author: Anders F Björklund <afb@users.sourceforge.net> 5*880b10faSchristos# 6*880b10faSchristos# This file has been put into the public domain. 7*880b10faSchristos# You can do whatever you want with this file. 8*880b10faSchristos############################################################################### 9*880b10faSchristos 10*880b10faSchristosmkdir -p Root 11*880b10faSchristosmkdir -p Resources 12*880b10faSchristos 13*880b10faSchristos# Abort immediately if something goes wrong. 14*880b10faSchristosset -e 15*880b10faSchristos 16*880b10faSchristosGCC="gcc-4.2" 17*880b10faSchristosSDK="/Developer/SDKs/MacOSX10.5.sdk" 18*880b10faSchristosMDT="10.5" 19*880b10faSchristosGTT=i686-apple-darwin9 20*880b10faSchristos 21*880b10faSchristosARCHES1="-arch ppc -arch ppc64 -arch i386 -arch x86_64" 22*880b10faSchristosARCHES2="-arch ppc -arch i386" 23*880b10faSchristosPKGFORMAT="10.5" # xar 24*880b10faSchristos 25*880b10faSchristos# avoid "unknown required load command: 0x80000022" from linking on Snow Leopard 26*880b10faSchristosuname -r | grep ^1 >/dev/null && LDFLAGS="$LDFLAGS -Wl,-no_compact_linkedit" 27*880b10faSchristos 28*880b10faSchristos# Clean up if it was already configured. 29*880b10faSchristos[ -f Makefile ] && make distclean 30*880b10faSchristos 31*880b10faSchristos# Build the regular fat program 32*880b10faSchristos 33*880b10faSchristosCC="$GCC" \ 34*880b10faSchristosCFLAGS="-O2 -g $ARCHES1 -isysroot $SDK -mmacosx-version-min=$MDT" \ 35*880b10faSchristos../configure --disable-dependency-tracking --disable-xzdec --disable-lzmadec $GTT 36*880b10faSchristos 37*880b10faSchristosmake 38*880b10faSchristos 39*880b10faSchristosmake check 40*880b10faSchristos 41*880b10faSchristosmake DESTDIR=`pwd`/Root install 42*880b10faSchristos 43*880b10faSchristosmake distclean 44*880b10faSchristos 45*880b10faSchristos# Build the size-optimized program 46*880b10faSchristos 47*880b10faSchristosCC="$GCC" \ 48*880b10faSchristosCFLAGS="-Os -g $ARCHES2 -isysroot $SDK -mmacosx-version-min=$MDT" \ 49*880b10faSchristos../configure --disable-dependency-tracking --disable-shared --disable-nls --disable-encoders --enable-small --disable-threads $GTT 50*880b10faSchristos 51*880b10faSchristosmake -C src/liblzma 52*880b10faSchristosmake -C src/xzdec 53*880b10faSchristosmake -C src/xzdec DESTDIR=`pwd`/Root install 54*880b10faSchristos 55*880b10faSchristoscp -a ../extra Root/usr/local/share/doc/xz 56*880b10faSchristos 57*880b10faSchristosmake distclean 58*880b10faSchristos 59*880b10faSchristos# Move development files to different package 60*880b10faSchristos 61*880b10faSchristostest -d liblzma && rm -r liblzma 62*880b10faSchristosmkdir -p liblzma/usr/local 63*880b10faSchristos 64*880b10faSchristosmv Root/usr/local/include liblzma/usr/local 65*880b10faSchristosmv Root/usr/local/lib liblzma/usr/local 66*880b10faSchristos 67*880b10faSchristosmkdir -p Root/usr/local/lib 68*880b10faSchristoscp -p liblzma/usr/local/lib/liblzma.5.dylib Root/usr/local/lib 69*880b10faSchristosmkdir -p liblzma/usr/local/share/doc/xz 70*880b10faSchristosmv Root/usr/local/share/doc/xz/examples* liblzma/usr/local/share/doc/xz 71*880b10faSchristos 72*880b10faSchristos# Strip debugging symbols and make relocatable 73*880b10faSchristos 74*880b10faSchristosfor bin in xz lzmainfo xzdec lzmadec; do 75*880b10faSchristos strip -S Root/usr/local/bin/$bin 76*880b10faSchristos install_name_tool -change /usr/local/lib/liblzma.5.dylib @executable_path/../lib/liblzma.5.dylib Root/usr/local/bin/$bin 77*880b10faSchristosdone 78*880b10faSchristos 79*880b10faSchristosfor lib in liblzma.5.dylib; do 80*880b10faSchristos strip -S Root/usr/local/lib/$lib 81*880b10faSchristos install_name_tool -id @executable_path/../lib/liblzma.5.dylib Root/usr/local/lib/$lib 82*880b10faSchristosdone 83*880b10faSchristos 84*880b10faSchristos# Create tarball, but without the HFS+ attrib 85*880b10faSchristos 86*880b10faSchristosrmdir debug lib po src/liblzma/api src/liblzma src/lzmainfo src/scripts src/xz src/xzdec src tests 87*880b10faSchristos 88*880b10faSchristos( cd Root/usr/local; COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true tar cvjf ../../../XZ.tbz * ) 89*880b10faSchristos( cd liblzma; COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true tar cvjf ../liblzma.tbz ./usr/local ) 90*880b10faSchristos 91*880b10faSchristos# Include documentation files for package 92*880b10faSchristos 93*880b10faSchristoscp -p ../README Resources/ReadMe.txt 94*880b10faSchristoscp -p ../COPYING Resources/License.txt 95*880b10faSchristos 96*880b10faSchristos# Make an Installer.app package 97*880b10faSchristos 98*880b10faSchristosID="org.tukaani.xz" 99*880b10faSchristosVERSION=`cd ..; sh build-aux/version.sh` 100*880b10faSchristosPACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker 101*880b10faSchristos$PACKAGEMAKER -r Root/usr/local -l /usr/local -e Resources -i $ID -n $VERSION -t XZ -o XZ.pkg -g $PKGFORMAT --verbose 102*880b10faSchristos$PACKAGEMAKER -r liblzma -w -k -i $ID.liblzma -n $VERSION -o liblzma.pkg -g $PKGFORMAT --verbose 103*880b10faSchristos 104*880b10faSchristos# Put the package in a disk image 105*880b10faSchristos 106*880b10faSchristosif [ "$PKGFORMAT" != "10.5" ]; then 107*880b10faSchristoshdiutil create -fs HFS+ -format UDZO -quiet -srcfolder XZ.pkg -ov XZ.dmg 108*880b10faSchristoshdiutil internet-enable -yes -quiet XZ.dmg 109*880b10faSchristosfi 110*880b10faSchristos 111*880b10faSchristosecho 112*880b10faSchristosecho "Build completed successfully." 113*880b10faSchristosecho 114