## Define the appropriate configuration variables.

PACKAGE = /fsys2/u/usystem/software/u++-4.7

## Include the architecture dependent definitions.

.INCLUDE : ${PACKAGE}/CONFIG

## Define the path names of important directories.

SRCDIR = ${PACKAGE}/src/translator

## Define some of the tools.

.INCLUDE : ../MakeTools

## Do not use the u++ compiler to build the u++ compiler.

CC := g++

CCFLAGS := -I. -D__${VENDOR}__ -D__${OS}__ -D__${CPU}__ -DPACKAGE=\"${PACKAGE}\" -DVERSION=\"${VERSION}\" -DTVENDOR=\"${TVENDOR}\" -DTCPU=\"${TCPU}\" -DTOS=\"${TOS}\" -DINSTALLBINDIR=\"${INSTALLBINDIR}\" -DINSTALLLIBDIR=\"${INSTALLLIBDIR}\" -DINSTALLINCDIR=\"${INSTALLINCDIR}\" -DTMPDIR=\"${TMPDIR}\" -DMULTI=\"${MULTI}\" -DTRACE=\"${TRACE}\"

HOSTNAME = $(shell hostname)
.IF ${HOSTNAME} == plg2.math
	CCFLAGS += -g -msupersparc # -O3
.ELSE
	CCFLAGS += # -O3 -DNDEBUG
.END

## Define the C++ source files.

#SRC = ${SRCDIR}/{\
#}.cc

#OBJ = ${OBJDIR}/{${SRC:b}}.o

## Define the source and object files for the driver.

DSRC = ${SRCDIR}/{\
u++ \
}.cc

DOBJ = ${OBJDIR}/{${DSRC:b}}.o

## Define the source and object files for the replacement preprocessor.

PSRC = ${SRCDIR}/{\
cpp \
}.cc

POBJ = ${OBJDIR}/{${PSRC:b}}.o

## Define the source and object files for the translator.

TSRC = ${SRCDIR}/{\
attribute \
gen \
hash \
input \
key \
main \
name \
output \
parse \
scan \
structor \
symbol \
table \
token \
}.cc

TOBJ = ${OBJDIR}/{${TSRC:b}}.o

## Use the host information

TVENDOR !:= ${VENDOR}
TOS !:= ${OS}
TCPU !:= ${CPU}

## Define the things that can be defined based upon previous definitions.

.INCLUDE : ../MakeDefinitions

## Define which dependencies should be built.

DEPENDS = ${OBJDIR}/depend.mk

## Define which executables should be built.

BINS = u++
LIBS = cpp u++-cpp

## Define the specific recipes.

all .SEQUENTIAL : ${OBJDIR} ${BINDIR} ${BINDIR}/{${BINS}} ${LIBDIR} ${LIBDIR}/{${LIBS}};

install .SEQUENTIAL : ${OBJDIR} ${BINDIR} ${BINDIR}/{${BINS}} ${LIBDIR} ${LIBDIR}/{${LIBS}} ${INSTALLBINDIR} ${INSTALLBINDIR}/{${BINS}} ${INSTALLLIBDIR} ${INSTALLLIBDIR}/{${LIBS}};

## Define how to make the dependencies.

depend : ${DEPENDS};

${DEPENDS} : ${OBJDIR}
	${CC} ${CCFLAGS} -M ${DSRC} ${PSRC} ${TSRC} | sed 's%\([^.]*\)\.o% ${OBJDIR}/\1.o%' > $@

## Everything depends on the make file.

${OBJ} ${DOBJ} ${POBJ} ${TOBJ} : Makefile

## Define default dependencies and recipes for object files.

.INCLUDE : ../MakeRecipes

## Define default dependencies and recipes for making object files.

${OBJDIR}/%.o : ${SRCDIR}/%.cc
	${CC} ${CCFLAGS} $< -c -o $@

## Dependencies and recipes for the driver.

${BINDIR}/u++ : ${OBJ} ${DOBJ}
	${CC} ${CCFLAGS} ${OBJ} ${DOBJ} -o $@

## Dependencies and recipes for the preprocessor.

${LIBDIR}/cpp : ${OBJ} ${POBJ}
	${CC} ${CCFLAGS} ${OBJ} ${POBJ} -o $@

## Dependencies and recipes for the translator.

${LIBDIR}/u++-cpp : ${OBJ} ${TOBJ}
	${CC} ${CCFLAGS} ${OBJ} ${TOBJ} -o $@

.IF ${INSTALLBINDIR} != ${NULL}
${INSTALLBINDIR}/% : ${BINDIR}/%
	${INSTALL} $< $@
.END

.IF ${INSTALLLIBDIR} != ${NULL}
${INSTALLLIBDIR}/% : ${LIBDIR}/%
	${INSTALL} $< $@
.END

## Constructed dependencies for object files.

.INCLUDE .IGNORE : ${DEPENDS}

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