From 07125d60fbf5fed48bc7846a6bd3cf51e0d1d1de Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Tue, 12 Mar 2024 11:30:59 +0300 Subject: [PATCH] Define default CFLAGS for GNU and LLVM compilers --- Makefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9c921d3..68c541e 100644 --- a/Makefile +++ b/Makefile @@ -34,17 +34,30 @@ endif LIBLINK = $(subst .$(VERSION),,$(LIBFILE)) ifndef CFLAGS -CFLAGS = -Wall -Wextra -pedantic -Wno-unused-parameter + cc_std = c89 + cc_version := $(shell $(CC) --version) + cc_is_gnu := $(if $(findstring Free Software Foundation,$(cc_version)),1) + ifdef cc_is_gnu + CFLAGS = $(if $(cc_std),-std=$(cc_std)) + CFLAGS += -pedantic -Wall -Wextra + CFLAGS += -Wno-unused-parameter + CFLAGS += -Wno-unreachable-code-return + else + CFLAGS = $(if $(cc_std),-std=$(cc_std)) + CFLAGS += -pedantic -Weverything + CFLAGS += -Wno-unused-parameter + CFLAGS += -Wno-unreachable-code-return + endif endif .SECONDEXPANSION: # to expand $$(@D)/.DIR -$(BUILD)/mpicc: CC := CC -$(BUILD)/mpicc: cc := cc -$(BUILD)/mpicc: op := cc -$(BUILD)/mpicxx: CC := CXX -$(BUILD)/mpicxx: cc := c++ -$(BUILD)/mpicxx: op := cxx +$(BUILD)/mpicc: override CC := CC +$(BUILD)/mpicc: override cc := cc +$(BUILD)/mpicc: override op := cc +$(BUILD)/mpicxx: override CC := CXX +$(BUILD)/mpicxx: override cc := c++ +$(BUILD)/mpicxx: override op := cxx $(BUILD)/mpic%: mpicc.in | $$(@D)/.DIR cp $< $@ $(SED_I) -e 's:@includedir@:$(abspath $(PREFIX))/$(INCDIR):' $@