changeset 2026:d46746607ae0

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 20 Jun 2016 13:48:36 +0200
parents e7e1858d9504
children 8c9426d0a3e2 d108412411e5
files Core/Pkcs11.cpp Resources/CMake/LibP11Configuration.cmake Resources/Patches/libp11-0.4.0.patch
diffstat 3 files changed, 59 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Pkcs11.cpp	Mon Jun 20 13:23:42 2016 +0200
+++ b/Core/Pkcs11.cpp	Mon Jun 20 13:48:36 2016 +0200
@@ -49,11 +49,11 @@
 
 extern "C"
 {
-#include <engine.h>  // This is P11's "engine.h"
+#include <libp11/engine.h>  // This is P11's "engine.h"
+#include <libp11/libp11.h>
 }
 
 #include <openssl/engine.h>
-#include <libp11.h>
 
 
 namespace Orthanc
--- a/Resources/CMake/LibP11Configuration.cmake	Mon Jun 20 13:23:42 2016 +0200
+++ b/Resources/CMake/LibP11Configuration.cmake	Mon Jun 20 13:48:36 2016 +0200
@@ -2,9 +2,29 @@
   SET(LIBP11_SOURCES_DIR ${CMAKE_BINARY_DIR}/libp11-0.4.0)
   SET(LIBP11_URL "www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/beid/libp11-0.4.0.tar.gz")
   SET(LIBP11_MD5 "00b3e41db5be840d822bda12f3ab2ca7")
+ 
+  if (IS_DIRECTORY "${LIBP11_SOURCES_DIR}")
+    set(FirstRun OFF)
+  else()
+    set(FirstRun ON)
+  endif()
+
   DownloadPackage(${LIBP11_MD5} ${LIBP11_URL} "${LIBP11_SOURCES_DIR}")
 
-  include_directories(${LIBP11_SOURCES_DIR}/src)
+  file(COPY
+    ${LIBP11_SOURCES_DIR}/src/engine.h
+    ${LIBP11_SOURCES_DIR}/src/libp11.h
+    DESTINATION ${AUTOGENERATED_DIR}/libp11)
+
+  execute_process(
+    COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Patches/libp11-0.4.0.patch
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    RESULT_VARIABLE Failure
+    )
+
+  if (Failure AND FirstRun)
+    message(FATAL_ERROR "Error while patching libp11")
+  endif()
 
   set(LIBP11_SOURCES 
     #${LIBP11_SOURCES_DIR}/src/eng_front.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/libp11-0.4.0.patch	Mon Jun 20 13:48:36 2016 +0200
@@ -0,0 +1,36 @@
+diff -urEb libp11-0.4.0.orig/src/atfork.c libp11-0.4.0/src/atfork.c
+--- libp11-0.4.0.orig/src/atfork.c	2016-06-20 13:38:43.845575107 +0200
++++ libp11-0.4.0/src/atfork.c	2016-06-20 13:46:52.969575591 +0200
+@@ -25,7 +25,7 @@
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+-#include <atfork.h>
++#include "atfork.h"
+ 
+ #ifdef __sun
+ # pragma fini(lib_deinit)
+diff -urEb libp11-0.4.0.orig/src/engine.h libp11-0.4.0/src/engine.h
+--- libp11-0.4.0.orig/src/engine.h	2016-06-20 13:38:43.845575107 +0200
++++ libp11-0.4.0/src/engine.h	2016-06-20 13:46:27.421575566 +0200
+@@ -29,7 +29,7 @@
+ #define _ENGINE_PKCS11_H
+ 
+ #ifndef _WIN32
+-#include "config.h"
++//#include "config.h"
+ #endif
+ 
+ #include "libp11.h"
+diff -urEb libp11-0.4.0.orig/src/libp11-int.h libp11-0.4.0/src/libp11-int.h
+--- libp11-0.4.0.orig/src/libp11-int.h	2016-06-20 13:38:43.845575107 +0200
++++ libp11-0.4.0/src/libp11-int.h	2016-06-20 13:46:27.421575566 +0200
+@@ -20,7 +20,7 @@
+ #define _LIBP11_INT_H
+ 
+ #ifndef _WIN32
+-#include "config.h"
++//#include "config.h"
+ #endif
+ 
+ #include "libp11.h"