#=====================================================================
#
# toplevel makefile for OMNeT++ libraries and programs
#
#=====================================================================

#
# Directories
#
OMNETPP_BIN_DIR =       /home/andras/omnetpp-2.3/bin
OMNETPP_LIB_DIR =       /home/andras/omnetpp-2.3/lib
OMNETPP_SRC_DIR =       /home/andras/omnetpp-2.3/src
OMNETPP_INCL_DIR =      /home/andras/omnetpp-2.3/include
OMNETPP_DOC_DIR =       /home/andras/omnetpp-2.3/doc
OMNETPP_SAMPLES_DIR =   /home/andras/omnetpp-2.3/samples
OMNETPP_TUTORIAL_DIR =  /home/andras/omnetpp-2.3/tutorial
OMNETPP_TEST_DIR =      /home/andras/omnetpp-2.3/test

#=====================================================================
#
# Main targets
#
#=====================================================================


all: check-env components

components: libs progs


#=====================================================================
#
# OMNeT++ components
#
#=====================================================================

LIBS=sim nedxml envir cmdenv tkenv
PROGS=utils nedc gned plove
SAMPLES=dyna dyna2 fddi fifo1 fifo2 hcube hist nim token topo demo

#
# Group targets. Note that utils has to be built BEFORE other libs and progs
# because tcl2c might be needed to build tkenv or gned.
#
libs: utils $(LIBS)
progs: $(PROGS)
samples: $(SAMPLES)
docs: api nedxml-api manual

#
# Libraries
#

sim:
	cd $(OMNETPP_SRC_DIR)/sim && $(MAKE)

nedxml:
	cd $(OMNETPP_SRC_DIR)/nedxml && $(MAKE)

envir:
	cd $(OMNETPP_SRC_DIR)/envir && $(MAKE)

cmdenv:
	cd $(OMNETPP_SRC_DIR)/cmdenv && $(MAKE)

tkenv:
	cd $(OMNETPP_SRC_DIR)/tkenv && $(MAKE)

#
# Programs
#

nedc:
	cd $(OMNETPP_SRC_DIR)/nedc && $(MAKE)

gned:
	cd $(OMNETPP_SRC_DIR)/gned && $(MAKE)

plove:
	cd $(OMNETPP_SRC_DIR)/plove && $(MAKE)

utils:
	cd $(OMNETPP_SRC_DIR)/utils &&  $(MAKE)

#
# Sample programs
#

dyna:
	cd $(OMNETPP_SAMPLES_DIR)/dyna && $(MAKE)

fddi:
	cd $(OMNETPP_SAMPLES_DIR)/fddi && $(MAKE)

fifo1:
	cd $(OMNETPP_SAMPLES_DIR)/fifo1 && $(MAKE)

fifo2:
	cd $(OMNETPP_SAMPLES_DIR)/fifo2 && $(MAKE)

hcube:
	cd $(OMNETPP_SAMPLES_DIR)/hcube && $(MAKE)

hist:
	cd $(OMNETPP_SAMPLES_DIR)/hist && $(MAKE)

nim:
	cd $(OMNETPP_SAMPLES_DIR)/nim && $(MAKE)

token:
	cd $(OMNETPP_SAMPLES_DIR)/token && $(MAKE)

dyna2:
	cd $(OMNETPP_SAMPLES_DIR)/dyna2 && $(MAKE)

topo:
	cd $(OMNETPP_SAMPLES_DIR)/topo && $(MAKE)

demo:
	cd $(OMNETPP_SAMPLES_DIR)/demo && $(MAKE)

tutorials:
	cd $(OMNETPP_TUTORIAL_DIR)/queues && $(MAKE)

#
# Documentation
#
api:
	cd $(OMNETPP_INCL_DIR) && $(MAKE) doc

nedxml-api:
	cd $(OMNETPP_SRC_DIR)/nedxml && $(MAKE) doc

manual:
	cd $(OMNETPP_DOC_DIR)/usman && $(MAKE)

#
# Test
#
tests: libs progs
	cd $(OMNETPP_TEST_DIR) && $(MAKE)

#=====================================================================
#
# Utilities
#
#=====================================================================

check-env:
	@probefile=__probe__; \
	if (echo '' >/home/andras/omnetpp-2.3/bin/$$probefile && \
	    chmod +x /home/andras/omnetpp-2.3/bin/$$probefile) 2>/dev/null; then \
	  if $$probefile >/dev/null 2>/dev/null; then :; else \
	    echo '  *** Warning: /home/andras/omnetpp-2.3/bin is not in the path, some components may not build!'; \
	  fi; \
	else \
	  echo '  *** Warning: Cannot write to /home/andras/omnetpp-2.3/bin, does it exist?'; \
	fi; \
	rm -f /home/andras/omnetpp-2.3/bin/$$probefile; \
	if uname | grep "CYGWIN" >/dev/null; then :; else \
	  if echo $$LD_LIBRARY_PATH | grep "/home/andras/omnetpp-2.3/lib" >/dev/null; then :; else \
	    echo '  *** Warning: Looks like /home/andras/omnetpp-2.3/lib is not in LD_LIBRARY_PATH, shared libs may not work!'; \
	  fi; \
	fi

clean:
	for i in $(LIBS) $(PROGS); do \
	    (cd $(OMNETPP_SRC_DIR)/$$i && $(MAKE) clean); \
	done
	- rm $(OMNETPP_BIN_DIR)/*
	- rm $(OMNETPP_LIB_DIR)/*
	for i in $(SAMPLES); do \
	    (cd $(OMNETPP_SAMPLES_DIR)/$$i && $(MAKE) clean); \
	done
	cd $(OMNETPP_TUTORIAL_DIR)/queues && $(MAKE) clean
	cd $(OMNETPP_TEST_DIR) && $(MAKE) clean

depend: utils
	for i in $(LIBS) $(PROGS); do \
	    (cd $(OMNETPP_SRC_DIR)/$$i && $(MAKE) depend); \
	done
	for i in $(SAMPLES); do \
	    (cd $(OMNETPP_SAMPLES_DIR)/$$i && $(MAKE) depend); \
	done



syntax highlighted by Code2HTML, v. 0.9.1