#################################################
##              In the name of GOD
##
## Copyright (C) 2009 Behnam Momeni.
## All rights reserved.
##
## This file is part of the HVNS project.
##
#################################################

COMPILER = g++
FLAGS = -Wall -g -Ibase -Iuser
LIBS = -lpthread

TARGET = dns.out

BASE_SOURCES = base/main.cpp \
	base/cf.cpp \
	base/interface.cpp \
	base/machine.cpp \
	base/frame.cpp

USER_SOURCES = user/dns.cpp

BASE_OBJ = ${BASE_SOURCES:.cpp=.o}
BASE_OBJECTS = ${BASE_OBJ:.c=.o}

USER_OBJ = ${USER_SOURCES:.cpp=.o}
USER_OBJECTS = ${USER_OBJ:.c=.o}

OBJECTS = ${BASE_OBJECTS} ${USER_OBJECTS}

all: dnsserver server client

dnsserver: ${OBJECTS}
	${COMPILER} ${FLAGS} -o ${TARGET} ${OBJECTS} ${LIBS}

client:
	${COMPILER} ${FLAGS} user/client.cpp -lpthread -o client.out

server:
	${COMPILER} ${FLAGS} user/server.cpp -lutil -lpthread -o server.out

clean:
	rm -f ${OBJECTS} client.out server.out ${TARGET} *~ base/*~ user/*~

.cpp.o:
	${COMPILER} ${FLAGS} -c $< -o $@
.c.o:
	${COMPILER} ${FLAGS} -c $< -o $@
