#
# Makefile for Zircon
#
# Lindsay F. Marshall (Lindsay.Marshall@newcastle.ac.uk)
# 		Hacked from Makefile for TkMail which was
# 		hacked from Makefile for TkMan from Tom Phelps
#

# This Makefile includes the most critical and site specific
# settings needed to run Zircon.
#

# # # SITE SETTINGS # # #

WISH = /usr/local/bin/dpwish
ZDIR = /usr/local

# directory to put *.tk support scripts
LIBDIR = $(ZDIR)/lib/zircon

# directory to put zircon executable script
BINDIR = /usr/local/bin

CC=cc
SHELL=/bin/sh

#--------------------------------------------------
#
# you shouldn't modify anything below here
#
#--------------------------------------------------

version = 1.15
srcs = zircon dccget.c dccsend.c crypt.c
objs = dccget.o dccsend.o crypt.o zping.o
execs = dccget dccsend crypt zping
libs = lib
index = lib/tclIndex
aux = zircon.ad rc
others = FAQ README CHANGES COPYRIGHT DOTzirconrc MANUAL Makefile TODO
bitmaps = bitmaps
sounds = sounds
distrib = $(index) $(srcs) $(libs) $(bitmaps) $(sounds) $(aux) $(others)

#LIBS =  -lsocket -linet -lnsl -lseq 
#
# Solaris....
#LIBS= -lsocket -lnsl -lelf -lucb

all: zircon $(execs)

zircon: Makefile $(index)
	mv zircon zircon.src
	echo '#!$(WISH) -f' > zircon
	echo 'set zircon(lib) $(LIBDIR)' >> zircon
	tail +3 zircon.src >> zircon
	chmod a+rx zircon
	rm -f zircon.src

zping: zping.c
	$(CC) -o zping -s -O zping.c

crypt: crypt.c
	$(CC) -o crypt -s -O crypt.c

dccget:	dccget.c
	$(CC) -o dccget -s -O dccget.c $(LIBS)

dccsend:	dccsend.c
	$(CC) -o dccsend -s -O dccsend.c $(LIBS)

$(index): lib
	cd lib ;  echo 'auto_mkindex . *.tcl ; exit' | $(WISH) -notk

install: all $(libs) $(bitmaps) $(sounds) $(aux)
	@if [ -d $(BINDIR) ]; then set +x; \
	else (set -x; mkdir $(BINDIR)); fi
	cp zircon $(BINDIR)
	@if [ -d $(LIBDIR) ]; then set +x; \
	else (set -x; mkdir $(LIBDIR)); fi
	cp -r $(execs) $(libs) $(bitmaps) $(sounds) $(LIBDIR)
	@if [ ! -f $(LIBDIR)/rc ]; then cp rc $(LIBDIR); \
	echo Remember to configure $(LIBDIR)/rc; fi
	@if [ ! -f $(LIBDIR)/zircon.ad ]; then cp zircon.ad $(LIBDIR); fi
	chmod a+r $(LIBDIR) $(LIBDIR)/* $(LIBDIR)/*/*
	chmod a+x $(LIBDIR) $(LIBDIR)/dccget $(LIBDIR)/dccsend
	chmod a+x $(LIBDIR) $(LIBDIR)/crypt $(LIBDIR)/zping
	chmod a+x $(LIBDIR)/lib $(LIBDIR)/bitmaps $(LIBDIR)/sounds

clean:
	rm -fr $(objs) core errs zircon-$(version)
