debian: Prepare for upload
[xz/debian.git] / macosx / build.sh
blobfd089f3b3648d246af543539bb5696efed534619
1 #!/bin/sh
3 ###############################################################################
4 # Author: Anders F Björklund <afb@users.sourceforge.net>
6 # This file has been put into the public domain.
7 # You can do whatever you want with this file.
8 ###############################################################################
10 mkdir -p Root
11 mkdir -p Resources
13 # Abort immediately if something goes wrong.
14 set -e
16 GCC="gcc-4.2"
17 SDK="/Developer/SDKs/MacOSX10.5.sdk"
18 MDT="10.5"
19 GTT=i686-apple-darwin9
21 ARCHES1="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
22 ARCHES2="-arch ppc -arch i386"
23 PKGFORMAT="10.5" # xar
25 # avoid "unknown required load command: 0x80000022" from linking on Snow Leopard
26 uname -r | grep ^1 >/dev/null && LDFLAGS="$LDFLAGS -Wl,-no_compact_linkedit"
28 # Clean up if it was already configured.
29 [ -f Makefile ] && make distclean
31 # Build the regular fat program
33 CC="$GCC" \
34 CFLAGS="-O2 -g $ARCHES1 -isysroot $SDK -mmacosx-version-min=$MDT" \
35 ../configure --disable-dependency-tracking --disable-xzdec --disable-lzmadec $GTT
37 make
39 make check
41 make DESTDIR=`pwd`/Root install
43 make distclean
45 # Build the size-optimized program
47 CC="$GCC" \
48 CFLAGS="-Os -g $ARCHES2 -isysroot $SDK -mmacosx-version-min=$MDT" \
49 ../configure --disable-dependency-tracking --disable-shared --disable-nls --disable-encoders --enable-small --disable-threads $GTT
51 make -C src/liblzma
52 make -C src/xzdec
53 make -C src/xzdec DESTDIR=`pwd`/Root install
55 cp -a ../extra Root/usr/local/share/doc/xz
57 make distclean
59 # Move development files to different package
61 test -d liblzma && rm -r liblzma
62 mkdir -p liblzma/usr/local
64 mv Root/usr/local/include liblzma/usr/local
65 mv Root/usr/local/lib liblzma/usr/local
67 mkdir -p Root/usr/local/lib
68 cp -p liblzma/usr/local/lib/liblzma.5.dylib Root/usr/local/lib
69 mkdir -p liblzma/usr/local/share/doc/xz
70 mv Root/usr/local/share/doc/xz/examples* liblzma/usr/local/share/doc/xz
72 # Strip debugging symbols and make relocatable
74 for bin in xz lzmainfo xzdec lzmadec; do
75 strip -S Root/usr/local/bin/$bin
76 install_name_tool -change /usr/local/lib/liblzma.5.dylib @executable_path/../lib/liblzma.5.dylib Root/usr/local/bin/$bin
77 done
79 for lib in liblzma.5.dylib; do
80 strip -S Root/usr/local/lib/$lib
81 install_name_tool -id @executable_path/../lib/liblzma.5.dylib Root/usr/local/lib/$lib
82 done
84 # Create tarball, but without the HFS+ attrib
86 rmdir debug lib po src/liblzma/api src/liblzma src/lzmainfo src/scripts src/xz src/xzdec src tests
88 ( cd Root/usr/local; COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true tar cvjf ../../../XZ.tbz * )
89 ( cd liblzma; COPY_EXTENDED_ATTRIBUTES_DISABLE=true COPYFILE_DISABLE=true tar cvjf ../liblzma.tbz ./usr/local )
91 # Include documentation files for package
93 cp -p ../README Resources/ReadMe.txt
94 cp -p ../COPYING Resources/License.txt
96 # Make an Installer.app package
98 ID="org.tukaani.xz"
99 VERSION=`cd ..; sh build-aux/version.sh`
100 PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
101 $PACKAGEMAKER -r Root/usr/local -l /usr/local -e Resources -i $ID -n $VERSION -t XZ -o XZ.pkg -g $PKGFORMAT --verbose
102 $PACKAGEMAKER -r liblzma -w -k -i $ID.liblzma -n $VERSION -o liblzma.pkg -g $PKGFORMAT --verbose
104 # Put the package in a disk image
106 if [ "$PKGFORMAT" != "10.5" ]; then
107 hdiutil create -fs HFS+ -format UDZO -quiet -srcfolder XZ.pkg -ov XZ.dmg
108 hdiutil internet-enable -yes -quiet XZ.dmg
111 echo
112 echo "Build completed successfully."
113 echo