# Makefile Version: $Id: Makefile,v 1.7 1996/02/15 20:04:58 thanatos Exp $
BINDIR=/usr/sbin
MANDIR=/usr/man/man1

# If you don't have "install", set INSTALL to "cp" and comment out
# INSTALLBIN and INSTALLMAN.  You'll have to fix the permissions yourself.
INSTALL=install
INSTALLBIN=-s -m 0500 -o root -g bin
INSTALLMAN=-m 0644 -o root -g bin

#CC=cc
CC=cc -pipe -Wall -Wno-parentheses -Wpointer-arith -Wcast-align -Winline -Wshadow -Waggregate-return -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wconversion -Wcast-qual
OPT=-O2 -ffast-math
LDFLAGS=-s
DEFS=
CFLAGS=$(OPT) $(DEFS)
LDLIBS=

TARGETS=useradd usermod userdel
MANPAGES=useradd.1 usermod.1 userdel.1
SAVENAME=ns-user
VERSION=0.1
TAR=tar
MAKEDEP=$(CC) $(CFLAGS) $(CPPFLAGS) -MM

all: do-it-all

.PHONY: do-it-all
ifeq (.depend,$(wildcard .depend))
include .depend
do-it-all: $(TARGETS)
else
do-it-all: depend
endif

.PHONY: depend
depend:
	$(MAKEDEP) *.c > .depend

.depend: *.c
	@$(RM) $@
	@-touch $^ 2>&-
	$(MAKEDEP) $^ > X$@
	@mv X$@ $@

.PHONY: debug
debug: clean offtarget
	$(MAKE) all OPT=-g LDFLAGS=

.PHONY: install installbin installman
install: installbin installman

installbin: $(TARGETS)
	$(INSTALL) $(INSTALLBIN) $^ $(BINDIR)
installman: $(MANPAGES)
	$(INSTALL) $(INSTALLMAN) $^ $(MANDIR)

.PHONY: clean offtarget realclean save checkin
clean:
	$(RM) core *~ .?*~ *.o *.ln

offtarget:
	$(RM) $(TARGETS)

realclean: clean offtarget
	$(RM) *.a .depend

checkin:
	-ci -u *.[ch1] Makefile README COPYING

save:
	$(TAR) czf $(HOME)/$(SAVENAME).tgz .

dist: realclean checkin
	$(TAR) -cz --exclude RCS -f $(HOME)/$(SAVENAME)-$(VERSION).tar.gz .
