# Architecture definitions.

SUPPORTED_ARCHS = linux win32 ns-2
DEFAULT_ARCH = linux

ifeq "$(ARCH)" ""
	ARCH = $(DEFAULT_ARCH)
endif

DEPENDENCY_FILE = Makefile.dep


# List source and objects files.

export SRC_DIR = src

export SOURCES = \
	$(SRC_DIR)/main.c \
	$(SRC_DIR)/interface.c \
	$(SRC_DIR)/util/debug.c \
	$(SRC_DIR)/util/list.c \
	$(SRC_DIR)/util/callback.c \
	$(SRC_DIR)/util/net.c \
	$(SRC_DIR)/icmp-light/icmp-light.c \
	$(SRC_DIR)/rudp-light/rudp-light.c \
	$(SRC_DIR)/slp-light/slp-light.c \
	$(SRC_DIR)/service/service.c \
	$(SRC_DIR)/service/service_client.c \
	$(SRC_DIR)/service/service_server.c \
	$(SRC_DIR)/service/service_management.c \
	$(SRC_DIR)/service/service_replication.c \
	$(SRC_DIR)/service/service_util.c \
	$(SRC_DIR)/placement/placement.c \
	$(SRC_DIR)/placement/placement_stats.c \
	$(SRC_DIR)/placement/simple_heuristic/simple_heuristic.c \
	$(SRC_DIR)/placement/tree-topology_migration/tree-topology_migration.c \
	$(SRC_DIR)/placement/linkpull_migration/linkpull_migration.c \
	$(SRC_DIR)/placement/peerpull_migration/peerpull_migration.c \
	$(SRC_DIR)/graphs/graphs.c \
	$(SRC_DIR)/graphs/graphs_local.c

export OBJECTS = \
	$(SRC_DIR)/main.o \
	$(SRC_DIR)/interface.o \
	$(SRC_DIR)/util/debug.o \
	$(SRC_DIR)/util/list.o \
	$(SRC_DIR)/util/callback.o \
	$(SRC_DIR)/util/net.o \
	$(SRC_DIR)/icmp-light/icmp-light.o \
	$(SRC_DIR)/rudp-light/rudp-light.o \
	$(SRC_DIR)/slp-light/slp-light.o \
	$(SRC_DIR)/service/service.o \
	$(SRC_DIR)/service/service_client.o \
	$(SRC_DIR)/service/service_server.o \
	$(SRC_DIR)/service/service_management.o \
	$(SRC_DIR)/service/service_replication.o \
	$(SRC_DIR)/service/service_util.o \
	$(SRC_DIR)/placement/placement.o \
	$(SRC_DIR)/placement/placement_stats.o \
	$(SRC_DIR)/placement/simple_heuristic/simple_heuristic.o \
	$(SRC_DIR)/placement/tree-topology_migration/tree-topology_migration.o \
	$(SRC_DIR)/placement/linkpull_migration/linkpull_migration.o \
	$(SRC_DIR)/placement/peerpull_migration/peerpull_migration.o \
	$(SRC_DIR)/graphs/graphs.o \
	$(SRC_DIR)/graphs/graphs_local.o



# Define build targets.

.PHONY: all install clean distclean doc public_doc stats

all: $(DEPENDENCY_FILE)
	@$(MAKE) -f Makefile.$(ARCH) all

$(DEPENDENCY_FILE):
	makedepend -DSP_ARCH_NONE -I/usr/include/linux -I/usr/lib/gcc/i486-linux-gnu/4.2/include/ -f- $(SOURCES) > $(DEPENDENCY_FILE)

install:
	@$(MAKE) -f Makefile.$(ARCH) install

clean:
	@$(MAKE) -f Makefile.$(ARCH) clean

distclean:
	@for arch in $(SUPPORTED_ARCHS); do \
		$(MAKE) -f Makefile.$$arch clean; \
		if [ $$? != 0 ]; then break; fi; \
	done
	$(RM) $(DEPENDENCY_FILE)
	$(RM) -r doc
	$(RM) -r public_doc
	$(RM) -r stats

doc:
	doxygen Doxyfile.complete

public_doc:
	doxygen Doxyfile.public

stats:
	mkdir -p stats/
	svn up
	svn log -v --xml > stats/logfile.log
	java -jar ~/usr/local/statsvn/statsvn.jar stats/logfile.log . -output-dir stats/ -cache-dir stats/
