Add support for FreeBSD
authorJonathan Dieter <jdieter@gmail.com>
Sat, 26 Sep 2020 23:08:57 +0000 (00:08 +0100)
committerJonathan Dieter <jdieter@gmail.com>
Sat, 26 Sep 2020 23:29:05 +0000 (00:29 +0100)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
meson.build
src/lib/index/index_read.c
src/unzck.c
src/zck.c
src/zck_dl.c
src/zck_gen_zdict.c
test/copy_chunks.c

index a705d5ac762b929dbafdbac4ab109add25a61624..5101fda68d4c386c8caaaaf377353b1b8fd26639 100644 (file)
@@ -1,16 +1,22 @@
-project('zck', 'c',
-        version : '1.1.6',
-        meson_version : '>=0.44.0',
-        default_options : ['c_std=gnu99'])
+project(
+    'zck', 'c',
+    version : '1.1.6',
+    meson_version : '>=0.44.0',
+    default_options : ['c_std=gnu99']
+)
 
 so_version = '1'
 
 common_cflags = [
-  '-Wunused-result',
+    '-Wunused-result',
 ]
 cc = meson.get_compiler('c')
 add_project_arguments(cc.get_supported_arguments(common_cflags), language : 'c')
 
+if build_machine.system() == 'freebsd'
+    add_project_arguments('-DFREEBSD', language : 'c')
+endif
+
 if get_option('with-zstd') == 'disabled'
     zstd_dep = dependency('', required : false)
 else
@@ -22,7 +28,7 @@ endif
 
 curl_dep = dependency('libcurl')
 
-if not cc.links('#include <argp.h>\nstatic error_t parse_opt (int key, char *arg, struct argp_state *state) { argp_usage(state); }; void main() {}')
+if build_machine.system() == 'freebsd' or not cc.links('#include <argp.h>\nstatic error_t parse_opt (int key, char *arg, struct argp_state *state) { argp_usage(state); }; void main() {}')
     argplib = cc.find_library('argp')
 else
     argplib = dependency('', required : false)
@@ -46,17 +52,19 @@ if not get_option('coverity')
 endif
 
 pkg_mod = import('pkgconfig')
-pkg_mod.generate(libraries : zcklib,
-                 version : meson.project_version(),
-                 name : 'libzck',
-                 filebase : 'zck',
-                 description : 'A library for generating easy-to-delta files.')
+pkg_mod.generate(
+    libraries : zcklib,
+    version : meson.project_version(),
+    name : 'libzck',
+    filebase : 'zck',
+    description : 'A library for generating easy-to-delta files.'
+)
 
 install_man([
-  'doc/unzck.1',
-  'doc/zck.1',
-  'doc/zck_delta_size.1',
-  'doc/zck_gen_zdict.1',
-  'doc/zck_read_header.1',
-  'doc/zckdl.1',
+    'doc/unzck.1',
+    'doc/zck.1',
+    'doc/zck_delta_size.1',
+    'doc/zck_gen_zdict.1',
+    'doc/zck_read_header.1',
+    'doc/zckdl.1',
 ])
index 6d8e49fda690473c5b189b719fa7024a9bb22550..c6ee98bdc141fc44f2d990ca849561e2d1b1a943 100644 (file)
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
+#ifdef FREEBSD
+#include <sys/endian.h>
+#else
 #include <endian.h>
+#endif
 #include <zck.h>
 
 #include "zck_private.h"
index 01eff6f49d9c852fa01681268eb3a510ea08a617..7cfe9e14583ad37d91eb980886e24def18c97a1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 Jonathan Dieter <jdieter@gmail.com>
+ * Copyright 2018, 2020 Jonathan Dieter <jdieter@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <unistd.h>
 #include <argp.h>
 #include <zck.h>
index 84231b17beefce9d18fd4fa5e2d8e53940c62b0e..854591cfdeb68dd49a747d151a631458f5e8318a 100644 (file)
--- a/src/zck.c
+++ b/src/zck.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 Jonathan Dieter <jdieter@gmail.com>
+ * Copyright 2018, 2020 Jonathan Dieter <jdieter@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <unistd.h>
 #include <argp.h>
 #include <zck.h>
index 045f08fc506d007a0d0dccde477da9f0885fe150..b19471ef7f8310cd0384a5a686b10859335489cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 Jonathan Dieter <jdieter@gmail.com>
+ * Copyright 2018, 2020 Jonathan Dieter <jdieter@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -34,6 +34,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <unistd.h>
 #include <errno.h>
 #include <argp.h>
index 030f09a63b4a430106f377986c4ac5f596df3e2d..0263eea35c3af335d4013e8822cc9693dc1e98b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 Jonathan Dieter <jdieter@gmail.com>
+ * Copyright 2018, 2020 Jonathan Dieter <jdieter@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <argp.h>
index ad8f2fb7a07e1dbac0b1a3541eea4f50a49b438e..111132c65c0b2901b1a5b89a200de2df1f00db73 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 Jonathan Dieter <jdieter@gmail.com>
+ * Copyright 2018, 2020 Jonathan Dieter <jdieter@gmail.com>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 #include <errno.h>
 #include <zck.h>
 #include <libgen.h>