diff -durN -x '*.orig' jdk8u-jdk8u66-b02.orig/common/autoconf/libraries.m4 jdk8u-jdk8u66-b02/common/autoconf/libraries.m4 --- jdk8u-jdk8u66-b02.orig/common/autoconf/libraries.m4 2015-09-18 13:18:24.000000000 +0200 +++ jdk8u-jdk8u66-b02/common/autoconf/libraries.m4 2015-09-18 13:19:49.000000000 +0200 @@ -747,6 +747,53 @@ ############################################################################### # + # Check for the pcsclite library + # + + AC_ARG_WITH(libpcsclite, [AS_HELP_STRING([--with-libpcsclite], + [use libpcsclite from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + + AC_CHECK_LIB(pcsclite, SCardConnect, + [ LIBPCSCLITE_FOUND=yes ], + [ LIBPCSCLITE_FOUND=no ]) + + AC_MSG_CHECKING([for which libpcsclite to use]) + + DEFAULT_LIBPCSCLITE=bundled + + if test "x${LIBPCSCLITE_FOUND}" != "xyes"; then + # + # If we don't find any system...set default to bundled + # + DEFAULT_LIBPCSCLITE=bundled + fi + + # + # If user didn't specify, use DEFAULT_PCSC + # + if test "x${with_libpcsclite}" = "x"; then + with_libpcsclite=${DEFAULT_LIBPCSCLITE} + fi + + if test "x${with_libpcsclite}" = "xbundled"; then + USE_EXTERNAL_LIBPCSCLITE=false + AC_MSG_RESULT([bundled]) + elif test "x${with_libpcsclite}" = "xsystem"; then + if test "x${LIBPCSCLITE_FOUND}" = "xyes"; then + USE_EXTERNAL_LIBPCSCLITE=true + AC_MSG_RESULT([system]) + else + AC_MSG_RESULT([system not found]) + AC_MSG_ERROR([--with-libpcsclite=system specified, but no libpcsclite found!]) + fi + else + AC_MSG_ERROR([Invalid value for --with-libpcsclite: ${with_libpcsclite}, use 'system' or 'bundled']) + fi + + AC_SUBST(USE_EXTERNAL_LIBPCSCLITE) + + ############################################################################### + # # Check for the zlib library # diff -durN -x '*.orig' jdk8u-jdk8u66-b02.orig/common/autoconf/spec.gmk.in jdk8u-jdk8u66-b02/common/autoconf/spec.gmk.in --- jdk8u-jdk8u66-b02.orig/common/autoconf/spec.gmk.in 2015-09-18 13:16:52.000000000 +0200 +++ jdk8u-jdk8u66-b02/common/autoconf/spec.gmk.in 2015-09-18 13:19:49.000000000 +0200 @@ -565,6 +565,7 @@ USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@ USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@ USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@ +USE_EXTERNAL_LIBPCSCLITE:=@USE_EXTERNAL_LIBPCSCLITE@ USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@ LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@ MSVCR_DLL:=@MSVCR_DLL@ diff -durN -x '*.orig' jdk8u-jdk8u66-b02.orig/jdk/make/lib/SecurityLibraries.gmk jdk8u-jdk8u66-b02/jdk/make/lib/SecurityLibraries.gmk --- jdk8u-jdk8u66-b02.orig/jdk/make/lib/SecurityLibraries.gmk 2015-07-23 16:17:35.000000000 +0200 +++ jdk8u-jdk8u66-b02/jdk/make/lib/SecurityLibraries.gmk 2015-09-18 13:19:49.000000000 +0200 @@ -75,11 +75,11 @@ CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio/MUSCLE, \ + -I/usr/include/PCSC -DUSE_SYSTEM_LIBPCSCLITE, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pcsc/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_posix := $(LIBDL), \ + LDFLAGS_SUFFIX_posix := -lpcsclite $(LIBDL), \ LDFLAGS_SUFFIX_windows := winscard.lib, \ LDFLAGS_SUFFIX_solaris := -lc, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ diff -durN -x '*.orig' jdk8u-jdk8u66-b02.orig/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c jdk8u-jdk8u66-b02/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c --- jdk8u-jdk8u66-b02.orig/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c 2015-07-23 16:17:35.000000000 +0200 +++ jdk8u-jdk8u66-b02/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c 2015-09-18 13:19:49.000000000 +0200 @@ -36,6 +36,7 @@ #include "pcsc_md.h" +#ifndef USE_SYSTEM_LIBPCSCLITE void *hModule; FPTR_SCardEstablishContext scardEstablishContext; FPTR_SCardConnect scardConnect; @@ -47,6 +48,7 @@ FPTR_SCardBeginTransaction scardBeginTransaction; FPTR_SCardEndTransaction scardEndTransaction; FPTR_SCardControl scardControl; +#endif /* * Throws a Java Exception by name @@ -75,7 +77,9 @@ throwByName(env, "java/io/IOException", msg); } +#ifndef USE_SYSTEM_LIBPCSCLITE void *findFunction(JNIEnv *env, void *hModule, char *functionName) { + return NULL; void *fAddress = dlsym(hModule, functionName); if (fAddress == NULL) { char errorMessage[256]; @@ -85,9 +89,11 @@ } return fAddress; } +#endif JNIEXPORT void JNICALL Java_sun_security_smartcardio_PlatformPCSC_initialize (JNIEnv *env, jclass thisClass, jstring jLibName) { +#ifndef USE_SYSTEM_LIBPCSCLITE const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL); if (libName == NULL) { throwNullPointerException(env, "PCSC library name is null"); @@ -141,4 +147,5 @@ #else scardControl = (FPTR_SCardControl) findFunction(env, hModule, "SCardControl132"); #endif // __APPLE__ +#endif } diff -durN -x '*.orig' jdk8u-jdk8u66-b02.orig/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h jdk8u-jdk8u66-b02/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h --- jdk8u-jdk8u66-b02.orig/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h 2015-07-23 16:17:35.000000000 +0200 +++ jdk8u-jdk8u66-b02/jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.h 2015-09-18 13:19:49.000000000 +0200 @@ -23,6 +23,8 @@ * questions. */ +#ifndef USE_SYSTEM_LIBPCSCLITE + typedef LONG (*FPTR_SCardEstablishContext)(ULONG dwScope, const void *pvReserved1, const void *pvReserved2, @@ -110,3 +112,41 @@ extern FPTR_SCardBeginTransaction scardBeginTransaction; extern FPTR_SCardEndTransaction scardEndTransaction; extern FPTR_SCardControl scardControl; + +#else + +#define CALL_SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext) \ + (SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext)) + +#define CALL_SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols) \ + (SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols)) + +#define CALL_SCardDisconnect(hCard, dwDisposition) \ + (SCardDisconnect(hCard, dwDisposition)) + +#define CALL_SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen) \ + (SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen)) + +#define CALL_SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders) \ + (SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders)) + +#define CALL_SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \ + pioRecvPci, pbRecvBuffer, pcbRecvLength) \ + (SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \ + pioRecvPci, pbRecvBuffer, pcbRecvLength)) + +#define CALL_SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders) \ + (SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders)) + +#define CALL_SCardBeginTransaction(hCard) \ + (SCardBeginTransaction(hCard)) + +#define CALL_SCardEndTransaction(hCard, dwDisposition) \ + (SCardEndTransaction(hCard, dwDisposition)) + +#define CALL_SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \ + pbRecvBuffer, pcbRecvLength, lpBytesReturned) \ + (SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \ + pbRecvBuffer, pcbRecvLength, lpBytesReturned)) + +#endif