void-packages/srcpkgs/mongoose/patches/fix-makefile.patch
Subhaditya Nath d6fe012f93 mongoose: update to 7.6
Closes: #36395 [via git-merge-pr]
2022-03-31 08:13:49 -04:00

59 lines
2.2 KiB
Diff

--- a/Makefile
+++ b/Makefile
@@ -5,5 +5,5 @@ SRCS = mongoose.c test/unit_test.c test/packed_fs.c
OPTS ?= -O3 -g3
INCS ?= -Isrc -I.
-CFLAGS ?= $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) $(EXTRA)
+CFLAGS := $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) $(CFLAGS)
SSL ?= MBEDTLS
CWD ?= $(realpath $(CURDIR))
@@ -10,6 +10,9 @@ CWD ?= $(realpath $(CURDIR))
DOCKER ?= docker run --rm -e Tmp=. -e WINEDEBUG=-all -v $(CWD):$(CWD) -w $(CWD)
VCFLAGS = /nologo /W3 /O2 /I. $(DEFS) $(TFLAGS)
IPV6 ?= 1
+ifneq "$(NO_SANITIZE)" "1"
+SANITIZE = -fsanitize=address,undefined
+endif
ASAN_OPTIONS ?=
EXAMPLES := $(wildcard examples/*)
PREFIX ?= /usr/local
@@ -19,12 +22,12 @@ VERSION ?= $(shell cut -d'"' -f2 src/version.h)
ifeq "$(SSL)" "MBEDTLS"
MBEDTLS ?= /usr
CFLAGS += -DMG_ENABLE_MBEDTLS=1 -I$(MBEDTLS)/include -I/usr/include
-LDFLAGS ?= -L$(MBEDTLS)/lib -lmbedtls -lmbedcrypto -lmbedx509
+LDFLAGS += -L$(MBEDTLS)/lib -lmbedtls -lmbedcrypto -lmbedx509
endif
ifeq "$(SSL)" "OPENSSL"
OPENSSL ?= /usr
CFLAGS += -DMG_ENABLE_OPENSSL=1 -I$(OPENSSL)/include
-LDFLAGS ?= -L$(OPENSSL)/lib -lssl -lcrypto
+LDFLAGS += -L$(OPENSSL)/lib -lssl -lcrypto
endif
all: mg_prefix unamalgamated unpacked test test++ arm examples vc98 vc2017 mingw mingw++ linux linux++ fuzz
@@ -59,7 +62,7 @@ fuzz: fuzzer
$(RUN) ./fuzzer
# make CC=/usr/local/opt/llvm\@8/bin/clang ASAN_OPTIONS=detect_leaks=1
-test: CFLAGS += -DMG_ENABLE_IPV6=$(IPV6) -fsanitize=address,undefined
+test: CFLAGS += -DMG_ENABLE_IPV6=$(IPV6) $(SANITIZE)
test: mongoose.h Makefile $(SRCS)
$(CC) $(SRCS) $(CFLAGS) -coverage $(LDFLAGS) -g -o unit_test
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./unit_test
@@ -108,10 +111,12 @@ linux++: CC = g++
linux++: WARN += -Wno-missing-field-initializers
linux++: linux
-linux-libs: CFLAGS += -fPIC
-linux-libs: mongoose.o
- $(CC) mongoose.o $(LDFLAGS) -shared -o libmongoose.so.$(VERSION)
+.PHONY: linux-libs
+linux-libs: libmongoose.a libmongoose.so.$(VERSION)
+libmongoose.a: mongoose.o
$(AR) rcs libmongoose.a mongoose.o
+libmongoose.so.$(VERSION): mongoose.o
+ $(CC) mongoose.o $(LDFLAGS) -shared -o libmongoose.so.$(VERSION)
install: linux-libs
install -Dm644 libmongoose.a libmongoose.so.$(VERSION) $(DESTDIR)$(PREFIX)/lib