#
# Mach Operating System
# Copyright (c) 1986 Carnegie-Mellon University
# All rights reserved.  The CMU software License Agreement specifies
# the terms and conditions for use and redistribution.
#  
######################################################################
# HISTORY
# $Log:	Makefile,v $
# Revision 2.5  88/11/23  16:43:11  rpd
# 	Added -DMOD135 -UATR to CPPFLAGS.
# 	[88/11/04  17:59:59  rpd]
# 
# Revision 2.4  88/09/01  13:59:04  mwyoung
# 	Make certain that rdb.ws gets built in the object directory.
# 	[88/08/30            mwyoung]
# 
# Revision 2.3  88/08/25  18:43:01  mwyoung
# 	Removed objects unused by rdb.ws, to make rdb.ws smaller and to save
# 	time during kernel builds.
# 	[88/08/15  23:17:13  rpd]
# 
# Revision 2.2  88/08/06  18:28:14  rpd
# Fixed rule for codes.h.
# Fixed to generate codes.h from codes and codes.awk.
# Created.
# 
######################################################################

SOURCE_DIR = ..

LD = ld
AS = as
CPP = /usr/cs/lib/cpp

SADIR = $(SOURCE_DIR)/standca
ENDCHECK = $(SADIR)/endcheck
RDBH = $(SOURCE_DIR)/ca/rdb.h
SALIB = libsa.a

CPPFLAGS = -MD -Dmain=_main -DIBMRTPC -DROMPC -DMOD135 -UATR -DSTANDALONE -DDEBUG

CFLAGS = -O -Hvolatile -DKERNEL $(CPPFLAGS) -DTRACE -DNOINT

SASOBJS =	callabs.o hfetch.o lps.o debugger.o ior.o mtsr.o
# Unused by rdb.ws, so omit it...
# setvec.o

SACOBJS =	printf.o sys2.o gets.o parse.o init.o debug.o unasm.o	\
		initvec.o atox.o trace.o display.o screen_conf.o	\
		ibm_emul.o std_emul.o apa8tty.o apa16tty.o apa8ctty.o	\
		apa_fontblt.o hard_delay.o crcgen.o vtop.o
# Unused by rdb.ws, so omit them...
# aton.o com.o dma.o perror.o premain.o rtt.o setvec.o
# startup.o sys3.o time.o hd.o fd.o conf.o sys.o

SAOBJS =	keyboard.o monotty.o aedtty.o egatty.o lptty.o		\
		$(SASOBJS) $(SACOBJS)

./rdb.ws	:	rdb.o relsrt0.o $(SALIB) $(ENDCHECK) $(RDBH)
	eval `awk '$$1 == "#define" {print $$2 "=" substr($$3,3)}' $(RDBH)`; \
	$(LD) -N -x -e start -T $$RDB_RELOC -o rdb.ws			\
		relsrt0.o rdb.o $(SALIB) -lc;				\
	$(ENDCHECK) rdb.ws $$RDB_END					\
		" - Adjust RDB_END to be bigger in $(RDBH)"
	md -f -d -u Makedep *.d

$(SALIB):	$(SAOBJS)
		rm -f $(SALIB)
		ar cr $(SALIB) $(SAOBJS)
		ranlib $(SALIB)

relsrt0.o :	$(SADIR)/srt0.s
		$(CPP) -DREL $(CPPFLAGS) $(SADIR)/srt0.s - $*.d | $(AS) -o relsrt0.o

monotty.o aedtty.o egatty.o lptty.o : $(SADIR)/$$(@:.o=.c)
		$(CC) $(CFLAGS) -DIBM3101 -c $(SADIR)/$*.c

keyboard.o :	$(SADIR)/$$(@:.o=.c)
		$(CC) $(CFLAGS) -DDEBOUNCE -DSECURE -c $(SADIR)/$*.c

$(SASOBJS) :	$(SADIR)/$$(@:.o=.s)
		$(CPP) $(CPPFLAGS) $(SADIR)/$*.s - $*.d | $(AS) -o $*.o

$(SACOBJS) rdb.o : $(SADIR)/$$(@:.o=.c)
		$(CC) $(CFLAGS) -c $(SADIR)/$*.c

keyboard.o :	codes.h

codes.h :	$(SADIR)/codes $(SADIR)/codes.awk
		awk -f $(SADIR)/codes.awk $(SADIR)/codes

-include Makedep
