CC = @CC@
CFLAGS = @CFLAGS@ @AFS_INCLUDES@ -D_GNU_SOURCE -I.
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
VERSION = @PACKAGE_VERSION@
RM = rm -f
MAKE = make

SOURCES = afsgettimes.c afssupport.c attr.c daemon.c error.c fd_cache.c fh.c fh_cache.c locate.c \
          md5.c mount.c nfs.c password.c readdir.c user.c xdr.c winsupport.c
OBJS = afsgettimes.o afssupport.o attr.o daemon.o error.o fd_cache.o fh.o fh_cache.o locate.o \
       md5.o mount.o nfs.o password.o readdir.o user.o xdr.o winsupport.o
CONFOBJ = Config/lib.a
EXTRAOBJ = @EXTRAOBJ@
LDFLAGS = @LDFLAGS@ @LIBS@ @LEXLIB@ @AFS_LIBS@
EXEEXT = @EXEEXT@

srcdir = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@
sbindir = @sbindir@
mandir = @mandir@
datarootdir = @datarootdir@

SUBDIRS = Config @SUBDIRS@

DESTDIR =

VPATH = $(srcdir)

all: subdirs
	$(MAKE) unfsd$(EXEEXT)

unfsd$(EXEEXT): $(OBJS) $(CONFOBJ) $(EXTRAOBJ)
	$(CC) -o $@ $(OBJS) $(CONFOBJ) $(EXTRAOBJ) $(LDFLAGS)

subdirs:
	for i in $(SUBDIRS); do (cd $$i && $(MAKE) all) || exit; done

install: unfsd$(EXEEXT)
	$(INSTALL) -d $(DESTDIR)$(sbindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man7
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
	$(INSTALL) unfsd$(EXEEXT) $(DESTDIR)$(sbindir)/unfsd$(EXEEXT)
	$(INSTALL_DATA) $(srcdir)/Extras/tags.7 $(DESTDIR)$(mandir)/man7/tags.7
	$(INSTALL_DATA) $(srcdir)/unfsd.8       $(DESTDIR)$(mandir)/man8/unfsd.8

# Not installed by default, since it installs files outside prefix
install-init: unfsd.init
	$(INSTALL) -d $(DESTDIR)/etc/init.d
	$(INSTALL) $(srcdir)/unfsd.init $(DESTDIR)/etc/init.d/unfsd

install-strip: install
	strip $(DESTDIR)$(sbindir)/unfsd$(EXEEXT)

uninstall:
	$(RM) $(DESTDIR)$(sbindir)/unfsd$(EXEEXT)
	$(RM) $(DESTDIR)$(mandir)/man7/tags.7
	$(RM) $(DESTDIR)$(mandir)/man8/unfsd.8

clean:
	for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done
	$(RM) $(OBJS)
	$(RM) unfsd$(EXEEXT)
	$(RM) unfs3-$(VERSION).tar.gz

distclean: clean
	for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done
	$(RM) Makefile config.h
	$(RM) config.log config.status

maintainer-clean: distclean
	$(RM) config.h.in configure
	$(RM) -rf autom4te.cache

dep: $(SOURCES)
	for i in $(SUBDIRS); do (cd $$i && $(MAKE) dep) || exit; done
	$(CC) $(CFLAGS) -MM $(SOURCES) >> Makefile

.PHONY: dist unfs3-$(VERSION).tar.gz

dist: unfs3-$(VERSION).tar.gz

unfs3-$(VERSION).tar.gz:
	rm -rf unfs3-$(VERSION)
	ln -sf `cd $(srcdir) && /bin/pwd` unfs3-$(VERSION)

	tar zcf unfs3-$(VERSION).tar.gz \
	 unfs3-$(VERSION)/fd_cache.c \
	 unfs3-$(VERSION)/md5.h \
	 unfs3-$(VERSION)/xdr.h \
	 unfs3-$(VERSION)/attr.c \
	 unfs3-$(VERSION)/README \
	 unfs3-$(VERSION)/backend.h \
	 unfs3-$(VERSION)/password.c \
	 unfs3-$(VERSION)/README.nfsroot \
	 unfs3-$(VERSION)/error.c \
	 unfs3-$(VERSION)/winsupport.c \
	 unfs3-$(VERSION)/fh_cache.h \
	 unfs3-$(VERSION)/user.c \
	 unfs3-$(VERSION)/unfs3.spec \
	 unfs3-$(VERSION)/winsupport.h \
	 unfs3-$(VERSION)/winerrno.h \
	 unfs3-$(VERSION)/readdir.h \
	 unfs3-$(VERSION)/nfs.c \
	 unfs3-$(VERSION)/configure \
	 unfs3-$(VERSION)/xdr.c \
	 unfs3-$(VERSION)/install-sh \
	 unfs3-$(VERSION)/mount.c \
	 unfs3-$(VERSION)/password.h \
	 unfs3-$(VERSION)/Extras/Makefile.in \
	 unfs3-$(VERSION)/Extras/cluster.c \
	 unfs3-$(VERSION)/Extras/tags.7 \
	 unfs3-$(VERSION)/Extras/cluster.h \
	 unfs3-$(VERSION)/NEWS \
	 unfs3-$(VERSION)/CREDITS \
	 unfs3-$(VERSION)/aclocal.m4 \
	 unfs3-$(VERSION)/daemon.h \
	 unfs3-$(VERSION)/doc/TODO \
	 unfs3-$(VERSION)/doc/README.win \
	 unfs3-$(VERSION)/doc/kirch1.txt \
	 unfs3-$(VERSION)/doc/passwords.txt \
	 unfs3-$(VERSION)/unfsd.8 \
	 unfs3-$(VERSION)/Makefile.in \
	 unfs3-$(VERSION)/unfsd.init \
	 unfs3-$(VERSION)/backend_win32.h \
	 unfs3-$(VERSION)/indent-all \
	 unfs3-$(VERSION)/backend_unix.h \
	 unfs3-$(VERSION)/nfs.h \
	 unfs3-$(VERSION)/locate.c \
	 unfs3-$(VERSION)/BRANCHES \
	 unfs3-$(VERSION)/fd_cache.h \
	 unfs3-$(VERSION)/daemon.c \
	 unfs3-$(VERSION)/error.h \
	 unfs3-$(VERSION)/contrib/nfsotpclient/README \
	 unfs3-$(VERSION)/contrib/nfsotpclient/mountclient \
	 unfs3-$(VERSION)/contrib/nfsotpclient/mountclient/__init__.py \
	 unfs3-$(VERSION)/contrib/nfsotpclient/mountclient/mountpacker.py \
	 unfs3-$(VERSION)/contrib/nfsotpclient/mountclient/mountconstants.py \
	 unfs3-$(VERSION)/contrib/nfsotpclient/mountclient/mounttypes.py \
	 unfs3-$(VERSION)/contrib/nfsotpclient/nfsotpclient.py \
	 unfs3-$(VERSION)/contrib/nfsotpclient/rpc.py \
	 unfs3-$(VERSION)/contrib/rpcproxy/rpcproxy \
	 unfs3-$(VERSION)/LICENSE \
	 unfs3-$(VERSION)/fh.h \
	 unfs3-$(VERSION)/fh.c \
	 unfs3-$(VERSION)/Config/exports.y \
	 unfs3-$(VERSION)/Config/exports.l \
	 unfs3-$(VERSION)/Config/exports.h \
	 unfs3-$(VERSION)/Config/Makefile.in \
	 unfs3-$(VERSION)/locate.h \
	 unfs3-$(VERSION)/md5.c \
	 unfs3-$(VERSION)/fh_cache.c \
	 unfs3-$(VERSION)/config.h.in \
	 unfs3-$(VERSION)/attr.h \
	 unfs3-$(VERSION)/configure.ac \
	 unfs3-$(VERSION)/mount.h \
	 unfs3-$(VERSION)/readdir.c \
	 unfs3-$(VERSION)/user.h \
	 unfs3-$(VERSION)/afsgettimes.c \
	 unfs3-$(VERSION)/afssupport.h \
	 unfs3-$(VERSION)/afssupport.c

	rm -f unfs3-$(VERSION)

# automatically generated dependencies follow
