# makefile for the students

#  This Makefile to make Frag_exec using network_layer.c from current directory, 
#  and default object files from $(CLASSDIR)
#  Using this makefile will leave the files network_layer.o, libcomp.a and 
#  Frag_exec in the current directory

#Root of Directory Tree which contains reference sources/object files etc
  CLASSDIR	= ../defaults
  OBJDIR	= $(CLASSDIR)/$(HOSTTYPE).obj

# Directory containing the simulator core sources.
  COMPSRCDIR	= $(CLASSDIR)/components.src
  SIMSRCDIR 	= $(CLASSDIR)/sim.src
  SIMLIBS	= -lsim -lcomp1 -lmem
# library for GUI
  XLIBDIR	= /usr/X11R6/lib
  TKLIBDIR	= ../tcltk

  SIMINCLUDES	= -I$(SIMSRCDIR) -I$(COMPSRCDIR)  -I$(XLIBDIR) -I$(TKLIBDIR) 

# the lab to be done
  STUDENTSRC	= network_layer.c
  STUDENTOBJ	= network_layer.o


# what to undefine to pull main out of libsim.a.  Will be _main for some
# operating systems.
  MAIN = main

# If using GCC:
  DEFINES	= -DMEMPOOL
  OFLAG		= -O -g
  CC		= gcc
  CXX		= g++

  CFLAGS	= $(OFLAG) $(DEFINES) $(SIMINCLUDES)
  LDFLAGS	= -L$(OBJDIR) -L$(TKLIBDIR) -L$(XLIBDIR) 
  LIBS		= $(SIMLIBS) -ltk8.3 -ltcl8.3 -lX11 -lm


.c.o:
	@rm -f $@
	@echo "	$(CC) $(OFLAG) $<"
	@$(CC) $(CFLAGS) -c $<


all: Frag_exec

# Make a simulator with only the default components:
Frag_exec: $(STUDENTOBJ)
	@echo "	$(CC) -o $@ $(STUDENTOBJ) -u $(MAIN) $(LIBS)"
	@$(CC) -o $@ $(STUDENTOBJ) -u $(MAIN) $(LDFLAGS) $(LIBS)
