# 
# Midway Distributed Shared Memory System
# Copyright (c) 1994 Carnegie Mellon University
# All Rights Reserved.
# 
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
# 
# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
#
# HISTORY
# 22 Aug 91 (mjz): add new header file midway.h (old midway_mem)
#		Add runtime files.  For now punt general dependency
#		mechanism for MiG files, and include dependencies here.
#
# 18 Sep 91 (mjz): fix dependency handling; only massage "lib" members
#		in Makedep
# 12 Dec 91 (mjz): add -DDEBUG_PRT for comm.c for a while...
# 29 Jan 92 (mjz): add -lcthread for smexecd for mach3bogus handler
# 18 Jun 92 (was): added commands to built porting library
# xx Sep 92 (mjz): convert to new structure.  adb smexecd to workaround bug
#  8 Jul 93 (mjz): change for MK79+ ode md/gcc
#

-include Makefile-common

LIBS = -lnetname -lthreads $(NETLIBS) -lmach
CFLAGS = $(CFLAGS) -I../runtime/memory
.SUFFIXES: .c .o

#ode md: need directories that it will find include files in
VDIRS = `echo $(VPATH) | sed -e 's/:/ -I/g' -e 's/^/-I/'`
CDIRS = `echo $(CPATH) | sed -e 's/::/:/g' -e 's/:/ -I/g' -e 's/^/-I/'`
CDIRK = `echo $(CPATH) | sed -e 's/::/:/g' -e 's/:/ -K/g' -e 's/^/-K/'`
MD_DIRS = $(VDIRS) -I. -I.. -I../runtime/memory -I- $(CDIRS) $(CDIRK)

.c.o:
	$(CC) $(CFLAGS) -c $*.c
	touch Makedep; md -file Makedep -std -rm $(MD_DIRS) $*.d


# Can't have ssUser.o, 'cause make think's the object is current, but it
# doesn't exist (it's in the library)
SMEXECDOBJ = smexecd.o smexecdServer.o smexecdSubs.o  ssUser.o \
	timer.o  midwayuxUser.o mach_msg_server.o smexec_utils.o \
	version.o
SMEXECOBJ = smexec.o smexecdUser.o ss.o ssServer.o midwayux.o \
	    midwayuxServer.o  smexec_utils.o timer.o mach_msg_server.o


all: smexec smexecd 


clean:
	$(RM) $(RMFLAGS) machine Makedep* a.out core errs \
			 *.d *.s *.S *.o *.BAK *.CKP */*.BAK */*.CKP

again:	rm all

rm:
	$(RM) -f smexec smexecd

#
# rules to get MiG generated include file dependencies if no Makedep yet...
#
ss.o: ss.c ss.h


#hand coded rules for MiG files
smexecd.h smexecdServer.c smexecdUser.c: smexecd.defs
	-rm smexecd.migout
	mig -v smexecd.defs > smexecd.migout

ss.h ssServer.c ssUser.c: ss.defs
	-rm ss.migout
	mig -v ss.defs > ss.migout

midwayux.h midwayuxServer.c midwayuxUser.c: midwayux.defs
	-rm midwayux.migout
	mig -v midwayux.defs > midwayux.migout

## hand coded rules for commands.
#for smexecd, explicit dependancy on smexecd.h so smexecd.defs exploded
smexecd.o: smexecd.c smexecd.h

smexecd: smexecd.h smexecd_types.h $(SMEXECDOBJ)
	$(CC) $(CFLAGS) -L. -o smexecd $(SMEXECDOBJ) $(LIBS) 
	adb -w smexecd < $(VPATH)/smexecd.adb

smexec.o: smexec.c smexecd.h

smexec: smexecd.h $(SMEXECOBJ)
	$(CC) $(CFLAGS) -o smexec $(SMEXECOBJ) $(LIBS)

libsmexec.a: ssUser.o midwayuxUser.o smexecdUser.o
	$(AR) r$(ARFLAGS) libsmexec.a $?
	$(RANLIB) libsmexec.a


-include Makedep



