# -*- mode: makefile -*-
#
# Makefile of ROOT for MacOS X, using g++ 64-bit mode
PLATFORM = macosx
DEBUGFLAGS = -g
OPTFLAGS = -O2
ifeq (debug,$(findstring debug,$(ROOTBUILD)))
OPT = $(DEBUGFLAGS)
NOOPT =
else
OPT = $(OPTFLAGS)
NOOPT =
endif
# OS version
MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2)
MACOSX_CPU := $(shell uname -p)
FINK_DIR := $(shell which fink 2>&1 | sed -ne "s/\/bin\/fink//p")
# Compiler:
# From "Apple clang version ... (based on LLVM 3.0svn)"
# i.e. OSX 10.7 we will take clang as default
APPLE_CLANG := $(shell clang -v 2>&1 | sed -n "s/.*based on LLVM //p" | cut -d . -f 1)
ifeq ($(APPLE_CLANG),)
APPLE_CLANG := 1
endif
ifeq ($(subst $(APPLE_CLANG),,12),12)
CXX = clang++
CC = clang
ifeq ($(LIBCXX),yes)
CXX11FLAGS = -stdlib=libc++
CXX11LDFLAGS = -stdlib=libc++
endif
else
CXX = g++
CC = gcc
endif
CXXFLAGS = -m64 -std=c++11 -pipe -Wshadow -W -Wall -Woverloaded-virtual \
-fsigned-char -fno-common $(EXTRA_CXXFLAGS) $(FINK_CXXFLAGS) \
$(TARGETFLAGS) $(CXX11FLAGS)
CFLAGS = -m64 -pipe -Wshadow -W -Wall -fsigned-char -fno-common \
$(EXTRA_CFLAGS) $(FINK_CFLAGS) $(TARGETFLAGS)
COMPILER = gnu
# Linker:
ifeq ($(subst $(APPLE_CLANG),,12),12)
LD = clang++
else
LD = g++
endif
LDFLAGS = $(OPT) -m64 -mmacosx-version-min=$(MACOSXVERS)
F77LDFLAGS := $(LDFLAGS)
LDFLAGS += $(CXX11LDFLAGS)
FORCELINK = yes
NEEDFINK = yes
ifeq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(USECONFIG),FALSE)
SOFLAGS = -dynamiclib -single_module -Wl,-dead_strip_dylibs \
-install_name @rpath/
else
SOFLAGS = -dynamiclib -single_module -Wl,-dead_strip_dylibs \
-install_name $(LIBDIR)/
endif
FORCELINK = no
NEEDFINK = no
else
ifeq ($(subst $(MACOSX_MINOR),,123),123)
SOFLAGS = -dynamiclib -single_module \
-undefined dynamic_lookup -install_name $(LIBDIR)/
FORCELINK = no
NEEDFINK = no
else
ifeq ($(MACOSX_MINOR),3)
SOFLAGS = -dynamiclib -single_module \
-undefined dynamic_lookup -install_name $(LIBDIR)/
LDFLAGS += -bind_at_load
else
SOFLAGS = -dynamiclib -single_module \
-undefined suppress -install_name $(LIBDIR)/
LDFLAGS += -bind_at_load
endif
endif
endif
ifeq ($(subst $(MACOSX_MINOR),,1234),1234)
SOEXT = so
else
SOEXT = dylib
endif
# System libraries:
SYSLIBS = -lm $(EXTRA_LDFLAGS) $(FINK_LDFLAGS) $(OSTHREADLIBDIR) \
$(OSTHREADLIB) -ldl $(ALLOCLIBDIR) $(ALLOCLIB)
XLIBS = $(XPMLIBDIR) $(XPMLIB) $(X11LIBDIR) -lXext -lX11
CILIBS = -lm $(EXTRA_LDFLAGS) $(FINK_LDFLAGS) -ldl
# Fortran:
F77ORG = gfortran
F77FLAGS = -m64 -std=legacy
ifneq ($(F77),)
F77LIBS := $(shell $(F77) -m64 -print-file-name=libgfortran.dylib 2>&1 | grep /)
F77LIBS += $(shell $(F77) -m64 -print-file-name=libgfortran.a 2>&1 | grep /)
F77LIBS += $(shell $(F77) -m64 -print-file-name=libgfortranbegin.a 2>&1 | grep /)
endif
# Override default in Makefile.config
INSTALL := /bin/cp -pPR
INSTALLDATA := /bin/cp -pPR
# Extras
ifeq ($(NEEDFINK),yes)
FINK_CXXFLAGS := $(shell [ -d $(FINK_DIR)/include ] && echo -I$(FINK_DIR)/include)
FINK_CFLAGS := $(shell [ -d $(FINK_DIR)/include ] && echo -I$(FINK_DIR)/include)
FINK_LDFLAGS := $(shell [ -d $(FINK_DIR)/lib ] && echo -L$(FINK_DIR)/lib)
endif
ifeq ($(MACOSX_MINOR),7)
MACOSX_SSL_DEPRECATED = yes
endif
ifeq ($(MACOSX_MINOR),8)
MACOSX_SSL_DEPRECATED = yes
MACOSX_ODBC_DEPRECATED = yes
endif
ifeq ($(MACOSX_MINOR),9)
MACOSX_SSL_DEPRECATED = yes
MACOSX_ODBC_DEPRECATED = yes
MACOSX_GLU_DEPRECATED = yes
MACOSX_KRB5_DEPRECATED = yes
endif
ifeq ($(CONFIGURE),yes)
showcxx:
@echo "$(CXX)"
showcc:
@echo "$(CC)"
showld:
@echo "$(LD)"
showf77:
@echo "$(F77ORG)"
endif