#
# 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.
#

CFLAGS  = $(OPTFLAGS) $(DEFINES)

# ******************************Linux******************************
OPTFLAGS= -O2 -fomit-frame-pointer
CC	= gcc -Wall
VENDORLIBS=

# ******************************Solaris 2.[45]******************************
# OPTFLAGS=-O2
# CC=gcc
# VENDORLIBS=-lsocket -lnsl

# ******************************Irix 5.[23]******************************
# OPTFLAGS=-O2
# CC=gcc
# VENDORLIBS=-lrpcsvc

# ******************************OSF/1 3.2c******************************
# OPTFLAGS=
# CC=cc
# VENDORLIBS=

# fill in path to compatibility library goes after -L, below.  Provides
# misc functions some vendors don't ship.
#GENERICLIB=-L/usr/local/lib -lgeneric


# 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

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

SRVROBJ = yppasswdd.o yppasswd_xdr.o update.o
CLNTOBJ = yppasswd.o  yppasswd_xdr.o obvious.o
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