# -*- Mode: Text;  -*-
# File: Makefile.site
# Author: Heinz Schmidt (hws@csis.dit.csiro.AU)
# Copyright (C) CSIRO Division of Information Technology, 1992
#
# COPYRIGHT NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY
# and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
# LICENSE contained in the file: "sather/doc/license.txt" of the Sather
# distribution. The license is also available from ICSI, 1947 Center
# St., Suite 600, Berkeley CA 94704, USA.
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#* FUNCTION: Makefile header included by all Makefiles. The file 
#*    consists of three parts: 
#*        Makefile.site: you normally need to edit only this one.
#*        Makefile.mach: the machine dependent part and defaults.
#*           This is machine generated you do not want to change it.
#*           When porting you want to change Makefile.mach.cpp
#*           instead.
#*        Makefile.gen: the generic make plans.
#*
#* HISTORY:
#*  Feb  1 19:32 1992 (hws): Extracted from top level Makefile. Avoids
#*    the need to adapt 10 Makefiles when defaults change upon ports.
#* Created: Sat Feb  1 19:30:33 1992 (hws)
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# These are the variables that you should adjust.

# The ultimate location of your Sather installation.
SATHER_HOME = /proj/hop/sather

# The location of the untarred sather distribution (i.e. the path locating
# the directory this Makefile is in).
TOPDIR = /proj/hop/dist

# The architecture for which the executables are generated defines
# the bin directory. This may also be used to conditionalize
# compiles. See the file Makefile.mach for architecture dependent settings.
# We used the following symbols: sparc, mips, vax, sony,...
# You may have to differentiate further (mips-dec-ultrix,littlemips ...). 
ARCH = sun4

# After installing you may run "make setgrp" to set group and permissions
# of the directory tree, if your defaults are different from what you want
# the installation to be. The default group name is "sather".
SATHERGRP = csis

# During installation all files generated by the Sather compiler, including
# the boot compiler in the distribution, are built using $SATHER_MAKE.
# Note that with SATHER_MAKE = pmake, c_makefiles mentioned in .sather
# are still run using "make" since "pmake" does not seem to support "include"
# yet.
SATHER_MAKE = make

# The Garbage collector runs silent in the background by default.
# GCSILENT=SILENT, or is prints statistics GCSILENT=NOSILENT
GCSILENT=SILENT

# The Garbage collector allocates chunks of memory. The maximum number
# is defined in sys/GC/gc.h MAXHBLKS = 6144 and is fine for ~ 64MB
# configured swap space. The initial setting MAXHBLKS = 4096 seems to be
# meant for about 32MB swap space. Reached the previous limit when trying
# to compile the compiler with all checking and debugging options switched
# on.

# The Sather to C (sac) interface provides some predefined 
# classes, C files etc that simplify interfacing to C. But it
# is not necessary to include them. You may want to follow different
# conventions. If you have Emacs users in your site, sac also includes
# a generator for generating C interface classes from higher level
# sather like description of C packages. 
# YES or NO controls whether sac installation skipped.
SKIPSAC = NO

# The release version that users refer to in bug reports to sather-admin.
RELEASEVERSION = 0.2g

# This should expand into the current date on your host. If not
# enter the current date as a string like "Thu Mar 19 16:09:31 EST 1992".
# The compiler will get to know about this and allow you to
# distinguish compiler listings of different versions at your site.
# The hostname may help us ask funny questions when tracking down compiler 
# errors due to compiling the compiler on that host.
CONFIG_DATE = `date`
HOSTNAME = `hostname`




# 1 "Mkf.mach.cpp" 
# -*- Mode: Text;  -*-
# File: Makefile.mach.cpp
# 
# Copyright (C) CSIRO Division of Information Technology, 1992
#
# COPYRIGHT NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY
# and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
# LICENSE contained in the file: "sather/doc/license.txt" of the Sather
# distribution. The license is also available from ICSI, 1947 Center
# St., Suite 600, Berkeley CA 94704, USA.
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#* FUNCTION: Makefile header included by all Makefiles. The file 
#*    consists of three parts: 
#*        Makefile.site: you normally need to edit only this one.
#*        Makefile.mach: the machine dependent part and defaults.
#*           This is machine generated you do not want to change it.
#*           When porting you want to change Makefile.mach.cpp
#*           instead.
#*        Makefile.gen: the generic make plans.
#*  
#*    This file contains the default macros possible overridden
#*    by machine dependent settings.
#*
#* HISTORY:
#*  Feb  1 19:32 1992 (hws): Extracted from top level Makefile. Avoids
#*    the need to adapt 10 Makefiles when defaults change upon ports.
#* Created: Sat Feb  1 19:30:33 1992 (hws)
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# These are default options you do *NOT* want to modify.


# 37 "Mkf.mach.cpp" 



# 44 "Mkf.mach.cpp" 

AR = /bin/ar


AR = /bin/ar
AS = /bin/as
AWK = /bin/awk

COMPRESS = /usr/ucb/compress
CP = /bin/cp

# I tried /lib/cpp on NeXT but this confuses make by  "/**/#" -> " #"
# If your cc is not properly installed you may
# do         make CPP="(/lib/cpp | sed s,' \#','#',g ) <" config
# instead, overriding the current CPP setting
CPP = cc -E

ECHO = /bin/echo
ED = /bin/ed
FALSE = /bin/false
FIND = /usr/bin/find

# 69 "Mkf.mach.cpp" 

INSTALL = /usr/bin/install
LN = /bin/ln -s


# 75 "Mkf.mach.cpp" 
# 78 "Mkf.mach.cpp" 

# 81 "Mkf.mach.cpp" 

MATHLIB=/usr/lib/libm.a



MD = /bin/mkdir
MV = /bin/mv

# 92 "Mkf.mach.cpp" 

# 95 "Mkf.mach.cpp" 

RANLIB = /usr/bin/ranlib



RM = /bin/rm -f
SED = /bin/sed
SHELL = /bin/sh

# 106 "Mkf.mach.cpp" 

TAR = /bin/tar


TRUE = /bin/true
WC = /usr/ucb/wc
YACC = /usr/bin/yacc

# Problems with your ARCHITECTURE or PORTING? 
# You may have to change here if you are porting.
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Architecture specific settings, extended with each port and perhaps
# replacing some of the defaults above.

# #include ${TOPDIR}/makemach
# -*- Mode: Text;  -*-
# File: makemach.cpp
# 
# 
# Copyright (C) CSIRO Division of Information Technology, 1992
# COPYRIGHT NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY
# and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
# LICENSE contained in the file: "sather/doc/license.txt" of the Sather
# distribution. The license is also available from ICSI, 1947 Center
# St., Suite 600, Berkeley CA 94704, USA.
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#* FUNCTION: Machine dependent setting for Makefile.header
#*           (All makefiles should be rewritten to use imake).
#* HISTORY:
#* Created: Mon Feb  3 00:27:40 1992 (hws)
#*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# The following conditionals are used so far and the
# current setting is depicted in the generated file.
# If you are porting to a new machine please record the new option here.
# It may help someone else interpreting compile conditionalizations.
# 
# Architectures:
# sparc_: 1, sun3_: sun3, sun4_: sun4,
# mips_: mips, hpux_: hpux, vax_: vax, sony_: sony,
# sequent_: sequent, vax_: vax, mips_: mips, MIPSEL_: MIPSEL,
# NeXT_: NeXT, mc68000_: mc68000, hp9000s300_: hp9000s300,
# i386_: i386, ibm032_: ibm032, _IBMR2_: _IBMR2,
# SCO_: SCO
# 
# Operating systems:
# unix_: 1, bsd4_2_: bsd4_2, bsd4_3_: bsd4_3, SYSTYPE_BSD: SYSTYPE_BSD
# SYSV_: SYSV, SYSTYPE_SYSV_: SYSTYPE_SYSV, M_SYSV_: M_SYSV
# ultrix_: ultrix, __MACH___: __MACH__

# MACHINE DEPENDENT REDEFINITIONS OF FLAGS

# -O is a bad option for compiling the cs MAIN_.c
# because cc crashes due to size. The main routine
# itself is relatively small. Other than this the options can be
# just like CFLAGS. MAINFLAGS is used when the MAIN_.c of 
# the sather compiler is processed. It has lots of symbols
# and requires special table sizes on some unixes.
# Since we include this header file, every make file sees the
# defaults, can save them or append to them or replace them.

# These are passed to cc, TCLIBS is only used in some tests etc/test
CC = cc
CFLAGS = -O -DSATHER -DGC_ 
TCLIBS =
MFLAGS =

# cc flags when compiling the big compiler MAIN_.c
MAINFLAGS= -DSATHER -DGC_
# some systems even want a different compiler in this case.
MAINCC=${CC}

# These are only passed to the make step which compiles the
# boot compiler and can be used to override flags in the make file
# that was generated when the distribution was constructed on another
# machine: compiler/cs.cs.boot/mkCS
BOOTFLAGS=
# These are passed to cs and can include -cflags, -cc etc., cf.
# doc/cs_options.txt. Will show up in the make file created
# by the compiler during the installation.
CSFLAGS = -w

# 192 "Mkf.mach.cpp" 


# 206 "Mkf.mach.cpp" 


# 215 "Mkf.mach.cpp" 

 
# 232 "Mkf.mach.cpp" 


# 237 "Mkf.mach.cpp" 


# 242 "Mkf.mach.cpp" 


# 246 "Mkf.mach.cpp" 


# 252 "Mkf.mach.cpp" 


# 260 "Mkf.mach.cpp" 


# WHILE PORTING ...
# MACHINE DEPENDENT SUBSYSTEM INCLUSION
# The following variables help skipping installations of part of the
# system that may require adaptation.

# The Sather debugger (sdb) is based on the GNU debugger. The current
# distribution contains only the setting for 1. You need
# to run your local Gnu gdb directory against debugger/C and
# edit the local make file there. We really should make this
# via a gdb.${ARCH} directory and links into it for the 3 or 4 files
# that are machine dependent.
# YES or NO controls whether sdb installation skipped.


SKIPSDB = NO
# 279 "Mkf.mach.cpp" 


# The Garbage Collector (GC) may require a new machine dependent
# patch if the machine is not yet supported.
# YES or NO controls whether gc installation skipped.
# 286 "Mkf.mach.cpp" 

SKIPGC = NO

# GC V1.9 runs now on Dec mipses and RT too.
# #if defined(mips) & defined(ultrix) & defined(bsd4_2)
# SKIPGC = YES
# #else
# SKIPGC = NO
# #endif

# 
# Local flags while developing, porting etc.
LOCFLAGS =


# This part should perhaps stay as it is. See also the note below.
# 
# Do not delete param passing for sather home and topdir, ever.
# "make dist" will run clean on the development system!
# Do not include CFLAGS param passing here, so every make file 
# can see the shared defaults (XCFLAGS) and append to them or redefine them
# appropirately.
# Moreover pass on make parameters (${MAKE}) so we can do the few non-interfering
# things "make ARCH=mips -f Makefile" on disjoint subdirectories for different
# architectures. 

MKCMD = ${MAKE} SATHER_HOME=${SATHER_HOME} TOPDIR=${TOPDIR}

CS = ${TOPDIR}/bin.${ARCH}/cs -mak ${SATHER_MAKE}
# File: Makefile.gen
# Author: Jeff Bilmes
# Copyright (C) International Computer Science Institute, 1991
# Changes: Heinz Schmidt (hws@csis.dit.csiro.AU)
# Copyright (C) CSIRO Division of Information Technology, 1992
#
# COPYRIGHT NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY
# and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
# LICENSE contained in the file: "sather/doc/license.txt" of the Sather
# distribution. The license is also available from ICSI, 1947 Center
# St., Suite 600, Berkeley CA 94704, USA.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# FUNCTION:
#    Makefile for the compiler itself.
#
# HISTORY:
#* Last edited: Feb 16 11:47 1992 (hws)
#*  Feb 16 11:47 1992 (hws): finally deleted all the sather home adj
#*                           stuff in the boot compiler.
#*  Feb  1 19:33 1992 (hws): include shared defaults now.
#*  Feb  1 17:46 1992 (hws): ARCH itecture dependent bin introduced 
#* Created: Mon Jan  7 09:33:08 1991
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Local defaults
SATHERBOOTCFILEDIR = cs.cs.boot
SATHERCFILEDIR = cs.cs
SATHER_HOMEADJUST = adj.commands

CODEFILES = c_codegen.sa classob.sa classob_s.sa classs_tab.sa \
  class_tab.sa codeob.sa common_data.sa cs_keys.sa constants.sa cs.sa \
  dbkey.sa dbsupport.sa dbtable.sa declob.sa declob_s.sa dot_sa.sa \
  exprob.sa exprob_s.sa exprob_s2.sa fd.macros fd.sa featob.sa featob_s.sa \
  filetypes.sa hash.sa inc_compile.sa info.sa install.sa \
  i2iset.sa key.sa lexer.h lst.sa lst_codeob.sa make-parser map-c-names \
  opt_stm_s.sa persist.sa semant.sa sorter.sa ssather.y stmtob.sa stmtob_s.sa \
  str_buffer.sa str_set.sa str_table.sa symtab.sa syserr.sa time.sa timer.c \
  timer.sa typeob.sa typeob_s.sa .sather .sa.c_fstat .sa.persist \
  syserr.macros

all: compiler

# compile the boot Sather compiler. After this, user can use compiler in
# "compiler/cs"
# Also make sure that while sather home is not created in "make" run, we are
# working on top directory instead.
# Pass on flags to make sure we use the machine dependent settings. The target settings
# may be different from the ones in the make files generated by boot-create (hws).
boot-compile:
	(cd ${SATHERBOOTCFILEDIR}; ${SATHER_MAKE} -f mkCS \
	 SATHER_HOME=${TOPDIR} CFLAGS="${CFLAGS}" \
	 CC=${MAINCC} SATHER_MAKE=${SATHER_MAKE} MAINFLAGS="${MAINFLAGS}" ${BOOTFLAGS}; )
	${MV} ${SATHERBOOTCFILEDIR}/cs ./cs
	@echo Boot version of compiler created!

# setup the boot compiler directory for a site. This makes the assumption
# that several files are linked.
# Note that different architectures will create different .o files for the 
# the .c files in lib/base/C and sys/C whenever make is run

# file            where should be linked

# ./lexer.h       ${SATHER_HOME}/compiler
# ./ssather.y     ${SATHER_HOME}/compiler
# ./timer.c       ${SATHER_HOME}/compiler

# ./all_.h        ${SATHER_HOME}/sys/C
# ./macros_.h     ${SATHER_HOME}/sys/C

# ./base_.o       ${SATHER_HOME}/bin.${ARCH}
# ./file_.o       ${SATHER_HOME}/bin.${ARCH}
# ./str_.o        ${SATHER_HOME}/bin.${ARCH}
# ./time_.o       ${SATHER_HOME}/bin.${ARCH}

# ./deep_save_.o  ${SATHER_HOME}/bin.${ARCH}
# ./envivars_.o   ${SATHER_HOME}/bin.${ARCH}
# ./gc_.a         ${SATHER_HOME}/bin.${ARCH}
# ./main_.o       ${SATHER_HOME}/bin.${ARCH}
# ./runtime_.o    ${SATHER_HOME}/bin.${ARCH}
# ./rt_sux_.o    ${SATHER_HOME}/bin.${ARCH}

# ./libm.a        ${SATHER_HOME}/bin.${ARCH}

COMPILERFILES = lexer.h ssather.y timer.c
ALIBBASECFILES = base_.o file_.o str_.o time_.o
ASYSCFILES = deep_save_.o gc_.a main_.o runtime_.o rt_sux_.o envivars_.o
SYSCFILES = all_.h macros_.h
ALLLINKEDFILES = ${COMPILERFILES} ${ALIBBASECFILES} ${ASYSCFILES} ${SYSCFILES}
# The following uses only relative names now (hws 12/15/91)
# However: note that we have cd'ed to $SATHER_HOME/compiler when executing
# this plan. Systems that need LN=cp won't find the files if we do not
# go one level done.

boot-setup:
	for i in ${COMPILERFILES} ; \
	do  \
	  ${RM} ${SATHERBOOTCFILEDIR}/$$i ; \
	  (cd ${SATHERBOOTCFILEDIR}; \
	  ${LN} ../../compiler/$$i $$i ; ); \
	done
	for i in  ${ALIBBASECFILES} ${ASYSCFILES}; \
	do  \
	  ${RM} ${SATHERBOOTCFILEDIR}/$$i ; \
	  (cd ${SATHERBOOTCFILEDIR}; \
	 ${LN} ../../bin.${ARCH}/$$i $$i ; ); \
	done
	for i in ${SYSCFILES} ; \
	do  \
	  ${RM} ${SATHERBOOTCFILEDIR}/$$i ; \
	  (cd ${SATHERBOOTCFILEDIR}; \
	 ${LN} ../../sys/C/$$i $$i ; ); \
	done
	-[ -f ${SATHERBOOTCFILEDIR}/libm.a ] || ${RM} ${SATHERBOOTCFILEDIR}/libm.a
	(cd ${SATHERBOOTCFILEDIR}; \
	 ${LN} ../../bin.${ARCH}/libm.a libm.a )


# create the boot directory by compiling a version with as many non-ln'ed files
# as possible. 
boot-create:
	${CS} -mak ${SATHER_MAKE} -dco -gen -all -info cs
	-${RM} -r ${SATHERBOOTCFILEDIR}
	${MV} ${SATHERCFILEDIR} ${SATHERBOOTCFILEDIR}
	(cd ${SATHERBOOTCFILEDIR}; ${RM} ${ALLLINKEDFILES}; ${RM} *.o *.a)

clean:
	-${RM} -r *~ ./cs *.cs
	(cd ${SATHERBOOTCFILEDIR}; ${RM} ${ALLLINKEDFILES}; ${RM} *.o *.a)
	-${RM} -r ${SATHERCFILEDIR}

# We need to make the SATHER_HOME and ARCH adjustments so different
# installations can rely on using these variables in sys_dot_sather.
# putenv_ seems not to work everywhere, therefore -hom wont do the job.

compiler:
	@echo Making complete compiler. 
	${MKCMD} config
	(ARCH=${ARCH}; export ARCH; \
	 SATHER_HOME=${TOPDIR}; export SATHER_HOME; \
	 ${CS} ${CSFLAGS} -mak ${SATHER_MAKE} -hom ${TOPDIR} cs ; )


config:
	@echo Adjusting compiler sources in-${ARCH}.sa
	-${RM} ${SATHER_HOMEADJUST}
	@echo '1,$$s,/usr/local/src/sather,'${SATHER_HOME}',g' > ${SATHER_HOMEADJUST}
	@echo '1,$$s,'\"sun4\"','\"${ARCH}\"',g' >> ${SATHER_HOMEADJUST}
	@echo '1,$$s,'\"DATE\"','\"${CONFIG_DATE}\"',g' >> ${SATHER_HOMEADJUST}
	@echo '1,$$s,'\"VERSION\"','\"${RELEASEVERSION}\"',g' >> ${SATHER_HOMEADJUST}
	@echo '1,$$s,'\"HOST\"','\"${HOSTNAME}\"',g' >> ${SATHER_HOMEADJUST}
	@echo '1,$$s,'\"CC\"','\"${CC}\"',g' >> ${SATHER_HOMEADJUST}
	@echo w >> ${SATHER_HOMEADJUST}
	@echo q >> ${SATHER_HOMEADJUST}
	-${RM} in-${ARCH}.sa
	-${CP} install.sa in-${ARCH}.sa
	${ED} in-${ARCH}.sa < ${SATHER_HOMEADJUST} 
	
comp:
	@echo Don't forget to update version in info.sa
	${CS} ${CSFLAGS} -mak ${SATHER_MAKE} -info cs

install:
	${CP} ./cs ${SATHER_HOME}/bin.${ARCH}/cs

# ICSI local only
release:
	${RM} -r ${SATHER_HOME}/compiler/
	(cd ..; ${CP} -pR compiler ${SATHER_HOME})

CIMSG = Sather file
allci:
	ci -u -m'${CIMSG}' ${CODEFILES}
allco:
	ci -l ${CODEFILES}

