###
#
# @file Makefile.internal
#
#  PLASMA is a software package provided by Univ. of Tennessee,
#  Univ. of California Berkeley and Univ. of Colorado Denver
#  
# This file set all the common variables used by all Makefile of
# the project thanks to make.inc
#
# @version 2.5.0
# @author Mathieu Faverge
# @date 2010-11-15
#
###

include $(PLASMA_DIR)/make.inc
-include $(PLASMA_DIR)/make.inc.${MACHINE}

prefix ?= ./install

#///// D /// O ////// N /// O /// T ////// T /// O /// U /// C /// H /////
QUARKDIR ?= $(PLASMA_DIR)/quark
INCQUARK  = -I$(QUARKDIR)
LIBQUARK  = -L$(QUARKDIR) -lquark

# Include directories
INC         = -I$(PLASMA_DIR)/include $(INCQUARK)
INCEXT      = $(INCCLAPACK)

# Location of the libraries.
LIBDIR      = -L$(PLASMA_DIR)/lib

# Location and name of the PLASMA library.
LIBCOREBLAS = $(PLASMA_DIR)/lib/libcoreblas.a
LIBPLASMA   = $(PLASMA_DIR)/lib/libplasma.a
LIBEZT_COREBLAS = $(PLASMA_DIR)/lib/libeztrace-coreblas.a
LIBEZT_CONVERT  = $(PLASMA_DIR)/lib/libeztrace-convert-coreblas.so

#             Trace librairies 
# (we guess that all librairies have been installed 
#     in the same directory by the installer)
EZT_DIR ?= /usr
GTG_DIR ?= $(EZT_DIR)
FXT_DIR ?= $(EZT_DIR)

ifeq (${PLASMA_TRACE}, 1)
	LIBTRACE = -L${EZT_DIR}/lib -leztrace -leztrace-coreblas -L$(FXT_DIR)/lib -lfxt
	CFLAGS += -DPLASMA_EZTRACE -I${EZT_DIR}/include
endif

#  All internal libraries
LIB    = $(LIBDIR) -lplasma ${LIBTRACE} -lcoreblas -lplasma $(LIBQUARK) 
#  All external libraries
LIBEXT = $(LIBCBLAS) $(LIBCLAPACK) $(LIBLAPACK) $(LIBBLAS) -lpthread -lm

# Use Hwloc
HWLOC = $(shell pkg-config --libs hwloc 2> /dev/null )
ifeq (1, $(words $(findstring hwloc, $(HWLOC))))
	CFLAGS  := $(CFLAGS) -DPLASMA_HWLOC -DQUARK_HWLOC
	INCEXT  := $(INCEXT) $(shell pkg-config --cflags-only-I hwloc)
	LIBEXT  := $(LIBEXT) $(shell pkg-config --libs hwloc)
	require := hwloc
endif

INC := $(INC) $(INCEXT)
LIB := $(LIB) $(LIBEXT)
#//////////////////////////////////////////////////////////////////////////

-include $(PLASMA_DIR)/Makefile.gen
