Skip to content

Commit 6f0889c

Browse files
committed
update generated config header to improve BSD support
1 parent 3587269 commit 6f0889c

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

build.zig

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22

3-
const version: std.SemanticVersion = .{ .major = 8, .minor = 13, .patch = 0 };
3+
const version = std.SemanticVersion.parse(@import("build.zig.zon").version) catch unreachable;
44

55
pub fn build(b: *std.Build) !void {
66
const upstream = b.dependency("curl", .{});
@@ -696,13 +696,18 @@ pub fn build(b: *std.Build) !void {
696696
},
697697
.HAVE_ARPA_INET_H = target.result.os.tag != .windows,
698698
.HAVE_ATOMIC = true,
699-
.HAVE_ACCEPT4 = target.result.os.tag == .linux,
699+
.HAVE_ACCEPT4 = switch (target.result.os.tag) {
700+
.linux => true,
701+
.freebsd => target.result.os.isAtLeast(.freebsd, .{ .major = 10, .minor = 0, .patch = 0 }) orelse false,
702+
.netbsd => target.result.os.isAtLeast(.netbsd, .{ .major = 8, .minor = 0, .patch = 0 }) orelse false,
703+
else => false,
704+
},
700705
.HAVE_FNMATCH = target.result.os.tag != .windows,
701706
.HAVE_BASENAME = true,
702707
.HAVE_BOOL_T = true,
703708
.HAVE_BUILTIN_AVAILABLE = null,
704709
.HAVE_CLOCK_GETTIME_MONOTONIC = target.result.os.tag != .windows,
705-
.HAVE_CLOCK_GETTIME_MONOTONIC_RAW = target.result.os.tag != .windows and target.result.os.tag != .wasi,
710+
.HAVE_CLOCK_GETTIME_MONOTONIC_RAW = target.result.os.tag == .linux or target.result.os.tag.isDarwin(),
706711
.HAVE_CLOSESOCKET = target.result.os.tag == .windows,
707712
.HAVE_CLOSESOCKET_CAMEL = null,
708713
.HAVE_DIRENT_H = true,
@@ -718,13 +723,25 @@ pub fn build(b: *std.Build) !void {
718723
.HAVE_GETADDRINFO_THREADSAFE = target.result.os.tag != .wasi,
719724
.HAVE_GETEUID = target.result.os.tag != .windows and target.result.os.tag != .wasi,
720725
.HAVE_GETPPID = target.result.os.tag != .windows and target.result.os.tag != .wasi,
721-
.HAVE_GETHOSTBYNAME_R = target.result.os.tag != .windows and !target.result.os.tag.isDarwin() and target.result.os.tag != .wasi,
726+
.HAVE_GETHOSTBYNAME_R = switch (target.result.os.tag) {
727+
.linux => true,
728+
.windows, .wasi => false,
729+
.freebsd => target.result.os.isAtLeast(.freebsd, .{ .major = 6, .minor = 2, .patch = 0 }) orelse false,
730+
.dragonfly => target.result.os.isAtLeast(.dragonfly, .{ .major = 2, .minor = 1, .patch = 0 }) orelse false,
731+
else => false,
732+
},
722733
.HAVE_GETHOSTBYNAME_R_3 = null,
723734
.HAVE_GETHOSTBYNAME_R_5 = null,
724-
.HAVE_GETHOSTBYNAME_R_6 = target.result.os.tag != .windows and !target.result.os.tag.isDarwin() and target.result.os.tag != .wasi,
735+
.HAVE_GETHOSTBYNAME_R_6 = switch (target.result.os.tag) {
736+
.linux => true,
737+
.windows, .wasi => false,
738+
.freebsd => target.result.os.isAtLeast(.freebsd, .{ .major = 6, .minor = 2, .patch = 0 }) orelse false,
739+
.dragonfly => target.result.os.isAtLeast(.dragonfly, .{ .major = 2, .minor = 1, .patch = 0 }) orelse false,
740+
else => false,
741+
},
725742
.HAVE_GETHOSTNAME = target.result.os.tag != .wasi,
726743
.HAVE_GETIFADDRS = target.result.os.tag != .windows and target.result.os.tag != .wasi,
727-
.HAVE_GETPASS_R = null,
744+
.HAVE_GETPASS_R = target.result.os.isAtLeast(.netbsd, .{ .major = 7, .minor = 0, .patch = 0 }) orelse false,
728745
.HAVE_GETPEERNAME = target.result.os.tag != .wasi,
729746
.HAVE_GETSOCKNAME = target.result.os.tag != .wasi,
730747
.HAVE_IF_NAMETOINDEX = target.result.os.tag != .windows and target.result.os.tag != .wasi,
@@ -808,11 +825,11 @@ pub fn build(b: *std.Build) !void {
808825
target.result.os.isAtLeast(.linux, .{ .major = 2, .minor = 14, .patch = 0 }),
809826
else => !target.result.os.tag.isDarwin(),
810827
},
811-
.HAVE_FSETXATTR = target.result.os.tag != .windows and !target.result.os.tag.isDarwin() and target.result.os.tag != .wasi,
812-
.HAVE_FSETXATTR_5 = target.result.os.tag != .windows and !target.result.os.tag.isDarwin() and target.result.os.tag != .wasi,
828+
.HAVE_FSETXATTR = target.result.os.tag == .linux or target.result.os.tag == .netbsd,
829+
.HAVE_FSETXATTR_5 = target.result.os.tag == .linux or target.result.os.tag == .netbsd,
813830
.HAVE_FSETXATTR_6 = null,
814831
.HAVE_SETLOCALE = true,
815-
.HAVE_SETMODE = target.result.os.tag == .windows or target.result.os.tag.isDarwin(),
832+
.HAVE_SETMODE = target.result.os.tag == .windows or target.result.os.tag.isBSD(),
816833
.HAVE__SETMODE = target.result.os.tag == .windows,
817834
.HAVE_SETRLIMIT = target.result.os.tag != .wasi,
818835
.HAVE_SETSOCKOPT_SO_NONBLOCK = null,
@@ -821,7 +838,7 @@ pub fn build(b: *std.Build) !void {
821838
.HAVE_SIGNAL = target.result.os.tag != .wasi,
822839
.HAVE_SIGSETJMP = target.result.os.tag != .windows and target.result.os.tag != .wasi,
823840
.HAVE_SNPRINTF = true,
824-
.HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID = true, // TODO
841+
.HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID = target.result.os.tag == .windows, // TODO
825842
.HAVE_SOCKET = target.result.os.tag != .wasi,
826843
.HAVE_PROTO_BSDSOCKET_H = null,
827844
.HAVE_SOCKETPAIR = target.result.os.tag != .windows and target.result.os.tag != .wasi,
@@ -839,13 +856,13 @@ pub fn build(b: *std.Build) !void {
839856
.HAVE_STRUCT_SOCKADDR_STORAGE = true,
840857
.HAVE_STRUCT_TIMEVAL = true,
841858
.HAVE_SYS_EVENTFD_H = target.result.os.tag != .windows and !target.result.os.tag.isDarwin(),
842-
.HAVE_SYS_FILIO_H = target.result.os.tag.isDarwin(),
859+
.HAVE_SYS_FILIO_H = target.result.os.tag.isBSD(),
843860
.HAVE_SYS_IOCTL_H = target.result.os.tag != .windows,
844861
.HAVE_SYS_PARAM_H = true,
845862
.HAVE_SYS_POLL_H = target.result.os.tag != .windows,
846863
.HAVE_SYS_RESOURCE_H = target.result.os.tag != .windows and target.result.os.tag != .wasi,
847864
.HAVE_SYS_SELECT_H = target.result.os.tag != .windows,
848-
.HAVE_SYS_SOCKIO_H = target.result.os.tag.isDarwin(),
865+
.HAVE_SYS_SOCKIO_H = target.result.os.tag.isBSD(),
849866
.HAVE_SYS_STAT_H = true,
850867
.HAVE_SYS_TYPES_H = true,
851868
.HAVE_SYS_UN_H = target.result.os.tag != .windows,
@@ -856,7 +873,7 @@ pub fn build(b: *std.Build) !void {
856873
.HAVE_UTIME = true,
857874
.HAVE_UTIMES = target.result.os.tag != .windows,
858875
.HAVE_UTIME_H = true,
859-
.HAVE_WRITABLE_ARGV = target.result.os.tag != .windows,
876+
.HAVE_WRITABLE_ARGV = target.result.os.tag.isDarwin(),
860877
.HAVE_TIME_T_UNSIGNED = null,
861878
.NEED_REENTRANT = null,
862879
.CURL_OS = b.fmt("\"{s}\"", .{target.result.zigTriple(b.allocator) catch @panic("OOM")}),
@@ -876,7 +893,7 @@ pub fn build(b: *std.Build) !void {
876893
.PACKAGE_VERSION = b.fmt("{f}", .{version}),
877894
.STDC_HEADERS = true,
878895
.USE_ARES = enable_ares,
879-
.USE_THREADS_POSIX = target.result.os.tag != .windows and !target.result.os.tag.isDarwin(),
896+
.USE_THREADS_POSIX = target.result.os.tag != .windows and !target.result.os.tag.isBSD(),
880897
.USE_THREADS_WIN32 = enable_threaded_resolver and target.result.os.tag == .windows,
881898
.USE_GNUTLS = use_gnutls,
882899
.USE_SSLS_EXPORT = use_ssls_export,

0 commit comments

Comments
 (0)