diff options
| -rw-r--r-- | project.janet | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/project.janet b/project.janet index 7c6f59a..6bc1246 100644 --- a/project.janet +++ b/project.janet @@ -6,10 +6,39 @@ :repo "https://github.com/CosmicToast/jurl.git" :dependencies ["spork"]) +(declare-source + :source ["jurl"]) + +# --- jurl/native +(defn- execute + [& args] + (try + (let [p (os/spawn args :p {:out :pipe :err :pipe}) + r (os/proc-wait p)] + {:status r + :out (:read (p :out) :all) + :err (:read (p :err) :all)}) + ([e] {:status false + :error e}))) +(def pkgconf (let [bin? |(if ((execute $) :status) $ false) + bin (or (bin? "pkgconf") (bin? "pkg-config"))] + (fn pkgconf + [defval & args] + (if bin + (string/split " " (-> bin + (execute ;args) + (get :out) + (string/trim))) + defval)))) +(def curl-cflags (pkgconf [] + "libcurl" "--cflags" "--static")) +(def curl-ldflags (pkgconf ["-lcurl"] + "libcurl" "--libs" "--static")) + (declare-native :name "jurl/native" - :cflags [;default-cflags] - :lflags [;default-lflags "-lcurl"] + :cflags [;default-cflags ;curl-cflags] + :ldflags [;default-lflags ;curl-ldflags] :headers ["src/jurl.h"] :source ["src/main.c" "src/jurl.c" @@ -21,6 +50,3 @@ "src/mime.c" "src/setopt.c" "src/util.c"]) - -(declare-source - :source ["jurl"]) |
