Skip to content

Commit

Permalink
improve build and release flags: g3, O2/Og, D_FORTIFY_SOURCE=2, Wpeda…
Browse files Browse the repository at this point in the history
…ntic, etc
  • Loading branch information
MestreLion committed Jul 5, 2020
1 parent 7c31706 commit b7a473f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ bindir = $(prefix)/bin

all: release

debug: CFLAGS += -g -O0 -Wall -Wextra
# DEBUG Build
# Add several compile- and run-time checks, warnings and preventions (Buffer Overflow, etc)
# -g3: Adds debugging information, level 3 (default for -g is level 2)
# -Og: Enables optimizations that do not interfere with debugging
# -Wall: Enables all the warnings about constructions that some users consider questionable, and that are easy to avoid
# -Wextra: Enables some extra warning flags that are not enabled by -Wall
debug: CFLAGS += -g3 -Og -Wall -Wextra -Wpedantic -D_FORTIFY_SOURCE=2
debug: clean $(TARGET)

release: CFLAGS += -s
# RELEASE Build
# Stripped binary, maximum optimization
# -s: Strip executable (remove all symbol table and relocation information)
# -O2: Optimize level 2 and activate default FORTIFY_SOURCE=2 in most setups
# -D_FORTIFY_SOURCE=2: explicitely enable additional compile-time and run-time checks for several libc functions
release: CFLAGS += -s -O2 -D_FORTIFY_SOURCE=2
release: clean $(TARGET)

$(TARGET): $(SOURCES) $(HEADERS)
Expand Down

0 comments on commit b7a473f

Please sign in to comment.