###############################################################################
#
#    Makefile,v : Makefile for cmds directory
#    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     : 1995/11/30 16:31:05
#  RCS Revision : 1.3
#  RCS Author   : lamberts
#
#  Authors: Stefan Lamberts, Christian R"oder
#
###############################################################################


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

SHELL = /bin/sh

INCLUDEPATH	= ../include
PFSDPATH	= ../pfsd

ARCH		= SUN4
CC		= gcc
ANSI_C		= -DANSI_C
CFLAGS		= -ansi -g
CPPFLAGS	= -I$(INCLUDEPATH) -I$(PFSDPATH) $(ANSI_C) -D$(ARCH) $(ADDCPPFLAGS)

LDFLAGS		=
LDLIBS		=

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

RM		= rm -f

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

.SUFFIXES: .ln $(SUFFIXES)

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

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

##############################################################################
# pfsdreset files                                                            #
##############################################################################

RESETSRC	= pfsdreset.c

RESETOBJ	=\
	pfsdreset.o\
	$(PFSDPATH)/pfsd_xdr.o\
	$(PFSDPATH)/pfsd_clnt.o

RESETLNOBJ	= pfsdreset.ln

RESETEXE	= pfsdreset

##############################################################################
# pfsdstat files                                                             #
##############################################################################

STATSRC		= pfsdstat.c

STATOBJ		=\
	pfsdstat.o\
	$(PFSDPATH)/pfsd_xdr.o\
	$(PFSDPATH)/pfsd_clnt.o

STATLNOBJ	= pfsdstat.ln

STATEXE		= pfsdstat

##############################################################################
# pfsdexit files                                                             #
##############################################################################

EXITSRC		= pfsdexit.c

EXITOBJ		=\
	pfsdexit.o\
	$(PFSDPATH)/pfsd_xdr.o\
	$(PFSDPATH)/pfsd_clnt.o

EXITLNOBJ	= pfsdexit.ln

EXITEXE		= pfsdexit

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

all: $(RESETEXE) $(STATEXE) $(EXITEXE)

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

#############
# pfsdreset #
#############

$(RESETEXE): $(RESETOBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(RESETOBJ) $(LDLIBS)

pfsdreset.ln \
pfsdreset.o:\
	$(PFSDPATH)/pfsd.h

#############
# pfsdstat  #
#############

$(STATEXE): $(STATOBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(STATOBJ) $(LDLIBS)

pfsdstat.ln \
pfsdstat.o:\
	$(PFSDPATH)/pfsd.h

#############
# pfsdexit  #
#############

$(EXITEXE): $(EXITOBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(EXITOBJ) $(LDLIBS)

pfsdexit.ln \
pfsdexit.o:\
	$(PFSDPATH)/pfsd.h

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

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

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

tags: TAGS

TAGS: $(RESETSRC) $(STATSRC) $(EXITSRC)
	etags -t $(RESETSRC) $(STATSRC) $(EXITSRC)


lint: $(RESETLNOBJ) $(STATLNOBJ) $(EXITLNOBJ)


clean:
	$(RM) *.o *.ln $(RESETEXE) $(STATEXE) $(EXITOBJ)

realclean: clean
	$(RM) *~

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