diff --git a/.gitignore b/.gitignore
index 16c1db40edcf8ce8aa0e8a57e2e7232370aefbec..114ace6b59f8d40aa84a87f9e555b3e395129aeb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,11 +27,25 @@
 *.swp
 
 bin/*
+bin-release/*
+bin-debug/*
 lib/*
+lib-release/*
+lib-debug/*
 doc/*
 **/bin
+**/bin-release
+**/bin-debug
 **/doc
 **/obj
+**/obj-release
+**/obj-debug
 **/lib
+**/lib-release
+**/lib-debug
 **/test-bin
+**/test-bin-release
+**/test-bin-debug
 **/test-obj
+**/test-obj-release
+**/test-obj-debug
diff --git a/acat2/makefile b/acat2/makefile
index d6e4d02f16e3116c8da713be9a56032cb6407c44..a485c148590a610eaaab5b9202e7eacbd654854c 100644
--- a/acat2/makefile
+++ b/acat2/makefile
@@ -1,33 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=acat2
-TESTBIN:=acat2test
 
-LDFLAGS= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -Wl,-rpath,.
-TEST_LDFLAGS:= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -lcppunit -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
-TEST_OBJECTS:=$(patsubst test-src/%.cpp, test-obj/%.o, $(shell find test-src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build test clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build test
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -38,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -59,73 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
 
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
 
-build: bin/$(EXECUTABLE)
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
 
-test-bin/$(TESTBIN): test-obj/ bin/$(EXECUTABLE) $(TEST_OBJECTS)
-	mkdir -p test-bin
-	$(CXX) $(TEST_OBJECTS) -o $@ $(TEST_LDFLAGS)
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
 
-test-obj/makefile:
-	mkdir -p $(dir $@)
-	echo "SHELL:=/bin/bash" > $@
-	echo "SRCDIR:=" >> $@
-	echo "DEPTH:=" >> $@
-	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/" >> $@
-	echo "" >> $@
-	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
-	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
-	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
-	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
-	echo "OBJECTS_DIRS_MAKEFILES:= \$$(patsubst %, %makefile, \$$(OBJECTS_DIRS))" >> $@
-	echo "" >> $@
-	echo ".PHONY: all" >> $@
-	echo ".PRECIOUS: \$$(DEPENDECIES) \$$(OBJECTS_DIRS_MAKEFILES)" >> $@
-	echo "" >> $@
-	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
-	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
-	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
-	echo "" >> $@
-	echo "%/makefile:" >> $@
-	echo "	mkdir -p \$$(dir \$$@)" >> $@
-	echo "	cp makefile \$$@" >> $@
-	echo "" >> $@
-	echo "%/: FORCE | %/makefile" >> $@
-	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
-	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
-	echo "		touch .; \\" >> $@
-	echo "	fi" >> $@
-	echo "" >> $@
-	echo "FORCE:" >> $@
-	echo "" >> $@
-	echo "-include \$$(DEPENDENCIES)" >> $@
 
-test-obj/: FORCE | test-obj/makefile
-	$(MAKE) -C $@
+build-debug: bin-debug/$(EXECUTABLE)
 
-$(TEST_OBJECTS): test-obj/
+build-release: bin-release/$(EXECUTABLE)
 
-test: test-bin/$(TESTBIN)
-	LD_LIBRARY_PATH="../alib2data/lib" test-bin/$(TESTBIN)
 
 
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
+
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/acat2/test-src/main.cpp b/acat2/test-src/main.cpp
deleted file mode 100644
index 1b3e03225779c209b81d8dfd664d46199dfaba7b..0000000000000000000000000000000000000000
--- a/acat2/test-src/main.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-//#include "stdafx.h"
-#include <cppunit/CompilerOutputter.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-#include <cppunit/TestResultCollector.h>
-#include <cppunit/TestResult.h>
-
-#include <cppunit/Test.h>
-#include <cppunit/TestFailure.h>
-#include <cppunit/portability/Stream.h>
-#include <cppunit/TestListener.h>
-#include <cppunit/SourceLine.h>
-#include <cppunit/Exception.h>
-
-CPPUNIT_NS_BEGIN
-
-class CPPUNIT_API TestProgressListener : public TestListener
-{
-public:
-  TestProgressListener();
-
-  virtual ~TestProgressListener();
-
-  void startTest( Test *test );
-
-  void addFailure( const TestFailure &failure );
-
-  void endTest( Test *test );
-
-  int getResult() const;
-
-  void printResults() const;
-
-private:
-  TestProgressListener( const TestProgressListener &copy );
-
-  void operator =( const TestProgressListener &copy );
-
-private:
-  int m_Failures;
-  int m_Tests;
-  int m_Assertions;
-  bool m_lastTestFailed;
-};
-
-TestProgressListener::TestProgressListener() : m_Failures( 0 ), m_Tests(0), m_Assertions(0), m_lastTestFailed( false )
-{
-}
-
-TestProgressListener::~TestProgressListener()
-{
-}
-
-void TestProgressListener::startTest( Test * test )
-{
-	stdCOut() << test->getName() << ":" << "\n";
-	stdCOut().flush();
-
-	m_lastTestFailed = false;
-	m_Tests++;
-}
-
-void TestProgressListener::addFailure( const TestFailure &failure )
-{
-	stdCOut() << (failure.isError() ? "error" : "assertion") << " : " << failure.failedTestName() << " : " << failure.sourceLine().lineNumber() << "\n";
-	stdCOut() << "Exception " << failure.thrownException()->message().details();
-
-	m_lastTestFailed = true;
-	if(failure.isError()) m_Failures++; else m_Assertions++;
-}
-
-void TestProgressListener::endTest( Test * test)
-{
-	stdCOut() << "Result (" << test->getName() << ")";
-	stdCOut().flush();
-
-	if ( !m_lastTestFailed )
-		stdCOut() <<  " : OK";
-	else
-		stdCOut() << " : Fail";
-	stdCOut() << "\n\n";
-}
-
-int TestProgressListener::getResult() const {
-	return m_Failures + m_Assertions;
-}
-
-void TestProgressListener::printResults() const {
-	stdCOut() << "Overal result: Tests: " << m_Tests << " Assertions: " << m_Assertions << " Failures: " << m_Failures << "\n";
-}
-
-CPPUNIT_NS_END
-
-int main(int , char*[])
-{
-  CppUnit::TestResult controller;
-
-  CppUnit::TestResultCollector result;
-  controller.addListener( &result );
-
-  CppUnit::TestProgressListener progressListener;
-  controller.addListener( &progressListener );
-
-  // Get the top level suite from the registry
-  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
-
-  // Adds the test to the list of test to run
-  CppUnit::TextUi::TestRunner runner;
-  runner.addTest( suite );
-
-  // Change the default outputter to a compiler error format outputter
-  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
-                                                       std::cerr ) );
-  // Run the tests.
-  runner.run( controller );
-
-  progressListener.printResults();
-
-  return progressListener.getResult();
-}
diff --git a/aconversions2/makefile b/aconversions2/makefile
index 11a66752857ebf5535854d56a9b697061e78303d..eca2822c56827e8c70334ad9c61fbd169623b3d6 100644
--- a/aconversions2/makefile
+++ b/aconversions2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aconversions2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/aconvert2/makefile b/aconvert2/makefile
index 6a5314fdd0df214f75ca5fe735aa0ebacd462aa0..f47522dfd6e1cc31582a6e7351c7d5d3e53a3ea7 100644
--- a/aconvert2/makefile
+++ b/aconvert2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aconvert2
 
-LDFLAGS= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/aderivation2/makefile b/aderivation2/makefile
index a9755f66eabe0c4afb30a30e72e8043d75deb064..fc0f57bbe57255de979410de3d5370e3c08494ce 100644
--- a/aderivation2/makefile
+++ b/aderivation2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aderivation2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
 	mkdir -p $(dir $@)
-	echo "SHELL:=/bin/bash" >> $@
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
+	mkdir -p $(dir $@)
+	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" >> \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/adeterminize2/makefile b/adeterminize2/makefile
index 3938bd1f31b0481830be246cdd2396386d844010..70ef8ad206432c4dcc920e8d5a0713f821649396 100644
--- a/adeterminize2/makefile
+++ b/adeterminize2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=adeterminize2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/adiff2/makefile b/adiff2/makefile
index 642ce408159feebda3a2f13693a7f77613ef422b..30007b1e1874f43a09496bdf853e9d4f21d197fc 100644
--- a/adiff2/makefile
+++ b/adiff2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=adiff2
 
-LDFLAGS= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/aepsilon2/makefile b/aepsilon2/makefile
index a27207f150a8cff36b6b1543aef5baabed02c4c1..61bebcda73b9f496530a9b58f3e74dad7d3e7cc5 100644
--- a/aepsilon2/makefile
+++ b/aepsilon2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aepsilon2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/aintegral2/makefile b/aintegral2/makefile
index 6d59646d2aeb5059c99cf6ed2f4a8dbea4018778..570e9c41d9436eb93a85c4fe42a0cf00714ae6e3 100644
--- a/aintegral2/makefile
+++ b/aintegral2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aintegral2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
 	mkdir -p $(dir $@)
-	echo "SHELL:=/bin/bash" >> $@
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
+	mkdir -p $(dir $@)
+	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" >> \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/alib2algo/makefile b/alib2algo/makefile
index 8aee9884a67dec11d0d80f711f39b844c07c9d33..d37762de574de179767d49b3ea3a574023778728 100644
--- a/alib2algo/makefile
+++ b/alib2algo/makefile
@@ -1,33 +1,56 @@
 SHELL:=/bin/bash
-LIBRARY:=libalib2algo.so 
+LIBRARY:=libalib2algo.so
 TESTBIN:=alib2test
 
-LDFLAGS:= -L../alib2data/lib -rdynamic -shared -lalib2data
-TEST_LDFLAGS:= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lalib2data -lalib2algo -lcppunit -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -rdynamic -shared -lxml2
+TEST_LDFLAGS_DEBUG:= -Llib-debug -L../alib2data/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -lcppunit -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
-TEST_OBJECTS:=$(patsubst test-src/%.cpp, test-obj/%.o, $(shell find test-src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -rdynamic -shared -lxml2
+TEST_LDFLAGS_RELEASE:= -Llib-release -L../alib2data/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -lcppunit -Wl,-rpath,.
 
-.PHONY: all build test clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
+TEST_OBJECTS_DEBUG:=$(patsubst test-src/%.cpp, test-obj-debug/%.o, $(shell find test-src/ -name *cpp))
 
-all: build test
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(filter-out $(wildcard src/debug/*), $(shell find src/ -name *cpp)))
+TEST_OBJECTS_RELEASE:=$(patsubst test-src/%.cpp, test-obj-release/%.o, $(shell find test-src/ -name *cpp))
 
+.PHONY: all build-debug build-tests-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-lib/$(LIBRARY): obj/ $(OBJECTS)
-	mkdir -p lib
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug build-tests-debug
 
-obj/makefile: makefile
+release: build-release build-tests-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+test: unit-test-debug unit-test-release
+
+
+
+lib-debug/$(LIBRARY): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+lib-release/$(LIBRARY): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -38,9 +61,9 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
 	echo "%/makefile: makefile" >> $@
@@ -49,7 +72,7 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -59,30 +82,48 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0 -DDEBUG"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3 -DRELEASE"
+
+
+
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: lib-debug/$(LIBRARY)
+
+build-release: lib-release/$(LIBRARY)
+
 
 
-build: lib/$(LIBRARY)
+test-bin-debug/$(TESTBIN): test-obj-debug/ lib-debug/$(LIBRARY) $(TEST_OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(TEST_OBJECTS_DEBUG) -o $@ $(TEST_LDFLAGS_DEBUG)
 
+test-bin-release/$(TESTBIN): test-obj-release/ lib-release/$(LIBRARY) $(TEST_OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(TEST_OBJECTS_RELEASE) -o $@ $(TEST_LDFLAGS_RELEASE)
 
 
-test-bin/$(TESTBIN): test-obj/ lib/$(LIBRARY) $(TEST_OBJECTS)
-	mkdir -p test-bin
-	$(CXX) $(TEST_OBJECTS) -o $@ $(TEST_LDFLAGS)
 
-test-obj/makefile: makefile
+test-obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -I/usr/include/libxml2 -I../\$$(DEPTH)src/ -I../../\$$(DEPTH)alib2data/src" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/ -I../../\$$(DEPTH)alib2data/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -93,9 +134,9 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
 	echo "%/makefile: makefile" >> $@
@@ -104,7 +145,7 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -114,20 +155,48 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-test-obj/: FORCE | test-obj/makefile
-	$(MAKE) -C $@
 
-$(TEST_OBJECTS): test-obj/
 
-test: test-bin/$(TESTBIN)
-	LD_LIBRARY_PATH="lib;../alib2data/lib" test-bin/$(TESTBIN)
+test-obj-debug/: FORCE | test-obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=test-obj-debug CXX_OTHER_FLAGS="-g -O0 -DDEBUG"
+
+test-obj-release/: FORCE | test-obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=test-obj-release CXX_OTHER_FLAGS="-O3 -DRELEASE"
+
+
+
+$(TEST_OBJECTS_DEBUG): test-obj-debug/
+
+$(TEST_OBJECTS_RELEASE): test-obj-release/
+
+
+
+build-tests-debug: test-bin-debug/$(TESTBIN)
+
+build-tests-release: test-bin-release/$(TESTBIN)
 
 
 
-clean:
-	$(RM) -r *.o *.d lib obj test-bin test-obj
+unit-test-debug: build-tests-debug
+	LD_LIBRARY_PATH="../alib2data/lib-debug;lib-debug" test-bin-debug/$(TESTBIN)
+
+unit-test-release: build-tests-release
+	LD_LIBRARY_PATH="../alib2data/lib-release;lib-release" test-bin-release/$(TESTBIN)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d lib-debug obj-debug test-bin-debug test-obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d lib-release obj-release test-bin-release test-obj-release
+
+
 
 FORCE:
 
+
+
 doc:
 	doxygen
+
diff --git a/alib2data/makefile b/alib2data/makefile
index f138e3cb545bebf552e6b1e72cca6c9cc262ff99..7b0e587e62f62745bb06d58b2de5f927208d217c 100644
--- a/alib2data/makefile
+++ b/alib2data/makefile
@@ -1,33 +1,58 @@
 SHELL:=/bin/bash
-LIBRARY:=libalib2data.so 
+LIBRARY:=libalib2data.so
 TESTBIN:=alib2test
 
-LDFLAGS:=-lbfd -liberty -lz -ldl -rdynamic -shared -lxml2
-TEST_LDFLAGS:= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -lcppunit -Wl,-rpath,.
+LDFLAGS_DEBUG:=-lbfd -liberty -lz -ldl -rdynamic -shared -lxml2
+TEST_LDFLAGS_DEBUG:= -Llib-debug -rdynamic -lxml2 -lalib2data -lcppunit -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
-TEST_OBJECTS:=$(patsubst test-src/%.cpp, test-obj/%.o, $(shell find test-src/ -name *cpp))
+LDFLAGS_RELEASE:=-rdynamic -shared -lxml2
+TEST_LDFLAGS_RELEASE:= -Llib-release -rdynamic -lxml2 -lalib2data -lcppunit -Wl,-rpath,.
 
-.PHONY: all build test clean doc
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
+TEST_OBJECTS_DEBUG:=$(patsubst test-src/%.cpp, test-obj-debug/%.o, $(shell find test-src/ -name *cpp))
 
-all: build test
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(filter-out $(wildcard src/debug/*), $(shell find src/ -name *cpp)))
+TEST_OBJECTS_RELEASE:=$(patsubst test-src/%.cpp, test-obj-release/%.o, $(shell find test-src/ -name *cpp))
 
+.PHONY: all build-debug build-tests-debug clean-debug doc
 
 
-lib/$(LIBRARY): obj/ $(OBJECTS)
-	mkdir -p lib
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
 
-obj/makefile: makefile
+all:
+	@echo "What to do master?"
+
+debug: build-debug build-tests-debug
+
+release: build-release build-tests-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+test: unit-test-debug unit-test-release
+
+
+
+lib-debug/$(LIBRARY): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+lib-release/$(LIBRARY): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -fPIC -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I/usr/include/libxml2/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -38,9 +63,9 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
 	echo "%/makefile: makefile" >> $@
@@ -49,7 +74,7 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -59,30 +84,48 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
 
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0 -DDEBUG"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3 -DRELEASE"
+
+
+
+$(OBJECTS_DEBUG): obj-debug/
 
-build: lib/$(LIBRARY)
+$(OBJECTS_RELEASE): obj-release/
 
 
+build-debug: lib-debug/$(LIBRARY)
 
-test-bin/$(TESTBIN): test-obj/ lib/$(LIBRARY) $(TEST_OBJECTS)
-	mkdir -p test-bin
-	$(CXX) $(TEST_OBJECTS) -o $@ $(TEST_LDFLAGS)
+build-release: lib-release/$(LIBRARY)
 
-test-obj/makefile: makefile
+
+
+test-bin-debug/$(TESTBIN): test-obj-debug/ lib-debug/$(LIBRARY) $(TEST_OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(TEST_OBJECTS_DEBUG) -o $@ $(TEST_LDFLAGS_DEBUG)
+
+test-bin-release/$(TESTBIN): test-obj-release/ lib-release/$(LIBRARY) $(TEST_OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(TEST_OBJECTS_RELEASE) -o $@ $(TEST_LDFLAGS_RELEASE)
+
+
+
+test-obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/ -I/usr/include/libxml2/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -93,9 +136,9 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
 	echo "%/makefile: makefile" >> $@
@@ -104,7 +147,7 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -114,20 +157,47 @@ test-obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-test-obj/: FORCE | test-obj/makefile
-	$(MAKE) -C $@
 
-$(TEST_OBJECTS): test-obj/
 
-test: test-bin/$(TESTBIN)
-	LD_LIBRARY_PATH="lib" test-bin/$(TESTBIN)
+test-obj-debug/: FORCE | test-obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=test-obj-debug CXX_OTHER_FLAGS="-g -O0 -DDEBUG"
+
+test-obj-release/: FORCE | test-obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=test-obj-release CXX_OTHER_FLAGS="-O3 -DRELEASE"
+
+
+
+$(TEST_OBJECTS_DEBUG): test-obj-debug/
+
+$(TEST_OBJECTS_RELEASE): test-obj-release/
+
+
+
+build-tests-debug: test-bin-debug/$(TESTBIN)
 
+build-tests-release: test-bin-release/$(TESTBIN)
+
+
+
+unit-test-debug: build-tests-debug
+	LD_LIBRARY_PATH="lib-debug" test-bin-debug/$(TESTBIN)
+
+unit-test-release: build-tests-release
+	LD_LIBRARY_PATH="lib-release" test-bin-release/$(TESTBIN)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d lib-debug obj-debug test-bin-debug test-obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d lib-release obj-release test-bin-release test-obj-release
 
 
-clean:
-	$(RM) -r *.o *.d doc lib obj test-bin test-obj
 
 FORCE:
 
+
+
 doc:
 	doxygen
diff --git a/alib2data/src/std/addr2line.cpp b/alib2data/src/debug/addr2line.cpp
similarity index 100%
rename from alib2data/src/std/addr2line.cpp
rename to alib2data/src/debug/addr2line.cpp
diff --git a/alib2data/src/std/addr2line.h b/alib2data/src/debug/addr2line.h
similarity index 100%
rename from alib2data/src/std/addr2line.h
rename to alib2data/src/debug/addr2line.h
diff --git a/alib2data/src/std/bfdStacktrace.cpp b/alib2data/src/debug/bfdStacktrace.cpp
similarity index 99%
rename from alib2data/src/std/bfdStacktrace.cpp
rename to alib2data/src/debug/bfdStacktrace.cpp
index 4b69bfef411eabc424af40bce0808993d0507309..6f51fe19eabaf824207623940fc53385d0ca5e9f 100644
--- a/alib2data/src/std/bfdStacktrace.cpp
+++ b/alib2data/src/debug/bfdStacktrace.cpp
@@ -13,7 +13,7 @@
 
 #include <sstream>
 #include <string>
-#include "map.hpp"
+#include "../std/map.hpp"
 
 #include "addr2line.h"
 
diff --git a/alib2data/src/std/bfdStacktrace.h b/alib2data/src/debug/bfdStacktrace.h
similarity index 100%
rename from alib2data/src/std/bfdStacktrace.h
rename to alib2data/src/debug/bfdStacktrace.h
diff --git a/alib2data/src/std/sigHandler.cpp b/alib2data/src/debug/sigHandler.cpp
similarity index 90%
rename from alib2data/src/std/sigHandler.cpp
rename to alib2data/src/debug/sigHandler.cpp
index 67f0272ba6980cbed24f29c33dc5c4d100b174ab..320a965290dc32756525ce0b229962fa5e7b4ae6 100644
--- a/alib2data/src/std/sigHandler.cpp
+++ b/alib2data/src/debug/sigHandler.cpp
@@ -5,6 +5,7 @@
 #include <unistd.h>
 
 #include "sigHandler.h"
+
 #include "bfdStacktrace.h"
 #include "simpleStacktrace.h"
 #include <iostream>
@@ -23,7 +24,9 @@ void SigHandler::handler(int signal) {
 			std::cout << "Unknown signal" << std::endl;
 			break;
 	}
-	std::cout << std::bfdStacktrace() << std::endl;
+	#ifdef DEBUG
+		std::cout << std::bfdStacktrace() << std::endl;
+	#endif
 	exit(1);
 }
 
diff --git a/alib2data/src/std/sigHandler.h b/alib2data/src/debug/sigHandler.h
similarity index 100%
rename from alib2data/src/std/sigHandler.h
rename to alib2data/src/debug/sigHandler.h
diff --git a/alib2data/src/std/simpleStacktrace.cpp b/alib2data/src/debug/simpleStacktrace.cpp
similarity index 100%
rename from alib2data/src/std/simpleStacktrace.cpp
rename to alib2data/src/debug/simpleStacktrace.cpp
diff --git a/alib2data/src/std/simpleStacktrace.h b/alib2data/src/debug/simpleStacktrace.h
similarity index 100%
rename from alib2data/src/std/simpleStacktrace.h
rename to alib2data/src/debug/simpleStacktrace.h
diff --git a/alib2data/src/exception/AlibException.cpp b/alib2data/src/exception/AlibException.cpp
index df03a717d02d396432b7a7c95914cf639a1209b4..ab7e44fc1815c7b1490bd18b78c8463375c82538 100644
--- a/alib2data/src/exception/AlibException.cpp
+++ b/alib2data/src/exception/AlibException.cpp
@@ -13,12 +13,18 @@
 #include <sstream>
 
 #include <execinfo.h>
-#include "../std/bfdStacktrace.h"
+#ifdef DEBUG
+	#include "../debug/bfdStacktrace.h"
+#endif
 
 namespace exception {
 
 AlibException::AlibException ( ) {
-//	this->backtrace = std::bfdStacktrace();
+	#ifdef DEBUG
+		this->backtrace = std::bfdStacktrace();
+	#else
+		this->backtrace = "";
+	#endif
 
 	this->whatMessage += this->backtrace;
 }
diff --git a/aminimize2/makefile b/aminimize2/makefile
index e0b982c6f806223f72833072dd4e76ecea7bfe9e..ee55f93ec0fff4d61bf2f2d0879b24265b2986d6 100644
--- a/aminimize2/makefile
+++ b/aminimize2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=aminimize2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/anormalize2/makefile b/anormalize2/makefile
index 6c93eb7afec39ca6e574eee0e982c0a996894e99..7e83c491818fcd809b836b8532bb038c22cb3d10 100644
--- a/anormalize2/makefile
+++ b/anormalize2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=anormalize2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/arand2/makefile b/arand2/makefile
index 41eec9290c1499ec3c8ea2926deb1de99677acdb..233c067d3d0db854cdc6f2c281eb99779aab202c 100644
--- a/arand2/makefile
+++ b/arand2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=arand2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/astat2/makefile b/astat2/makefile
index fb3e0af5b6212ff2bdf0b55f54c64fabef2df233..e001526e9e8452f27738c095e14cda2e4851cadd 100644
--- a/astat2/makefile
+++ b/astat2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=astat2
 
-LDFLAGS= -L../alib2data/lib -rdynamic -lxml2 -lalib2data -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/atrim2/makefile b/atrim2/makefile
index 54ff5a10e87943829808c7b2c3a66f3a021fc587..77686be709eda5baf01cb7016da0067dca6284eb 100644
--- a/atrim2/makefile
+++ b/atrim2/makefile
@@ -1,30 +1,49 @@
 SHELL:=/bin/bash
 EXECUTABLE:=atrim2
 
-LDFLAGS= -L../alib2data/lib -L../alib2algo/lib -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
+LDFLAGS_DEBUG:=-L../alib2data/lib-debug -L../alib2algo/lib-debug -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-OBJECTS:=$(patsubst src/%.cpp, obj/%.o, $(shell find src/ -name *cpp))
+LDFLAGS_RELEASE:=-L../alib2data/lib-release -L../alib2algo/lib-release -rdynamic -lxml2 -lalib2data -lalib2algo -Wl,-rpath,.
 
-.PHONY: all build clean
+OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp))
 
-all: build
+OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp))
 
+.PHONY: all build-debug clean-debug doc
 
+all:
+	@echo "What to do master?"
 
-bin/$(EXECUTABLE): obj/ $(OBJECTS)
-	mkdir -p bin
-	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
+debug: build-debug
 
-obj/makefile: makefile
+release: build-release
+
+clean: clean-debug clean-release
+	$(RM) -r doc
+
+
+
+bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG)
+
+bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE)
+	mkdir -p $(dir $@)
+	$(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE)
+
+
+
+obj%/makefile: makefile
 	mkdir -p $(dir $@)
 	echo "SHELL:=/bin/bash" > $@
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
+	echo "OBJECTS_BASE_DIR:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -fPIC -I../../\$$(DEPTH)alib2data/src/ -I../../\$$(DEPTH)alib2algo/src/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
-	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
+	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
 	echo "OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))" >> $@
 	echo "SOURCES_DIRS:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)" >> $@
 	echo "OBJECTS_DIRS:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))" >> $@
@@ -35,18 +54,18 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "all: \$$(OBJECTS_DIRS) \$$(OBJECTS)" >> $@
 	echo "" >> $@
-	echo "%.d:" >> $@
-	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)obj/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
-	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\"))\" >> \$$@" >> $@
+	echo "%.d: makefile" >> $@
+	echo "	@echo \"\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -MM \\$$\$$(CXXFLAGS) \$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst ../\$$(DEPTH)\$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\" > \$$@" >> $@
+	echo "	@echo \"\$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/  -//g\")) makefile\" >> \$$@" >> $@
 	echo "	@echo \"	\\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\" >> \$$@" >> $@
 	echo "" >> $@
-	echo "%/makefile:" >> $@
+	echo "%/makefile: makefile" >> $@
 	echo "	mkdir -p \$$(dir \$$@)" >> $@
 	echo "	cp makefile \$$@" >> $@
 	echo "" >> $@
 	echo "%/: FORCE | %/makefile" >> $@
 	echo "	@accesstime=\`stat -c %Y \$$@\` && \\" >> $@
-	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ && \\" >> $@
+	echo "	\$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ DEPTH=\$$(DEPTH)../ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\" >> $@
 	echo "	accesstime2=\`stat -c %Y \$$@\` && \\" >> $@
 	echo "	if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\" >> $@
 	echo "		touch .; \\" >> $@
@@ -56,18 +75,39 @@ obj/makefile: makefile
 	echo "" >> $@
 	echo "-include \$$(DEPENDENCIES)" >> $@
 
-obj/: FORCE | obj/makefile
-	$(MAKE) -C $@
 
-$(OBJECTS): obj/
+
+obj-debug/: FORCE | obj-debug/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-debug CXX_OTHER_FLAGS="-g -O0"
+
+obj-release/: FORCE | obj-release/makefile
+	$(MAKE) -C $@ OBJECTS_BASE_DIR=obj-release CXX_OTHER_FLAGS="-O3"
 
 
-build: bin/$(EXECUTABLE)
 
+$(OBJECTS_DEBUG): obj-debug/
+
+$(OBJECTS_RELEASE): obj-release/
+
+
+build-debug: bin-debug/$(EXECUTABLE)
+
+build-release: bin-release/$(EXECUTABLE)
+
+
+
+clean-debug:
+	$(RM) -r *.o *.d bin-debug obj-debug
+
+clean-release:
+	$(RM) -r *.o *.d bin-release obj-release
 
 
-clean:
-	$(RM) -r *.o *.d bin lib obj test-bin test-obj
 
 FORCE:
 
+
+
+doc:
+	doxygen
+
diff --git a/makefile b/makefile
index 3cd64bc98ee24c9d0a65669538c7b3ff0b9d45d9..46b5505029cc13d392bd76fc7133a75e2223a7b8 100644
--- a/makefile
+++ b/makefile
@@ -20,54 +20,150 @@ SUBDIRS_BINS = acat2 \
 
 SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile))
 
-.PHONY: $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS) build copy test
+.PHONY: $(addsuffix .build-debug  , $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))  \
+	$(addsuffix .build-release, $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))\
+	$(addsuffix .build-debug-tests  , $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))  \
+	$(addsuffix .build-release-tests, $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))\
+	build-debug   build-test-debug   unit-test-debug   copy-debug   test-debug   clean-debug   \
+	build-release build-test-release unit-test-release copy-release test-release clean-release \
+	doc all
 
-all: build copy test
+# ifneq (3.82, $(firstword $(sort $(MAKE_VERSION) 3.81)))
+# 	$(error version at least 3.82 is needed for make to work)
+# endif
 
-build: $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS)
+all: debug release doc
 
-$(CORE_LIB):
-	$(MAKE) -C $@
 
-$(SUBDIRS_LIBS): $(CORE_LIB)
-	$(MAKE) -C $@
 
-$(SUBDIRS_BINS): $(SUBDIRS_LIBS)
-	$(MAKE) -C $@
+debug  : build-debug   build-tests-debug   unit-test-debug   copy-debug   test-debug
 
-clean:
+release: build-release build-tests-release unit-test-release copy-release test-release
+
+clean  : clean-debug   clean-release
+	$(RM) -r bin-debug bin-release
+
+build-debug  : $(addsuffix .build-debug  , $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))
+
+build-release: $(addsuffix .build-release, $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))
+
+
+
+build-tests-debug  : build-debug   $(addsuffix .build-tests-debug  , $(CORE_LIB) $(SUBDIRS_LIBS))
+
+build-tests-release: build-release $(addsuffix .build-tests-release, $(CORE_LIB) $(SUBDIRS_LIBS))
+
+
+
+$(addsuffix .build-debug, $(CORE_LIB)):
+	$(MAKE) build-debug -C $(basename $@)
+
+$(addsuffix .build-debug, $(SUBDIRS_LIBS)): $(addsuffix .build-debug, $(CORE_LIB))
+	$(MAKE) build-debug -C $(basename $@)
+
+$(addsuffix .build-debug, $(SUBDIRS_BINS)): $(addsuffix .build-debug, $(SUBDIRS_LIBS))
+	$(MAKE) build-debug -C $(basename $@)
+
+
+
+$(addsuffix .build-release, $(CORE_LIB)):
+	$(MAKE) build-release -C $(basename $@)
+
+$(addsuffix .build-release, $(SUBDIRS_LIBS)): $(addsuffix .build-release, $(CORE_LIB))
+	$(MAKE) build-release -C $(basename $@)
+
+$(addsuffix .build-release, $(SUBDIRS_BINS)): $(addsuffix .build-release, $(SUBDIRS_LIBS))
+	$(MAKE) build-release -C $(basename $@)
+
+
+
+$(addsuffix .build-tests-debug, $(CORE_LIB)): $(addsuffix .build-debug, $(CORE_LIB))
+	$(MAKE) build-tests-debug -C $(basename $@)
+
+$(addsuffix .build-tests-debug, $(SUBDIRS_LIBS)): $(addsuffix .build-tests-debug, $(CORE_LIB)) $(addsuffix .build-debug, $(SUBDIRS_LIBS))
+	$(MAKE) build-tests-debug -C $(basename $@)
+
+
+
+$(addsuffix .build-tests-release, $(CORE_LIB)): $(addsuffix .build-release, $(CORE_LIB))
+	$(MAKE) build-tests-release -C $(basename $@)
+
+$(addsuffix .build-tests-release, $(SUBDIRS_LIBS)): $(addsuffix .build-tests-release, $(CORE_LIB)) $(addsuffix .build-release, $(SUBDIRS_LIBS))
+	$(MAKE) build-tests-release -C $(basename $@)
+
+
+
+clean-debug:
 	for dir in $(SUBDIRS_WITH_MAKE); do \
-	    $(MAKE) -C $$dir clean; \
+	    $(MAKE) clean-debug -C $$dir; \
 	done
 
-copy: $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS)
-	mkdir -p $(BINFOLDER)
-	rm -rf $(BINFOLDER)/*
+clean-release:
+	for dir in $(SUBDIRS_WITH_MAKE); do \
+	    $(MAKE) clean-release -C $$dir; \
+	done
+
+
+
+copy-debug: $(addsuffix .build-debug, $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))
+	mkdir -p $(addsuffix -debug, $(BINFOLDER))
+	rm -rf $(addsuffix -debug, $(BINFOLDER))/*
+	for dir in $(CORE_LIB) $(SUBDIRS_LIBS); do \
+	    cp $$dir/lib-debug/* $(addsuffix -debug, $(BINFOLDER)); \
+	done
+	for dir in $(SUBDIRS_BINS); do \
+	    cp $$dir/bin-debug/* $(addsuffix -debug, $(BINFOLDER)); \
+	done
+
+copy-release: $(addsuffix .build-release, $(CORE_LIB) $(SUBDIRS_LIBS) $(SUBDIRS_BINS))
+	mkdir -p $(addsuffix -release, $(BINFOLDER))
+	rm -rf $(addsuffix -release, $(BINFOLDER))/*
 	for dir in $(CORE_LIB) $(SUBDIRS_LIBS); do \
-	    cp $$dir/lib/* $(BINFOLDER); \
+	    cp $$dir/lib-release/* $(addsuffix -release, $(BINFOLDER)); \
 	done
 	for dir in $(SUBDIRS_BINS); do \
-	    cp $$dir/bin/* $(BINFOLDER); \
+	    cp $$dir/bin-release/* $(addsuffix -release, $(BINFOLDER)); \
 	done
 
-install:
-	cp alib/lib/libalib.so $(LIBPATH)
-	cp acat/bin/acat $(APPPATH)
-	cp aconvert/bin/aconvert $(APPPATH)
-	cp aconvert.dot/bin/aconvert.dot $(APPPATH)
-	cp aconvert.gastex/bin/aconvert.gastex $(APPPATH)
-	cp aminimize/bin/aminimize $(APPPATH)
-
-uninstall:
-	rm $(LIBPATH)/libalib.so
-	rm $(APPPATH)/acat
-	rm $(APPPATH)/aconvert
-	rm $(APPPATH)/aconvert.dot
-	rm $(APPPATH)/aconvert.gastex
-	rm $(APPPATH)/aminimize
-
-test: copy
-	./tests.aconversion.sh
+
+
+# install:
+# 	cp alib/lib/libalib.so $(LIBPATH)
+# 	cp acat/bin/acat $(APPPATH)
+# 	cp aconvert/bin/aconvert $(APPPATH)
+# 	cp aconvert.dot/bin/aconvert.dot $(APPPATH)
+# 	cp aconvert.gastex/bin/aconvert.gastex $(APPPATH)
+# 	cp aminimize/bin/aminimize $(APPPATH)
+
+# uninstall:
+# 	rm $(LIBPATH)/libalib.so
+# 	rm $(APPPATH)/acat
+# 	rm $(APPPATH)/aconvert
+# 	rm $(APPPATH)/aconvert.dot
+# 	rm $(APPPATH)/aconvert.gastex
+# 	rm $(APPPATH)/aminimize
+
+unit-test-debug: build-tests-debug
+	for dir in $(CORE_LIB) $(SUBDIRS_LIBS); do \
+	    $(MAKE) unit-test-debug -C $$dir; \
+	done
+
+unit-test-verbose: build-tests-release
+	for dir in $(CORE_LIB) $(SUBDIRS_LIBS); do \
+	    $(MAKE) unit-test-release -C $$dir; \
+	done
+
+
+
+test-debug: copy-debug unit-test-debug
+	./tests.aconversion.sh debug
+
+
+
+test-release: copy-release unit-test-release
+	./tests.aconversion.sh release
+
+
 
 doc:
 	$(MAKE) doc -C alib2data
diff --git a/tests.aconversion.sh b/tests.aconversion.sh
index 2216a35f9f903f9c0d65408d1a2584749bb9dd02..ff45fc25b59c6d34130403b9928392e94bb160e1 100755
--- a/tests.aconversion.sh
+++ b/tests.aconversion.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+# $1 test dir suffix (debug / release)
+
 # SETTINGS
 TESTCASE_ITERATIONS=100
 TESTCASE_TIMEOUT=10
@@ -22,13 +24,13 @@ RES_UNKN=0
 # ----------------------------
 
 for FILE in $EXECUTABLES; do
-	if [ ! -f bin/$FILE ]; then
-		echo "Executable" $FILE "is required for testing. Make sure it is in bin folder."
+	if [ ! -f bin-$1/$FILE ]; then
+		echo "Executable $FILE is required for testing. Make sure it is in bin-$1 folder."
 		exit 1
 	fi
 done
 
-cd bin/
+cd bin-$1/
 rm -f $LOGFILE
 
 # ----------------------------