# 
# (c) Copyright 1994 OPEN SOFTWARE FOUNDATION, INC.
# (c) Copyright 1994 HEWLETT-PACKARD COMPANY
# (c) Copyright 1994 DIGITAL EQUIPMENT CORPORATION
# To anyone who acknowledges that this file is provided "AS IS"
# without any express or implied warranty:
#                 permission to use, copy, modify, and distribute this
# file for any purpose is hereby granted without fee, provided that
# the above copyright notices and this notice appears in all source
# code copies, and that none of the names of Open Software
# Foundation, Inc., Hewlett-Packard Company, or Digital Equipment
# Corporation be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.  Neither Open Software Foundation, Inc., Hewlett-
# Packard Company, nor Digital Equipment Corporation makes any
# representations about the suitability of this software for any
# purpose.
# 
#

CC	      = gcc
IDL	      = ../idl/idl_compiler/idl

TARGET	      = AT386
CFLAGS	      = -I. -I../runtime -I../runtime/$(TARGET) -I$(INCDIR) \
		-D_BSD -DNCK -DLINUX -D_REENTRANT -DDEBUG
IDLFLAGS      = -keep object -no_cpp -v -no_mepv \
		-I. -I$(INCDIR) \
		-cc_cmd "gcc -D_BSD -DLINUX -D_REENTRANT -c" 
IDLDIR	      = ../sys_idl
INCDIR	      = ../../inc

DEST	      = .

EXTHDRS	      = ../runtime/$(TARGET)/comsoc_sys.h \
		../runtime/$(TARGET)/sysconf.h \
		../runtime/com.h \
		../runtime/comauth.h \
		../runtime/comfwd.h \
		../runtime/cominit.h \
		../runtime/commonp.h \
		../runtime/comnaf.h \
		../runtime/comp.h \
		../runtime/comprot.h \
		../runtime/comsoc.h \
		../runtime/comsoc_bsd.h \
		../runtime/comtwr.h \
		../runtime/comtwrflr.h \
		../runtime/comtwrref.h \
		../runtime/rpcclock.h \
		../runtime/rpcdbg.h \
		../runtime/rpcfork.h \
		../runtime/rpclist.h \
		../runtime/rpclog.h \
		../runtime/rpcmem.h \
		../runtime/rpcmutex.h \
		../runtime/rpcrand.h \
		../runtime/rpcsvc.h \
		../runtime/rpctimer.h

HDRS	      = dsm_p.h \
		rpcddb.h \
		rpcdepdb.h \
		rpcdepdbp.h \
		rpcdp.h \
		rpcdutil.h

INSTALL	      = /usr/bin/install

LD	      = $(CC)

LDFLAGS	      =

LIBS	      = ../runtime/libnck.a ../idl/lib/libidl.a ../../threads/libpthreads-ext.a

MAKEFILE      = Makefile

OBJS	      = dsm.o \
		dsm_unix.o \
		rpcd.o \
		rpcddb.o \
		rpcdep.o \
		rpcdepdb.o \
		rpcdsliv.o \
		rpcdutil.o \
		ep_sstub.o

PRINT	      = pr

PROGRAM       = rpcd

SHELL	      = /bin/sh

SRCS	      = dsm.c \
		dsm_unix.c \
		rpcd.c \
		rpcddb.c \
		rpcdep.c \
		rpcdepdb.c \
		rpcdsliv.c \
		rpcdutil.c

SYSHDRS	      =

all:		$(PROGRAM) optinstall

$(PROGRAM):     $(OBJS) $(LIBS)
		@echo "Linking $(PROGRAM) ..."
		$(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM) \
		-lpthread
# -lc_r -lc_p -lmach
		@echo "done"

optinstall:	$(PROGRAM)
		@echo "Copying $(PROGRAM) to /opt/dcelocal/bin"
		cp $(PROGRAM) /opt/dcelocal/bin

clean:;		@rm -f $(OBJS) core ep_sstub.c ep.h dsm.h

clobber:;	@rm -f $(OBJS) $(PROGRAM) core tags ep_sstub.c ep.h dsm.h

depend:;	@mkmf -f $(MAKEFILE) ROOT=$(ROOT)

echo:;		@echo $(HDRS) $(SRCS)

index:;		@ctags -wx $(HDRS) $(SRCS)

install:	$(PROGRAM)
		@echo Installing $(PROGRAM) in $(DEST)
		@-strip $(PROGRAM)
		@if [ $(DEST) != . ]; then \
		(rm -f $(DEST)/$(PROGRAM); $(INSTALL) -f $(DEST) $(PROGRAM)); fi

print:;		@$(PRINT) $(HDRS) $(SRCS)

tags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)

#update:		$(DEST)/$(PROGRAM)
#
#$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
#		@$(MAKE) -f $(MAKEFILE) ROOT=$(ROOT) DEST=$(DEST) install

#
# dependencies and rules
#
ep_sstub.o: $(IDLDIR)/ep.idl
	$(IDL) -keep object -no_cpp -v -no_mepv -cepv -client none \
		-I$(INCDIR) -cc_cmd "gcc -D_BSD -DLINUX -D_REENTRANT -c" \
		$(IDLDIR)/ep.idl
	@rm -f ep.h

dsm.h: dsm.idl
	$(IDL) -keep c_source -v -no_mepv -cepv -client none \
	-server none -I. -I$(INCDIR) dsm.idl

${OBJS}: dsm.h

rpcd.o: rpcd.c
	$(CC) $(CFLAGS) -DDCELOCAL_PATH='"/opt/dcelocal"' -c rpcd.c

#
# following dependencies are incomplete
#
###
dsm.o: dsm_p.h  \
	  ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h  \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h \
	../runtime/comfwd.h rpcdp.h rpcddb.h rpcdepdb.h \
	 ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h rpcdp.h \
	rpcddb.h
rpcdep.o: ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h rpcdp.h \
	rpcdepdb.h
rpcdepdb.o: ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h \
	../runtime/comp.h ../runtime/comprot.h ../runtime/comnaf.h \
	../runtime/comauth.h rpcdp.h rpcddb.h rpcdepdb.h rpcdepdbp.h \
	rpcdutil.h ../runtime/comtwr.h
rpcdsliv.o: ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h rpcdp.h \
	rpcddb.h rpcdepdbp.h rpcdutil.h
rpcdutil.o: ../runtime/commonp.h ../runtime/$(TARGET)/sysconf.h \
	 ../runtime/rpclog.h \
	../runtime/rpcsvc.h   \
	 ../runtime/rpcfork.h ../runtime/rpcdbg.h \
	../runtime/rpcclock.h ../runtime/rpcmem.h ../runtime/rpcmutex.h \
	../runtime/rpctimer.h ../runtime/rpclist.h ../runtime/rpcrand.h \
	../runtime/com.h ../runtime/cominit.h ../runtime/comsoc.h \
	../runtime/$(TARGET)/comsoc_sys.h ../runtime/comsoc_bsd.h rpcdp.h \
	rpcddb.h rpcdepdbp.h rpcdutil.h ../runtime/comtwr.h \
	../runtime/comtwrflr.h ../runtime/comtwrref.h
