
RPCSRCS = nfs_prot_dispatch.c nfs_prot_xdr.c mount_dispatch.c mount_xdr.c
RPCHDRS = include/nfs_prot.h include/mount.h

CSRCS = nfs_main.c $(RPCSRCS) nfs_prot_svc.c mount_svc.c
CXXSRCS = nfs_fh_cache.cpp
OBJS = $(CSRCS:.c=.o) $(CXXSRCS:.cpp=.o)

CFLAGS = -Wall -g -O2 -I./include
CXXFLAGS = $(CFLAGS)

CC = gcc
CXX = g++

all: nfs_server

nfs_server: $(RPCHDRS) $(OBJS)
	$(CXX) -o $@ $(OBJS)

clean:
	rm -f $(RPCSRCS) $(RPCHDRS) *~ *.o nfs_server core


# RPC header, xdr, and dispatch generation
# generate MT-safe, but omit the #include<pthread.h> in the *.h
include/%.h: %.x
	@rm -f $@
	rpcgen -hM $< | grep -v pthread > $@
%_xdr.c: %.x include/%.h
	@rm -f $@
	rpcgen -cM $< -o $@
%_dispatch.c: %.x include/%.h
	@rm -f $@
	rpcgen -mM $< -o $@
# RPCGEN makes broken code... ignore the warnings
%_xdr.o: %_xdr.c
	@rm -f $@
	$(CC) -w $(CFLAGS) -c $<

