--- build/gmake.macosx/curl-lib.make	2025-03-29 23:44:23.000000000 +0800
+++ build/gmake.macosx/curl-lib.make	2025-05-17 22:24:36.000000000 +0800
@@ -47,7 +47,7 @@
 TARGETDIR = bin/Release
 TARGET = $(TARGETDIR)/libcurl-lib.a
 OBJDIR = obj/Release/curl-lib
-DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DLUA_STATICLIB -DNDEBUG -DBUILDING_LIBCURL -DCURL_STATICLIB -DHTTP_ONLY -DUSE_ZLIB -DUSE_SECTRANSP
+DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DLUA_STATICLIB -DNDEBUG -DBUILDING_LIBCURL -DCURL_STATICLIB -DHTTP_ONLY -DUSE_ZLIB -DUSE_MBEDTLS -D_DARWIN_C_SOURCE -DCURL_HIDDEN_SYMBOLS -DCURL_CA_BUNDLE=\"@PREFIX@/share/curl/curl-ca-bundle.crt\" -DCURL_CA_PATH=\"@PREFIX@/share/curl\"
 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -w
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 -w -fno-stack-protector
 
@@ -55,7 +55,7 @@
 TARGETDIR = bin/Debug
 TARGET = $(TARGETDIR)/libcurl-lib.a
 OBJDIR = obj/Debug/curl-lib
-DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DLUA_STATICLIB -D_DEBUG -DBUILDING_LIBCURL -DCURL_STATICLIB -DHTTP_ONLY -DUSE_ZLIB -DUSE_SECTRANSP
+DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DLUA_STATICLIB -D_DEBUG -DBUILDING_LIBCURL -DCURL_STATICLIB -DHTTP_ONLY -DUSE_ZLIB -DUSE_MBEDTLS -D_DARWIN_C_SOURCE -DCURL_HIDDEN_SYMBOLS -DCURL_CA_BUNDLE=\"@PREFIX@/share/curl/curl-ca-bundle.crt\" -DCURL_CA_PATH=\"@PREFIX@/share/curl\"
 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -w
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -w
 
--- build/gmake.macosx/mbedtls-lib.make	2025-03-29 23:44:23.000000000 +0800
+++ build/gmake.macosx/mbedtls-lib.make	2025-05-17 22:33:47.000000000 +0800
@@ -48,7 +48,7 @@
 TARGET = $(TARGETDIR)/libmbedtls-lib.a
 OBJDIR = obj/Release/mbedtls-lib
 DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DCURL_STATICLIB -DLUA_STATICLIB -DNDEBUG
-ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -w
+ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=gnu99 -O3 -w
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 -w -fno-stack-protector
 
 else ifeq ($(config),debug)
@@ -56,7 +56,7 @@
 TARGET = $(TARGETDIR)/libmbedtls-lib.a
 OBJDIR = obj/Debug/mbedtls-lib
 DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DCURL_STATICLIB -DLUA_STATICLIB -D_DEBUG
-ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -w
+ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=gnu99 -g -w
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -w
 
 endif

--- build/gmake.macosx/Makefile	2025-03-29 23:44:23.000000000 +0800
+++ build/gmake.macosx/Makefile	2025-05-17 23:01:45.000000000 +0800
@@ -44,7 +44,7 @@
 
 contrib: curl-lib lua-lib luashim-lib mbedtls-lib zip-lib zlib-lib
 
-Premake5: lua-lib zip-lib zlib-lib curl-lib
+Premake5: lua-lib zip-lib zlib-lib curl-lib mbedtls-lib
 ifneq (,$(Premake5_config))
 	@echo "==== Building Premake5 ($(Premake5_config)) ===="
 	@${MAKE} --no-print-directory -C . -f Premake5.make config=$(Premake5_config)

--- premake5.lua	2025-03-29 23:44:23.000000000 +0800
+++ premake5.lua	2025-05-17 23:08:07.000000000 +0800
@@ -348,19 +348,16 @@
 		filter "system:linux or hurd"
 			links       { "dl", "rt" }
 
-		filter { "system:not windows", "system:not macosx", "options:curl-src=contrib" }
+		filter { "system:not windows", "options:curl-src=contrib" }
 			links       { "mbedtls-lib" }
 
 		filter "system:macosx"
 			defines     { "LUA_USE_MACOSX" }
-			links       { "CoreServices.framework", "Foundation.framework", "Security.framework", "readline" }
+			links       { "CoreServices.framework", "Foundation.framework", "mbedtls-lib", "readline" }
 
 		filter { "system:linux", "toolset:not cosmocc" }
 			links		{ "uuid" }
 
-		filter { "system:macosx", "action:gmake" }
-			toolset "clang"
-
 		filter { "system:solaris" }
 			links       { "m", "socket", "nsl" }
 
--- build/gmake.macosx/Premake5.make	2025-03-29 23:44:23.000000000 +0800
+++ build/gmake.macosx/Premake5.make	2025-05-17 23:23:46.000000000 +0800
@@ -48,8 +48,8 @@
 DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DCURL_STATICLIB -DLUA_STATICLIB -DNDEBUG -DLUA_USE_MACOSX
 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -Wall -Wextra
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 -Wall -Wextra -fno-stack-protector
-LIBS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a -framework CoreServices -framework Foundation -framework Security -lreadline
-LDDEPS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a
+LIBS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a -framework CoreServices -framework Foundation bin/Release/libmbedtls-lib.a -lreadline
+LDDEPS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a bin/Release/libmbedtls-lib.a
 
 else ifeq ($(config),debug)
 TARGETDIR = ../../bin/debug
@@ -58,8 +58,8 @@
 DEFINES += -DPREMAKE_COMPRESSION -DPREMAKE_CURL -DCURL_STATICLIB -DLUA_STATICLIB -D_DEBUG -DLUA_USE_MACOSX
 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
-LIBS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a -framework CoreServices -framework Foundation -framework Security -lreadline
-LDDEPS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a
+LIBS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a -framework CoreServices -framework Foundation bin/Debug/libmbedtls-lib.a -lreadline
+LDDEPS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a bin/Debug/libmbedtls-lib.a
 
 endif
 
--- contrib/curl/premake5.lua	2025-03-29 23:44:23.000000000 +0800
+++ contrib/curl/premake5.lua	2025-05-18 02:39:19.000000000 +0800
@@ -22,21 +22,22 @@
 		defines { "USE_SCHANNEL", "USE_WINDOWS_SSPI" }
 		links { "crypt32", "bcrypt" }
 
-	filter { "system:macosx" }
-		defines { "USE_SECTRANSP" }
-
-	filter { "system:not windows", "system:not macosx" }
+	filter { "system:not windows" }
 		defines { "USE_MBEDTLS" }
 
+	filter { "system:macosx" }
+		defines { "_DARWIN_C_SOURCE" }
+
 	filter { "system:linux or toolset:cosmocc"}
 		defines { "_GNU_SOURCE" }
 
-	filter { "system:linux or bsd or solaris or haiku or toolset:cosmocc" }
+	filter { "system:linux or bsd or macosx or solaris or haiku or toolset:cosmocc" }
 		defines { "CURL_HIDDEN_SYMBOLS" }
 
 		-- find the location of the ca bundle
 		local ca = nil
 		for _, f in ipairs {
+            "@PREFIX@/share/curl/curl-ca-bundle.crt",
 			"/etc/ssl/certs/ca-certificates.crt",
 			"/etc/openssl/certs/ca-certificates.crt",
 			"/etc/pki/tls/certs/ca-bundle.crt",

--- contrib/mbedtls/premake5.lua	2025-03-29 23:44:23.000000000 +0800
+++ contrib/mbedtls/premake5.lua	2025-05-18 02:47:28.000000000 +0800
@@ -2,6 +2,7 @@
 	language    "C"
 	kind        "StaticLib"
 	warnings    "off"
+	buildoptions "-std=gnu99"
 
 	includedirs { 'include' }
 
