summaryrefslogtreecommitdiff
path: root/vere/ext/natpmp
diff options
context:
space:
mode:
Diffstat (limited to 'vere/ext/natpmp')
-rw-r--r--vere/ext/natpmp/build.zig45
-rw-r--r--vere/ext/natpmp/build.zig.zon15
2 files changed, 60 insertions, 0 deletions
diff --git a/vere/ext/natpmp/build.zig b/vere/ext/natpmp/build.zig
new file mode 100644
index 0000000..1dfe1ba
--- /dev/null
+++ b/vere/ext/natpmp/build.zig
@@ -0,0 +1,45 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const t = target.result;
+ const optimize = b.standardOptimizeOption(.{});
+
+ const lib = b.addStaticLibrary(.{
+ .name = "natpmp",
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const dep_c = b.dependency("natpmp", .{
+ .target = target,
+ .optimize = optimize,
+ });
+
+ lib.addIncludePath(dep_c.path("include"));
+
+ lib.addCSourceFiles(.{
+ .root = dep_c.path(""),
+ .files = &.{
+ "natpmp.c",
+ "getgateway.c",
+ "wingettimeofday.c",
+ },
+ .flags = &.{
+ "-fno-sanitize=all",
+ },
+ });
+
+ lib.installHeader(dep_c.path("natpmp.h"), "natpmp.h");
+ lib.installHeader(dep_c.path("getgateway.h"), "getgateway.h");
+ lib.installHeader(dep_c.path("natpmp_declspec.h"), "natpmp_declspec.h");
+
+ if (t.os.tag == .windows and t.cpu.arch == .x86_64) {
+ lib.root_module.addCMacro("WIN32", "");
+ lib.root_module.addCMacro("NATPMP_STATICLIB", "");
+ lib.root_module.addCMacro("ENABLE_STRNATPMPERR", "");
+ }
+
+ lib.linkLibC();
+ b.installArtifact(lib);
+}
diff --git a/vere/ext/natpmp/build.zig.zon b/vere/ext/natpmp/build.zig.zon
new file mode 100644
index 0000000..30e5682
--- /dev/null
+++ b/vere/ext/natpmp/build.zig.zon
@@ -0,0 +1,15 @@
+.{
+ .name = .natpmp,
+ .fingerprint = 0x1794aa3995c13962,
+ .version = "0.0.1",
+ .dependencies = .{
+ .natpmp = .{
+ .url = "https://mirrors.wikimedia.org/ubuntu/ubuntu/pool/main/libn/libnatpmp/libnatpmp_20230423.orig.tar.gz",
+ // .url = "https://debian.mirror.root.lu/debian/pool/main/libn/libnatpmp/libnatpmp_20230423.orig.tar.gz",
+ .hash = "N-V-__8AAKudAQA_d3eW8d8dskxBlLzGBg0qe-4u6ohSfCM2",
+ },
+ },
+ .paths = .{
+ "",
+ },
+}