107 lines
3.6 KiB
Bash
Executable File
107 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Building the installer is only tested and supported on 10.9 with Xcode 5.0.1
|
|
# Command line tools for Xcode required, isntall with "xcode-select --install"
|
|
# PackageMaker comes from Auxiliary Tools for Xcode - Late July 2012
|
|
# Download from https://developer.apple.com/downloads/index.action?name=packagemaker#
|
|
# Built package targets 10.9+
|
|
# Building should also work on older versions with older revisions or slight changes, YMMV
|
|
|
|
set -ex
|
|
test -x ./configure || ./bootstrap
|
|
BUILDPATH=${PWD}
|
|
|
|
# Use new locations for SDK on 10.8+
|
|
OSX_RELEASE=`sw_vers -productVersion`
|
|
case ${OSX_RELEASE:0:4} in
|
|
"10.8")
|
|
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk"
|
|
PKGMAKER="/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"
|
|
export CFLAGS="-isysroot $SYSROOT -arch x86_64 -mmacosx-version-min=10.8"
|
|
;;
|
|
"10.9")
|
|
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk"
|
|
PKGMAKER="/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"
|
|
export CFLAGS="-isysroot $SYSROOT -arch x86_64 -mmacosx-version-min=10.9"
|
|
;;
|
|
*)
|
|
SYSROOT="/Developer/SDKs/MacOSX10.6.sdk"
|
|
PKGMAKER="/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
|
|
export CFLAGS="-isysroot $SYSROOT -arch x86_64 -mmacosx-version-min=10.6"
|
|
;;
|
|
esac
|
|
|
|
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 \
|
|
--enable-sm # TODO: remove this
|
|
|
|
# always make clean
|
|
make clean
|
|
|
|
# compile
|
|
make -j 2
|
|
|
|
# copy files
|
|
rm -rf target
|
|
make install DESTDIR=${BUILDPATH}/target
|
|
|
|
# remove garbage
|
|
rm -f target/Library/OpenSC/lib/*.la
|
|
|
|
# generate .bundle (required by Adobe Acrobat)
|
|
./MacOSX/libtool-bundle target/Library/OpenSC/lib/opensc-pkcs11.so target/Library/OpenSC/lib
|
|
|
|
# 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)
|
|
test -d engine_pkcs11 || git clone http://github.com/OpenSC/engine_pkcs11.git
|
|
(cd engine_pkcs11
|
|
test -x configure || ./bootstrap
|
|
PKG_CONFIG_PATH=${BUILDPATH}/build/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure --disable-dependency-tracking --prefix=/Library/OpenSC && make install DESTDIR=${BUILDPATH}/target)
|
|
|
|
# Check out OpenSC.tokend, if not already fetched.
|
|
if ! test -e OpenSC.tokend; then
|
|
git clone http://github.com/OpenSC/OpenSC.tokend.git
|
|
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
|
|
${PKGMAKER} \
|
|
-r target \
|
|
-o OpenSC-@PACKAGE_VERSION@.pkg \
|
|
-t "OpenSC @PACKAGE_VERSION@ for Mac OS X 10.9+" \
|
|
-i org.opensc-project.mac \
|
|
-n @PACKAGE_VERSION@ \
|
|
-g 10.4 \
|
|
-b \
|
|
-v \
|
|
--no-relocate \
|
|
-e MacOSX/resources \
|
|
-s MacOSX/scripts
|
|
|
|
# Create .dmg
|
|
rm -f OpenSC-@PACKAGE_VERSION@.dmg
|
|
TIMESTAMP=$(date +%Y.%m.%d)
|
|
hdiutil create -srcfolder OpenSC-@PACKAGE_VERSION@.pkg -volname "OpenSC @PACKAGE_VERSION@ for Mac OS X 10.9+ (${TIMESTAMP})" OpenSC-@PACKAGE_VERSION@.dmg
|