# $Id$
CXX=g++
CXXFLAGS=-g -Werror -funroll-loops -fmessage-length=0 -Wall -Wshadow -Wextra -Wpointer-arith -Wconversion -O3
TEST_CXXFLAGS=-Werror -funroll-loops -fmessage-length=0 -Wall -Wshadow -Wextra -Wpointer-arith -Wconversion -Winline -finline-small-functions
SOCI_CXXFLAGS=
LDFLAGS=
BOOST_LDFLAGS=
MAIN_SOURCES=cputest.cc tests.cc
MODULE_SOURCES=
DESTDIR=
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
SBINDIR=$(PREFIX)/sbin
LIBDIR=$(PREFIX)/lib
INCLUDEDIR=$(PREFIX)/include
DATADIR=$(PREFIX)/data
VERSION=0.2
ARCHIVES=

all: build

build: cputest cputest.s tests.s

cputest: $(MAIN_SOURCES:.cc=.o) $(ARCHIVES)
	$(CXX) $(CXXFLAGS) -o $@ $(MAIN_SOURCES:.cc=.o) $(ARCHIVES) $(LDFLAGS) $(BOOST_LDFLAGS)

%.o: %.cc
	$(CXX) $(CXXFLAGS) -c -o $@ $<

%.s: %.cc
	$(CXX) $(CXXFLAGS) -S -o $@ $<

tests.o: tests.cc
	$(CXX) $(TEST_CXXFLAGS) -c -o $@ $<

tests.s: tests.cc
	$(CXX) $(TEST_CXXFLAGS) -S -o $@ $<

%.d: %.cc
	@set -e; rm -f $@; \
	    $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$.t; \
	    sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$.t > $@; \
	    rm -f $@.$$$$.t

clean:
	rm -f cputest *.a *.o *.d *.t *.s

-include $(MAIN_SOURCES:.cc=.d)

install:
	mkdir -p "$(DESTDIR)$(BINDIR)/"
	cp -f cputest "$(DESTDIR)$(BINDIR)/"
	chmod 711 "$(DESTDIR)$(BINDIR)/cputest"

# EOF