# which machine are we going to on?
# Choose one of the following:
#	* sun -> Sparc/SunOs
#	* nothing else at this time :-(
#
TARGET = sun

# where are tcl/tk base libraries and include files?
#
INCLUDEPATH = -I/usr/local/include 
LIBPATH = -L/usr/local/lib 

CC = gcc -Wall
CFLAGS = $(INCLUDEPATH) -DEXTENDED 
LDFLAGS = $(LIBPATH) 

# where are you going to install dtcl and dwish?
#
BASEDIR = /usr/tools/shells-$(VERSION)
BINDIR = $(BASEDIR)/bin
MANDIR = $(BASEDIR)/man

# which sections do you want man pages to installed into?
#
SECT = l


## End of Configurable Parameters #########################################


VERSION = 1.0

BINS = dtcl dwish

CMDS = dwish dtcl 
PROCS = load 
FUNCS = Tk_MainWindow

TCLOBJS = tcl.o dl.o $(TARGET).o
TCLLIBS = -ltcl

TKOBJS = tk.o dl.o $(TARGET).o
TKLIBS = -ltcl -ltk -lXext -lX11 -lm

DIRS = demo

## Rules ##################################################################

all : $(BINS)

dtcl : $(TCLOBJS) 
	$(CC) -o $@ $(LDFLAGS) $(TCLOBJS) $(TCLLIBS)

dwish : $(TKOBJS) 
	$(CC) -o $@ $(LDFLAGS) $(TKOBJS) $(TKLIBS)

dl.o : dl.c version.h

version.h :
	echo "#define VERSION \"$(REV)\"" > $@

clean :
	rm -f $(BINS) version.h core *.o *~ *.err
	-for i in $(DIRS); \
		do (cd $$i; if [ -f Makefile ]; then make clean; fi); done

install : $(BINS)
	if [ ! -d $(BINDIR) ] ; then mkdir -p $(BINDIR); fi
	install -c $(BINS) $(BINDIR)
	if [ ! -d $(MANDIR)/man$(SECT) ] ; \
		then mkdir -p $(MANDIR)/man$(SECT) ; fi
	for i in $(CMDS) $(FUNCS) $(PROCS) ; do \
		install -c -m 664 $$i.man $(MANDIR)/man$(SECT)/$$i.$(SECT); \
	done
