Skip to content

Commit cd7dec8

Browse files
raphael-proustygrek
authored andcommitted
discover: use ARGN instead of custom call to pkgconfig
1 parent 7fc1e88 commit cd7dec8

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

config/discover.ml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -397,28 +397,20 @@ let dynamic over libs =
397397
let (_over,libs) = List.partition (fun l -> List.mem l over) libs in
398398
(if over <> [] then ["-Wl,--push-state"; "-Wl,-Bdynamic"] @ over @ ["-Wl,--pop-state"] else []) @ libs
399399

400-
(* basically Pkg_config.query_expr_err with --static and no smartness finding pkg-config itself (it is up to the host owner to set it up properly) *)
401-
let pkg_config ~package ?(expr=package) c =
402-
let open C in
403-
let run args =
404-
Flags.extract_blank_separated_words @@ String.trim @@ Process.run_capture_exn c "pkg-config" @@ [ "--print-errors"] @ args @ [ package ]
405-
in
406-
match Process.run c "pkg-config" [ "--print-errors"; expr ] with
407-
| { exit_code = 0; _ } -> Ok { Pkg_config.libs = run ["--static"; "--libs"]; cflags = run ["--static"; "--cflags"] }
408-
| { stderr; _ } -> Error stderr
409-
410400
let main c =
411401
let cflags, libs =
412402
match C.ocaml_config_var c "ccomp_type" with
413403
| Some "cc" ->
414404
let {C.Pkg_config.cflags; libs} =
415405
match C.Pkg_config.get c with
416406
| None -> { cflags = []; C.Pkg_config.libs = [ "-lcurl" ]}
417-
| Some _pc ->
418-
(match pkg_config c ~package:"libcurl" ~expr:"libcurl >= 7.28.0" with
419-
(* static sasl is unusable (requires a lot of dependencies), p11-kit doesn't provide static lib *)
420-
(* TODO figure the absence of static lib automatically *)
421-
| Ok c -> { c with libs = dynamic ["-lsasl2";"-lp11-kit"] c.libs }
407+
| Some pc ->
408+
Unix.putenv "PKG_CONFIG_ARGN" "--static";
409+
(match C.Pkg_config.query_expr_err pc ~package:"libcurl" ~expr:"libcurl >= 7.28.0" with
410+
| Ok c ->
411+
(* static sasl is unusable (requires a lot of dependencies), p11-kit doesn't provide static lib *)
412+
(* TODO figure the absence of static lib automatically *)
413+
{ c with libs = dynamic ["-lsasl2";"-lp11-kit"] c.libs }
422414
| Error err -> C.die "%s" err)
423415
in
424416
"-Wall" :: "-Wno-deprecated-declarations" :: cflags, libs

0 commit comments

Comments
 (0)