
# Modified Definitions #

HOME = /u/usystem/software/concc

VENDOR = sun
CPU = sparc
OS = solaris

# Basic Definitions #

INC = ../inc
INC1 = ${HOME}/inc
INC2 = ${HOME}/library/work/inc
LIB = ../lib

# List all the things that need to be made.  These include the lib directory,
# the bin directory, the begin and end files, and all the versions of
# the kernel files.  On the architectures that support shared memory,
# the multiple processor versions of the libraries as well as the single
# processor versions are built.

# There must be some sort of precedence established for the
# extenders, in order that the naming conventions be unambiguous.
# The -m extender has highest precedence, followed by the -d extender.

ALL = ${LIB} ${LIB}/uBegin.o ${LIB}/uEnd.o ${LIB}/uSystem{.a -d.a}
.IF ${VENDOR:s/sequent//:s/encore//:s/sgi//} == ${NULL}
    ALL += ${LIB}/uSystem-m{.a -d.a}
.END

all .SEQUENTIAL : ${ALL};

# List the source files.

SRC = uPrivate.c uKernel.c uExcept.c uInter.c uSystemEx.c uStart.c main.c

# These are the derived object files.

OBJ = {${SRC:b}}.o
OBJ-M = {${SRC:b}}-m.o
OBJ-D = {${SRC:b}}-d.o
OBJ-M-D = {${SRC:b}}-m-d.o

# These are the include files that all object files depend on.

HFILES = ${INC1}/uUnix.h ${INC}/{uSystem.h uMachine.h uKernel.h uExcept.h uInter.h uMalloc.h uSystemEx.h uStart.h configure/cd-${VENDOR}-${CPU}.h}

# These are the individual dependencies on the various include files.
# All the object files depend on the standard include files.
# The kernel object files depend on the machine dependent files.
# The except object files depend on the machine dependent files.

${OBJ} ${OBJ-D} ${OBJ-P} ${OBJ-M} ${OBJ-M-D} ${OBJ-M-P} : ${HFILES} Makefile

uKernel{.o -d.o -m.o -m-d.o} : uPeek.i uQueue.i uStack.i uIdle.i \
	uMachine.i configure/{cd-${VENDOR}-${OS}-${CPU}.i os-${OS}.i md-${CPU}.i}

uExcept{.o -d.o -m.o -m-d.o} : \
	uMachine.i configure/{cd-${VENDOR}-${OS}-${CPU}.i os-${OS}.i md-${CPU}.i}

uInter{.o -d.o -m.o -m-d.o} : uMalloc.i

# Describe how to make the object files, standard,
# debug and profiles versions for both single and multiple
# processor versions.  Note that the private modules
# must be specified separately, without the gcc shared
# data flag.

CC = gcc -O -I${INC} -I${INC1} -I${INC2} -Wall -finline-functions -fvolatile -fno-defer-pop -D__${VENDOR}__
.IF ${VENDOR} == sequent || ${vendor} == "encore" || (${vendor} == "dec" && ${cpu} == "mips")
    CC += -B${HOME}/gnu/bin/
.END
.IF ${VENDOR} == sgi
    CC += -D__EXTENSIONS__ -D_LANGUAGE_C
.END

SH = -fshared-data

uPrivate-m.o : uPrivate.c ; ${CC} $< -D__U_MULTI__ -c -o $@
uPrivate-m-d.o : uPrivate.c ; ${CC} $< -D__U_MULTI__ -D__U_DEBUG__ -c -o $@

%.o : %.c ; ${CC} $< -c -o $@
%-m.o : %.c ; ${CC} $< ${SH} -D__U_MULTI__ -c -o $@
%-d.o : %.c ; ${CC} $< -D__U_DEBUG__ -c -o $@
%-m-d.o : %.c ; ${CC} $< ${SH} -D__U_MULTI__ -D__U_DEBUG__ -c -o $@

# The code that the kernel uses to spin while waiting for work includes
# a timing loop whose parameters are stored in the calibration file.  This
# file must be created before the kernel can be compiled.  This is only
# necessary for the multiple processor version of the kernel.

uKernel{-m.o -m-d.o} : uCalibrate.h

uCalibrate.h : uCalibrate.r
	./$< > $@

uCalibrate.r : uCalibrate.c uIdle.i
	${CC} uCalibrate.c -o $@

# Make the library directory if needed.

${LIB} :
	mkdir $@

# Compile the uBeginUserCode and uEndUserCode routines and
# place them in the library directory.  These files will be loaded
# at the hi and lo end of user space.

${LIB}/uBegin.o : uBegin.c ; ${CC} $< -c -o $@
${LIB}/uEnd.o : uEnd.c ; ${CC} $< -c -o $@

# Make the libraries from those files that are out of date.
# The command "ar r" is used followed by only those files that were
# out of date.  These files are specified with the "$<" special macro.
# Finally, the intermediate ".o" files are removed when finished.

AR = ar r
RL = ranlib

${LIB}/uSystem.a .LIBRARY : ${OBJ}
${LIB}/uSystem-m.a .LIBRARY : ${OBJ-M}
${LIB}/uSystem-d.a .LIBRARY : ${OBJ-D}
${LIB}/uSystem-m-d.a .LIBRARY : ${OBJ-M-D}

%.a :
[
	${AR} $@ $?
.IF ${OS} == bsd43
	${RL} $@
.END
	rm $?
]

# Local Variables: #
# compile-command: "dmake" #
# End: #
