# Name: Makefile
# Description: Makefile for the nfs directory. It uses rpcgen to generate
#     the rpc server stubs.
# Author: Christian Starkjohann <cs@hal.kph.tuwien.ac.at>
# Date: 1996-11-14
# Copyright: GNU-GPL
# Tabsize: 4

VPATH = .
srcdir = .

#CC = gcc
AR = ar
RANLIB = ranlib

RPCGEN = rpcgen 

CFLAGS = -g -I. -I..
LDFLAGS = -g
WARNFLAGS = -Wall
RPC_WARNFLAGS = -Wno-unused -Wno-switch -Wno-uninitialized
TRANSPORTFLAGS =  -s udp -s tcp

XDRFILES	= nfs_prot.x
# OFILES		= nfs_prot_xdr.o nfs_prot_sstub.o mount.o nfs_funcs.o
OFILES		= nfs_prot_xdr.o nfs_prot_sstub.o mount.o nfs_funcs.o

all: nfs.o

COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARNFLAGS)

.c.o:
	$(COMPILE) $<

nfs.o: $(OFILES)
	$(LD) -r -o $@ $(OFILES)

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

nfs_prot_xdr.c: nfs_prot.x
	rm -f $@
	$(RPCGEN) -c $? | \
		sed 's;^#include ".*/nfs_prot.h"$$;#include "nfs_prot.h";' >$@

nfs_prot_sstub.c: nfs_prot.x
	rm -f $@
	$(RPCGEN) $(TRANSPORTFLAGS) $? | \
		sed -e 's/main/int nfsd_&/' \
		    -e 's/static//g' \
		    -e 's;^#include ".*/nfs_prot.h"$$;#include "nfs_prot.h";' >$@

nfs_prot_xdr.o: nfs_prot_xdr.c nfs_prot.h
	$(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_xdr.c
nfs_prot_sstub.o: nfs_prot_sstub.c nfs_prot.h
	$(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_sstub.c


clean:
	rm -f $(OFILES) nfs.o nfs_prot.h nfs_prot_xdr.c nfs_prot_sstub.c

