# Copyright (c) 1993 Xerox Corporation.  All rights reserved.
#
#-$Id$
#
#-$Date$
#

#
# VERY IMPORTANT:
#   NO target-config-dependent things go in in Makefile directly.
#   ALL target-config-dependent things go in config.mk, below.
#
#

#
# include config.mk here to define:
#
#   CC - C compiler
#   CONFIG←CPPFLAGS
#   CONFIG←CFLAGS
#
#   ASPP - assembler preprocessor (CPP)
#   CONFIG←ASPPFLAGS
#
#   AS - assembler
#   CONFIG←ASFLAGS
#
#   LDR - loader for reloadable modules
#   CONFIG←LDRFLAGS
#
#   LD - loader
#   CONFIG←LDFLAGS
#
#   INCLUDE -- search path for header files  
#

include ../config/config.mk

#
# locations of object files
#

INSTALL←LIB = ../lib
INSTALL←BIN = ../bin

#
# compilation flags, etc.
#


CPPFLAGS = $(INCLUDE) $(CONFIG←CPPFLAGS) \
	-DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR
CFLAGS	=-c $(CONFIG←CFLAGS)

ASPPFLAGS  = $(INCLUDE) $(CONFIG←ASPPFLAGS) \
	-DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR -DASM

ASFLAGS	= $(CONFIG←ASFLAGS)

LDRFLAGS = $(CONFIG←LDRFLAGS)

LDFLAGS = $(CONFIG←LDFLAGS)

#
# standard commands and default rules
#


INSTALL = cp -p


.s.o:
	$(ASPP) $(ASPPFLAGS) $< > tmp.s ; $(AS) $(ASFLAGS) tmp.s -o $@ ; \
		rm -f tmp.s

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

#
#
#
#
# BEGIN PACKAGE-SPECIFIC PART
#
#
#
#

#
# Default target
#

default: exec.o


#
# SOURCE FILE DEFINITION
#
# define CSRC SSRC MISCSRC HDEFS MISCDEFS.
#
# define MAKEDEP←MISCSRC = commands to make MISCSRC dependencies
#   (dependencies for .c and .s files are done automatically).
#

CSRC = PCR←ExecClient.c PCR←ExecCmds.c PCR←ExecSetup.c
ServerCSRC = PCR←ExecServer.c

SSRC = 

MISCSRC = PCR←Exec←xdr.x

SRC = $(CSRC) $(SSRC) $(MISCSRC)

MAKEDEP←MISCSRC =


HDEFS = PCR←Exec.h

MISCDEFS =

DEFS = $(HDEFS) $(MISCDEFS)

#
#
# INSTALL DEFINITION
#
# define INSTALL←LIBFILES = targets to be copied into INSTALL←LIB
# define INSTALL←BINFILES = targets to be copied into INSTALL←BIN
#

INSTALL←BINFILES =
INSTALL←LIBFILES = exec.o


#
# package-specific definitions and rules
#

COBJ = PCR←ExecClient.o PCR←ExecCmds.o PCR←ExecSetup.o
ServerCOBJ = PCR←ExecServer.o
SOBJ = 

MISCOBJ = PCR←Exec←xdr←client.o
ServerMISCOBJ = PCR←Exec←xdr←server.o

exec.o: $(MISCOBJ) $(COBJ) $(SOBJ) $(MISCOBJ) PCR←ExecServer
	$(LDR) $(LDRFLAGS) -o exec.o $(COBJ) $(SOBJ) $(MISCOBJ)

PCR←Exec←xdr.c: PCR←Exec←xdr.x 
	rpcgen PCR←Exec←xdr.x
	mv PCR←Exec←xdr←xdr.c PCR←Exec←xdr.c

PCR←Exec←xdr.h: PCR←Exec←xdr.x
	rpcgen PCR←Exec←xdr.x
	mv PCR←Exec←xdr←xdr.c PCR←Exec←xdr.c

PCR←Exec←xdr←client.o: PCR←Exec←xdr.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c PCR←Exec←xdr.c  -o PCR←Exec←xdr←client.o

PCR←ExecServer.o: PCR←ExecServer.c 
	$(CC) $(CONFIG←CPPFLAGS) -DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR -c $(CONFIG←CFLAGS) \
		PCR←ExecServer.c -o PCR←ExecServer.o

PCR←ExecSetup.o: PCR←ExecSetup.c 
	$(CC) $(CONFIG←CPPFLAGS) -DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR -c $(CONFIG←CFLAGS) \
		PCR←ExecSetup.c -o PCR←ExecSetup.o

PCR←ExecServer: $(ServerCOBJ) $(ServerMISCOBJ)
	$(CC) $(ServerCOBJ) $(ServerMISCOBJ) -o PCR←ExecServer $(SOCKLIB)

PCR←Exec←xdr←server.o: PCR←Exec←xdr.c
	$(CC) $(CONFIG←CPPFLAGS) -DPCR←NO←RENAME -DPCR←NO←HOSTDEP←ERR -c $(CONFIG←CFLAGS) \
		PCR←Exec←xdr.c  -o PCR←Exec←xdr←server.o


#
#
#
#
# END PACKAGE-SPECIFIC PART
#
#
#
#

#
#
# STANDARD TARGETS
#
#

#
# make install
#

install:  $(INSTALL←LIBFILES) $(INSTALL←BINFILES)
	-if [ -n "$(INSTALL←LIBFILES)" ] ; then \
		( cd $(INSTALL←LIB) ; rm -f $(INSTALL←LIBFILES) ) ; \
		$(INSTALL) $(INSTALL←LIBFILES) $(INSTALL←LIB) ; \
	fi
	-if [ -n "$(INSTALL←BINFILES)" ] ; then \
		( cd $(INSTALL←BIN) ; rm -f $(INSTALL←BINFILES) ) ; \
		$(INSTALL) $(INSTALL←BINFILES) $(INSTALL←BIN) ; \
	fi


#
# make clean
#

clean:
	rm -f *.o *~ core a.out *.a *.BAK *.bak *.CKP logmsg.txt PCR←Exec←xdr.h PCR←Exec←xdr.c

#
# make depend
#
# NOTE: the makefile must include "# DO NOT DELETE THIS LINE" 
#   and at least one additional line of text after the last target.
#   "make depend" will replace everything following that line
#   by a newly-constructed list of dependencies.
#
# You can modify the behavior of this target by defining $(MAKEDEP←MISCSRC).
#

makedep: $(CSRC) $(SSRC) $(MISCSRC)
	rm -f makedep
	$(MAKEDEP←MISCSRC)
	-for x in $(CSRC) END ; \
		do if [ $$x != END ]; then \
			$(CPP) -M $(CPPFLAGS) $$x \
			| sed -e '/:$$/d' >> makedep ; \
			fi ; \
		done
	-for x in $(SSRC) END ; \
		do if [ $$x != END ]; then \
			$(ASPP) -M $(ASPPFLAGS) $$x \
			| sed -e '/:$$/d' \
			| sed -e 's/[.]s[.]o :/.o :/g' >> makedep ; \
			fi ; \
		done

depend: makedep 
	echo '/↑# DO NOT DELETE THIS LINE/,$$c' > eddep
	echo '# DO NOT DELETE THIS LINE' >> eddep
	echo '# Make depend depends on it' >> eddep
	echo '.' >> eddep
	echo '$$r makedep' >> eddep
	echo 'w' >> eddep
	rm -f Makefile.bak
	mv Makefile Makefile.bak
	cp Makefile.bak Makefile
	chmod u+w Makefile
	ex - Makefile < eddep
	-if [ ! -w Makefile.bak ] ; then chmod u-w Makefile ; fi
	rm -f eddep makedep

#
#
# END OF HUMAN-EDITABLE PART
#
#

#
#-$Log$
#

#
# DO NOT DELETE THIS LINE
# Make depend depends on it
PCR←ExecClient.o : PCR←ExecClient.c ../rpc/rpc.h ../rpc/PCR←rpc←names.h \
  ../ansi/stdio.h ../config/PCR←StdTypes.h \
  /import/gnu/lib/gcc-include/stdarg.h ../posix/stddef.h \
  ../posix/host/stddef.h ../ansi/stdlib.h ../posix/host/stdlib.h \
  /usr/include/sys/stdtypes.h ../ansi/ctype.h ../host/ctype.h \
  ../ansi/string.h ../posix/sys/types.h ../posix/host/sys/types.h \
  /usr/include/sys/sysmacros.h ../posix/unistd.h ../posix/utime.h \
  ../host/utime.h ../posix/host/unistd.h ../rpc/types.h \
  /usr/include/sys/time.h ../posix/time.h ../host/time.h \
  /usr/include/netinet/in.h ../rpc/xdr.h ../rpc/auth.h ../rpc/clnt.h \
  ../rpc/rpc←msg.h ../rpc/auth←unix.h /usr/include/rpc/auth←des.h \
  ../rpc/svc.h ../rpc/svc←auth.h ../exec/PCR←Exec.h ../config/PCR←Arch.h \
  ../config/PCR←StdDefs.h ../th/PCR←Th.h ../sig/PCR←Sig.h ../config/PCR←OS.h \
  ../sig/PCR←SigTypes.h ../th/PCR←ThTypes.h ../posix/sys/socket.h \
  ../io/PCR←IOSocket.h ../host/sys/socket.h ../posix/host/sys/sockio.h \
  /import/gnu/lib/gcc-include/sys/ioccom.h ../posix/host/netinet/in.h \
  ../posix/host/netinet/tcp.h 
PCR←ExecCmds.o : PCR←ExecCmds.c ../posix/unistd.h ../posix/host/unistd.h \
  ../posix/sys/types.h ../posix/host/sys/types.h /usr/include/sys/stdtypes.h \
  /usr/include/sys/sysmacros.h ../ansi/stdlib.h ../posix/host/stdlib.h \
  ../posix/signal.h ../sig/PCR←Sig.h ../config/PCR←StdTypes.h \
  ../config/PCR←OS.h ../sig/PCR←SigTypes.h ../config/PCR←StdDefs.h \
  ../config/PCR←Arch.h ../exec/PCR←Exec.h ../th/PCR←Th.h ../th/PCR←ThTypes.h \
  ../exec/PCR←ExecPvt.h /usr/include/netinet/in.h ../cmd/PCR←Cmd.h \
  ../ansi/setjmp.h /usr/include/sys/param.h /usr/include/machine/param.h \
  /usr/include/sys/signal.h /usr/include/vm/faultcode.h ../ansi/string.h 
PCR←ExecSetup.o : PCR←ExecSetup.c ../rpc/rpc.h ../rpc/PCR←rpc←names.h \
  ../ansi/stdio.h ../config/PCR←StdTypes.h \
  /import/gnu/lib/gcc-include/stdarg.h ../posix/stddef.h \
  ../posix/host/stddef.h ../ansi/stdlib.h ../posix/host/stdlib.h \
  /usr/include/sys/stdtypes.h ../ansi/ctype.h ../host/ctype.h \
  ../ansi/string.h ../posix/sys/types.h ../posix/host/sys/types.h \
  /usr/include/sys/sysmacros.h ../posix/unistd.h ../posix/host/unistd.h \
  ../rpc/types.h /usr/include/sys/time.h ../posix/time.h ../host/time.h \
  /usr/include/netinet/in.h ../rpc/xdr.h ../rpc/auth.h ../rpc/clnt.h \
  ../rpc/rpc←msg.h ../rpc/auth←unix.h /usr/include/rpc/auth←des.h \
  ../rpc/svc.h ../rpc/svc←auth.h PCR←ExecPvt.h PCR←Exec←xdr.h \
  ../posix/sys/socket.h ../io/PCR←IOSocket.h ../config/PCR←OS.h \
  ../th/PCR←ThTypes.h ../config/PCR←Arch.h ../sig/PCR←SigTypes.h \
  ../host/sys/socket.h ../posix/host/sys/sockio.h \
  /import/gnu/lib/gcc-include/sys/ioccom.h ../posix/host/netinet/in.h \
  ../posix/host/netinet/tcp.h ../posix/errno.h ../host/errno.h \
  /usr/include/sys/errno.h ../posix/limits.h ../posix/host/limits.h \
  ../posix/signal.h ../sig/PCR←Sig.h