#
# Copyright 1994, John F. Haugh II
#
# This software is derived from the Shadow Password Suite, version 3.3.2.
# No portion of this comment block or copyright statement may be altered
# without the written permission of the copyright holder.
#
#    This library is free software; you can redistribute it and/or modify
#    it under the terms of the GNU Library General Public License as
#    published by the Free Software Foundation; either version 2 of the
#    License, or (at your option) any later version.
#
#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Library General Public License for more details.
#
#    You should have received a copy of the GNU Library General Public
#    License along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#	@(#)Makefile	1.1	12:22:44	13 Feb 1994	(GNU Shadow Library Suite)
#
SHELL = /bin/sh

# Pick your favorite C compiler and tags command
CC = gcc
TAGS = ctags

# Pick the features you want.
DEF_NIS = -DUSE_NIS
DEF_NDBM = -DNDBM
# DEBUG = -g
OPTIM = -O
LOCAL = -ansi
INCLUDES = -I.

CFLAGS = $(DEF_NIS) $(DEF_NDBM) $(DEBUG) $(OPTIM) $(LOCAL) $(INCLUDES)

# Do you have to do ranlib?
RANLIB = ranlib
# RANLIB = echo

DEST_INCLUDE_DIR = /usr/include

# Define your library name and directory
LIBDIR = /lib
LIBSEC = libsec.a

# Some flags for making the shar file
SHARFLAGS = -D -c -dSpam_Animals

# Rules for .L (lint) files.
.SUFFIXES: .L
LINT = lint
LINTFLAGS = $(OS) -Dlint

.c.L:
	$(LINT) -pxu $(LINTFLAGS) $*.c > $*.L

ALLSRCS = gshadow.c shadow.c

FILES = COPYING Makefile shadow.c shadow.h gshadow.c gshadow.h

all:	$(LIBSEC)

.PRECIOUS: $(LIBSEC)

$(LIBSEC): \
	$(LIBSEC)(shadow.o) \
	$(LIBSEC)(gshadow.o)
	$(RANLIB) $(LIBSEC)

save:
	[ ! -d save ] && mkdir save
	-cp $(LIBDIR)/$(LIBSEC) save
	-cp $(DEST_INCLUDE_DIR)/shadow.h $(DEST_INCLUDE_DIR)/gshadow.h save

restore:
	[ -d save ]
	-(cd save ; cp shadow.h gshadow.h $(DEST_INCLUDE_DIR) )
	-(cd save ; cp $(LIBSEC) $(LIBDIR) )

install: all
	cp shadow.h gshadow.h $(DEST_INCLUDE_DIR)
	cp $(LIBSEC) $(LIBDIR)
	chown bin $(LIBDIR)/$(LIBSEC) $(DEST_INCLUDE_DIR)/shadow.h \
		$(DEST_INCLUDE_DIR)/gshadow.h
	chgrp bin $(LIBDIR)/$(LIBSEC) $(DEST_INCLUDE_DIR)/shadow.h \
		$(DEST_INCLUDE_DIR)/gshadow.h
	chmod 444 $(DEST_INCLUDE_DIR)/shadow.h $(DEST_INCLUDE_DIR)/gshadow.h
	chmod 555 $(LIBDIR)/$(LIBSEC)

lint:	$(ALLSRCS:.c=.L)

tags:	$(ALLSRCS)
	$(TAGS) $(ALLSRCS)

libshadow.a(shadow.o): shadow.h
libshadow.a(gshadow.o): gshadow.h

clean:
	-rm -f *.o

clobber: clean
	-rm -f $(LIBSEC)

shar: gnu-shadow-lib.shar

gnu-shadow-lib.shar: $(FILES)
	shar $(SHARFLAGS) $(FILES) > gnu-shadow-lib.shar
