Try to fix build on older Ubuntus etc.
authorCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2018 13:15:37 +0000 (13:15 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2018 13:15:37 +0000 (13:15 +0000)
src/lib/internet.cc
wscript

index 1e8c5d8e9e19dcdb2c4af155ca29ecdfec3c781c..67f6ed2bc8a71dc42f7e9975fd6fe0102963f0fc 100644 (file)
@@ -79,6 +79,12 @@ get_from_zip_url (string url, string file, bool pasv, function<void (boost::file
 
        /* Open the ZIP file and read `file' out of it */
 
+#ifdef DCPOMATIC_HAVE_ZIP_SOURCE_T
+       /* This is the way to do it with newer versions of libzip, and is required on Windows.
+          The zip_source_t API is missing in the libzip versions shipped with Ubuntu 14.04,
+          Centos 6, Centos 7, Debian 7 and Debian 8.
+       */
+
        FILE* zip_file = fopen_boost (temp_zip.file (), "rb");
        if (!zip_file) {
                return optional<string> (_("Could not open downloaded ZIP file"));
@@ -94,6 +100,10 @@ get_from_zip_url (string url, string file, bool pasv, function<void (boost::file
                return optional<string> (_("Could not open downloaded ZIP file"));
        }
 
+#else
+       struct zip* zip = zip_open (temp_zip.c_str(), 0, 0);
+#endif
+
        struct zip_file* file_in_zip = zip_fopen (zip, file.c_str(), 0);
        if (!file_in_zip) {
                return optional<string> (_("Unexpected ZIP file contents"));
diff --git a/wscript b/wscript
index f10692a16728edc835adb57731ef98ecb569b9b6..1bb72b6f515c9fc904acbd738653c0c3ab42235b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -269,6 +269,15 @@ def configure(conf):
 
     # libzip
     conf.check_cfg(package='libzip', args='--cflags --libs', uselib_store='ZIP', mandatory=True)
+    conf.check_cxx(fragment="""
+                            #include <zip.h>
+                            int main() { zip_source_t* foo; }
+                            """,
+                   mandatory=False,
+                   msg="Checking for zip_source_t",
+                   uselib="ZIP",
+                   define_name='DCPOMATIC_HAVE_ZIP_SOURCE_T'
+                   )
 
     # fontconfig
     conf.check_cfg(package='fontconfig', args='--cflags --libs', uselib_store='FONTCONFIG', mandatory=True)