-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.zig
More file actions
54 lines (51 loc) · 1.46 KB
/
build.zig
File metadata and controls
54 lines (51 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const std = @import("std");
pub fn build(b: *std.Build) void {
const pic = b.option(bool, "pie", "Produce Position Independent Code");
const upstream = b.dependency("zlib", .{});
const lib = b.addLibrary(.{
.name = "z",
.linkage = .static,
.root_module = b.createModule(.{
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.link_libc = true,
.pic = pic,
}),
});
const base_cflags = [_][]const u8{
"-DHAVE_SYS_TYPES_H",
"-DHAVE_STDINT_H",
"-DHAVE_STDDEF_H",
"-DZ_HAVE_UNISTD_H",
};
const cflags_with_pic = base_cflags ++ [_][]const u8{"-fPIC"};
const cflags = if (pic orelse false) &cflags_with_pic else &base_cflags;
lib.root_module.addCSourceFiles(.{
.root = upstream.path(""),
.files = &.{
"adler32.c",
"crc32.c",
"deflate.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"zutil.c",
"compress.c",
"uncompr.c",
"gzclose.c",
"gzlib.c",
"gzread.c",
"gzwrite.c",
},
.flags = cflags,
});
lib.installHeadersDirectory(upstream.path(""), "", .{
.include_extensions = &.{
"zconf.h",
"zlib.h",
},
});
b.installArtifact(lib);
}