
#   Debug options you can define on the following line:

#	-DALT_UI    --	Select an alternative user interface
#			that doesn't require curses.  This allows
#			running an egg even if there's a problem
#			with terminal configuration.
#
#	-DDEBUG     --	General debug output
#
#	-DHEXDUMP   --	Dump network packets sent and received
#			in hexadecimal, identifying the recipient
#			or sender by IP address.  Handy when
#			tracking down byte alignment problems.
#
#	-DNICE=x    --	Priority increment (positive value) which
#			eggsh raises to while collecting data when
#			run by super-user.  Default is 10.  Setting
#			-DNICE=0 disables the priority adjustment
#			mechanism.
#
#	-DNO_UI     --	Disable user interface in the egg.  This
#			is handy when you want to watch other
#			debug output.
#
#	-DPACKETDUMP -- Interpreted dump of packets.
#
#	-DSTORAGE_DEBUG  -- Debug output from storage.c database
#			functions.
#
#	-DTESTPORT  --	Use EGGPORT = 2074, BASKETPORT = 2075.
#			This permits testing an experimental
#			version of eggsh and basket on a machine
#			which is running production version(s)
#			on the standard ports.
#
#	-DUSLEEP    --	Use a built-in emulation of usleep()
#			based on setitimer() instead of the
#			system library function (which may not
#			exist on all flavours of Unix).

#DEBUGOPTIONS = -DDEBUG -DPACKETDUMP -DTESTPORT -DHEXDUMP -DNO_UI -DSTORAGE_DEBUG

#DEBUGOPTIONS = -DTESTPORT -DDEBUG -DPACKETDUMP -DNO_UI -DALT_UI

#DEBUGOPTIONS = -DTESTPORT

#DEBUGOPTIONS =

#DEBUGOPTIONS = -DTESTPORT -DALT_UI -DNO_UI

#DEBUGOPTIONS = -DDEBUG -DALT_UI -DNO_UI

#DEBUGOPTIONS = -DDEBUG -DNO_UI -DHEXDUMP

# Build for throop/Orion egg
#DEBUGOPTIONS = -DNO_UI -DALT_UI -DDEBUG -DUSLEEP -DFLUSH

# Current debug options
#DEBUGOPTIONS = -DNO_UI -DALT_UI -DDEBUG -DTESTPORT

DEBUGOPTIONS = -DREPORT=1 -DEGG_DYNAMIC

#   For Linux with GCC
CC = gcc
PFLAGS = -g -ansi -Wall -DLinux -DUSLEEP -D_GNU_SOURCE
LIBS = -lncurses

#   For Solaris 2.6 with Sun compiler
#CC = cc
#PFLAGS = -g -DSolaris
#LIBS = -lcurses -lsocket -lnsl

#   Silicon Graphics Irix 5.3 with SGI compiler.  Yes
#   we do define "Solaris" along with "Irix" for such a build.
#CC = cc
#PFLAGS = -g -DSolaris -DIrix -DUSLEEP
#LIBS = -lcurses

CFLAGS = $(PFLAGS) $(DEBUGOPTIONS)

HWOBJ = reg_orion.o reg_pear.o reg_pseudo.o
APPOBJ = storage.o network.o crc16.o genlib.o xdsub.o
EGGOBJ = egg.o eggui.o lecuyer.o usleep.o
BASKETOBJ = basket.o
TESTOBJ = testmain.o

PROGRAMS = eggsh basket regtest

default: $(PROGRAMS)

all: $(PROGRAMS) tarballs

eggsh:	$(EGGOBJ) $(HWOBJ) $(APPOBJ)
	$(CC) $(CFLAGS) -o eggsh $(EGGOBJ) $(HWOBJ) $(APPOBJ) $(LIBS)

examine: $(APPOBJ) examine.o
	$(CC) $(CFLAGS) -o examine storage.o crc16.o genlib.o examine.o

basket: $(BASKETOBJ) $(APPOBJ)
	$(CC) $(CFLAGS) -o basket $(BASKETOBJ) $(APPOBJ) $(LIBS)

tarballs: $(PROGRAMS)
	tar czf eggware.tgz sample.eggrc eggsh regtest README
	tar czf eggsrc.tgz  sample.eggrc sample.basketrc $(PROGRAMS) README Makefile *.c *.h

test:	eggsh
	eggsh 1 9600 200 10 10

clean:
	rm -f $(PROGRAMS) *.o *.bak .*.bak core dumpreg.dat egg.status eggsample.pid

cleandata:
	rm -rf 199*-*

basket.o: basket.c global.h genlib.h storage.h network.h version.h

#collect.o: collect.c global.h genlib.h regs.h collect.h

egg.o: egg.c global.h genlib.h storage.h network.h regs.h version.h

eggui.o: eggui.c global.h genlib.h errnos.h eggui.h regs.h version.h

global.h: byteorder.h

hw_pear.o: hw_pear.c global.h genlib.h

lecuyer.o: lecuyer.c

network.o: network.c global.h genlib.h network.h

regs.h: reg.h

reg_orion.o: reg_orion.c reg.h

reg_pear.o: reg_pear.c reg.h

reg_pseudo.o: reg_pseudo.c reg.h lecuyer.h

storage.o: storage.c global.h genlib.h storage.h

usleep.o: usleep.c
