changeset 2998:d4a25746b7d7 draft

Add build file for libzip - Build against latest stable release - Cross-compilation broke somewhere between 0.9 and 0.10, we could recommend http://www.sourceware.org/autobook/autobook/autobook_255.html to upstream so they fix 'zip.h'. Provided quick patch meanwhile. - Added 'Requires: zlib' in the pkg-config file, we could suggest the improvement to upstream - _UPDATE rule implemented - Test case included Coded while hacking GNU FreeDink :)
author Sylvain Beucler <beuc@beuc.net>
date Sun, 16 Dec 2012 21:18:29 +0100
parents 5dfe10a45b1b
children 48dc0367d605
files index.html src/libzip-1-static_build.patch src/libzip-test.c src/libzip.mk
diffstat 4 files changed, 100 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/index.html
+++ b/index.html
@@ -1597,6 +1597,11 @@
         <td id="libxslt-website"><a href="http://xmlsoft.org/XSLT/">libxslt</a></td>
     </tr>
     <tr>
+        <td id="libzip-package">libzip</td>
+        <td id="libzip-version">0.10.1</td>
+        <td id="libzip-website"><a href="http://www.nih.at/libzip/">libzip</a></td>
+    </tr>
+    <tr>
         <td id="llvm-package">llvm</td>
         <td id="llvm-version">3.1</td>
         <td id="llvm-website"><a href="http://llvm.org/">llvm</a></td>
new file mode 100644
--- /dev/null
+++ b/src/libzip-1-static_build.patch
@@ -0,0 +1,21 @@
+This file is part of MXE.
+See index.html for further information.
+
+This is a quick&dirty fix.
+
+The bug is being discussed at
+http://www.nih.at/listarchive/libzip-discuss/msg00304.html
+
+--- a/lib/zip.h	2012-03-15 10:28:05.000000000 +0100
++++ b/lib/zip.h	2012-12-18 02:05:31.416621709 +0100
+@@ -37,8 +37,8 @@
+ 
+ 
+ #ifndef ZIP_EXTERN
+-#ifdef _WIN32
+-#define ZIP_EXTERN __declspec(dllimport)
++#ifdef _MSC_VER
++#define ZIP_EXTERN __declspec(dllexport)
+ #else
+ #define ZIP_EXTERN
+ #endif
new file mode 100644
--- /dev/null
+++ b/src/libzip-test.c
@@ -0,0 +1,42 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <zip.h>
+#include <stdlib.h>
+
+/* Adapted from freedink/src/SDL_rwops_libzip.c */
+int main(int argc, char* argv[])
+{
+    struct zip* zarchive;
+    int errorp = 0;
+
+    (void)argc;
+    (void)argv;
+
+    zarchive = zip_open("idontexist.zip", ZIP_CHECKCONS, &errorp);
+    if (errorp != 0)
+        {
+            char *errorbuf = NULL;
+            int len = 1;
+            errorbuf = malloc(len);
+            len = zip_error_to_str(errorbuf, len, errorp, errno);
+            errorbuf = realloc(errorbuf, len + 1);
+            len = zip_error_to_str(errorbuf, len, errorp, errno);
+            fprintf(stderr, "zip_open: %s\n", errorbuf);
+            free(errorbuf);
+        }
+    else
+        {
+            struct zip_file* zfile;
+            zfile = zip_fopen(zarchive, "fichier.txt", 0);
+            if (zfile == NULL)
+                {
+                    fprintf(stderr, "zip_open: %s\n", zip_strerror(zarchive));
+                    zip_close(zarchive);
+                }
+        }
+
+    return 0;
+}
new file mode 100644
--- /dev/null
+++ b/src/libzip.mk
@@ -0,0 +1,32 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libzip
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 04be811a1919e1063a1f5210671181b7b5416d45
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_URL      := http://www.nih.at/libzip/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc zlib
+
+define $(PKG)_UPDATE
+    wget -q -O- 'http://www.nih.at/libzip/' | \
+    $(SED) -n 's,.*libzip-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+# TODO: send a patch upstream
+    echo 'Requires: zlib' >> '$(1)/libzip.pc.in'
+
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libzip.exe' \
+        `'$(TARGET)-pkg-config' libzip --cflags --libs`
+endef