diff options
| author | 2023-04-16 16:08:20 -0400 | |
|---|---|---|
| committer | 2023-04-16 16:08:20 -0400 | |
| commit | 17f9223d14bd7d0a71608eccfd45772df0a3a685 (patch) | |
| tree | 3c0da7c2965ed6ac49a6b66eeb36144724abc277 | |
| parent | meta: prepare 1.3.0 (diff) | |
meta: improve build system
use pkg-config!
the main concern at this point is whether or not adding a "--static" is
safe.
if you don't add "--static", there's no guarantee of static linking.
however, if you do add "--static" but not all of the libraries in
question are available in static form, it will fail to build.
the likely correct way to approach this is to use an env var.
furthermore, I'm not entirely sure as to how/whether the link flags get
passed on to upstream packages.
| -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"]) |
