#
# Makefile for yppasswd/yppasswdd
# 
# Copyright 1994,1995 by Olaf Kirch, <okir@monad.swb.de>.
# Shadow support added by Charles Lopez.
#
VERSION	= 0.6

CFLAGS  = $(OPTFLAGS) $(DEFINES) -DVERSION=\"$(VERSION)\"
OPTFLAGS= -O2 -fomit-frame-pointer
CC	= gcc -Wall

# Where to install everything. yppasswd goes to BINDIR, the daemon goes
# to SBINDIR, and the update script goes to LIBDIR
BINDIR	= /bin
SBINDIR	= /usr/sbin
LIBDIR	= /usr/lib/yp
MANDIR	= /usr/man

# To allow users to change their GECOS field, enable this:
CHFN	= -DALLOW_CHFN

# To allow users to change their login shell, enable this:
CHSH	= -DALLOW_CHSH

# if you want to use old-style NIS instead of NYS, comment this out:
NYSLIB	= -lnsl
NYSDEF	= -DNYS

# for shadow password support, uncomment these lines
#SPWLIB	= -DSHADOWPWD
#SPWDEF	= -lshadow

# Combine defines and libs....
DEFINES = -D_GNU_SOURCE $(NYSDEF) $(SPWDEF) $(CHFN) $(CHSH) \
	  -DYPLIBDIR=\"$(LIBDIR)\"
LIBS	= $(NYSLIB) $(SPWLIB)

SRVROBJ = yppasswdd.o yppasswd_xdr.o update.o
CLNTOBJ = yppasswd.o  yppasswd_xdr.o
OBJ	= $(SRVROBJ) $(CLNTOBJ)
CLIENTS	= yppasswd
SERVER	= yppasswdd 
PROGS	= $(SERVER) $(CLIENTS) 
MAN1	= yppasswd.1 ypchsh.1 ypchfn.1
MAN8	= yppasswdd.8

all: $(PROGS)

yppasswd: $(CLNTOBJ)
	$(CC) $(LDFLAGS) -o $@ $(CLNTOBJ) $(LIBS)

yppasswdd: $(SRVROBJ)
	$(CC) $(LDFLAGS) -o $@ $(SRVROBJ) $(LIBS)

$(OBJ):: yppasswd.h

clean::
	$(RM) core $(PROGS) $(OBJ)

install:: $(PROGS)
	@echo "Installing... "
	install -o bin -g bin -m 755 -s $(CLIENTS) $(BINDIR)
	ln -sf yppasswd $(BINDIR)/ypchfn
	ln -sf yppasswd $(BINDIR)/ypchsh
	install -o bin -g bin -m 700 -s $(SERVER) $(SBINDIR)/rpc.yppasswdd
	install -o bin -g bin -m 755 -d $(LIBDIR)
	install -o bin -g bin -m 700 pwupdate $(LIBDIR)

install installman::
	@echo "Installing manpages... "
	install -o bin -g bin -m 644 $(MAN8) $(MANDIR)/man8
	install -o bin -g bin -m 644 $(MAN1) $(MANDIR)/man1
