# $Id: Makefile_common.in,v 1.23 2008/05/16 04:26:35 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@
QOS = @QOS@
QOSLIB = ${QOS}/quser/gcc-lib-user///
CC = @CC@
CXX = @CXX@
AS  = @AS@
LDFLAGS = @LDFLAGS@

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@

#
# 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

CSRC := $(notdir $(wildcard $(VPATH)/*.c) )
CCSRC := $(notdir $(wildcard $(VPATH)/*.C) )
SSRC := $(notdir $(wildcard $(VPATH)/*.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)
	$(CXX) $(OBJS) $(LIBLIST) $(LDFLAGS) -o $(BIN)

.c.o:
	$(CC) -o $@ $(CFLAGS) $(DFLAGS) -c $(INCLIST) $<
.C.o:
	$(CXX) -o $@ $(CXXFLAGS) $(DFLAGS) -c $(INCLIST) $<
.S.o:
	$(AS) -o $@ $(ASFLAGS) -c $(INCLIST) $<

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

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

