# 
# Mach Operating System
# Copyright (c) 1992 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.
# 
# Carnegie Mellon requests users of this software to return to
# 
#  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
#  School of Computer Science
#  Carnegie Mellon University
#  Pittsburgh PA 15213-3890
# 
# any improvements or extensions that they make and grant Carnegie Mellon 
# the rights to redistribute these changes.
#  
# HISTORY
# $Log:	Makeconf,v $
# Revision 2.7  92/04/08  23:26:30  rpd
# 	Cross compilation support.
# 	Added Makeconf-site.
# 	[92/03/19            jvh]
# 
# Revision 2.6  92/01/22  22:51:13  rpd
# 	Revised for new Makefile organization.
# 	[92/01/17            rpd]
# 

# TARGET_MACHINE is the platform for which the build is being done.
# HOST_MACHINE is the platform on which the build is being performed.
# make doesn't set HOST_MACHINE automatically.  To cross-compile,
# override the definitions of HOST_MACHINE and/or TARGET_MACHINE.
# (You can do this on the command line or in Makeconf-site.)

HOST_MACHINE = ${TARGET_MACHINE}

# In AFS, the string "@sys" at the end of filenames is replaced
# by the client machine's system type.  The UX server picked up this idea
# and does this replacement for all file systems.  However, we use
# "${atsys}" instead of "@sys" so as not to rely on this support.
# Machine-dependent object/release areas use this naming convention.

VAX_atsys = vax_mach
IBMRT_atsys = rt_mach
SUN3_atsys = sun3_mach
MMAX_atsys = mmax_mach
PMAX_atsys = pmax_mach
I386_atsys = i386_mach
SUN4_atsys = sun4_mach
I860_atsys = i860_mach
LUNA88K_atsys = luna88k_mach
MAC2_atsys = mac2_mach
PC532_atsys = pc532_mach

atsys = ${$(TARGET_MACHINE)_atsys}
host_atsys = ${$(HOST_MACHINE)_atsys}

# The kernel uses a different convention for naming machine-dependent
# directories, which we follow for naming source subdirectories.
# If a source directory needs to have machine-dependent files,
# they should go into subdirectories named mips, sun3, vax, etc.
# The source Makefile should use
#	VPATH = .:${cpu}
# to instruct make to search the machine-dependent subdirectory.

VAX_cpu = vax
IBMRT_cpu = ca
SUN3_cpu = sun3
MMAX_cpu = mmax
PMAX_cpu = mips
I386_cpu = i386
SUN4_cpu = sun4
I860_cpu = i860
LUNA88K_cpu = luna88k
MAC2_cpu = mac2
PC532_cpu = ns532

cpu = ${${TARGET_MACHINE}_cpu}
host_cpu = ${${HOST_MACHINE}_cpu}

# Where objects get made:
OBJECTDIR = ../../obj/${atsys}/user

# Where stuff gets installed:
INSTALLDIR = ${MAKECONF;(.*)/src/user/Makeconf;\1/release/${atsys}}

# Where stuff gets released (copied from FRELEASEDIR to TRELEASEDIR):
# These are default values that one often overrides for a 'make release'.
FRELEASEDIR = ${INSTALLDIR}
TRELEASEDIR = /usr/mach3

# When cross-compiling, it is important to distinguish between
# the host and target environments.  Therefore, we also define
# HOST_INSTALLDIR, HOST_FRELEASEDIR, and HOST_TRELEASEDIR, which
# contain the host environment.  (INSTALLDIR etc. contain the
# target environment.)
#
# PATH, HOST_CPATH, HOST_LPATH search the host environment.
# CPATH and LPATH search the target environment.
# (For consistency, it should be HOST_PATH instead of PATH,
# but that would be very inconvenient.)
#
# If HOST_MACHINE == TARGET_MACHINE, we use the same tree for
# the host and target environments.  Otherwise, the host environment
# is placed in a ${host_atsys} subtree.
#
# The HOST_MACHINE == TARGET_MACHINE comparison is done by defining
# ${TARGET_MACHINE}_hack = 1 and then checking if ${HOST_MACHINE}_hack
# is defined.  (The definition of ${TARGET_MACHINE}_hack follows
# Makeconf-site.)

HOST_INSTALLDIR = ${INSTALLDIR}${${HOST_MACHINE}_hack?:/${host_atsys}}
HOST_FRELEASEDIR = ${FRELEASEDIR}${${HOST_MACHINE}_hack?:/${host_atsys}}
HOST_TRELEASEDIR = ${TRELEASEDIR}${${HOST_MACHINE}_hack?:/${host_atsys}}

HOST_CPATH = ${CPATH}
HOST_LPATH = ${LPATH}

# Makeconf-site contains site-dependent definitions.  It may be used
# to add a definition of SOURCEDIR, or add more definitions of
# <machine>_atsys and <machine>_cpu, or override the default
# definitions of TARGET_MACHINE, HOST_MACHINE, OBJECTDIR, INSTALLDIR,
# etc, or override/define initial values for PATH, CPATH, LPATH,
# HOST_CPATH, HOST_LPATH, etc, etc.

-include Makeconf-site

${TARGET_MACHINE}_hack = 1

# We automatically add HOST_INSTALLDIR directories to the host
# environment paths and add INSTALLDIR directories to the target
# environment paths, so that stuff we build and install is found by
# later makes.  Recursive makes should override the definitions of
# PATH, etc.  to keep the paths from getting longer with successive
# submakes.

HOST_CPATH = ${HOST_INSTALLDIR}/include:${INSTALLDIR}/include:${HOST_CPATH}
HOST_LPATH = ${HOST_INSTALLDIR}/lib:${HOST_LPATH}

PATH = ${HOST_INSTALLDIR}/bin:${PATH}
CPATH = ${INSTALLDIR}/include:${CPATH}
LPATH = ${INSTALLDIR}/lib:${LPATH}

# When running HOST_CC, etc. we wish to use HOST_CPATH and HOST_LPATH.
# This is accomplished with commands like
#
#	.c.o:
#		${USE_HOST_PATHS} ${HOST_CC} -c ${HOST_CFLAGS} $*.c
#
#	program : ${OBJS}
#		${RM} $@ $@.out
#		${USE_HOST_PATHS} ${DEPS/%/$@} \
#		${HOST_CC} -o $@.out ${HOST_CFLAGS} ${OBJS} ${LIBS} && \
#		${MV} $@.out $@
#
# Note that USE_HOST_PATHS must precede DEPS.
#
# We only bother with these definitions if we are actually cross-compiling.

USE_HOST_CPATH = $(${HOST_MACHINE}_hack?:CPATH="$${HOST_CPATH}"; export CPATH;)
USE_HOST_LPATH = $(${HOST_MACHINE}_hack?:LPATH="$${HOST_LPATH}"; export LPATH;)

USE_HOST_PATHS = ${USE_HOST_CPATH} ${USE_HOST_LPATH}

.EXPORT:	PATH CPATH LPATH HOST_CPATH HOST_LPATH \
		TARGET_MACHINE HOST_MACHINE
