From 6a34b6ef964676f4b000a452ab6894b3f49a0f1e Mon Sep 17 00:00:00 2001 From: Trevor Bentley Date: Thu, 16 Nov 2017 16:14:02 +0100 Subject: [PATCH] Fix cross-compiling for mingw64 --- lib/tests/api.c | 4 ++++ windows.mk | 10 +++++++++- ykcs11/tests/ykcs11_tests.c | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tests/api.c b/lib/tests/api.c index 3dc359a..b36f0ff 100644 --- a/lib/tests/api.c +++ b/lib/tests/api.c @@ -38,6 +38,10 @@ #include +#ifdef __MINGW32__ +#define dprintf(fd, ...) fprintf(stdout, __VA_ARGS__) +#endif + int destruction_confirmed(void); // only defined in libcheck 0.11+ (linux distros still shipping 0.10) diff --git a/windows.mk b/windows.mk index baf29c0..5dfc9db 100644 --- a/windows.mk +++ b/windows.mk @@ -27,6 +27,7 @@ PACKAGE=yubico-piv-tool OPENSSLVERSION=1.0.2l +CHECKVERSION=0.12.0 all: usage 32bit 64bit @@ -55,11 +56,18 @@ doit: rm $(PWD)/tmp$(ARCH)/root/bin/c_rehash && \ rm -rf $(PWD)/tmp$(ARCH)/root/lib/engines/ && \ cd .. && \ + cp ../check-$(CHECKVERSION).tar.gz . || \ + curl -L -O "https://github.com/libcheck/check/releases/download/$(CHECKVERSION)/check-$(CHECKVERSION).tar.gz" && \ + tar xfa check-$(CHECKVERSION).tar.gz && \ + cd check-$(CHECKVERSION) && \ + CC=$(HOST)-gcc PKG_CONFIG_PATH=$(PWD)/tmp$(ARCH)/root/lib/pkgconfig ./configure --host=$(HOST) --build=x86_64-unknown-linux-gnu --prefix=$(PWD)/tmp$(ARCH)/root --disable-subunit --enable-static --disable-shared && \ + make all install && \ + cd .. && \ cp ../$(PACKAGE)-$(VERSION).tar.gz . && \ tar xfa $(PACKAGE)-$(VERSION).tar.gz && \ cd $(PACKAGE)-$(VERSION)/ && \ CC=$(HOST)-gcc PKG_CONFIG_PATH=$(PWD)/tmp$(ARCH)/root/lib/pkgconfig lt_cv_deplibs_check_method=pass_all ./configure --host=$(HOST) --build=x86_64-unknown-linux-gnu --prefix=$(PWD)/tmp$(ARCH)/root LDFLAGS=-L$(PWD)/tmp$(ARCH)/root/lib CPPFLAGS=-I$(PWD)/tmp$(ARCH)/root/include && \ - make install $(CHECK) && \ + WINEPATH="/usr/$(HOST)/lib/" make install $(CHECK) && \ rm $(PWD)/tmp$(ARCH)/root/lib/*.la && \ rm -rf $(PWD)/tmp$(ARCH)/root/lib/pkgconfig/ && \ cp COPYING $(PWD)/tmp$(ARCH)/root/licenses/$(PACKAGE).txt && \ diff --git a/ykcs11/tests/ykcs11_tests.c b/ykcs11/tests/ykcs11_tests.c index 53c26cd..5f19d81 100644 --- a/ykcs11/tests/ykcs11_tests.c +++ b/ykcs11/tests/ykcs11_tests.c @@ -42,6 +42,10 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpointer-sign" +#ifdef __MINGW32__ +#define dprintf(fd, ...) fprintf(stdout, __VA_ARGS__) +#endif + void dump_hex(const unsigned char *buf, unsigned int len, FILE *output, int space) { unsigned int i; for (i = 0; i < len; i++) {