VPATH=@srcdir@
srcdir=@srcdir@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
datadir=@datadir@
includedir=@includedir@
infodir=@infodir@
libdir=@libdir@
libexecdir=@libexecdir@
localstatedir=@localstatedir@
mandir=@mandir@
sbindir=@sbindir@
sharedstatedir=@sharedstatedir@
sysconfdir=@sysconfdir@

SHELL=	/bin/sh

#
#  set this to the name of your primary discuss server.
#
DS_MAINSERVER=	charon.mit.edu

CC=	@CC@
INSTALL=@INSTALL@

DEFS=	@DEFS@
LIBS=	@LIBS@

KLIBS=	@KLIBS@
ETLIB=	../utils/et/libcom_err.a
SSLIB=	../utils/ss/libss.a

INCLUDES= -I../include -I$(srcdir)/../include -I$(srcdir)/../dsgrep/regexp
CFLAGS=	-O $(INCLUDES) $(DEFS)

SRCS=	pmtg.c mkds.c crmtgs.c create_mtg_dir.c \
	dsc_setup.sh dspipe.c dlsm.c dsmail.c

PROGS=	pmtg mkds crmtgs rmds create_mtg_dir dsmail dspipe

SCRIPTS= dsc_setup
SPROGS=	 dsc_setup.sh

all:	${PROGS} ${SPROGS}

clean:	
	rm -f ${PROGS} *.o *~ *.bak

install: all
	for prog in ${PROGS}; do \
		@INSTALL@ -s $$prog ${bindir}/$$prog ; done
	for prog in ${SCRIPTS}; do \
		@INSTALL@ $$prog.sh ${bindir}/$$prog ; done

pmtg:	pmtg.o ../libds/libds.a ../usp/libusp.a ${ETLIB}
	rm -f pmtg
	${CC} ${CFLAGS} -o pmtg pmtg.o ../libds/libds.a ../usp/libusp.a ${ETLIB} ${KLIBS} ${LIBS}

dlsm:	dlsm.o
	rm -f dlsm
	${CC} ${CFLAGS} -o dlsm dlsm.o

dspipe:	dspipe.o ../libds/libds.a ../usp/libusp.a ${ETLIB}
	rm -f dspipe
	${CC} ${CFLAGS} -o dspipe dspipe.o ../libds/libds.a ../usp/libusp.a ${ETLIB} ${KLIBS} ${LIBS}

dsmail:	dsmail.o ../libds/libds.a ../usp/libusp.a ${ETLIB}
	rm -f dstmp
	${CC} ${CFLAGS} -o dstmp -g dsmail.o ../libds/libds.a ../usp/libusp.a ../dsgrep/regexp/libregexp.a ${ETLIB} ${KLIBS} ${LIBS}
	mv dstmp dsmail

crmtgs:	crmtgs.o ../libds/libds.a ../usp/libusp.a ${ETLIB}
	rm -f crmtgs
	${CC} ${CFLAGS} -o crmtgs -g crmtgs.o ../libds/libds.a ../usp/libusp.a ${ETLIB} ${KLIBS} ${LIBS}

mkds:	mkds.o ../libds/libds.a ../usp/libusp.a ${ETLIB}
	rm -f mkds
	${CC} ${CFLAGS} -o mkds mkds.o ../libds/libds.a ../usp/libusp.a ${ETLIB} ${KLIBS} ${LIBS}

rmds:	mkds
	rm -f rmds
	ln mkds rmds

create_mtg_dir: create_mtg_dir.o
	${CC} ${CFLAGS} -o create_mtg_dir create_mtg_dir.o ${LIBS}

dsc_setup.sh: dsc_setup-proto.sh
	sed -e 's/__DS_MAINSERVER__/$(DS_MAINSERVER)/g' $(srcdir)/dsc_setup-proto.sh > $@

dist: ${SRCS} Makefile.in
	-mkdir ../../dist/source/mclient
	cp -p ${SRCS} ../../dist/source/mclient/
	cp -p Makefile.in ../../dist/source/mclient/
	chmod 644 ../../dist/source/mclient/Makefile

pmtg.o : pmtg.c ../include/discuss/discuss.h \
  ../include/discuss/types.h \
  ../include/discuss/tfile.h ../include/discuss/dsc_et.h \
  ../include/discuss/acl.h ../include/discuss/interface.h \
  ../include/discuss/dsname.h
dspipe.o : dspipe.c ../include/discuss/tfile.h \
  ../include/discuss/interface.h ../include/discuss/types.h \
  ../include/discuss/dsc_et.h ../include/rpc.h \
  ../include/usp.h ../include/usp_et.h \
  ../include/rpc_et.h
mkds.o : mkds.c ../include/discuss/discuss.h \
  ../include/discuss/types.h \
  ../include/discuss/tfile.h ../include/discuss/dsc_et.h \
  ../include/discuss/acl.h ../include/discuss/interface.h \
  ../include/discuss/dsname.h
dlsm.o : dlsm.c 
crmtgs.o : crmtgs.c ../include/discuss/discuss.h \
  ../include/discuss/types.h \
  ../include/discuss/tfile.h ../include/discuss/dsc_et.h \
  ../include/discuss/acl.h ../include/discuss/interface.h \
  ../include/discuss/dsname.h 
