BINDIR=/usr/local/bin
MANDIR=/usr/local/man
FTPDIR=/home/ftp/pub/users
HLPDIR=/usr/local/lib/help
LOGGRP=wheel
FTPGRP=ftpadm
HLPGRP=wheel

all :		ftp-dir
install :	install_ftp-dir	\
		install_help	\
		install_lg-td	\
		install_mailname
clean :
	rm -f ftp-dir

install_ftp-dir :	ftp-dir
	install -o root -g $(FTPGRP) -m 2775 -d $(FTPDIR)
	install -o root -g $(FTPGRP) -m 2111 -s ftp-dir $(BINDIR)
	install -o root -g root -m 644 ftp-dir.man $(MANDIR)/man1/ftp-dir.1

install_help :
	install -o root -g root -m 755 help $(BINDIR)
	ln -sf $(BINDIR)/help $(BINDIR)/welcome
	install -o root -g root -m 644 help.man $(MANDIR)/man1/help.1
	echo ".so man1/help.1" > $(MANDIR)/man1/welcome.1
	install -o root -g $(HLPGRP) -m 2775 -d $(HLPDIR)
	install -o root -g $(HLPGRP) -m 664 help.txt $(HLPDIR)/help
	install -o root -g $(HLPGRP) -m 664 welcome.txt $(HLPDIR)/welcome

install_lg-td :
	install -o root -g $(LOGGRP) -m 750 lg $(BINDIR)
	install -o root -g $(LOGGRP) -m 750 td $(BINDIR)
	install -o root -g root -m 644 lg.man $(MANDIR)/man8/lg.8
	install -o root -g root -m 644 td.man $(MANDIR)/man8/td.8

install_mailname :
	install -o root -g root -m 755 mailname $(BINDIR)
	install -o root -g root -m 644 mailname.man $(MANDIR)/man1/mailname.1

ftp-dir : 	ftp-dir.c
	cc -O2 ftp-dir.c -Wall -o ftp-dir
