Преглед на файлове

add libp11 0.4.13 (#6550)

* add libp11 0.4.13

* fixup

* fixup

* fixup

* re

* config.h.in

* re

* re

* limit wasm

* elseif is_plat("linux", "bsd", "android") then add_defines("HAVE_PTHREAD")

* fixup

* limit to !wasm and !iphoneos, try pss "_POSIX_C_SOURCE=200809L"

* lower to 199506

* Update xmake.lua

* Test for _DEFAULT_SOURCE
Saikari преди 4 месеца
родител
ревизия
e1649a444e
променени са 3 файла, в които са добавени 219 реда и са изтрити 0 реда
  1. 124 0
      packages/l/libp11/port/config.h.in
  2. 73 0
      packages/l/libp11/port/xmake.lua
  3. 22 0
      packages/l/libp11/xmake.lua

+ 124 - 0
packages/l/libp11/port/config.h.in

@@ -0,0 +1,124 @@
+/* src/config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* Default PKCS#11 module. */
+#undef DEFAULT_PKCS11_MODULE
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* Have PTHREAD_PRIO_INHERIT. */
+#undef HAVE_PTHREAD_PRIO_INHERIT
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <utmp.h> header file. */
+#undef HAVE_UTMP_H
+
+/* Define to 1 if you have the 'X509_get0_notAfter' function. */
+#undef HAVE_X509_GET0_NOTAFTER
+
+/* Define to 1 if you have the 'X509_get0_notBefore' function. */
+#undef HAVE_X509_GET0_NOTBEFORE
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+   your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
+#undef STDC_HEADERS
+
+/* Define if you are on Cygwin */
+#undef USE_CYGWIN
+
+/* Version number of package */
+#undef VERSION
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif

+ 73 - 0
packages/l/libp11/port/xmake.lua

@@ -0,0 +1,73 @@
+add_rules("mode.debug", "mode.release")
+set_languages("c11")
+add_requires("openssl")
+
+includes("@builtin/check")
+
+configvar_check_cincludes("HAVE_DLFCN_H", "dlfcn.h", {default = 0})
+configvar_check_cincludes("HAVE_ERRNO_H", "errno.h", {default = 0})
+configvar_check_cincludes("HAVE_FCNTL_H", "fcntl.h", {default = 0})
+configvar_check_cincludes("HAVE_GETOPT_H", "getopt.h", {default = 0})
+configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h", {default = 0})
+configvar_check_cincludes("HAVE_LOCALE_H", "locale.h", {default = 0})
+configvar_check_cincludes("HAVE_MALLOC_H", "malloc.h", {default = 0})
+
+configvar_check_cincludes("HAVE_STDINT_H", "stdint.h", {default = 0})
+configvar_check_cincludes("HAVE_STDIO_H", "stdio.h", {default = 0})
+configvar_check_cincludes("HAVE_STDLIB_H", "stdlib.h", {default = 0})
+configvar_check_cincludes("HAVE_STRINGS_H", "strings.h", {default = 0})
+configvar_check_cincludes("HAVE_STRING_H", "string.h", {default = 0})
+configvar_check_cincludes("HAVE_SYS_STAT_H", "sys/stat.h", {default = 0})
+configvar_check_cincludes("HAVE_SYS_TIME_H", "sys/time.h", {default = 0})
+configvar_check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h", {default = 0})
+configvar_check_cincludes("HAVE_SYS_WAIT_H", "sys/wait.h", {default = 0})
+configvar_check_cincludes("HAVE_UNISTD_H", "unistd.h", {default = 0})
+configvar_check_cincludes("HAVE_UTMP_H", "utmp.h", {default = 0})
+
+configvar_check_cfuncs("HAVE_X509_GET0_NOTBEFORE", "X509_get0_notBefore", {includes = "openssl/x509.h", default = 0})
+configvar_check_cfuncs("HAVE_X509_GET0_NOTAFTER", "X509_get0_notAfter", {includes = "openssl/x509.h", default = 0})
+
+if is_plat("android") then
+    configvar_check_cfuncs("HAVE_PTHREAD", "pthread_create", {includes = "pthread.h"})
+else
+    configvar_check_links("HAVE_PTHREAD", "pthread")
+end
+
+configvar_check_csnippets("HAVE_PTHREAD_PRIO_INHERIT", [[
+#include <pthread.h>
+void test() {
+    int i = PTHREAD_PRIO_INHERIT;
+    return i; 
+}]])
+
+target("libp11")
+    set_kind("$(kind)")
+
+    add_packages("openssl")
+
+    set_configdir("src")
+    add_configfiles("src/(config.h.in)", {filename = "config.h"})
+
+    add_includedirs("src")
+    add_files("src/*.c")
+    add_headerfiles("src/libp11.h", "src/p11_err.h", "src/util.h")
+
+    if is_plat("windows", "mingw", "cygwin") then
+        add_defines("WIN32_LEAN_AND_MEAN", "_WIN32_WINNT=0x0600")
+        add_syslinks("ws2_32", "user32", "advapi32", "crypt32", "gdi32")
+        if is_plat("cygwin") then
+            add_defines("USE_CYGWIN")
+        end
+    elseif is_plat("linux", "bsd", "android") then
+        add_defines("HAVE_PTHREAD", "_DEFAULT_SOURCE", "_POSIX_C_SOURCE=200809L")
+        add_syslinks("pthread", "dl")
+    end
+
+    if is_plat("windows") and is_kind("shared") then
+        add_rules("utils.symbols.export_all")
+    end
+
+    if is_plat("windows", "mingw") then
+        add_configfiles("src/libp11.rc.in")
+        add_configfiles("src/pkcs11.rc.in")
+    end

+ 22 - 0
packages/l/libp11/xmake.lua

@@ -0,0 +1,22 @@
+package("libp11")
+    set_homepage("https://github.com/OpenSC/libp11")
+    set_description("PKCS#11 wrapper library")
+    set_license("LGPL-2.1")
+
+    add_urls("https://github.com/OpenSC/libp11/archive/refs/tags/libp11-$(version).tar.gz",
+             "https://github.com/OpenSC/libp11.git")
+
+    add_versions("0.4.13", "5e8e258c6a8e33155c3a2bd2bd7d12a758f82b7bda1f92e8b77075d16edc9889")
+
+    add_deps("openssl")
+
+    on_install("!wasm and !iphoneos" , function (package)
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "src/config.h.in")
+        io.gsub("src/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("PKCS11_CTX_new", {includes = "libp11.h"}))
+    end)