# This line is needed on some machines.
MAKE=make

# Uncomment if you don't have strchr() and strrchr() or if you want to use
# index() and rindex() instead.
#STR=-Dstrchr=index -Dstrrchr=rindex

# Uncomment next line if your signal call is reset when caught.
# This is assumed for AIX and linux..
#SIGNAL=-DOLD_SIGNAL

# Uncomment if your local YP/NIS server is dodgy (ie. server hangs after the
# 'connection' message and suddenly comes back to life after ~60 seconds
# ftpd will not attempt to resolve hostnames.
#YP=-DMESSED_UP_YP

# Uncomment if ctime() and time() functions aren't defined in your header
# files (unlikely) - if you get errors about prototypes for those functions
#CTIME=-DBUGGY_CTIME

# Next line is for debugging access lists etc.
# Define if you want to check them.
#DEBUG=-DDEBUG

# Next line is for running ftpd through a debugger. 
# Define and the process wont exit and background itself.
#FORK=-DNO_FORK

#Some machines will need the socket library for the 'auth' option
#EXTRA_LIBS = -lsocket

# Uncomment the following line if compiling on Solaris
#CC=/usr/ucb/cc

# Uncomment if you have gcc (on AIX, better off using 'cc')
#CC=gcc

# Set your yacc program.
#YACC=yacc
#YACC=bison -y
YACC=byacc

# Set optimisation level
#OPTIMISE=-g
OPTIMISE=-O
#OPTIMISE=-O2

# Enable warnings from the compiler (if wanted!)
#WARN=-Wall

# Define any extra options here.
COPTS=

#
#
# You shouldn't have to touch anything below!
#
#

CFLAGS=	${OPTIMISE} -I. ${WARN} ${DEBUG} ${SIGNAL} ${COMPILER} ${COPTS} \
	${YP} ${CTIME} ${FORK} ${STR}
SRCS=	ftpd.c glob.c popen.c\
	strtok.c strpbrk.c valid.c message.c access.c\
	list.c auth.c mudauth.c
OBJS=	$(SRCS:.c=.o) ftpcmd.o
INCS=	security.h domains.h version.h

all: ftpd 

tags:
	ctags ftpcmd.y ${SRCS} *.h

VERSION = `cat /mud2/zips/version.h | cut -d\. -f2-3 | cut -d\" -f1`

distrib:
	mv security.h ../security.h
	cp version.h ../version.h
	cat ../security.h | sed 's/^.*OVERRIDE.*$$/#undef OVERRIDE \"password here\"/' > security.h
	-rm -f valid.c
	-rm -f domains.h
	mv domains.h~ domains.h
	mv tmud ..
	(cd ..; mv ftpd ftpd-${VERSION}; tar -cvf ftpd-${VERSION}.tar ftpd-${VERSION}; gzip -9v ftpd-${VERSION}.tar; mv ftpd-${VERSION} ftpd; mv security.h ftpd; cd ftpd)
	rm ../version.h
	mv domains.h domains.h~
	mv ../tmud .
	ln -s tmud/domains.h
	ln -s tmud/valid.c

tidy:
	(cd ..; tar -cvf ftpdt ftpd; gzip -9v ftpdt; rm -rf ftpd; gzip -9v /mud2/bin/byacc)

backup:
	(cd ..; tar -cvf ftpdt ftpd; cd ftpd)

ftpd: ${OBJS} 
	${CC} -o $@ ${OBJS} ${EXTRA_LIBS}

clean:
	rm -f ${OBJS} ftpcmd.c ftpd core tags

$(OBJS): $(INCS)


