#
# Makefile for ypmake
# Sorry, this requires GNU make
#

YPLIBDIR = /usr/lib/yp
YPBINDIR = /usr/sbin
YPMAPDIR = /var/yp
YPMODDIR = /usr/lib/yp/ypmake
MANPATH	 = @(YPMANDIR)
MAN5EXT  = 5
MAN5DIR	 = /usr/share/man/man5
MAN8EXT  = 8
MAN8DIR	 = /usr/share/man/man8
MANUSER  = root
MANGROUP = root
PERL     = /usr/bin/perl
MAKEDBM  = /usr/lib/yp/makedbm
YPPUSH   = /usr/sbin/yppush
MODULES  = aliases arrays automount config ethers group gshadow hosts \
	   netgroup netid networks passwd protocols publickey \
	   rpc services shadow ypservers
PROGRAM	 = ypmake
MAN5PAGES= ypmake.conf.man
MAN8PAGES= ypmake.man
CONF	 = ypmake.conf.sample

all install::	$(PROGRAM) $(MODULES) $(MAN5PAGES) $(MAN8PAGES)

install::
	install -o root -g root -m 755 -d $(ROOT)$(YPMAPDIR)
	install -o root -g root -m 755 -d $(ROOT)$(YPLIBDIR)
	install -o root -g root -m 755 -d $(ROOT)$(YPMODDIR)
	install -o root -g root -m 755 -d $(ROOT)$(YPBINDIR)
	install -o root -g root -m 755 $(PROGRAM) $(ROOT)$(YPBINDIR)
	install -o root -g root -m 644 $(MODULES) $(ROOT)$(YPMODDIR)
	install -o root -g root -m 644 $(CONF)    $(ROOT)$(YPMAPDIR)
	for man in $(MAN5PAGES); do \
		install -o $(MANUSER) -g $(MANGROUP) -m 644 $$man \
			$(ROOT)$(MAN5DIR)/`basename $$man .man`.$(MAN5EXT); \
	done
	for man in $(MAN8PAGES); do \
		install -o $(MANUSER) -g $(MANGROUP) -m 644 $$man \
			$(ROOT)$(MAN8DIR)/`basename $$man .man`.$(MAN8EXT); \
	done

%:	%.in defs.sed
	@rm -f $@
	@echo Making $@ from $@.in
	@sed -f defs.sed $@.in > $@

distclean clean::
	rm -rf maps $(PROGRAM) $(MODULES) $(MAN5PAGES) $(MAN8PAGES)

distclean::
	rm -f Makefile defs.sed
