#
# mountd	This program handles RPC "NFS" mount requests.
#		UNIX Makefile for LINUX using GCC 2.3.3 and JT4.2.
#
# Version:	@(#)Makefile	1.5	04/04/93
#
# Authors:	Mark A. Shand, May 1988
#		Rick Sladkey, <jrs@world.std.com>
#		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
#		Copyright 1988 Mark A. Shand
#		This software maybe be used for any purpose provided
#		the above copyright notice is retained.  It is supplied
#		as is, with no warranty expressed or implied.
#

# Select the compiler.  GCC 2.3.3 with LIBC JumpTable/DLL 4.3.3.
CC		= gcc -Wall -O6
LD		= gcc

# Select any extra libraries.
LDLIBS		= #-lrpclib
LDFLAGS		= -N -s

OPTS		= -DSYSLOG #-DDEBUG -DAUTH_DEBUG -DREAD_ONLY
CFLAGS		= -DANSI -DLINUX $(OPTS)
XDRCFLAGS 	= $(CFLAGS) #-Wno-unused

RPCGEN		= rpcgen
RPCSVCDIR	= rpcsvc
#RPCSVCDIR	= /usr/include/rpcsvc
TRANSPORTFLAGS	= -s udp -s tcp

# Installation defines.
PROGS		= nfsd mountd
BININSTALL	= install -m 500
MANINSTALL	= install -m 444
ETCDIR		= $(BINROOTDIR)/usr/sbin
MAN5DIR		= $(BINROOTDIR)/usr/man/man5
MAN8DIR		= $(BINROOTDIR)/usr/man/man8
MAN5FILES	= man/exports.5
MAN8FILES	= man/mountd.8 man/nfsd.8 man/ugidd.8

CFILES		= nfsd.c mountd.c dispatch.c getattr.c fh.c logging.c \
		  auth_init.c auth_clnt.c
HFILES		= nfsd.h fh.h auth.h

XDRFILES	= mount.x nfs_prot.x
GENCFILES	= mount_svc.c mount_xdr.c nfs_prot_xdr.c
GENHFILES	= mount.h nfs_prot.h
GENFILES	= $(XDRFILES) $(GENCFILES) $(GENHFILES)

OBJS		= logging.o fh.o auth_init.o auth_clnt.o
NFSD_OBJS	= nfsd.o dispatch.o getattr.o nfs_prot_xdr.o $(OBJS)
MOUNTD_OBJS	= mountd.o mount_svc.o mount_xdr.o $(OBJS)


.c.o:		$< $(GENFILES)
		$(CC) -c $(CFLAGS) $<

all:		$(PROGS)


nfsd:		$(NFSD_OBJS)
		$(LD) $(LDFLAGS) -o $@ $(NFSD_OBJS) $(LDLIBS)

mountd:		$(MOUNTD_OBJS)
		$(LD) $(LDFLAGS) -o $@ $(MOUNTD_OBJS) $(LDLIBS)

nfs_prot.x:
		cp $(RPCSVCDIR)/nfs_prot.x .

mount.x:
		cp $(RPCSVCDIR)/mount.x .

nfs_prot.h:	nfs_prot.x
		$(RPCGEN) -h -o $@ $?

nfs_prot_xdr.c: nfs_prot.x
		$(RPCGEN) -c -o $@ $?

mount.h:	mount.x
		$(RPCGEN) -h -o $@ $?

mount_xdr.c:	mount.x
		$(RPCGEN) -c -o $@ $?

mount_svc.c:	mount.x
		$(RPCGEN) $(TRANSPORTFLAGS) $? | \
			sed 's/main/mount_run/' >$@

nfs_prot_xdr.o:	nfs_prot_xdr.c
		$(CC) $(XDRCFLAGS) -c $<

mount_xdr.o:	mount_xdr.c
		$(CC) $(XDRCFLAGS) -c $<

install:
		$(BININSTALL) $(PROGS) $(ETCDIR)
		$(MANINSTALL) $(MAN5FILES) $(MAN5DIR)
		$(MANINSTALL) $(MAN8FILES) $(MAN8DIR)

rpcsvc:		$(GENFILES)
		cp -p $(GENFILES) rpcsvc

dep:		$(CFILES) $(HFILES) $(GENFILES)
		sed '/^### Dep/q' Makefile >tmp_make
		$(CC) -M $(CFLAGS) $(CFILES) $(GENCFILES) >> tmp_make
		mv Makefile Makefile~
		mv tmp_make Makefile

clean:
		rm -f *.o *.b *.bak *~ \#* tmp_make 
		rm -f $(PROGS) $(GENCFILES)

### Dependencies: do not delete this line
