# Makefile for yppasswd/yppasswdd
# 
# Copyright 1994,1995 by Olaf Kirch, <okir@monad.swb.de>.
# Shadow support added by Charles Lopez.
# Various fixes by Peter Tobias.
# Support for non-Linux platforms by Dan Stromberg
#

CFLAGS  = $(OSFLGS) $(OSDEFS) $(DEFINES)

# OS-Dependent setup. You can define the following OS-dependent macros:
# NO_PATHS_H	if your system doesn't have <paths.h>
# NO_GETOPT_H	if your system doesn't have <getopt.h>. A working getopt()
#		is assumed, though.

# AIX 4.2 (IBM RS/6000)
#OSFLGS = -Wall -O2 -fomit-frame-pointer
#OSDEFS = -D_GNU_SOURCE 
#CC     = gcc
#XTRA   = -lnsl -lrpcsvc -L/usr/ccs/lib

# RedHat Linux 4.2 (libc)
#OSFLGS	= -Wall -O2 -fomit-frame-pointer
#OSDEFS	= -D_GNU_SOURCE
#CC	= gcc
#XTRA	= 

# RedHat Linux 5.0 (glibc)
OSFLGS = -Wall -O2 -fomit-frame-pointer
OSDEFS = -D_GNU_SOURCE
CC     = gcc
XTRA   = -lnsl -lcrypt 

# Where to install everything. yppasswd goes to BINDIR, the daemon goes
# to SBINDIR, and the update script goes to LIBDIR. The traditional
# place for the client is /bin, but for FSSTND compliance, you may want
# to use /usr/bin.
BINDIR	= /bin
SBINDIR	= /usr/sbin
LIBDIR	= /usr/lib/yp
MANDIR	= /usr/man

# If you want to use NYS instead of the old-style NIS code in libc,
# uncomment these lines
#NYSDEF	= -DNYS
#NYSLIB	= -lnsl

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

# For password timestamping (Morrison Industries)
#NISEXPIRE = -DNISEXPIRE

# To enable proactive password checking with obvious(), uncomment these:
#OBVDEF	= -DUSE_OBVIOUS
#OBVOBJ	= obvious.o

# Combine defines and libs....
DEFINES = $(NYSDEF) $(SPWDEF) $(NISEXPIRE) $(OBVDEF) \
	  -DYPLIBDIR=\"$(LIBDIR)\"
LIBS	= $(NYSLIB) $(SPWLIB) $(XTRA)

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

all:	version.h $(PROGS)

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

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

$(OBJ):: yppasswd.h

version.h: .version
	echo "#define VERSION \"`cat .version`\"" > $@

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

distclean::
	$(RM) -f $(PROGS)

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

