-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
configure
executable file
·158 lines (135 loc) · 4.65 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /bin/bash
# Copyright (C) 2007-2009 Ludovic Rousseau <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
# to use
# ./MacOSX/configure
# make
# make install
# the driver is installed in /usr/libexec/SmartCardServices/drivers
# Colors
RED="\033[31m"
NORMAL="\033[0m"
# run this script as ./MacOSX/configure to configure for Mac OS X
if [ ! -d MacOSX ]
then
echo -e $RED
echo "ERROR!"
echo "run ./MacOSX/configure from the source top directory"
echo -e $NORMAL
exit -1
fi
# find pcsc-lite header files in MacOSX/
# use ${varname:-word} to return word only if varname is not already defined
PCSC_CFLAGS=${PCSC_CFLAGS:--I$(pwd)/MacOSX}
PCSC_LIBS=${PCSC_LIBS:--framework PCSC}
# use libusb-1.0
LIBUSB_DIR=$(pkg-config --variable=libdir libusb-1.0)
LIBUSB_ARCHIVE="$LIBUSB_DIR"/libusb-1.0.a
LIBUSB_CFLAGS=$(pkg-config --cflags --static libusb-1.0)
LIBUSB_LIBS=$(pkg-config --libs --static libusb-1.0)
LIBUSB_IS_HOMEBREW=$(which brew 2> /dev/null)
ls -1 "$LIBUSB_DIR"/libusb-1.0*.dylib > /dev/null 2>&1
if [ "$?" ] && [ ! -f $LIBUSB_IS_HOMEBREW ]; then
echo -en $RED
echo "*****************************"
echo "Dynamic library libusb found in $LIBUSB_DIR"
echo "*****************************"
echo -en $NORMAL
echo "Rename it to force a static link"
exit -1
fi
# RESPONSECODE is already defined by PCSC/wintypes.h
# define needed here to compile examples/scardcontrol.c since config.h is
# not included
CFLAGS="$CFLAGS -DRESPONSECODE_DEFINED_IN_WINTYPES_H"
# get the Mac OS X major version. Example: El Capitan 10.11 -> 10011
MAC_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 * 1000 + $2}')
# check for Universal Binary only on macOS Mavericks 10.9 and earlier
if [ $MAC_VERSION -le 10009 ]
then
# Build a Universal Binary?
UB=$(file $LIBUSB_ARCHIVE | grep "Mach-O universal binary")
echo $UB
if [ -z "$UB" ]
then
echo -en $RED
echo "*************************"
echo "No Universal Binary build"
echo "*************************"
echo -en $NORMAL
else
echo "Universal Binary build"
CFLAGS="$CFLAGS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -arch i386 -arch x86_64"
fi
echo
fi
CONFIGURE_ARGS="--disable-dependency-tracking"
# Are we on a CryptoTokenKit system? (like Mac OS X 10.10 Yosemite)
if [ -d /System/Library/CryptoTokenKit ]
then
if [ 10012 -gt $MAC_VERSION ]
then
# use syslog(3) to logs for macOS < 10.12
CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-syslog"
else
# use os_log(3) to logs for macOS >= 10.12
CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-oslog"
fi
fi
# Check where to install the driver
if [ 10011 -gt $MAC_VERSION ]
then
# Mac OS X < 10.11
DROPDIR="/usr/libexec/SmartCardServices/drivers"
else
# Mac OS X >= 10.11 (El Capitan)
DROPDIR="/usr/local/libexec/SmartCardServices/drivers"
fi
# do not build a static driver
# (building fails when linking statically with libusb)
CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-static"
# do not use pcscd debug feature
CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-pcsclite"
# simulate a composite device as multi slots
CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-composite-as-multislot"
# set BUNDLE_ID to a specific value for a specific driver
#BUNDLE_ID="vendor-reader"
if [ ! -z "$BUNDLE_ID" ]
then
# do not build a class driver (not yet used by pcsc-lite on Mac OS X)
CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-class"
# use a specific bundle name to NOT overwrite the official CCID driver
CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-bundle=ifd-ccid-$BUNDLE_ID.bundle"
# differentiate each libccid library by the dynamic linker
CONFIGURE_ARGS="$CONFIGURE_ARGS --prefix=/fake/$BUNDLE_ID"
fi
set -x
./configure \
CFLAGS="$CFLAGS" \
PCSC_CFLAGS="$PCSC_CFLAGS" \
PCSC_LIBS="$PCSC_LIBS" \
LIBUSB_CFLAGS="$LIBUSB_CFLAGS" \
LIBUSB_LIBS="$LIBUSB_LIBS" \
LDFLAGS="$LDFLAGS" \
--enable-usbdropdir="$DROPDIR" \
$CONFIGURE_ARGS \
"$@"
r=$?
# force a regeneration of Info.plist
rm -f src/Info.plist
# exit with the return code from ./configure
exit $r