# $Id: Makefile,v 1.5 1997/02/18 19:14:14 kukuk Exp $
#
# Set GLIBC to 1 for GNU libc 2.x (libc 6.0 under Linux)
GLIBC = 0
#
# Set NYS to 1 for libc 5.x.x with NYS support
NYS = 0
#
CC = gcc
CFLAGS = -Wall -O6 -pipe $(OPTS) 
#
ifeq ($(GLIBC),1)
CFLAGS += -DGLIBC
LIBS = -lnsl -lcrypt -lnss_nis
endif
ifeq ($(NYS),1)
CFLAGS += -DNYS
endif
#
# Crack library usage begin ----------------------------------
#
# Note: To use this fuctionality, you must have already compiled
#       cracklib, and installed a dictionary.  Redefine the
#       variables as required.
#
#       Read the cracklib documentation for more information.
#
# The cracklib dictionary to use.
# If not specified, defaults to /usr/local/lib/pw_dict
CRACKLIB_DICTPATH = /usr/dict/pw_dict
# 
# The cracklib compiled library to link with. 
# This should be in your cracklib source tree unless you put
# it somewhere else.
ARCHIVE_DIR = /usr/local/src/cracklib-2.5/cracklib
#
# These should be OK.
ARCHIVE_NAME = crack
CRACK_LIBS = -l$(ARCHIVE_NAME) -L$(ARCHIVE_DIR)
CRACK_OPTS = -DCRACKLIB_DICTPATH=\\\"$(CRACKLIB_DICTPATH)\\\" -DCRACKLIB_USE
# 
# Crack library usage end ------------------------------------

SRCS = passwd.c pwd_shell.c pwd_util.c readpwd.c pwd_yp.c vipw.c
PWDOBJS = passwd.o pwd_shell.o pwd_util.o readpwd.o pwd_yp.o
VIPWOBJS = vipw.o pwd_util.o

all: 
	@echo ""
	@echo "*** AT FIRST, YOU SHOULD EDIT THE MAKEFILE ! ***"
	@echo ""
	@echo "make options:"
	@echo " * make normal    build with very basic built-in password checking"
	@echo "                  (version 1.2 standard)"
	@echo ""
	@echo " * make cracklib  build with the cracklib library"
	@echo "                  (edit this Makefile for config options)"		@echo ""
	@echo " * make clean     removes compiled files"
	@echo ""
	@echo " * make install   installs programs and man pages"
	@echo ""
	@echo "note: you can't make both 'normal' and 'cracklib'.  do a 'make clean'"
	@echo "to switch from one to the other."
	@echo ""

normal: passwd vipw

cracklib: 
	@$(MAKE) normal EXTRA_LIBS="$(CRACK_LIBS)" OPTS="$(CRACK_OPTS)"

passwd: $(PWDOBJS) 
	$(CC) -o passwd $(PWDOBJS) $(LIBS) $(EXTRA_LIBS)

vipw: $(VIPWOBJS)
	$(CC) -o vipw $(VIPWOBJS)

install: passwd vipw
	cp -fa /usr/bin/passwd /usr/bin/passwd.old
	cp -fa /usr/bin/yppasswd /usr/bin/yppasswd.old
	cp -fa /usr/bin/chsh /usr/bin/chsh.old
	cp -fa /usr/bin/ypchsh /usr/bin/ypchsh.old
	cp -fa /usr/bin/chfn /usr/bin/chfn.old
	cp -fa /usr/bin/ypchfn /usr/bin/ypchfn.old
	cp -fa /usr/sbin/vipw /usr/sbin/vipw.old
	install -s -m 4511 -o root -g wheel passwd /usr/bin
	(cd /usr/bin; ln -f passwd yppasswd)
	(cd /usr/bin; ln -f passwd chsh)
	(cd /usr/bin; ln -f passwd ypchsh)
	(cd /usr/bin; ln -f passwd chfn)
	(cd /usr/bin; ln -f passwd ypchfn)
	install -s -m 0511 -o bin -g bin vipw /usr/sbin
	install -m 644 -o man -g man passwd.1 /usr/man/man1
	install -m 644 -o man -g man yppasswd.1 /usr/man/man1
	install -m 644 -o man -g man chsh.1 /usr/man/man1
	install -m 644 -o man -g man ypchsh.1 /usr/man/man1
	install -m 644 -o man -g man chfn.1 /usr/man/man1
	install -m 644 -o man -g man ypchfn.1 /usr/man/man1

clean:
	rm -f *.o *~ passwd vipw core .depend
