Skip to content

Commit

Permalink
Merge pull request #157 from sagudev/extract-var-pc
Browse files Browse the repository at this point in the history
Write more variables into zlib.pc
  • Loading branch information
Byron authored Sep 13, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
2 parents 004f3f9 + 929c9a3 commit c19e488
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -137,11 +137,22 @@ fn build_zlib(cfg: &mut cc::Build, target: &str) {
fs::copy("src/zlib/zconf.h", dst.join("include/zconf.h")).unwrap();

fs::create_dir_all(lib.join("pkgconfig")).unwrap();
let zlib_h = fs::read_to_string(dst.join("include/zlib.h")).unwrap();
let version = zlib_h
.lines()
.find(|l| l.contains("ZLIB_VERSION"))
.unwrap()
.split("\"")
.nth(1)
.unwrap();
fs::write(
lib.join("pkgconfig/zlib.pc"),
fs::read_to_string("src/zlib/zlib.pc.in")
.unwrap()
.replace("@prefix@", dst.to_str().unwrap()),
.replace("@prefix@", dst.to_str().unwrap())
.replace("@includedir@", "${prefix}/include")
.replace("@libdir@", "${prefix}/lib")
.replace("@VERSION@", version),
)
.unwrap();

0 comments on commit c19e488

Please sign in to comment.