# $Id: Makefile.users.in,v 1.6 2011/03/24 16:20:52 chulwoo Exp $
# @configure_input@
#   This is the makefile for all the commands
#   that are common for all testing applications.
#----------------------------------------------------------------------


SRCDIR = @abs_top_srcdir@
BUILDDIR = @abs_top_builddir@
CC = @CC@
CXX = @CXX@
AS  = @AS@
LDFLAGS = @LDFLAGS@ @LIBS@

me = $(notdir $(PWD))
BIN = @ARCH@.x

#VPATH :=$(SRCDIR)/tests/$(me)



#
# include list for the Columbia code
#
INCLIST = -I${BUILDDIR} -I${SRCDIR}/include @INCLUDE_FLAGS@

CFLAGS= @CFLAGS@
CXXFLAGS= @CXXFLAGS@
ASFLAGS= @ASFLAGS@
DFLAGS += @DFLAGS@

libcps_CXXFLAGS = $(INCLIST) $(CXXFLAGS) $(DFLAGS)
libcps_CFLAGS = $(INCLIST) $(CFLAGS) $(DFLAGS)

#
# Libraries for the Columbia code
#
# (These are for the scalar version of the code)
#
#

.PHONY: cps clean


LIBLIST =\
  $(BUILDDIR)/libcps.a \

#
#  targets
#


all:$(BIN)

.SUFFIXES:
.SUFFIXES:  .o .C .S .c .x

CSRC :=$(wildcard *.c)
CCSRC :=$(wildcard *.C)
SSRC :=$(wildcard *.S)

COBJ=$(CSRC:.c=.o)
CCOBJ=$(CCSRC:.C=.o)
SOBJ=$(SSRC:.S=.o)

OBJS_SRC = $(SOBJ) $(CCOBJ) $(COBJ)
OBJS := $(notdir $(OBJS_SRC))

$(BIN):  $(OBJS) $(LIBLIST)
	@echo OBJS = $(OBJS)
	$(CXX) $(OBJS) -L$(BUILDDIR) -lcps  $(LDFLAGS) -o $(BIN)

.c.o:
	$(CC) -o $@ $(libcps_CFLAGS)  -c $<
.C.o:
	$(CXX) -E $(libcps_CXXFLAGS) $< > $*.i
	$(CXX) -o $@ $(libcps_CXXFLAGS) -c $<
.S.o:
	$(AS) -o $@ $(ASFLAGS) -c $(INCLIST) $<

.o.x: $(LIBLIST)
	$(CXX) $< $(LIBLIST) $(LDFLAGS) -o $@

cps:
	$(MAKE) -C $(BUILDDIR)

clean:
	rm -f *.dat *.o  $(BIN)
	rm -f ../regressions/*$(me).dat
	rm -f ../regressions/*$(me).checklog
