#######################################################################
#
# GNUmakefile - RPC Build Makefile
#
# Demonstration code from 'Professional Linux Programming'
#
# Written by Neil Matthew, Rick Stones et. al.
#
# Copyright (C) 2000 Wrox Press.
# 
# http://www.wrox.com
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# 
#######################################################################

CC = gcc

#
# defining RPC_DEBUG turns on debugging fprintfs to stderr
COMPILER_FLAGS= -g -DRPC_DEBUG

#
# Generic Build Rule - not used at the moment
#
# %.o: $.c 
#	$(CC) -c $(COMPILER_FLAGS) $< -o $@

all: dvd_rpc_server dvd_rpc_client dvd_local_client

dvd_local_client:  flatfile.o dvd_test_client.c
	$(CC) -o dvd_local_client dvd_test_client.o flatfile.o

dvd_rpc_server:  flatfile.o dvd_server_wrapper.o dvd_store_svc.o \
                 dvd_store_xdr.o dvd.h dvd_store.h
	$(CC) -o dvd_rpc_server flatfile.o dvd_server_wrapper.o \
            dvd_store_svc.o dvd_store_xdr.o

dvd_rpc_client:  dvd_test_client.o dvd_client_wrapper.o dvd_store_clnt.o \
                 dvd_store_xdr.o dvd.h dvd_store.h
	$(CC) -o dvd_rpc_client dvd_test_client.o dvd_client_wrapper.o \
            dvd_store_clnt.o dvd_store_xdr.o

dvd_store.h dvd_store_svc.c dvd_store_clnt.c dvd_store_xdr.c: dvd_store.x
	rpcgen dvd_store.x

dvd_server_wrapper.o: dvd_server_wrapper.c dvd.h dvd_store.h
	$(CC) -c $(COMPILER_FLAGS) $< -o $@

dvd_client_wrapper.o: dvd_client_wrapper.c dvd.h dvd_store.h
	$(CC) -c $(COMPILER_FLAGS) $< -o $@

dvd_store_svc.o: dvd_store_svc.c dvd_store.h
	$(CC) -c $(COMPILER_FLAGS) $< -o $@

dvd_store_xdr.o: dvd_store_xdr.c dvd_store.h
	$(CC) -c $(COMPILER_FLAGS) $< -o $@

dvd_store_clnt.o: dvd_store_clnt.c dvd_store.h
	$(CC) -c $(COMPILER_FLAGS) $< -o $@

clean:
	-$(RM) dvd_rpc_server dvd_rpc_client dvd_local_client \
            *.o dvd_store_svc.c dvd_store_clnt.c dvd_store_xdr.c dvd_store.h *.dat
