From a4bae1bdcd893a5590312fa4716724af3b1b63c0 Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Wed, 22 Mar 2017 16:22:16 -0500 Subject: [PATCH] ENH more makefile updates (#2133) This commit proposes a simpler single compiler specification for OSX and *nix. It also let's people override the setting on both systems, not just *nix. --- Makefile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index afb003912..add236f0a 100644 --- a/Makefile +++ b/Makefile @@ -31,20 +31,24 @@ include $(DMLC_CORE)/make/dmlc.mk # include the plugins include $(XGB_PLUGINS) -# use customized config file -ifndef CC -export CC = $(if $(shell which gcc-6),gcc-6,gcc) -endif -ifndef CXX -export CXX = $(if $(shell which g++-6),g++-6,g++) -endif - -# on Mac OS X, force brew gcc-6, since the Xcode c++ fails anyway -# it is useful for pip install compiling-on-the-fly +# set compiler defaults for OSX versus *nix +# let people override either OS := $(shell uname) ifeq ($(OS), Darwin) -export CC = $(if $(shell which gcc-6),gcc-6,$(if $(shell which gcc-mp-6), gcc-mp-6, $(if $(shell which gcc), gcc, clang))) -export CXX = $(if $(shell which g++-6),g++-6,$(if $(shell which g++-mp-6),g++-mp-6, $(if $(shell which g++), g++, clang++))) +ifndef CC +export CC = $(if $(shell which clang), clang, gcc) +endif +ifndef CXX +export CXX = $(if $(shell which clang++), clang++, g++) +endif +else +# linux defaults +ifndef CC +export CC = gcc +endif +ifndef CXX +export CXX = g++ +endif endif export LDFLAGS= -pthread -lm $(ADD_LDFLAGS) $(DMLC_LDFLAGS) $(PLUGIN_LDFLAGS)