summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-03-16 06:55:42 -0400
committerTest_User <hax@andrewyu.org>2024-03-16 06:55:42 -0400
commit659f0d647ca27d03815e799f74e1023fa5f3bc25 (patch)
tree1c12847f2689bb334acaec13637cbca7b7c5afea
parent74c0da6f69af63a53fbd01e2c574b48cfaa53826 (diff)
downloadcoupserv-659f0d647ca27d03815e799f74e1023fa5f3bc25.tar.gz
coupserv-659f0d647ca27d03815e799f74e1023fa5f3bc25.zip
backport makefile improvements to current haxserv (from next in-progress haxserv)
-rw-r--r--.gitignore1
-rw-r--r--Makefile56
2 files changed, 52 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index f743c6d..b5805e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ config.c
.*.swp
haxserv
core
+.makeopts
diff --git a/Makefile b/Makefile
index 4ddf248..3ad6141 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,54 @@
#INCLUDEFLAGS =
+CFLAGS += $(INCLUDEFLAGS) -D_REENTRANT -ggdb3 -Wall -Wextra -Wsign-conversion -Wno-unused-parameter $(shell pkg-config gnutls --cflags)
+
+LDFLAGS = -lpthread $(shell pkg-config gnutls --libs)
+
+.makeopts:
+ @printf '%s\n' 'LAST_VERBOSE = 1' > .makeopts
+ @printf '%s\n' 'LAST_COLORIZE = 1' >> .makeopts
+ @printf '%s\n' 'LAST_SAFE_STACK = 0' >> .makeopts
+
+include .makeopts
+
+rebuild = 0
+
+#tabs not allowed :(
+ifneq ($(VERBOSE),)
+ifneq ($(VERBOSE),$(LAST_VERBOSE))
+rebuild = 1
+endif
+else
+VERBOSE = $(LAST_VERBOSE)
+endif
+
+ifneq ($(COLORIZE),)
+ifneq ($(COLORIZE),$(LAST_COLORIZE))
+rebuild = 1
+endif
+else
+COLORIZE = $(LAST_COLORIZE)
+endif
+
+ifneq ($(SAFE_STACK),)
+ifneq ($(SAFE_STACK),$(LAST_SAFE_STACK))
+rebuild = 1
+endif
+else
+SAFE_STACK = $(LAST_SAFE_STACK)
+endif
+
+ifeq ($(rebuild),1)
+$(shell printf '%s%s\n' 'LAST_VERBOSE = ' $(VERBOSE) > .makeopts)
+$(shell printf '%s%s\n' 'LAST_COLORIZE = ' $(COLORIZE) >> .makeopts)
+$(shell printf '%s%s\n' 'LAST_SAFE_STACK = ' $(SAFE_STACK) >> .makeopts)
+
+$(shell $(RM) haxserv *.o)
+endif
+
+DEPS = $(shell $(CC) $(INCLUDEFLAGS) -MM -MT $(1).o $(1).c | sed -z 's/\\\n //g')
+
ifeq ($(VERBOSE), 1)
CFLAGS += -DLOGALL=1
endif
@@ -36,11 +84,9 @@ ifeq ($(COLORIZE), 1)
CFLAGS += -DCOLORIZE=1
endif
-CFLAGS += $(INCLUDEFLAGS) -D_REENTRANT -ggdb3 -Wall -Wextra -Wsign-conversion -Wno-unused-parameter $(shell pkg-config gnutls --cflags)
-
-LDFLAGS = -lpthread $(shell pkg-config gnutls --libs)
-
-DEPS = $(shell $(CC) $(INCLUDEFLAGS) -MM -MT $(1).o $(1).c | sed -z 's/\\\n //g')
+ifeq ($(SAFE_STACK), 1)
+ CFLAGS += -fstack-check
+endif
.PHONY: all clean cleanall release
all: haxserv