2011-04-20 12:14:44 +00:00
#!/bin/bash
2013-02-20 12:08:29 +00:00
# Building is only tested on 10.7 but package targets 10.6, 10.7 and 10.8
2011-04-20 12:14:44 +00:00
set -ex
test -x ./configure || ./bootstrap
BUILDPATH=${PWD}
2013-02-20 12:08:29 +00:00
export CFLAGS="-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -mmacosx-version-min=10.6 -g"
2011-04-20 12:14:44 +00:00
export SED=/usr/bin/sed
PREFIX=/Library/OpenSC
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
./configure --prefix=$PREFIX \
--sysconfdir=$PREFIX/etc \
--disable-dependency-tracking \
--enable-shared \
--disable-static \
--enable-strict \
--disable-assert
2013-02-20 12:08:29 +00:00
# always make clean
make clean
2011-04-20 12:14:44 +00:00
# compile
make -j 2
# copy files
rm -rf target
make install DESTDIR=${BUILDPATH}/target
# remove garbage
2011-12-08 09:21:29 +00:00
rm -f target/Library/OpenSC/lib/*.la
2011-04-20 12:14:44 +00:00
# generate .bundle (required by Adobe Acrobat)
./MacOSX/libtool-bundle target/Library/OpenSC/lib/opensc-pkcs11.so target/Library/OpenSC/lib
2013-02-20 12:08:29 +00:00
# Build engine_pkcs11 + libp11
test -d libp11 || git clone http://github.com/OpenSC/libp11.git
(cd libp11
test -x confiure || ./bootstrap
./configure --enable-static --disable-shared --disable-dependency-tracking --prefix=${BUILDPATH}/build && make && make install
cd ..)
test -d engine_pkcs11 || git clone http://github.com/OpenSC/engine_pkcs11.git
(cd engine_pkcs11
test -x configure || ./bootstrap
2013-02-22 13:12:18 +00:00
PKG_CONFIG_PATH=${BUILDPATH}/build/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure --disable-dependency-tracking --prefix=/Library/OpenSC && make install DESTDIR=${BUILDPATH}/target)
2013-02-20 12:08:29 +00:00
# Check out OpenSC.tokend, if not already fetched.
2011-04-20 12:14:44 +00:00
if ! test -e OpenSC.tokend; then
2013-02-20 12:08:29 +00:00
git clone http://github.com/OpenSC/OpenSC.tokend.git
2011-04-20 12:14:44 +00:00
fi
2013-02-20 12:08:29 +00:00
# Fetch binary dependencies
2013-02-25 09:59:59 +00:00
curl -O https://www.opensc-project.org/downloads/build-10.6.tar.gz
2011-04-20 12:14:44 +00:00
# Unpack the binary building components
if ! test -e OpenSC.tokend/build; then
2013-02-20 12:08:29 +00:00
tar -C OpenSC.tokend -xzvf build-10.6.tar.gz
2011-04-20 12:14:44 +00:00
fi
# Create the symlink to OpenSC sources
test -L OpenSC.tokend/build/opensc-src || ln -sf ${BUILDPATH}/src OpenSC.tokend/build/opensc-src
# build and copy OpenSC.tokend
xcodebuild -configuration Deployment -project OpenSC.tokend/Tokend.xcodeproj
mkdir -p target/System/Library/Security/tokend
mv OpenSC.tokend/build/OpenSC.tokend target/System/Library/Security/tokend
# The "UnInstaller"
mkdir -p target/usr/local/bin
cp MacOSX/opensc-uninstall target/usr/local/bin
# Build installer package
/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker \
-r target \
2013-02-20 12:08:29 +00:00
-o OpenSC-@PACKAGE_VERSION@.pkg \
-t "OpenSC @PACKAGE_VERSION@ for Mac OS X 10.6+" \
2011-04-20 12:14:44 +00:00
-i org.opensc-project.mac \
-n @PACKAGE_VERSION@ \
2011-05-18 05:33:40 +00:00
-g 10.4 \
2011-04-20 12:14:44 +00:00
-b \
-v \
--no-relocate \
2013-02-20 12:08:29 +00:00
-e MacOSX/resources \
-s MacOSX/scripts
2011-04-20 12:14:44 +00:00
# Create .dmg
2013-02-20 12:08:29 +00:00
rm -f OpenSC-@PACKAGE_VERSION@.dmg
2011-04-20 12:14:44 +00:00
TIMESTAMP=$(date +%Y.%m.%d)
2013-02-20 12:08:29 +00:00
hdiutil create -srcfolder OpenSC-@PACKAGE_VERSION@.pkg -volname "OpenSC @PACKAGE_VERSION@ for Mac OS X 10.6+ (${TIMESTAMP})" OpenSC-@PACKAGE_VERSION@.dmg