#########################################
### 
###      M A K E F I L E
###
###
###


# compiler flags ------------------------------

CPP = g++

# uncomment to enable debug builds
#DEBUGFLAGS = -g 
CFLAGS = -Wall -Iinclude $(DEBUGFLAGS)


$./%.o %.o: %.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -c -o $@ $<

# compile --------------------------------------------------------
all:	configreader



datalink.o:  datalink.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

simulator.o:  simulator.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

netreader.o:  netreader.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

simreader.o:  simreader.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

network.o:  network.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

parse.o:  parse.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

router.o : router.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

ipaddress.o: ipaddress.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

configreader.o: configreader.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

simulation.o: simulation.cpp
	@ echo "    ---- Compiling $< (C++)"
	@ $(CPP) $(CFLAGS) -DOUTPUT_VIEW -c -o $@ $<

configreader:	Makefile.depend  configreader.o ipaddress.o \
	         datalink.o router.o simreader.o netreader.o parse.o \
                 network.o simulator.o 

	@ echo "    ---- Linking"
	@ $(CPP) ipaddress.o configreader.o datalink.o router.o \
	         simreader.o netreader.o network.o simulator.o parse.o \
	         $(LIBS) -o configreader $(DEBUGFLAGS)

clean:
	rm -f -R *.o Makefile.depend configreader core
	 

# General dependencies -------------------------------------------


Makefile.depend:
	@ echo "    ---- Analyzing dependencies"
	@ $(CPP) -MM $(CFLAGS) *.cpp > Makefile.depend

depend:	Makefile.depend

include Makefile.depend
















