# WAFE should point to the wafe home directory
WAFE = /u/neumann/wafe
SRC = ..
GLOBINCS = -I$(WAFE)/src -I$(WAFE)/lib/dbug

#CFLAGS = -Wall -g
CFLAGS = -O2 -m486

# if wafe was configured with RDD, define it here as well
# WAFEDEFINES = -DRDD 

# where are your X libraries installed? do you need an extra load path?
#  XLIBS = -L/usr/local/X11R5/lib
XLIBS = -L/usr/X386/lib


XMLIB = -lXm
XMLIB = /usr/lib/libXm.a

STDLIBS = \
	-L$(WAFE)/src \
	-L$(WAFE)/lib/xpm-3.4a/lib \
	-L$(WAFE)/lib/tcl7.3 \
	-L$(WAFE)/lib/dbug \
	-L$(WAFE)/lib/plotter/At \
	-L$(WAFE)/lib/libhtmlw \

# ALIBS will be used to make wafeperl 
#    using Athena widgets (Xaw3d)
#          Plotter widgets
#          HTML Widget (XMosaic's hypertext widget)
#          xpm
ALIBS = \
	$(STDLIBS) \
	-L$(WAFE)/lib/Xaw3d \
	$(XLIBS) \
	-lwafe \
	-lXpm -lAt -lhtmlw \
	-lXaw3d -lXmu -lXt -lXext -lX11 -ltcl -ldbug -lm \
	`. $(SRC)/config.sh; echo $$libs`

# MLIBS will be used to make mofe perl 
#   using OSF/Motif widgets
#          Plotter widgets
#          HTML Widget (XMosaic's hypertext widget)
#          xpm
#          XmGraph
#          layout (used here from Xaw3d)
MLIBS = \
	$(STDLIBS) \
	-L$(WAFE)/lib/XmGraph \
	$(XLIBS) \
	-lmofe \
	-lXpm -lAt -lm-htmlw -lgraph $(XMLIB) \
	-lXmu -lXt -lXext -lX11 -ltcl -ldbug -lm \
	`. $(SRC)/config.sh; echo $$libs`


wafeperl: $(SRC)/uperl.o usersub.o wafesub.o 
	cc $(CFLAGS) $(SRC)/uperl.o usersub.o wafesub.o $(ALIBS) -o wafeperl

mofeperl: $(SRC)/uperl.o usersub.o mofesub.o
	cc $(CFLAGS) $(SRC)/uperl.o usersub.o mofesub.o $(MLIBS) -o mofeperl

usersub.o: usersub.c
	cc -c $(CFLAGS) -I$(SRC) $(GLOBINCS) -DDEBUGGING usersub.c

wafesub.o: wafesub.c
	cc -c $(CFLAGS) $(WAFEDEFINES) -I$(SRC) $(GLOBINCS) -DDEBUGGING \
		wafesub.c

mofesub.o: wafesub.c
	ln -sf wafesub.c mofesub.c
	cc -c $(CFLAGS) -DMOTIF11 $(WAFEDEFINES) -I$(SRC) $(GLOBINCS) \
		-DDEBUGGING mofesub.c 

wafesub.c: wafesub.mus
	mus wafesub.mus >wafesub.c

binary-dist:
	(cd ..; tar zcvf wafeperl-linux.tar.gz \
		wafeperl/README-binary \
		wafeperl/wafe-sample \
		wafeperl/wafe-one-of-many \
		wafeperl/mofe-tiny \
		wafeperl/mofe-sample \
		wafeperl/mofeperl \
		wafeperl/wafeperl \
		wafeperl/wafe.sizes \
		/usr/lib/X11/wafe/tcllib \
		/usr/local/lib/tcl \
	)

tar:
	(cd ..; tar zcvf wafeperl-0.2.tar.gz \
		wafeperl/README \
		wafeperl/Makefile \
		wafeperl/usersub.c \
		wafeperl/wafesub.mus \
		wafeperl/wafe-sample \
		wafeperl/wafe-one-of-many \
		wafeperl/mofe-tiny \
		wafeperl/mofe-sample \
		wafeperl/mus \
	)
