From 659f0d647ca27d03815e799f74e1023fa5f3bc25 Mon Sep 17 00:00:00 2001 From: Test_User Date: Sat, 16 Mar 2024 06:55:42 -0400 Subject: backport makefile improvements to current haxserv (from next in-progress haxserv) --- .gitignore | 1 + Makefile | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 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 -- cgit v1.2.3