#
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the University of California, Berkeley.  The name of the
# University may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#	@(#)Makefile	5.8 (Berkeley) 9/22/88 + portability hacks by 
#						rick@seismo.css.gov
#
# CFLAGS=	-O
#  Apollo flags, (wjw@eb.ele.tue.nl)
#       
VERSION = v`cat version`
CFLAGS  =-O -A cpu,3000
LINKFLAGS=	
LIBC=
SRCS=	ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c apollo.c
OBJS=	ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o strpbrk.o strtok.o \
	getusershell.o apollo.o
ARCHIVE = /usr/user/ftp/pub/apollo
DESTDIR = /usr/local

all: ftpd

ftpd: ${OBJS} ${LIBC}
	${CC} ${LINKFLAGS} -o $@ ${OBJS}

#vers.o: ftpd.c ftpcmd.y newvers.sh version logwtmp.c popen.c apollo.c
#	sh newvers.sh
#	${CC} ${CFLAGS} -c vers.c

ftpcmd.c:	ftpcmd.y
	bison ftpcmd.y
	mv ftpcmd.tab.c ftpcmd.c

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

cleandir: clean
	rm -f tags .depend

depend: ${SRCS}
	mkdep ${CFLAGS} ${SRCS}

install: 
	if [ ! -s /etc/shells ] ; then cp etc.shells /etc/shells; fi
	if [ -s ${DESTDIR}/etc/ftpd ] ; then \
		install -s -o bin -g bin -m 755 ftpd ${DESTDIR}/etc/ftpd; \
	else \
		install -s -o bin -g bin -m 755 ftpd ${DESTDIR}/usr/etc/in.ftpd; \
	fi

#  Create an tar archive
archive:
	tar cvf myftpd.tar.${VERSION} *.c newvers.sh *README* Makefile etc.shells ftpcmd.y rfc959 version
	compress myftpd.tar.${VERSION}
	rm ${ARCHIVE}/myftpd.tar.v*.Z
	cp myftpd.tar.${VERSION}.Z ${ARCHIVE}
	chmod 664 ${ARCHIVE}/myftpd.tar.v*.Z
	rm myftpd.tar.Z

lint: ${SRCS}
	lint ${CFLAGS} ${SRCS}

tags: ${SRCS}
	ctags ${SRCS}
