diff --git a/.gitignore b/.gitignore index c1fe288..fc9cd6e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ *.so *.cmt *.cmti +.merlin +config/.merlin test/minigzip test/minizip test/testzlib diff --git a/config/discover.ml b/config/discover.ml new file mode 100644 index 0000000..04fc75b --- /dev/null +++ b/config/discover.ml @@ -0,0 +1,21 @@ +module C = Configurator.V1 + +let () = +C.main ~name:"zip" (fun c -> + +let stale_gzip : C.Pkg_config.package_conf = { + libs = [ "-lz" ]; + cflags = [] +} in + +let conf = + match C.Pkg_config.get c with + | None -> C.die "'pkg-config' missing" + | Some pc -> + match (C.Pkg_config.query pc ~package:"zlib") with + | None -> stale_gzip + | Some deps -> deps + in + + C.Flags.write_sexp "c_flags.sexp" conf.cflags; + C.Flags.write_sexp "c_library_flags.sexp" conf.libs) diff --git a/config/dune b/config/dune new file mode 100644 index 0000000..21a5f9a --- /dev/null +++ b/config/dune @@ -0,0 +1,3 @@ +(executable + (name discover) + (libraries dune.configurator)) diff --git a/dune b/dune new file mode 100644 index 0000000..78489d2 --- /dev/null +++ b/dune @@ -0,0 +1,18 @@ +(library + (public_name zip) + (synopsis "OCaml ZIP interface") + (wrapped false) + (modules gzip zip zlib) + (libraries stdlib-shims) + (c_names zlibstubs) + (c_flags + (:include c_flags.sexp)) + (c_library_flags + (:include c_library_flags.sexp))) + +(rule + (targets c_flags.sexp c_library_flags.sexp) + (deps + (:discover config/discover.exe)) + (action + (run %{discover}))) diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..b9afc80 --- /dev/null +++ b/dune-project @@ -0,0 +1,26 @@ +(lang dune 1.10) + +(generate_opam_files true) + +(license "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception") + +(authors "Xavier Leroy") + +(maintainers "Cryptosense ") + +(homepage "https://github.com/xavierleroy/camlzip") + +(bug_reports "https://github.com/xavierleroy/camlzip/issues") + +(package + (name zip) + (synopsis + "Provides easy access to compressed files in ZIP, GZIP and JAR format") + (description "Reading and writing zip and gzip files from OCaml.") + (depends + dune-configurator + dune + stdlib-shims + conf-zlib + (ocaml + (>= 4.02.0)))) diff --git a/zip.opam b/zip.opam new file mode 100644 index 0000000..cfa78cb --- /dev/null +++ b/zip.opam @@ -0,0 +1,23 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} +] +maintainer: ["Cryptosense "] +authors: ["Xavier Leroy"] +bug-reports: "https://github.com/xavierleroy/camlzip/issues" +homepage: "https://github.com/xavierleroy/camlzip" +license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" +synopsis: + "Provides easy access to compressed files in ZIP, GZIP and JAR format" +description: "Reading and writing zip and gzip files from OCaml." +depends: [ + "dune-configurator" + "dune" + "stdlib-shims" + "conf-zlib" + "ocaml" {>= "4.02.0"} +]