From d5daca9f40958fba7f3a17238202193f7eb52d67 Mon Sep 17 00:00:00 2001
From: ram <ram>
Date: Tue, 1 Nov 1994 19:50:01 +0000
Subject: [PATCH] Initial revision

---
 tools/build-and-install | 304 ++++++++++++++++++++++++++++++++++++++++
 tools/variant-lisp      |  82 +++++++++++
 2 files changed, 386 insertions(+)
 create mode 100755 tools/build-and-install
 create mode 100755 tools/variant-lisp

diff --git a/tools/build-and-install b/tools/build-and-install
new file mode 100755
index 000000000..bc7c265ea
--- /dev/null
+++ b/tools/build-and-install
@@ -0,0 +1,304 @@
+#!/bin/sh
+# Install/build cmucl cores. 
+# David Axmark (davida@isil.detron.se) 
+# Rewritten 940501.
+# This script was suppled by David Axmark.  It rebuilds CMU CL from sources.
+# It uses his build-and-install script, and may contain sun dependencies. 
+#
+
+# Try to avoid depending on locally installed stuff.
+PATH=/bin:$PATH
+export PATH
+
+sed_fix ()
+{
+	(
+	file=$1; shift
+	if test ! -f $file.before-sed
+	then
+		sedscript=/tmp/sedscript-$$
+		> $sedscript
+		while test -n "$1"
+		do
+			# Dont fail for args begginging with -n
+			/usr/5bin/echo "$1" >> $sedscript
+			shift
+		done
+		mv $file $file.before-sed
+		echo "Applying sed fixes to $file"
+		sed -f $sedscript $file.before-sed > $file
+		rm -f $sedscript
+	fi
+	)
+}
+
+mkdir_if_needed () { if test ! -d "$1"; then mkdir "$1"; fi }
+
+usage ()
+{
+	echo "Usage:$0 cmucl_version [build_options]"
+	echo "Example: $0 17e -all"
+	exit 1
+}
+
+if test -z "$1"; then usage; fi
+
+ver=$1; shift
+if expr "$ver" : "[0-9]\{1,3\}[a-z]\{1,\}" > /dev/null
+then
+	dummy=t
+else
+	echo "The version $ver seems funny to me. Expected somthing like 17e."
+	exit 1
+fi
+
+# Set a lot of variables.
+sys=sunos
+base=${MY_BASEDIR:-/my}/cmucl
+local_dir=$base/own-builds
+CMUCL_ROOT=$base
+CMUCL_EMPTYFILE=/var/tmp/empty
+subdir=$ver
+src=$base/src/$ver
+tooldir=$src/tools
+build_dir=$base/build
+dest=$build_dir/$sys/$subdir
+lisp=variant-lisp
+safe_lisp="variant-lisp -version $ver"
+logfile=$build_dir/build-$ver-log-`date +%H%M%S`
+report_memory_layout=\
+'(format t "read-only ~X~%static ~X~%dynamic ~X~%"
+ sparc:target-read-only-space-start sparc:target-static-space-start
+ sparc:target-dynamic-space-start)'
+export ver tooldir build_dir CMUCL_ROOT CMUCL_EMPTYFILE sys subdir dest src lisp
+
+if test -z "$1"; then usage; fi
+
+# We need this for the log file
+mkdir_if_needed $build_dir
+(
+while test -n "$1"
+do
+echo "Doing: $1"
+case "$1"
+in
+	-all-build-steps)
+	# All steps
+	echo "Doing all steps nesessariy to build a cmucl core."
+	set - -all \
+        -setup -genesis -compile-c-code -compile-lisp-code -worldbuild -mk-lisp
+    	;;
+
+	-remove-old-installation)
+	rm -rf $base/release-$ver
+	;;
+
+	-remove-build-directory)
+	# We leave $base/build since we want to keep the log files.
+	rm -rf $dest
+	;;
+
+	-install-distribution)
+	cd $base
+	if test -d release-$ver
+	then
+		echo "Release $ver already installed"
+		exit 1
+	fi
+	vername=sunos
+	mkdir release-$ver
+	cd release-$ver
+	any_cat $base/distributions/$ver-$vername.tar* | gtar xf -
+	any_cat $base/distributions/$ver-extra-$vername.tar* | gtar xf -
+	mkdir src; cd src
+	any_cat $base/distributions/$ver-source.tar.* | gtar xf -
+	cd $base/src
+	ln -s ../release-$ver/src $ver
+	;;
+
+	-config)
+	# Configure a default kernel with CLX
+	cd $base/release-$ver/lib
+	conf=`/usr/5bin/echo -e "4\n6\n"`
+	echo "$conf" | CMUCL_VERSION=$ver ./config
+	;;
+
+	-clean-up)
+	# Remove or compress some files that are not strictly needed
+	rm -rf *.BAK subsystems
+	cd ../doc
+	gzip --best *.ps *.doc *.txt
+	echo "Done"
+	;;
+
+	-apply-patch)
+	name=$2; shift
+	echo "Applying patch: $name"
+	if test ! -f  $src/patch-$name-applied
+	then
+		patch --directory $src --strip=1 < $local_dir/$ver-$name-patch
+		touch $src/patch-$name-applied
+	fi
+	;;
+
+	-add-local-c-code)
+	# Make sure that we link again
+	rm -f $dest/lisp/lisp  
+	ml=$MY_BASEDIR_VERSION/lib
+	clm_lib=$MY_BASEDIR_VERSION/wlisp/gina/clm/lib.sun4
+	local_src=17e-extra-c-code.c
+	local_libs="-L$ml -lreg -lpisam -lhash -lmisam \
+		 -lmerge -lnisam -lheap -linput -lmycurses -lpcurses -lmysys \
+		 -ldbug -lstrings $ml/rx.o $ml/replace-many.o \
+		  $clm_lib/unixsocket.o $clm_lib/io.o"
+	;;
+
+	-clean-c-code)
+	cd $dest/lisp
+	gmake -f $src/lisp/GNUmakefile clean
+	;;
+
+	-setup)
+        # Fix makefile so we can use the VPATH feature.
+	if test ! -f  $src/lisp/patch-GNUmakefile-applied
+	then
+		patch --directory $src/lisp \
+    	    	    < $local_dir/$ver-GNUmakefile-patch
+		touch $src/lisp/patch-GNUmakefile-applied
+	fi
+	# Create build directory stucture
+	mkdir_if_needed $build_dir/$sys
+	mkdir_if_needed $build_dir/$sys/$subdir
+	# Create directory structure if needed.
+	if test ! -d $build_dir/$sys/$subdir/lisp
+	then
+		cd $src
+		# Suns find will not do a $var/{} substitution.
+		# So we do this instead.
+		find . -type d -print | while read dir; do mkdir $dest/$dir; done
+	fi
+	# Create Config & Depends
+	cd $dest/lisp
+	# Create Config file.
+		cat > Config << EOF
+	CPPFLAGS = -I. -I/usr/include/X11 -DSUNOS # -DDEBUG
+	CC = gcc # -Wall -Wstrict-prototypes -Wmissing-prototypes
+	CPP = /lib/cpp
+	CFLAGS = -O
+	ASFLAGS = -O
+	NM = nm -gp
+	ASSEM_SRC = sparc-assem.S
+	ARCH_SRC = sparc-arch.c
+	OS_SRC = sunos-os.c os-common.c $local_src
+	OS_LINK_FLAGS=-static
+	OS_LIBS=$local_libs
+	VPATH=$src/lisp:$local_dir
+EOF
+	# Create a Depends file
+	if test ! -f Depends
+	then
+		> Depends
+		# Create fake internals.h so make depend works.
+		> internals.h
+	        gmake -f $src/lisp/GNUmakefile depend
+		rm -f internals.h
+	fi
+	;;
+
+	-genesis)
+	echo "Map file for ldb version 0" > $dest/lisp/lisp.map
+	$safe_lisp -noinit << EOF 
+	(setf (ext:search-list "target:") '("$dest/"))
+	(setf (ext:search-list "src:") '("$base/src/$ver/"))
+	(load "src:compiler/sparc/parms")
+	(load "src:compiler/generic/new-genesis")
+    	$report_memory_layout
+	(in-package :lisp)
+	(setf *genesis-core-name* "target:lisp/kernel.core")
+	(setf *genesis-c-header-name* t)
+	(setf *genesis-symbol-table* "target:lisp/lisp.map")
+	(setf *genesis-map-name* t)
+	(setf *target-page-size* 8192)
+	(genesis nil)
+	(ext:quit)
+EOF
+	;;
+
+	-compile-c-code)
+	cd $dest/lisp
+	gmake -f $src/lisp/GNUmakefile all
+	;;
+
+	-compile-lisp-code)
+	sed_fix $tooldir/compile-all \
+		"s;/afs/cs/project/clisp/build/;$base/build/;" \
+		"s;/afs/cs/project/clisp/;$base/;"
+	chmod a+x $tooldir/compile-all
+	cd $build_dir
+	echo "Starting compile of all lisp code. This takes a long time."
+	LISP=$safe_lisp \
+	$tooldir/compile-all -target sunos -release $ver -lisp $base/release-$ver \
+        		     -noupdate -nocompile hemlock 
+	;;
+	-worldbuild)
+	cd $build
+	$safe_lisp -noinit << EOF
+	(setf (search-list "target:") '("$dest/" "$src/"))
+	(load "target:compiler/sparc/parms")
+	$report_memory_layout
+	(load "target:bootstrap" :if-does-not-exist nil)
+	(load "target:tools/setup")
+	(load "target:compiler/generic/new-genesis" :if-source-newer :compile)
+	(load "target:tools/worldbuild" :if-source-newer :compile)
+        $report_memory_layout
+	(quit)
+EOF
+	;;
+
+	-mk-lisp)
+	sed_fix $tooldir/mk-lisp "s;/@sys/;/\$sys/;"
+	chmod a+x $tooldir/mk-lisp
+	cd $dest
+	$tooldir/mk-lisp -now $ver :no-hemlock
+	;;
+
+	-install-as)
+	new_ver=$2; shift
+	if test "$ver" = "$new_ver"
+	then 
+		echo "buildver $ver can not be equal to installver $new_ver"
+		exit 1
+	fi
+	echo "Inststalling new core as version $new_ver"
+	mkdir_if_needed $base/release-$new_ver
+	mkdir_if_needed $base/release-$new_ver/bin
+	mkdir_if_needed $base/release-$new_ver/lib
+	# Make symlinks to original version.
+	cd $base/release-$new_ver
+	rm -f doc man src
+	ln -s ../release-$ver/doc ../release-$ver/man ../release-$ver/src .
+	cd $base/release-$new_ver/lib
+	for file in `echo ../../release-$ver/lib/*`
+	do
+		rm -f ./`basename $file`; ln -s $file .
+	done
+	rm -f $base/release-$new_ver/bin/lisp $base/release-$new_ver/lib/lisp.core
+	cp $dest/lisp/lisp $base/release-$new_ver/bin/lisp
+	cp $dest/lisp.core $base/release-$new_ver/lib/lisp.core
+	;;
+
+	-make-default)
+	# Change symlink so this becomes the default version
+	new_ver=$2; shift
+	cd $base
+	rm -f release; ln -s release-$new_ver release
+	;;
+
+	*)
+		echo "No such function: $1"
+		exit 1
+	;;
+esac
+shift
+done
+) 2>&1 | tee $logfile
diff --git a/tools/variant-lisp b/tools/variant-lisp
new file mode 100755
index 000000000..03928acfd
--- /dev/null
+++ b/tools/variant-lisp
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Start a CMU CL lisp.
+# This script was suppled by David Axmark.  It supports starting various
+# different versions of CMU CL, and is used by his build-and-install script.
+# It may contain Sun dependencies.
+
+MY_BASEDIR=${MY_BASEDIR:-/my}
+BASE_DIR=$MY_BASEDIR/cmucl
+
+# We require all arguments to this script to come before other
+# arguments.  This is so we dont have to try to pass on arguments
+# with spaces, quotes and so on in them.
+
+VERSION=
+VARIANT=
+
+# Default version/variant may be changed in the environment.
+if test -n "$CMUCL_VERSION"; then VERSION=-$CMUCL_VERSION; fi
+if test -n "$CMUCL_VARIANT"; then VARIANT=-$CMUCL_VARIANT; fi
+
+while test -n "$1" -a -z "$END_LOOP"
+do
+	case $1
+	in
+		-version)	VERSION=-$2; shift; shift;;
+		-variant)	VARIANT=-$2; shift; shift;;
+		-prod)	    	PROD=t; shift;;
+		*)		END_LOOP=t;;
+	esac
+done
+
+if test -n "$VERSION" -a ! -d "$BASE_DIR/release$VERSION"
+then
+	echo "Could not find lisp version $VERSION."
+	if test -n "LISP_MUST_HAVE_RIGHT_CORE"
+	then
+		exit 1
+	fi
+	echo "Trying to use default version"
+	VERSION=
+fi
+
+if test -n "$PROD"
+then
+	BASE=$MY_BASEDIR/production/interview
+else
+	BASE=$BASE_DIR/release$VERSION
+fi
+
+LISP=$BASE/bin/lisp
+CORE=$BASE/lib/lisp.core
+CMUCLLIB=$BASE/lib
+
+PATH=$BASE/bin:$PATH
+
+# Avoid tmpfs filesystems for CMUCL_EMPTYFILE
+CMUCL_EMPTYFILE=/var/tmp/empty
+
+export PATH CMUCLLIB CMUCL_EMPTYFILE
+
+# Use this systems version as default if it exists. Ex if we are running
+# under /my/ok we will use the -ok core.
+MY_VERSION=`basename ${MY_BASEDIR_VERSION:-/}`
+if test -n "$MY_VERSION" -a -f $CORE$VARIANT-$MY_VERSION
+then
+	VARIANT="$VARIANT-$MY_VERSION"
+fi
+
+if test -n "$VARIANT" -a ! -f $CORE$VARIANT
+then
+	echo "Could not find lisp variant $CORE$VARIANT."
+	if test -n "LISP_MUST_HAVE_RIGHT_CORE"
+	then
+		exit 1
+	fi
+	echo "Trying to use default variant"
+	VARIANT=
+else
+	CORE="$CORE$VARIANT"
+fi
+
+exec $LISP -core $CORE "$@"
-- 
GitLab