# 
# $Id$
# 
# [ Description ]
# 
# Makefile
# 

#-----[ Directory ]----------------------------------------
DIR_SRC				= src
DIR_OBJ				= obj
DIR_BIN				= bin
DIR_DATA			= data

#-----[ Commands ]-----------------------------------------
ECHO				= echo
MKDIR				= mkdir
RM				= rm -fr
PWD				= `pwd`

CXX				= g++
CXX_OPT				= -O3 -g3 -Wall -ansi $(INCLUDE) 

INCLUDE				= -I. -I.. -I../include -I../../Include

OBJECTS				= $(patsubst ../$(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard ../$(DIR_SRC)/*.cpp)) \
				  $(patsubst $(DIR_SRC)/%.cpp,$(DIR_OBJ)/%.o,$(wildcard $(DIR_SRC)/*.cpp))

EXE				= soft

#-----[ Rules ]--------------------------------------------
.PRECIOUS			: $(DIR_BIN)/%.x $(DIR_OBJ)/%.o

all				: $(DIR_OBJ) $(DIR_BIN) $(DIR_BIN)/$(EXE).x

test				: all
				./$(DIR_BIN)/$(EXE).x

$(DIR_BIN)/%.x			: $(OBJECTS)
				@$(ECHO) "Compilation        : $*"
				@$(CXX) $(CXX_OPT)     -o $@ $^

$(DIR_OBJ)/%.o			: $(DIR_SRC)/%.cpp
				@$(ECHO) "Compilation        : $*"
				@$(CXX) $(CXX_OPT) -c -o $@ $<

$(DIR_OBJ)/%.o			: ../$(DIR_SRC)/%.cpp
				@$(ECHO) "Compilation        : $*"
				@$(CXX) $(CXX_OPT) -c -o $@ $<

$(DIR_OBJ)			:
				@$(ECHO) "Create directory   : $@"
				@$(MKDIR) $@

$(DIR_BIN)			:
				@$(ECHO) "Create directory   : $@"
				@$(MKDIR) $@

clean				:
				@$(ECHO) "Delete     temporary files in directory "$(PWD)
				@$(RM) $(DIR_OBJ) $(DIR_BIN) *~ $(DIR_SRC)/*~

