#
# Makefile for REAL 4.5. Note that some sections of this file
# have to be uncommented (or commented) for IRIX, SunOS, and Solaris
# 
# If the loader complains about a bad ar header, just delete ../src/nest.a
# remake nest.a, change the LD options in this directory, and try again.

# Configuration options
FUNC_FILE = ./FUNC_TABLE
 
# Standard make variables
 
CC = cc
CFLAGS = -w  -g
 
LINT = lint
LINTFLAGS = -buxz
 
CPP = /lib/cpp 
AS = as
 
LD = ld
LDFLAGS = 
LIBS = 

RANLIB = /usr/bin/ranlib

kernelobj =  \
	kernel/channels.o \
	kernel/fuzzy.o \
	kernel/hash.o \
	kernel/init.o \
	kernel/monitor.o \
	kernel/node_queue.o \
	kernel/plotting.o \
	kernel/timer.o \
	kernel/routing.o \
	kernel/sim.o \
	kernel/switches.o \
	kernel/symtab.o \
	kernel/table.o 

routerobj =  \
	router/fq.o \
	router/hrr.o \
	router/queues.o \
	router/router.o \
	router/xunet.o \
	router/scheduler.o

sourceobj = \
	sources/background.o \
	sources/controlled_rate.o \
	sources/dec.o \
	sources/generic.o \
	sources/jk_reno.o \
	sources/jk_tahoe.o \
	sources/mmpp.o \
	sources/poisson.o \
	sources/pp.o \
	sources/random_rate.o \
	sources/send.o \
	sources/sink.o \
	sources/telnet.o \
	sources/onoff.o \
	sources/onoff_closed.o \
	sources/trace.o\
	sources/ecn_simple.o \
	sources/ecn_master.o \
	sources/ecn_slave.o \
	sources/ecn_router.o \
	sources/ecn_sender1.o \
	sources/ecn_sender2.o \
	sources/ecn_sender3.o \
	sources/ecn_sender4.o \
	sources/ecn_receiver.o \
	sources/ecn_error.o \
	sources/ecn_flow.o


allobj = $(kernelobj) $(routerobj) $(sourceobj)

final: 
	@echo Executing make in subdirectories:
	echo ./lang;
	cd lang;\
	make;\
	echo ./kernel;\
	cd ../kernel;\
	make;\
	echo ./sources;\
	cd ../sources;\
	make;\
	echo ./router;\
	cd ../router;\
	make;\
	cd ..;\
	echo .
#
# we need differnt options for different flavors of UNIX
#
# use next line for SGI IRIX >= 5.2
#	$(CC) $(CFLAGS) $(LDFLAGS) $(allobj) ../src/nest.so -o simulate -lm;
# use next line for Solaris
#	$(CC) $(CFLAGS) $(LDFLAGS) $(allobj) ../src/nest.a -o simulate -lsocket -lnsl -lm;
# use next line for all others 
	$(CC) $(CFLAGS) $(LDFLAGS) $(allobj) ../src/nest.a -o simulate -lm;
	\rm -f $(FUNC_FILE)
#
# the next line will work almost all the time (except SunOS/Solaris/IRIX)
#
#	nm -g simulate | awk -f nm1.awk | sort | cat > $(FUNC_FILE)
#
# use the next line for SunOS < 5 (i.e. pre-Solaris)
#
	nm -g simulate | awk -f nm2.awk | cat > $(FUNC_FILE)
#
# use the next line for Solaris
#
#	nm -gp -tx simulate | awk -f nm1.awk | sort | cat > $(FUNC_FILE)
#
# use the next line for IRIX and Digital Unix
#
#	nm -B simulate | awk -f nm1.awk | cat > $(FUNC_FILE)
	chmod a+r $(FUNC_FILE)

depend:
	echo Executing make depend in subdirectories:
	cd lang; \rm -f *.c; cd ..; 
	echo ./kernel;\
	cd kernel;\
	make depend;\
	echo ./sources;\
	cd ../sources;\
	make depend;\
	echo ./router;\
	cd ../router;\
	make depend;\
	cd ..;\
	echo .
