# Makefile for afpmount
# $Id: Makefile,v 1.19 1994/03/18 08:14:45 tml Exp $

# The HP-UX rpcgen produces code that is buggy unless "hpux" is defined!
# The following incredible code snippet is generated:
# #ifdef hpux
# 	memset(&argument, 0, sizeof(argument));
# #else  hpux
# 	memset(&argument, sizeof(argument));
# #endif hpux
#

# Your C compiler (ANSI C if available)
CC = c89 -D_HPUX_SOURCE -Dhpux

# rpcgen invocation
RPCGEN = rpcgen

# BSD-type install program
INSTALL = gnuinstall

# makedepend if you have it
MAKEDEPEND = /usr/bin/X11/makedepend

# Extra defines possibly needed, for example:
# -DDONT_HAVE_STRERROR
# -DDONT_HAVE_MEMMOVE
DEFINES =

# Use -g to debug, -O if you trust your optimizer
CDEBUGFLAGS = -g

# Include path to CAP includes (<netat/*>)
CAPINCLUDES = -I/usr/include

# Where to put afpmount and afplogin
ETCDIR = /usr/local/etc
BINDIR = /usr/local/bin

# The CAP libraries
CAPLIBS = -L/usr/local/lib -lafpc -lafp -lcap

# Extra libraries possibly needed.
EXTRALIBS =

CFLAGS = ${CDEBUGFLAGS} ${CAPINCLUDES} ${DEFINES}

# Lint flags
LINTFLAGS = -Aa -D_HPUX_SOURCE -uvx

LDFLAGS = ${CDEBUGFLAGS}

NFS_SRCS = nfs_prot_svc.c nfs_prot_xdr.c nfs_prot.h
NFS_OBJS = nfs_prot_svc.o nfs_prot_xdr.o

MOUNT_SRCS = mount_xdr.c mount.h
MOUNT_OBJS = mount_xdr.o 

COMMON_SRCS = log_nfs.c log_nfs.h util.h
COMMON_OBJS = log_nfs.o

REV_SRC = revision.c
REV_OBJ = revision.o

AFPMOUNT_SRCS = afpmount.c afpmount.h afpm_svc_subr.c
AFPMOUNT_OBJS = afpmount.o afpm_svc_subr.o ${NFS_OBJS} ${COMMON_OBJS} ${REV_OBJ}

NFSTRACE_SRCS = nfstrace.c trace_svc_subr.c
NFSTRACE_OBJS = nfstrace.o trace_svc_subr.o ${NFS_OBJS} ${MOUNT_OBJS} ${COMMON_OBJS}

OTHER_SRCS = dumpfi.c

XFILES = nfs_prot.x mount.x

MY_SRCS = ${COMMON_SRCS} ${AFPMOUNT_SRCS} ${NFSTRACE_SRCS} ${OTHER_SRCS} ${REV_SRC}
SRCS = ${MY_SRCS} ${NFS_SRCS} ${MOUNT_SRCS}

OTHER = README COPYRIGHT NOTES TODO ChangeLog Makefile afplogin.sh afpmount.8 afplogin.1

DIST = ${OTHER} ${MY_SRCS} ${XFILES}

all: afpmount nfstrace

install: afpmount afplogin.sh
	${INSTALL} afpmount ${ETCDIR}/afpmount
	${INSTALL} afplogin.sh ${BINDIR}/afplogin

afpmount: ${AFPMOUNT_OBJS}
	${CC} ${LDFLAGS} -o $@ ${AFPMOUNT_OBJS} ${CAPLIBS} ${EXTRALIBS}

nfstrace: ${NFSTRACE_OBJS}
	${CC} ${LDFLAGS} -o $@ ${NFSTRACE_OBJS} ${EXTRALIBS}

dumpfi: dumpfi.c
	${CC} ${LDFLAGS} -o $@ dumpfi.c

nfs_prot.h: nfs_prot.x
	${RPCGEN} -h -o $@ $?

nfs_prot_svc.c: nfs_prot.x
	${RPCGEN} -m -o $@ $?

nfs_prot_xdr.c: nfs_prot.x
	${RPCGEN} -c -o $@ $?

mount.h: mount.x
	${RPCGEN} -h -o $@ $?

mount_svc.c: mount.x
	${RPCGEN} -m -o $@ $?

mount_xdr.c: mount.x
	${RPCGEN} -c -o $@ $?

lint:
	lint ${CFLAGS} ${LINTFLAGS} ${MY_SRCS}

clean:
	rm -f afpmount *.o ${NFS_SRCS} ${MOUNT_SRCS}

depend: ${SRCS}
	${MAKEDEPEND} ${CFLAGS} ${SRCS}

tar:	${DIST}
	tar cf afpmount-`expr "\`head -1 revision.c\`" : ".*: *\([^ ]*\)"`.tar ${DIST}

Revision=Revision
revision.c:
	(echo 'char revision[] = "$$${Revision}: $$";';			\
	echo 'char idents[] = "\\';					\
	ident ${MY_SRCS} | sed -e 's,$$,\\n\\,' -e 's,Id,SourceId,';	\
	echo '";') >revision.c

newversion: ${MY_SRCS}
	rcs -l revision.c
	rm -f revision.c
	${MAKE} revision.c
	date | ci -f -u revision.c 

shar:
	shar ${DIST}

# For those without makedepend, here are dependencies on the rpcgen-generated
# headers to make building easier:

afpm_svc_subr.o: nfs_prot.h
log_nfs.o: nfs_prot.h
mount_xdr.o: mount.h
nfstrace.o: mount.h
nfs_prot_svc.o: nfs_prot.h
nfs_prot_xdr.o: nfs_prot.h
trace_svc_subr.o: nfs_prot.h

# Here follows makedepend-generated dependencies, if any:

