summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShivesh Mandalia <mail@shivesh.org>2022-04-17 16:34:47 +0100
committerShivesh Mandalia <mail@shivesh.org>2022-04-17 16:34:47 +0100
commit31a66b832990c63308aa1236bd68af242866d3d7 (patch)
treef63a57b338f003445f3660bd4190cca11add4210
parente226b6a74e115f2dea82800f5492a976423a74ca (diff)
downloadbasic_makefile-master.tar.gz
basic_makefile-master.zip
Add DEBUG flag to control build typeHEADmaster
-rw-r--r--Makefile14
1 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 3e7f9db..9359d29 100644
--- a/Makefile
+++ b/Makefile
@@ -6,11 +6,15 @@
BIN_NAME :=
SRC_DIRS :=
+# enable debug build
+DEBUG = 1
+
# general program flags
-# Debug
-MY_CFLAGS = -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -g -fsanitize=address,undefined
-# Release
-# MY_CFLAGS = -O3
+ifdef DEBUG
+ MY_CFLAGS = -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -g -fsanitize=address,undefined
+else
+ MY_CFLAGS = -O3
+endif
MY_LIBS =
WARNINGS = -fstack-protector-strong -fpie -pedantic -Wall -Wextra
@@ -81,7 +85,7 @@ print-%: ; @echo $*=$($*)
## Build everything
##-----------------------------------------------------------------------------
-all: format check $(BIN_NAME)
+all: $(if $(DEBUG), format check) $(BIN_NAME)
## Static analysis
##-----------------------------------------------------------------------------