#------------------------------------------------------------------------------
# KOJAK Makefile Definitions (Makefile.defs.linux-gomp)
#------------------------------------------------------------------------------

CFGKEY = darwin
CONFIG = Mac OS X with Open MPI and openMP. Open MPI is not included with Lion

# Mac must have XCode from the App Store installed
# And click Command-Line tools in Xcode's preferences/downloads
# Since clang does not have fortran,
# Tested with gcc/gfortran 4.8, openmpi 1.6, binutils 2.22 and gettext 0.18-1.1 on OS X Lion 10.7.4
# Gfortran and gcc 4.8 can be found at http://hpc.sourceforge.net/
# Binutils is found at http://ftp.gnu.org/gnu/binutils/ - it is necessary for the epik adapter compiler
# GNU Gettext is at http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
# DON'T BOTHER WITH MACPORTS!!!!
# Configure both openmpi, gettext AND binutils with
# ./configure CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ F77=/usr/local/bin/gfortran F90=/usr/local/bin/gfortran --prefix=/usr/local
# add --disable-nls for binutils
# I used -fpermissive on PEARL Base for the conversion between elg_ui8* and uint64_t - I have no idea of the consequences.
# Gettext triggers a bug on GCC and so far I cannot go further.
#------------------------------------------------------------------------------
# Platform Settings
#------------------------------------------------------------------------------
PREC   = 64
PFLAG  = -m$(PREC)
AFLAG  =

PREFIX = ~/opt/scalasca
OPARI2DIR ~= /opt/scalasca

PLAT      = darwin
MACHINE   = -DMACHINE=\"Mac\ OS\ X\"
#PLAT_LDIR = -DPFORM_LDIR=\"/tmp\"
PLAT_CONF = $(MACHINE) $(PLAT_LDIR)
PLATCC    = gcc $(PFLAG)
PLAT_CFLAGS =

OPTFLAGS = -Wall
CC       = /usr/local/bin/gcc
CFLAGS   = $(PFLAG) $(OPTFLAGS) -Wno-unknown-pragmas
CXX      = /usr/local/bin/g++
CXXFLAGS = $(PFLAG) $(OPTFLAGS) -Wno-unknown-pragmas -O3
F77      = /usr/local/bin/gfortran
F90      = $(F77)
FFLAGS   = $(PFLAG) $(OPTFLAGS)
FPP      =
FDOPT    = -D
LDFLAGS  = $(PFLAG) $(OPTFLAGS)
UTILLIB  =
FOBASE   = pomp2_fwrapper_base.o

#------------------------------------------------------------------------------
# MPI Settings
#------------------------------------------------------------------------------

MPICC     = mpicc
MPICXX    = mpicxx
MPIF90    = mpif90
MPILIB    = -lmpi
PMPILIB   = 
FMPILIB   = -lmpi_f77
FMPIOBJ   =
MPIEXTRA  = -DHAS_MPI2_1SIDED
MPIELGLIB = libelg.mpi.a

MPI_BUILD_TARGETS   = all-salsa
MPI_INSTALL_TARGETS = install-salsa
MPI_CONFIG_TARGETS  = mpi_gen_headers

#------------------------------------------------------------------------------
# OpenMP Settings
#------------------------------------------------------------------------------

OMPCC      = $(CC)
OMPCXX     = $(CXX)
OMPF90     = $(F90)
OMPFLAG    = -fopenmp
OMPELGLIB  = libelg.omp.a

#------------------------------------------------------------------------------
# Hybrid MPI/OpenMP Settings
#------------------------------------------------------------------------------

HYBCC      = $(MPICC)
HYBCXX     = $(MPICXX)
HYBF90     = $(MPIF90)
HYBFLAG    = $(OMPFLAG)
HYBELGLIB  = libelg.ompi.a

#------------------------------------------------------------------------------
# Hardware-Counter Settings
#------------------------------------------------------------------------------

#METR       = papi
#METRDIR    = /usr/local/papi
#METRINC    = -I$(METRDIR)/include
#METRLIB32  = -lpapi
#METRLIB64  = -lpapi
#METRLDIR32 = $(METRDIR)/lib
#METRLDIR64 = $(METRDIR)/lib
#METRLIB    = -L$(METRLDIR$(PREC)) -Wl,-rpath,$(METRLDIR$(PREC)) $(METRLIB$(PREC))
#METROBJS   = esd_metric_$(METR).o
#METRCFLAGS = -DEPK_METR

#------------------------------------------------------------------------------
# Compression Support
#------------------------------------------------------------------------------

SZLIB          = szlib
SZLIB_OPTFLAGS = -O3
SZLIB_CFLAGS   = -I$(TOPDIR)/utils/szlib -DELG_COMPRESSED -DCUBE_COMPRESSED
SZLIB_LIBPATH  = -L$(TOPDIR)/utils/szlib
SZLIB_LIB      = -lsc.z

#------------------------------------------------------------------------------
# Alternative compiler for SCAN, EARL, EXPERT, and CUBE
#------------------------------------------------------------------------------

ECXX         = g++
ECXXLIBS     = -lstdc++
ECXX_AR      = ar
ECXX_ARFLAGS = -rcs

BINUTILS     = /opt/binutils
LIBERTY      = -L$(BINUTILS)/lib64 -L$(BINUTILS)/lib -liberty

#------------------------------------------------------------------------------
# Special compiler interface: generic|pgi|intel|gnu|xl|hitachi|phat|ftrace
#------------------------------------------------------------------------------

COMP      = gnu
CINSTFLAG = -finstrument-functions
LINSTFLAG = $(CINSTFLAG)
DEMANGLE  = -DGNU_DEMANGLE -I$(BINUTILS)/include
BFDLIB    = -L$(BINUTILS)/lib64 -L$(BINUTILS)/lib -lbfd -lz $(LIBERTY)
EXTRAOBJS =
KINST_EXTRA = kinst-gnu

#------------------------------------------------------------------------------
# VTF3 Support
#------------------------------------------------------------------------------

#VTF3DIR     =
#ELG_VTF3    = elg_vtf3
#VTF3LIB     = -L$(VTF3DIR)/i386_linux/lib -lvtf3
#INST_VTF3   = install-vtf3

#------------------------------------------------------------------------------
# OTF Support
#-----------------------------------------------------------------------------

#OTFDIR      =
#OTFRTTI     =
#OTFUNIFY    = elg_otfunify
##OTFUNIFY    = elg_otfunify.omp
#ELG_OTF     = elg2otf
#OTFLIB      = -L$(OTFDIR)/lib64 -L$(OTFDIR)/lib -lotf -lz
#INST_OTF    = install-otf
#OTFELGLIB     = libelg.otf.a
#OTFMPIELGLIB  = libelg.otf.mpi.a
#OTFOMPELGLIB  = libelg.otf.omp.a
#OTFHYBELGLIB  = libelg.otf.ompi.a

