summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-09-08 10:21:18 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-09-08 10:21:18 +0200
commit5b8ec08d57fa932b769e590ecfe6a471910c05ec (patch)
tree1e3aff5cacbf09e1bdaf35bec229b50566944dcd /Makefile
parentee339c1af78312527312a812dce579266a9ba5bc (diff)
build: Detect compiler (gcc or clang) and filter out compiler flags
Create a make variable $(COMPILER) which is set to either `gcc' or `clang' depending on the compiler used. Use this variable to filter out command line options not supported by clang (for now only -fno-delete-null-pointer-checks). Compiler detection snippet extracted from the Linux kernel Makefile. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 12 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 72f0585..90387ab 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,16 @@ else
DEBUG := 0
endif
+# Compiler detection
+ifneq ($(CC),)
+ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
+COMPILER := clang
+else
+COMPILER := gcc
+endif
+export COMPILER
+endif
+
# For packaging purposes, you might want to call your own:
# make CFLAGS="<flags>"
CFLAGS_DEF = -std=gnu99
@@ -83,7 +93,9 @@ endif
CFLAGS_DEF += -fomit-frame-pointer
CFLAGS_DEF += -fno-strict-aliasing
CFLAGS_DEF += -fasynchronous-unwind-tables
+ifneq ($(COMPILER), clang)
CFLAGS_DEF += -fno-delete-null-pointer-checks
+endif
CFLAGS_MIN = -D_REENTRANT
CFLAGS_MIN += -D_LARGEFILE_SOURCE