# -*- mode: makefile -*-
#
# Makefile of ROOT for Itanium/Linux with Intel icc compiler

PLATFORM      = linux

DEBUGFLAGS    = -g
OPTFLAGS      = -O
ifeq (debug,$(findstring debug,$(ROOTBUILD)))
OPT           = $(DEBUGFLAGS)
NOOPT         = -O0
else
OPT           = $(OPTFLAGS)
NOOPT         = -O0
endif

# Compiler version:
ICC_MAJOR    := $(shell ecc -quiet -V 2>&1 | awk '{ if (NR==2) print $$2 }' | \
                cut -d'.' -f1)
ICC_MINOR    := $(shell ecc -quiet -V 2>&1 | awk '{ if (NR==2) print $$2 }' | \
                cut -d'.' -f2 | cut -d',' -f1)

ifeq ($(ICC_MAJOR),8)
ICC           = icc
IFORT         = ifort
else
ICC           = ecc
IFORT         = efc
endif

# Compiler:
CXX          := $(ICC)
CC           := $(ICC)
CXXFLAGS      = $(EXTRA_CXXFLAGS)
CFLAGS        = $(EXTRA_CFLAGS) -restrict
CINTCXXFLAGS  = $(EXTRA_CXXFLAGS) \
                -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__64BIT
CINTCFLAGS    = $(EXTRA_CFLAGS) -restrict \
                -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__64BIT

ifeq ($(ICC_MAJOR),8)
CXXFLAGS     += -fPIC
CFLAGS       += -fPIC
CINTCXXFLAGS += -fPIC
CINTCFLAGS   += -fPIC
endif

# Linker:
LD           := $(ICC)
LDFLAGS       = $(OPT) $(EXTRA_LDFLAGS)
SOFLAGS       = -shared -Wl,-soname,
SOEXT         = so

# System libraries:
SYSLIBS       = -lm -ldl $(OSTHREADLIBDIR) $(OSTHREADLIB) -rdynamic
XLIBS         = $(XPMLIBDIR) $(XPMLIB) $(X11LIBDIR) -lX11
CILIBS        = -lm -ldl -rdynamic
CRYPTLIBS     = -lcrypt

# Fortran:
F77          := $(IFORT)
F77FLAGS      =
# check path for libg2c and libfrtbegin
LIBG2C       := $(shell gcc -print-file-name=libg2c.a | \
                  awk '{ if ($$1 != "libg2c.a") print $$1}')
LIBFRTBEGIN  := $(shell gcc -print-file-name=libfrtbegin.a | \
                  awk '{ if ($$1 != "libfrtbegin.a") print $$1}')
ifeq ($(ICC_MAJOR),8)
F77LIBS       = $(LIBFRTBEGIN) $(LIBG2C) \
                -L$(shell which ifort | sed -e 's|bin/ifort|lib|') \
                -lifcore
else
F77LIBS       = $(LIBFRTBEGIN) $(LIBG2C) \
                -L$(shell which efc | sed -e 's|bin/efc|lib|') \
                -lF90 -lCEPCF90 -lintrins
endif

# Extras

