##############################################################################
#                                                                            #
#    Makefile,v
#    Makefile for directory clnt
#                                                                            #
#    Copyright (C) 1995 A. Bode, S. Lamberts, T. Ludwig, C. R"oder           #
#                                                                            #
#    PFSLib (Parallel I/O on workstations)                                   #
#                                                                            #
#    PFSLib offers parallel access to files for a parallel application       #
#    running on a cluster of workstations.                                   #
#    It is intended but not restricted to be used in message passing         #
#    applications based on PVM, NXLib, MPI, and other.                       #
#                                                                            #
#    PFSLib consists of a LIBRARY, deamon PROGRAMS, and utility PROGRAMS.    #
#                                                                            #
#    PFSLib is free software; you can redistribute the LIBRARY and/or        #
#    modify it under the terms of the GNU Library General Public             #
#    License as published by the Free Software Foundation; either            #
#    version 2 of the License, or (at your option) any later version.        #
#    You can redistribute the daemon PROGRAMS and utility PROGRAMS           #
#    and/or modify them 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.        #
#                                                                            #
#    PFSLib 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       #
#    Library General Public License and GNU General Public License           #
#    for more details.                                                       #
#                                                                            #
#    You should have received a copy of the GNU Library General Public       #
#    License and the GNU General Public License along with this              #
#    library; if not, write to the Free                                      #
#    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.      #
#                                                                            #
#    Contact to the authors:                                                 #
#                                                                            #
#    electronic mail: pfslib@informatik.tu-muenchen.de                       #
#                                                                            #
#    paper mail:      Prof. Dr. A. Bode                                      #
#                     Lehrstuhl f"ur Rechnertechnik und                      #
#                     Rechnerorganisation                                    #
#                     Institut f"ur Informatik                               #
#                     Technische Universit"at M"unchen                       #
#                     80290 M"unchen                                         #
#                     Germany                                                #
#                                                                            #
#    This project was partially funded by a research grant form Intel        #
#    Corporation.                                                            #
#                                                                            #
##############################################################################


##############################################################################
#                                                                            #
#  RCS Filename : Makefile,v
#  RCS Date     : 1996/10/18 14:38:31
#  RCS Revision : 1.4
#  RCS Author   : lamberts
#  RCS State    : V2_0_B
#                                                                            #
#  Authors: Stefan Lamberts                                                  #
#                                                                            #
##############################################################################


##############################################################################
# Macros                                                                     #
##############################################################################

SHELL = /bin/sh

INCLUDEPATH	= ../include
PFSDPATH	= ../pfsd
IODPATH		= ../iod
ADDPATH		= ../add

LIBPFS		= libpfs.a

ANSI_C		= -DANSI_C
CC		= gcc
CPPFLAGS	= -I$(INCLUDEPATH) -I$(IODPATH) -I$(PFSDPATH) $(ANSI_C) -D$(ARCH) $(CPPDEFINES) $(ARCHCPPFLAGS)

AR		= ar
ARFLAGS		= rv
RANLIB		= ranlib

LINT		= lint
LINTFLAGS	= -a -b -c -h
# lint option to create .ln file
LINT_ln		= -i

RM		= rm -f

INSTALLLIBDIR	= .

##############################################################################
# Suffixes                                                                   #
##############################################################################

.SUFFIXES: .ln $(SUFFIXES)

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

.c.ln:
	$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(LINT_ln) $<

.c.a:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $% $<
	$(AR) $(ARFLAGS) $@ $%
	$(RM) $%

##############################################################################
# Client object files generated by rcpgen                                    #
##############################################################################

RPCOBJ		=\
	$(PFSDPATH)/pfsd_clnt.o\
	$(PFSDPATH)/pfsd_xdr.o\
	$(IODPATH)/iod_clnt.o\
	$(IODPATH)/iod_xdr.o

RPCLNOBJ	= $(RCPOBJ:.o=.ln)

##############################################################################
# Additional object files                                                    #
##############################################################################

ADDOBJ		=\
	$(ADDPATH)/add_xdr.o

ADDLNOBJ	= $(ADDOBJ:.o=.ln)

##############################################################################
# Library files                                                              #
##############################################################################

SRC		=\
	clnt_close.c\
	clnt_error.c\
	clnt_fattr.c\
	clnt_getioid.c\
	clnt_getiom.c\
	clnt_init.c\
	clnt_iodone.c\
	clnt_ioop.c\
	clnt_ioop_iod.c\
	clnt_iowait.c\
	clnt_iseof.c\
	clnt_islocal.c\
	clnt_lseek.c\
	clnt_lsize.c\
	clnt_open.c\
	clnt_read.c\
	clnt_setiom.c\
	clnt_timout.c\
	clnt_timing.c\
	clnt_vecop.c\
	clnt_write.c

OBJ		= $(SRC:.c=.o)

LNOBJ		= $(SRC:.c=.ln)

##############################################################################
# Main targets                                                               #
##############################################################################

all: lib

lib: $(LIBPFS)

$(LIBPFS): $(OBJ) $(RPCOBJ) $(ADDOBJ)
	$(AR) $(ARFLAGS) $(LIBPFS) $?
	@if [ "$(ARCH)" != "SGI" ] ;\
	then	echo $(RANLIB) $(LIBPFS) ;\
		$(RANLIB) $(LIBPFS);\
	fi

##############################################################################
# Installation                                                               #
##############################################################################

inst_files: $(INSTALLLIBDIR)/$(LIBPFS)

$(INSTALLLIBDIR)/libpfs.a: $(LIBPFS)
	cp $(LIBPFS)		$(INSTALLLIBDIR)/
	@if [ "$(ARCH)" != "SGI" ] ;\
	then	echo $(RANLIB) $@ ;\
		$(RANLIB) $@;\
	fi
	

unist_files:
	@if [ "$(INSTALLLIBDIR)" != "." ]
	then
		echo "rm -f			$(INSTALLLIBDIR)/libpfs.a"
		rm -f			$(INSTALLLIBDIR)/libpfs.a
	fi

##############################################################################
# Dependencies and rules                                                     #
##############################################################################

clnt_close.ln \
clnt_close.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_error.ln \
clnt_error.o:\
	$(INCLUDEPATH)/pfslib_errno.h\
	$(INCLUDEPATH)/global.h

clnt_fattr.ln \
clnt_fattr.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_getioid.ln \
clnt_getioid.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_getiod.ln \
clnt_getiod.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_getiom.ln \
clnt_getiom.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_init.ln \
clnt_init.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h\
	$(INCLUDEPATH)/rpc_defaults.h

clnt_iodone.ln \
clnt_iodone.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_ioop.ln \
clnt_ioop.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h\
	$(INCLUDEPATH)/rpc_defaults.h

clnt_ioop_iod.ln \
clnt_ioop_iod.o:\
	$(IODPATH)/iod.h\
	$(INCLUDEPATH)/global.h\
	clnt_macros.h\
	$(INCLUDEPATH)/rpc_defaults.h

clnt_ioop_pfs.ln \
clnt_ioop_pfs.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_iowait.ln \
clnt_iowait.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_iseof.ln \
clnt_iseof.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_iseof.ln \
clnt_iseof.o:\
	$(INCLUDEPATH)/global.h\
	$(INCLUDEPATH)/rpc_defaults.h

clnt_lseek.ln \
clnt_lseek.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_lsize.ln \
clnt_lsize.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_open.ln \
clnt_open.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_read.ln \
clnt_read.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_setiom.ln \
clnt_setiom.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

clnt_timout.ln \
clnt_timout.o:\
	$(INCLUDEPATH)/rpc_defaults.h

vecop.ln \
vecop.c:

clnt_write.ln \
clnt_write.o:\
	$(PFSDPATH)/pfsd.h\
	$(INCLUDEPATH)/global.h\
	clnt_defines.h\
	clnt_macros.h\
	$(INCLUDEPATH)/pfslib_errno.h

##############################################################################
# targets in other directories                                               #
##############################################################################

$(IODPATH)/iod_clnt.o \
$(IODPATH)/iod_clnt.ln \
$(IODPATH)/iod_xdr.o \
$(IODPATH)/iod_xdr.ln:
	@echo "Making $@ in directory $(IODPATH)"
	@(\
		cd $(IODPATH);\
		target=`echo $@ | sed -e 's%$(IODPATH)/%%'`;\
		$(MAKE) $(MFLAGS)\
			"ARCH=$(ARCH)"\
			"CFLAGS=$(CFLAGS)"\
			"ANSI_C=$(ANSI_C)"\
			"CPPDEFINES=$(CPPDEFINES)"\
			"ARCHCPPFLAGS=$(ARCHCPPFLAGS)"\
			"CC=$(CC)"\
			"LINT=$(LINT)"\
			"LINTFLAGS=$(LINTFLAGS)"\
			"LINT_ln=$(LINT_ln)"\
			$$target;\
	)

$(PFSDPATH)/pfsd_xdr.o \
$(PFSDPATH)/pfsd_xdr.ln \
$(PFSDPATH)/pfsd_clnt.o \
$(PFSDPATH)/pfsd_clnt.ln:
	@echo "Making $@ in directory $(PFSDPATH)"
	@(\
		cd $(PFSDPATH);\
		target=`echo $@ | sed -e 's%$(PFSDPATH)/%%'`;\
		$(MAKE) $(MFLAGS)\
			"ARCH=$(ARCH)"\
			"CFLAGS=$(CFLAGS)"\
			"ANSI_C=$(ANSI_C)"\
			"CPPDEFINES=$(CPPDEFINES)"\
			"ARCHCPPFLAGS=$(ARCHCPPFLAGS)"\
			"CC=$(CC)"\
			"LINT=$(LINT)"\
			"LINTFLAGS=$(LINTFLAGS)"\
			"LINT_ln=$(LINT_ln)"\
			$$target;\
	)

$(ADDOBJ):
	@echo "Making $@ in directory $(ADDPATH)"
	@(\
		cd $(ADDDPATH);\
		target=`echo $@ | sed -e 's%$(ADDPATH)/%%'`;\
		$(MAKE) $(MFLAGS)\
			"ARCH=$(ARCH)"\
			"CFLAGS=$(CFLAGS)"\
			"ANSI_C=$(ANSI_C)"\
			"CPPDEFINES=$(CPPDEFINES)"\
			"ARCHCPPFLAGS=$(ARCHCPPFLAGS)"\
			"CC=$(CC)"\
			"LINT=$(LINT)"\
			"LINTFLAGS=$(LINTFLAGS)"\
			"LINT_ln=$(LINT_ln)"\
			$$target;\
	)


##############################################################################
# Additional targets                                                         #
##############################################################################

tags: TAGS

TAGS: $(SRC)
	etags -t $(SRC)

lint: $(LNOBJ) $(RPCLNOBJ)
	$(LINT) $(LINTFLAGS) $(LNOBJ) $(RPCLNOBJ)

cflow: $(SRC)
	cflow $(CPPFLAGS) -i_ $(SRC) > $@

rcflow: $(SRC)
	cflow $(CPPFLAGS) -r -i_ $(SRC) > $@

clean:
	$(RM) *.o *.ln $(LIBPFS)

realclean: clean
	$(RM) cflow rcflow TAGS *~


##############################################################################
# End of Makefile                                                            #
##############################################################################
