diff --git a/configure.ac b/configure.ac index 33f0469a..9906c160 100644 --- a/configure.ac +++ b/configure.ac @@ -416,8 +416,12 @@ if test "${enable_minidriver}" = "yes"; then AC_CHECK_HEADER( [cardmod.h], , - [AC_MSG_ERROR([cardmod.h is not found and required for minidriver])] - ) + [AC_MSG_ERROR([cardmod.h from CNG is required for minidriver])], + [#if defined(__MINGW32__) +#include "${srcdir}/src/minidriver/cardmod-mingw-compat.h" +#endif + ]) + AC_DEFINE([ENABLE_MINIDRIVER], [1], [Enable minidriver support]) fi diff --git a/src/libopensc/Makefile.am b/src/libopensc/Makefile.am index ec49ff4d..1f6d07ae 100644 --- a/src/libopensc/Makefile.am +++ b/src/libopensc/Makefile.am @@ -19,7 +19,7 @@ AM_CPPFLAGS = -DOPENSC_CONF_PATH=\"$(sysconfdir)/opensc.conf\" \ AM_CFLAGS = $(OPENPACE_CFLAGS) $(OPTIONAL_OPENSSL_CFLAGS) $(OPTIONAL_OPENCT_CFLAGS) \ $(OPTIONAL_PCSC_CFLAGS) $(OPTIONAL_ZLIB_CFLAGS) -libopensc_la_SOURCES = \ +libopensc_la_SOURCES_BASE = \ sc.c ctx.c log.c errors.c \ asn1.c base64.c sec.c card.c iso7816.c dir.c ef-atr.c padding.c apdu.c \ simpletlv.c \ @@ -54,8 +54,10 @@ libopensc_la_SOURCES = \ pkcs15-coolkey.c \ pkcs15-dnie.c pkcs15-gids.c pkcs15-iasecc.c pkcs15-jpki.c \ compression.c p15card-helper.c sm.c \ - aux-data.c \ + aux-data.c +libopensc_la_SOURCES = $(libopensc_la_SOURCES_BASE) \ libopensc.exports +libopensc_static_la_SOURCES = $(libopensc_la_SOURCES_BASE) if WIN32 libopensc_la_SOURCES += $(top_builddir)/win32/versioninfo.rc endif @@ -69,6 +71,7 @@ libopensc_la_LIBADD = $(OPENPACE_LIBS) $(OPTIONAL_OPENSSL_LIBS) $(OPTIONAL_OPENC if WIN32 libopensc_la_LIBADD += -lws2_32 endif +libopensc_static_la_LIBADD = $(libopensc_la_LIBADD) libopensc_la_LDFLAGS = $(AM_LDFLAGS) \ -version-info @OPENSC_LT_CURRENT@:@OPENSC_LT_REVISION@:@OPENSC_LT_AGE@ \ -export-symbols "$(srcdir)/libopensc.exports" \ @@ -79,4 +82,8 @@ if WIN32 mylibdir=$(libdir) mylib_DATA=.libs/@WIN_LIBPREFIX@opensc-@OPENSC_LT_OLDEST@.dll.def .libs/@WIN_LIBPREFIX@opensc-@OPENSC_LT_OLDEST@.dll.def: libopensc.la + +if ENABLE_MINIDRIVER +noinst_LTLIBRARIES = libopensc_static.la +endif endif diff --git a/src/minidriver/Makefile.am b/src/minidriver/Makefile.am index 419a7dc4..6448e7ae 100644 --- a/src/minidriver/Makefile.am +++ b/src/minidriver/Makefile.am @@ -12,12 +12,14 @@ else dist_noinst_DATA = opensc-minidriver.inf minidriver-westcos.reg minidriver-sc-hsm.reg minidriver-feitian.reg endif +AM_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/src opensc_minidriver@LIBRARY_BITNESS@_la_SOURCES = minidriver.c minidriver.exports versioninfo-minidriver.rc opensc_minidriver@LIBRARY_BITNESS@_la_LIBADD = \ - $(top_builddir)/src/libopensc/libopensc.la \ - -lcrypt32 + $(top_builddir)/src/libopensc/libopensc_static.la \ + $(OPTIONAL_OPENSSL_LIBS) \ + -lbcrypt -lcrypt32 -lrpcrt4 opensc_minidriver@LIBRARY_BITNESS@_la_LDFLAGS = $(AM_LDFLAGS) \ -export-symbols "$(srcdir)/minidriver.exports" \ -module -avoid-version -no-undefined diff --git a/src/minidriver/cardmod-mingw-compat.h b/src/minidriver/cardmod-mingw-compat.h new file mode 100644 index 00000000..2bf01a7f --- /dev/null +++ b/src/minidriver/cardmod-mingw-compat.h @@ -0,0 +1,47 @@ +/* + * cardmod-mingw-compat.h: Compat defines to make minidriver with cardmod.h + * buildable under mingw + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define __deref +#define __deref_opt_inout_bcount_part_opt(x,y) +#define __deref_opt_out_bcount(x) +#define __deref_out_bcount(x) +#define __deref_out_bcount_opt(x) +#define __deref_out_ecount(x) +#define __in +#define __in_bcount(x) +#define __in_bcount_opt(x) +#define __in_ecount(x) +#define __in_opt +#define __inout +#define __inout_bcount_full(x) +#define __inout_bcount_opt(x) +#define __out +#define __out_bcount(x) +#define __out_bcount_full(x) +#define __out_bcount_part_opt(x,y) +#define __out_bcount_part_opt(x,y) +#define __out_ecount(x) +#define __out_opt +#define __struct_bcount(x) +#define __success(x) +#define _Printf_format_string_ + +#ifndef NTE_BUFFER_TOO_SMALL +#define NTE_BUFFER_TOO_SMALL _HRESULT_TYPEDEF_(0x80090028) +#endif diff --git a/src/minidriver/minidriver.c b/src/minidriver/minidriver.c index c313246c..807f059a 100644 --- a/src/minidriver/minidriver.c +++ b/src/minidriver/minidriver.c @@ -30,12 +30,13 @@ #pragma managed(push, off) #endif +#define MINGW_HAS_SECURE_API 1 + #include #include #include #include -#include "cardmod.h" #include "libopensc/asn1.h" #include "libopensc/cardctl.h" @@ -54,10 +55,11 @@ #endif #if defined(__MINGW32__) -/* Part of the build svn project in the include directory */ #include "cardmod-mingw-compat.h" #endif +#include "cardmod.h" + /* store the instance given at DllMain when attached to access internal resources */ HINSTANCE g_inst; diff --git a/src/minidriver/versioninfo-minidriver.rc.in b/src/minidriver/versioninfo-minidriver.rc.in index f80f165f..4ff841cc 100644 --- a/src/minidriver/versioninfo-minidriver.rc.in +++ b/src/minidriver/versioninfo-minidriver.rc.in @@ -53,4 +53,8 @@ BEGIN LTEXT "This window will be closed automatically after the PIN has been submitted on the PINPAD or if the PINPAD timeout occurs (in general 30 seconds).",IDC_STATIC,7,46,298,19 END +#ifndef __MINGW32__ IDI_LOGO ICON "..\\..\\win32\\OpenSC.ico" +#else +IDI_LOGO ICON "../../win32/OpenSC.ico" +#endif