SHELL=	     /bin/sh
CC=	     @CC@
INSTALL=     @INSTALL@
prefix =     @prefix@
exec_prefix= @exec_prefix@
bindir=      @bindir@

DEFS=	     @DEFS@
LIBS=	     @LIBS@
KLIBS=	     @KLIBS@
ETLIB=	     -lcom_err
SSLIB=	     -lss

CFLAGS=	  -O
INCLUDES= -I../include -I../regex -I$(prefix)/include
LDFLAGS=  -L$(prefix)/lib

PROGS=	mkds crmtgs rmds create_mtg_dir dsmail dspipe
SCRIPTS= dsc_setup

all:	${PROGS} ${SCRIPTS}

.c.o:	
	${CC} ${CFLAGS} ${INCLUDES} ${DEFS} -c $*.c

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

install: all
	for prog in ${PROGS}; do \
		$(INSTALL) -s $$prog ${bindir}; done
	for prog in ${SCRIPTS}; do \
		$(INSTALL) $$prog ${bindir}; done

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

dsmail:	dsmail.o ../libds/libds.a ../usp/libusp.a
	rm -f dsmail
	${CC} ${LDFLAGS} -o dsmail -g dsmail.o ../libds/libds.a ../usp/libusp.a ../regex/libregexp.a ${ETLIB} ${KLIBS} ${LIBS}

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

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

rmds:	mkds
	rm -f rmds
	ln -s mkds rmds

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

dsc_setup: dsc_setup.in server
	sed -e "s/__SERVER__/`./server`/g" dsc_setup.in > dsc_setup

server: server.o
	${CC} ${LDFLAGS} -o server server.o

distclean: clean
	rm -f Makefile
