From f4a06036c6df155d367b56c4faabbd0c4d559ddd Mon Sep 17 00:00:00 2001 From: Emil Gedda Date: Wed, 17 Apr 2019 04:07:03 +0200 Subject: [PATCH] Allows additional C(XX)FLAGS to be passed through command line (#142) * Allow passing additional compiler flags through command line * Simplify branching for compiler flags * Optimize for debug while debugging or sanitizing specified --- Makefile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 41ab044d4..936eb7bc3 100644 --- a/Makefile +++ b/Makefile @@ -7,19 +7,16 @@ .PHONY: clean cleandist COREDEPSINCLUDE = -Idependencies/rapidjson/include -Idependencies/sajson/include -Idependencies/cJSON -Idependencies/jsmn EXTRADEPSINCLUDE = -Idependencies/jsoncppdist -Idependencies/json11 -Idependencies/fastjson/src -Idependencies/fastjson/include -Idependencies/gason/src -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src -CXXFLAGS = -std=c++17 -march=native -Wall -Wextra -Wshadow -Iinclude -Ibenchmark/linux -CFLAGS = -march=native -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src +CXXFLAGS := $(CXXFLAGS) -std=c++17 -march=native -Wall -Wextra -Wshadow -Iinclude -Ibenchmark/linux -O3 +CFLAGS := $(CFLAGS) -march=native -Idependencies/ujson4c/3rdparty -Idependencies/ujson4c/src -O3 + ifeq ($(SANITIZE),1) - CXXFLAGS += -g3 -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined - CFLAGS += -g3 -O0 -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -else -ifeq ($(DEBUG),1) - CXXFLAGS += -g3 -O0 - CFLAGS += -g3 -O0 -else - CXXFLAGS += -O3 - CFLAGS += -O3 + CXXFLAGS += -g3 -Og -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined + CFLAGS += -g3 -Og -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined endif +ifeq ($(DEBUG),1) + CXXFLAGS += -g3 -Og + CFLAGS += -g3 -Og endif MAINEXECUTABLES=parse minify json2json jsonstats statisticalmodel