-# $Id$
+############################################################
+# Directory with the DEAL distribution
+############################################################
+
+D = ../..
+
+
+############################################################
+# Include general settings for including DEAL libraries
+############################################################
+
+include $D/common/Make.global_options
+
+
+############################################################
+# Set debug-mode as a default
+############################################################
+
+debug-mode = on
+
+
+############################################################
+# Define library names
+############################################################
+
+libs = -llac -lbase
+libs.g = -llac.g -lbase.g
+
+
+############################################################
+# Select compiler flags according to debug-mode
+############################################################
+
+ifeq ($(debug-mode),on)
+libraries = $(libs.g)
+flags = $(CXXFLAGS.g) $(CXXFLAGS)
+endif
+
+ifeq ($(debug-mode),off)
+libraries = $(libs)
+flags = $(CXXFLAGS.o) $(CXXFLAGS)
+endif
+
+all: logtest.check reference.check tensor.check
+exe: $(all:.check=.testcase)
+output: $(all:.check=.output)
+############################################################
+# Typical block for building a running program
+#
+# 1. provide a list of source files in ...-cc-files
+#
+# 2. generate the list of object files according to debug-mode
+#
+# 3. make executable
#
-# Set root directory of DEAL distribution.
-# This is only one letter to make the rest MORE readable.
+# 4. Explicit dependencies of object files (will be automatic soon)
+#
+############################################################
+
+logtest-cc-files = logtest.cc
+
+ifeq ($(debug-mode),on)
+logtest-o-files = $(logtest-cc-files:.cc=.go)
+else
+logtest-o-files = $(logtest-cc-files:.cc=.o)
+endif
+
+logtest.testcase: $(logtest-o-files) $(libraries)
+ $(CXX) $(flags) -o $@ $^
+
+
+############################################################
+
+
+tensor-cc-files = tensor.cc
+
+ifeq ($(debug-mode),on)
+tensor-o-files = $(tensor-cc-files:.cc=.go)
+else
+tensor-o-files = $(tensor-cc-files:.cc=.o)
+endif
-D=../..
+tensor.testcase: $(tensor-o-files) $(libraries)
+ $(CXX) $(flags) -o $@ $^
-include $D/deal.II/Make.global_options
-%.go : %.cc
- @echo ============================ Compiling with debugging information: $<
- @$(CXX) $(CXXFLAGS) -c $< -o $@
-%.o : %.cc
- @echo ============================ Compiling with optimization: $<
- @$(CXX) $(CXXFLAGS) -c $< -o $@
+############################################################
-vpath %.a: $D/base/lib
-vpath %.a: $D/lac/lib
-vpath %.a: $D/deal.II/lib
-test: run-reference run-logtest run-tensor
+reference-cc-files = reference.cc
+ifeq ($(debug-mode),on)
+reference-o-files = $(reference-cc-files:.cc=.go)
+else
+reference-o-files = $(reference-cc-files:.cc=.o)
+endif
-reference: reference.go -lbase.g
- $(CXX) $(CXXFLAGS) -o $@ $^
+reference.testcase: $(reference-o-files) $(libraries)
+ $(CXX) $(flags) -o $@ $^
-run-reference: reference
- -./reference
-logtest: logtest.go -lbase.g
- $(CXX) $(CXXFLAGS) -o $@ $^
-run-logtest: logtest
- -./logtest
+############################################################
+# Continue with other targets if needed
+############################################################
-tensor: tensor.go -lbase.g -llac.g
- $(CXX) $(CXXFLAGS) -o $@ $^
-run-tensor: tensor
- -./tensor
+############################################################
+# Continue with other targets if needed
+############################################################
+target1-cc-files = t1.cc t2.cc t3.cc
+
+ifeq ($(debug-mode),on)
+target1-o-files = $(target1-cc-files:.cc=.go)
+else
+target1-o-files = $(target1-cc-files:.cc=.o)
+endif
+
+target1: $(target1-o-files) $(libraries)
+ $(CXX) $(flags) -o $@ $^
+
+
+############################################################
+# Postprocessing
+############################################################
+
+%.output:%.testcase
+ $<
+ @perl -pi.bak -e 's/JobId.*//;s/value.*//;' $@
+ @rm $@.bak
+
+%.check:%.output
+ @-diff $< $(patsubst %.output,%.checked, $<)
+############################################################
+# Cleanup targets
+############################################################
+
clean:
- -rm *.o *.go reference logtest tensor
+ rm -f *.o *.go *.output
+
+veryclean: clean
+ rm -f *.testcase *.inp *.gpl *.eps *.gnuplot
+
+############################################################
+# Automatic generation of dependencies
+############################################################
+all-cc-files = $(wildcard *.cc)
+Make.depend: $(all-cc-files)
+ @echo =====Dependecies=== Make.depend
+ @$(CXX) $(flags) $^ -M > $@
+ @perl -pi~ -e 's/(^[^.]+)\.o:/\1.o \1.go:/;' $@
-.PHONY: test run-reference run-logtest run-tensor clean
+include Make.depend
-#include <iostream>
+#include <fstream>
#include <base/subscriptor.h>
#include <base/smartpointer.h>
-
+#include <base/logstream.h>
class Test : public Subscriptor
{
Test(const char* n) :
name(n)
{
- cout << "Construct " << name << endl;
+ deallog << "Construct " << name << endl;
}
~Test()
{
- cout << "Destruct " << name << endl;
+ deallog << "Destruct " << name << endl;
}
void f()
{
- cout << "mutable" << endl;
+ deallog << "mutable" << endl;
}
void f() const
{
- cout << "const" << endl;
+ deallog << "const" << endl;
}
};
main()
{
+ ofstream logfile("reference.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ cerr = logfile;
Test a("A");
const Test b("B");
SmartPointer<Test> r=&a;
SmartPointer<const Test> u=&b;
- cout << "a ";
+ deallog << "a ";
a.f(); // should print "mutable", since #a# is not const
- cout << "b ";
+ deallog << "b ";
b.f(); // should print "const", since #b# is const
- cout << "r ";
+ deallog << "r ";
r->f(); // should print "mutable", since it points to the non-const #a#
- cout << "s ";
+ deallog << "s ";
s->f(); // should print "const", since it points to the const #b#
// but we made it const
- cout << "t ";
+ deallog << "t ";
t->f(); // should print "mutable", since #b# is const, but
// we casted the constness away
- cout << "u ";
+ deallog << "u ";
u->f(); // should print "const" since #b# is const
// Now try if subscriptor works
{
#include <base/tensor.h>
+#include <base/logstream.h>
#include <lac/vector.h>
-#include <iostream>
+#include <fstream>
-int main () {
+int main ()
+{
+ ofstream logfile("tensor.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
double a[3][3] = {{1, 2, 3}, {3, 4, 5}, {6, 7, 8}};
double b[3][3] = {{25,31,37}, {45,57,69}, {75,96,117}};
Vector<double> unrolled(9);
t.unroll(unrolled);
- cout << "unrolled:";
+ deallog << "unrolled:";
for (unsigned i=0;i<9;i++)
- cout << ' ' << unrolled(i);
- cout << endl;
+ deallog << ' ' << unrolled(i);
+ deallog << endl;
- cout << "t=" << endl;
+ deallog << "t=" << endl;
for (unsigned int i=0; i<dim; ++i)
{
for (unsigned int j=0; j<dim; ++j)
- cout << t[i][j] << ' ';
- cout << endl;
+ deallog << t[i][j] << ' ';
+ deallog << endl;
};
- cout << endl;
+ deallog << endl;
contract (tt,t,t);
- cout << "tt=" << endl;
+ deallog << "tt=" << endl;
for (unsigned int i=0; i<dim; ++i)
{
for (unsigned int j=0; j<dim; ++j)
- cout << tt[i][j] << ' ';
- cout << endl;
+ deallog << tt[i][j] << ' ';
+ deallog << endl;
};
- cout << endl;
+ deallog << endl;
if (tt==result)
{
- cout << "Result OK." << endl;
+ deallog << "Result OK." << endl;
return 0;
}
else
{
- cout << "Result WRONG!" << endl;
+ deallog << "Result WRONG!" << endl;
return 1;
};
};