#
# Copyright (c) 1980 Regents of the University of California.
# All rights reserved.  The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
#	@(#)Makefile	5.3 (Berkeley) 4/30/86
#
CFLAGS=-O
TAGSFILE=tags
LIBNAME = libdbm.a

#all: libdbm.a libdbm_p.a
all: libdbm.a

libdbm.a: dbm.c
	${CC} -c ${CFLAGS} dbm.c
	mv dbm.o libdbm.a

libdbm_p.a: dbm.c
	${CC} -p -c ${CFLAGS} dbm.c
	ld -r -o libdbm_p.a -X dbm.o
	rm -f dbm.o

install: $(LIBNAME)
	if [ ! -d $(ROOT) ]; then mkdir $(ROOT); fi
	if [ ! -d $(ROOT)/usr ]; then mkdir $(ROOT)/usr; fi
	if [ ! -d $(ROOT)/usr/lib ]; then mkdir $(ROOT)/usr/lib; fi
	cp $(LIBNAME) $(ROOT)/usr/lib/$(LIBNAME)
	chown bin $(ROOT)/usr/lib/$(LIBNAME)
	chgrp bin $(ROOT)/usr/lib/$(LIBNAME)
	chmod 664 $(ROOT)/usr/lib/$(LIBNAME)

#install: all
#	install -m 644 libdbm.a $(DESTDIR)/usr/lib
#	install -m 644 libdbm_p.a $(DESTDIR)/usr/lib
#	-cmp -s dbm.h $(DESTDIR)/usr/include/dbm.h || \
#		install -c -m 444 dbm.h $(DESTDIR)/usr/include

tags:
	ctags -a -f ${TAGSFILE} `pwd`/dbm.c

clean:
	rm -f *.o libdbm.a libdbm_p.a errs a.out core
clobber: clean
	rm -f ${LIBNAME}
