# Define our compilers.................................
#
F90    = mpxlf90_r
F77    = mpxlf_r
CC     = mpcc_r

# wsmp lives here.
#
WSMP_DIR   = /home/beaumnt1/software/wsmp/lib/Power4

# for 32 bit compile..................................
#
AR=ar
BITS=-q32
OPTIONS = -bmaxdata:0x80000000 -bhalt:0 -bnoquiet
PGPLOT = /home/beaumnt1/software/pgplot-5.2.2
WSMP_LIB = -L$(WSMP_DIR) -lpwsmp

# for 64 bit compile..................................
#
AR=ar -X 64
BITS=-q64
OPTIONS = -b 64 -bmaxdata:0x80000000 -bhalt:0 -bnoquiet
PGPLOT = /home/beaumnt1/software/pgplot-5.2.2-q64
WSMP_LIB = -L$(WSMP_DIR) -lpwsmp64


# Define FORTRAN compiler flags.......................
#
# I would like to add -u here, but Wow!  Just try it.
# FLAGS  = -O3 -qstrict -Q -qarch=auto -qtune=auto -qfloat=nomaf:nofold
# Trouble on the p690; time to get serious.
# douar bombs quickly; removing qflttrap=inexact
# -qport options might be worth looking at later
# -qwarn64 casues interesting messages in NN
#
# for xlf 8.1
# -qflttrap=overflow:underflow:zerodivide:invalid:enable 
# for xlf 10.1
# -qflttrap=overflow:underflow:zerodivide:invalid:NANQ:enable 

# take -qextchk out for the final compile
FFLAGS  = -g -O2 -qstrict -Q $(BITS)  -qarch=auto -qtune=auto -qmaxmem=-1 \
-qcheck -qwarn64 \
-qfloat=nomaf:nofold:norsqrt:strictnmaf \
-qflttrap=overflow:underflow:zerodivide:invalid:NANQ:enable \
-qsigtrap \
-qhalt=s -qextchk


# Define C compiler flags.............................
#
# take -qextchk out for the final compile
CFLAGS  = -g -O2 -qstrict -Q $(BITS)  -qarch=auto -qtune=auto \
-qcheck -qwarn64 \
-qfloat=nomaf:nofold:norsqrt \
-qflttrap=overflow:underflow:zerodivide:invalid:NANQ:enable \
-qhalt=e -qextchk

# compile rules.......................................
#
COMPILE_OUT=$(NAME)$(BITS).compile
.SUFFIXES:
.SUFFIXES: .o .c .f .f90
.f90.o:
	@echo "--"                                    >>$(COMPILE_OUT) 2>&1
	@echo "xlf is `which xlf`"                    >>$(COMPILE_OUT) 2>&1
	@echo "$(F90) -qsuffix=f=f90 $(FFLAGS) -c $<" >>$(COMPILE_OUT) 2>&1
	$(F90) -qsuffix=f=f90 $(FFLAGS) -c $<         >>$(COMPILE_OUT) 2>&1

.f.o:
	@echo "--"                                   >>$(COMPILE_OUT) 2>&1
	@echo "xlf is `which xlf`"                   >>$(COMPILE_OUT) 2>&1
	@echo "$(F77) -qsuffix=f=f $(FFLAGS) -c $<"  >>$(COMPILE_OUT) 2>&1
	$(F77) -qsuffix=f=f $(FFLAGS) -c $<          >>$(COMPILE_OUT) 2>&1

.c.o:
	@echo "--"                     >>$(COMPILE_OUT) 2>&1
	@echo "$(CC) $(CFLAGS) -c $<"  >>$(COMPILE_OUT) 2>&1
	$(CC) $(CFLAGS) -c $<          >>$(COMPILE_OUT) 2>&1


# Libraries................
#
# libs removed on p690...
# -lacml
# -lpthread 

LIBS = \
-LOCTREE -lOctree$(BITS) \
-LCASCADE -lcascade$(BITS) \
-LRESAMPLE -lresample$(BITS) \
-LNN -lnn$(BITS) \
$(WSMP_LIB) \
-L$(PGPLOT) -lpgplot \
-L/usr/lpp/X11 -lX11