#
# Makefile.in	Makefile for the liblockfile package (Darwin version)
#
# Gentoo version for Darwin, based on original:
# version:	@(#)Makefile.in  1.01  16-Apr-1999  miquels@cistron.nl
#

VER	= 1.0
NVER	= 0.1

CFLAGS		= @CFLAGS@ -I.
LDFLAGS		= @LDFLAGS@
AR		= @AR@
CC		= @CC@

prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
libdir		= @libdir@
mandir		= @mandir@
nfslockdir	= @nfslockdir@
includedir	= @includedir@

MAILGROUP	= @MAILGROUP@

all:		@TARGETS@
install:	@INSTALL_TARGETS@

static:		liblockfile.a dotlockfile
shared:		liblockfile.dylib dotlockfile
nfslib:		nfslock.$(VER).dylib

liblockfile.a:	lockfile.o
		$(AR) rv liblockfile.a lockfile.o

liblockfile.dylib: liblockfile.a
		$(CC) $(LDFLAGS) -fPIC -dynamiclib -install_name @libdir@/liblockfile.1.0.dylib \
			-o liblockfile.dylib lockfile.o -lc

nfslock.$(VER).dylib:	nfslock.o
		$(CC) $(LDFLAGS) -fPIC -dynamiclib -install_name nfslock.0.dylib \
			-o nfslock.$(NVER).dylib nfslock.o

dotlockfile:	dotlockfile.o xlockfile.o
		$(CC) $(LDFLAGS) -o dotlockfile dotlockfile.o xlockfile.o

lockfile.o:	lockfile.c
		$(CC) $(CFLAGS) -DLIB -DLOCKPROG=\"$(bindir)/dotlockfile\" \
			-c lockfile.c

xlockfile.o:	lockfile.c
		$(CC) $(CFLAGS) -DLOCKPROG=\"$(bindir)/dotlockfile\" -c lockfile.c -o xlockfile.o

install_static:	static install_common
		install -d $(DESTDIR)$(libdir)
		install -m 644 liblockfile.a $(DESTDIR)$(libdir)

install_shared:	shared install_common
		install -d $(DESTDIR)$(libdir)
		install -m 755 liblockfile.dylib \
			$(DESTDIR)$(libdir)/liblockfile.$(VER).dylib
		ln -s liblockfile.$(VER).dylib $(DESTDIR)$(libdir)/liblockfile.dylib

install_common:
		install -d $(DESTDIR)$(includedir)
		install -d $(DESTDIR)$(bindir)
		install -m 644 lockfile.h maillock.h $(DESTDIR)$(includedir)
		if [ "$(MAILGROUP)" != "" ]; then\
		  install  -g $(MAILGROUP) -m 2755 dotlockfile $(DESTDIR)$(bindir);\
		else \
		  install  -g root -m 755 dotlockfile $(DESTDIR)$(bindir); \
		fi
		install -d $(DESTDIR)$(mandir)
		install -d $(DESTDIR)$(mandir)/man1
		install -d $(DESTDIR)$(mandir)/man3
		install -m 644 *.1 $(DESTDIR)$(mandir)/man1
		install -m 644 *.3 $(DESTDIR)$(mandir)/man3

install_nfslib:	nfslib
		install -d $(DESTDIR)$(nfslockdir)
		install -m 755 nfslock.$(VER).dylib $(DESTDIR)$(nfslockdir)

clean:
		rm -f *.a *.o *.dylib dotlockfile

distclean:	clean
		rm -f Makefile autoconf.h maillock.h \
			config.cache config.log config.status

