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 :)
This commit is contained in:
Sylvain Beucler 2012-12-16 21:18:29 +01:00
parent 6124d1a06e
commit 5e33afc277
4 changed files with 100 additions and 0 deletions

View File

@ -1596,6 +1596,11 @@ USE_OSGPLUGIN(<plugin2>)
<td id="libxslt-version">1.1.28</td>
<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>

View File

@ -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

42
src/libzip-test.c Normal file
View File

@ -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;
}

32
src/libzip.mk Normal file
View File

@ -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