3 # Copyright (C) 2007-2009 Ludovic Rousseau <ludovic.rousseau@free.fr>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 # the driver is installed in /usr/libexec/SmartCardServices/drivers
30 # run this script as ./MacOSX/configure to configure for Mac OS X
35 echo "run ./MacOSX/configure from the source top directory"
40 # find pcsc-lite header files in MacOSX/
41 # use ${varname:-word} to return word only if varname is not already defined
42 PCSC_CFLAGS=${PCSC_CFLAGS:--I$(pwd)/MacOSX}
43 PCSC_LIBS=${PCSC_LIBS:--framework PCSC}
46 LIBUSB_DIR=$(pkg-config --variable=libdir libusb-1.0)
47 LIBUSB_ARCHIVE="$LIBUSB_DIR"/libusb-1.0.a
48 LIBUSB_CFLAGS=$(pkg-config --cflags --static libusb-1.0)
49 LIBUSB_LIBS=$(pkg-config --libs --static libusb-1.0)
51 if ls "$LIBUSB_DIR"/libusb-1.0*.dylib 2> /dev/null
54 echo "*****************************"
55 echo "Dynamic library libusb found in $LIBUSB_DIR"
56 echo "*****************************"
58 echo "Rename it to force a static link"
62 # RESPONSECODE is already defined by PCSC/wintypes.h
63 # define needed here to compile examples/scardcontrol.c since config.h is
65 CFLAGS="$CFLAGS -DRESPONSECODE_DEFINED_IN_WINTYPES_H"
67 # get the Mac OS X major version. Example: El Capitan 10.11 -> 10011
68 MAC_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 * 1000 + $2}')
70 # check for Universal Binary only on macOS Mavericks 10.9 and earlier
71 if [ $MAC_VERSION -le 10009 ]
73 # Build a Universal Binary?
74 UB=$(file $LIBUSB_ARCHIVE | grep "Mach-O universal binary")
79 echo "*************************"
80 echo "No Universal Binary build"
81 echo "*************************"
84 echo "Universal Binary build"
85 CFLAGS="$CFLAGS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -arch i386 -arch x86_64"
90 CONFIGURE_ARGS="--disable-dependency-tracking"
92 # Are we on a CryptoTokenKit system? (like Mac OS X 10.10 Yosemite)
93 if [ -d /System/Library/CryptoTokenKit ]
95 if [ 10012 -gt $MAC_VERSION ]
97 # use syslog(3) to logs for macOS < 10.12
98 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-syslog"
100 # use os_log(3) to logs for macOS >= 10.12
101 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-oslog"
105 # Check where to install the driver
106 if [ 10011 -gt $MAC_VERSION ]
109 DROPDIR="/usr/libexec/SmartCardServices/drivers"
111 # Mac OS X >= 10.11 (El Capitan)
112 DROPDIR="/usr/local/libexec/SmartCardServices/drivers"
115 # do not build a static driver
116 # (building fails when linking statically with libusb)
117 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-static"
119 # do not use pcscd debug feature
120 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-pcsclite"
122 # simulate a composite device as multi slots
123 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-composite-as-multislot"
125 # set BUNDLE_ID to a specific value for a specific driver
126 #BUNDLE_ID="vendor-reader"
127 if [ ! -z "$BUNDLE_ID" ]
129 # do not build a class driver (not yet used by pcsc-lite on Mac OS X)
130 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-class"
132 # use a specific bundle name to NOT overwrite the official CCID driver
133 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-bundle=ifd-ccid-$BUNDLE_ID.bundle"
135 # differentiate each libccid library by the dynamic linker
136 CONFIGURE_ARGS="$CONFIGURE_ARGS --prefix=/fake/$BUNDLE_ID"
142 PCSC_CFLAGS="$PCSC_CFLAGS" \
143 PCSC_LIBS="$PCSC_LIBS" \
144 LIBUSB_CFLAGS="$LIBUSB_CFLAGS" \
145 LIBUSB_LIBS="$LIBUSB_LIBS" \
147 --enable-usbdropdir="$DROPDIR" \
153 # force a regeneration of Info.plist
156 # exit with the return code from ./configure