From dad63fb977e59ffcf2cf0ef6b4eabe09af959c09 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 18 Jun 2014 00:27:47 +0200 Subject: make gcc specific flags only present when gcc is selected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f65940d..518098b 100644 --- a/Makefile +++ b/Makefile @@ -31,21 +31,27 @@ PKGNAME ?= libgamma # General-preprocess command. (https://github.com/maandree/gpp) GPP ?= gpp +# C compiler, GNU C Compiler by default CC = gcc # Enabled warnings. -WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self \ - -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow \ - -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \ - -Wnested-externs -Winline -Wno-variadic-macros -Wsign-conversion \ - -Wswitch-default -Wconversion -Wsync-nand -Wunsafe-loop-optimizations \ - -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef \ - -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op \ - -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked \ - -Wvector-operation-performance -Wunsuffixed-float-constants \ - -Wsuggest-attribute=const -Wsuggest-attribute=noreturn \ - -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc +WARN = -Wall -Wextra -pedantic -Wformat=2 -Winit-self -Wmissing-include-dirs \ + -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations \ + -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros \ + -Wswitch-default -Wconversion -Wunsafe-loop-optimizations -Wcast-align \ + -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wcast-qual \ + -Wbad-function-cast -Wwrite-strings -Waggregate-return -Wpacked \ + -Wstrict-prototypes -Wold-style-definition -Wnormalized=nfkc + +ifeq ($(CC),gcc) +WARN += -Wdouble-promotion -Wtrampolines -Wsign-conversion -Wsync-nand \ + -Wlogical-op -Wvector-operation-performance \ + -Wunsuffixed-float-constants -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \ + -Wsuggest-attribute=format +endif + # The C standard used in the code. STD = c99 @@ -77,9 +83,17 @@ include .config.mk # Optimisation level (and debug flags.) ifeq ($(DEBUG),y) +ifeq ($(CC),gcc) OPTIMISE = -Og -g else +OPTIMISE = -g +endif +else +ifeq ($(CC),gcc) OPTIMISE = -Ofast +else +OPTIMISE = -O6 +endif endif # C compiler debug flags. @@ -90,8 +104,13 @@ endif # Options for the C compiler for the test. TEST_FLAGS = $(OPTIMISE) $(WARN) -std=$(STD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ - -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstack-usage \ - -fstrict-overflow -funsafe-loop-optimizations -fno-builtin + -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstrict-overflow \ + -funsafe-loop-optimizations -fno-builtin + +ifeq ($(CC),gcc) +TEST_FLAGS += -fstack-usage +endif + # Options for the C compiler for the library. LIB_FLAGS = $(TEST_FLAGS) $(DEBUG_FLAGS) $(DEFINITIONS) -DLIBGAMMA_CONFIG_H -- cgit v1.2.3-70-g09d2