head	1.2;
access;
symbols
	pkgsrc-2013Q2:1.2.0.54
	pkgsrc-2013Q2-base:1.2
	pkgsrc-2012Q4:1.2.0.52
	pkgsrc-2012Q4-base:1.2
	pkgsrc-2011Q4:1.2.0.50
	pkgsrc-2011Q4-base:1.2
	pkgsrc-2011Q2:1.2.0.48
	pkgsrc-2011Q2-base:1.2
	pkgsrc-2009Q4:1.2.0.46
	pkgsrc-2009Q4-base:1.2
	pkgsrc-2008Q4:1.2.0.44
	pkgsrc-2008Q4-base:1.2
	pkgsrc-2008Q3:1.2.0.42
	pkgsrc-2008Q3-base:1.2
	cube-native-xorg:1.2.0.40
	cube-native-xorg-base:1.2
	pkgsrc-2008Q2:1.2.0.38
	pkgsrc-2008Q2-base:1.2
	pkgsrc-2008Q1:1.2.0.36
	pkgsrc-2008Q1-base:1.2
	pkgsrc-2007Q4:1.2.0.34
	pkgsrc-2007Q4-base:1.2
	pkgsrc-2007Q3:1.2.0.32
	pkgsrc-2007Q3-base:1.2
	pkgsrc-2007Q2:1.2.0.30
	pkgsrc-2007Q2-base:1.2
	pkgsrc-2007Q1:1.2.0.28
	pkgsrc-2007Q1-base:1.2
	pkgsrc-2006Q4:1.2.0.26
	pkgsrc-2006Q4-base:1.2
	pkgsrc-2006Q3:1.2.0.24
	pkgsrc-2006Q3-base:1.2
	pkgsrc-2006Q2:1.2.0.22
	pkgsrc-2006Q2-base:1.2
	pkgsrc-2006Q1:1.2.0.20
	pkgsrc-2006Q1-base:1.2
	pkgsrc-2005Q4:1.2.0.18
	pkgsrc-2005Q4-base:1.2
	pkgsrc-2005Q3:1.2.0.16
	pkgsrc-2005Q3-base:1.2
	pkgsrc-2005Q2:1.2.0.14
	pkgsrc-2005Q2-base:1.2
	pkgsrc-2005Q1:1.2.0.12
	pkgsrc-2005Q1-base:1.2
	pkgsrc-2004Q4:1.2.0.10
	pkgsrc-2004Q4-base:1.2
	pkgsrc-2004Q3:1.2.0.8
	pkgsrc-2004Q3-base:1.2
	pkgsrc-2004Q2:1.2.0.6
	pkgsrc-2004Q2-base:1.2
	pkgsrc-2004Q1:1.2.0.4
	pkgsrc-2004Q1-base:1.2
	pkgsrc-2003Q4:1.2.0.2
	pkgsrc-2003Q4-base:1.2
	buildlink2:1.1.0.2
	buildlink2-base:1.1
	netbsd-1-5-PATCH003:1.1;
locks; strict;
comment	@# @;


1.2
date	2002.07.04.20.24.42;	author wiz;	state dead;
branches;
next	1.1;

1.1
date	2001.10.26.14.26.27;	author agc;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Update to 110.38, provided by Chris Richards in pkg/15427.
Changes since 110.9.1:
 * Bug fixes, improvements to generated code, and miscellaneous
   user-invisible tweaks too numerous to mention.
 * Autoloaded libraries now load correctly, due to the new
   `CM_PATHCONFIG' mechanism.  Autoloading failed in the package's
   previous version, despite the best effort of the do-install target.
 * New commands `ml-build' and `ml-makedepend'.  The former automates
   the process of building standalone heap images, while the latter
   generates dependencies for traditional makefiles.
 * Major overhaul of the Compilation Manager (CM).  For example, most
   `sources.cm' files now require including `$/basis.cm', as well as
   substituting `$/foo.cm' for `foo.cm' wherever `foo.cm' refers to an
   autoloaded library bundled with the system (e.g. `smlnj-lib.cm').
   For details, see http://www.smlnj.org/NEWS/110.20-README.html, and
   the CM manual at
   http://cm.bell-labs.com/cm/cs/what/smlnj/doc/CM/new.pdf .
 * Reduced virtual memory consumption.
 * Support for running under Mac OS X (Darwin).  Such support is not
   currently reflected in the pkgsrc, however, since I have no way to
   test it.
@
text
@#!/bin/sh
#
# usage: get-cm work_dir
#
# Find all .cm Group and Library descriptions that are referenced
# from the top level alias files in $SML_BASE/lib/

# temp file
tmpfile="${TMP:-/tmp}/chomp$$"

# attempt to change directory to work dir
cd $1 || exit 1
work_dir=`pwd`	# get the canonical name for the current directory

trap "rm -f $tmpfile" 0 1 2 3 15

# hack to remove SML comments '(* ... *)' 

strip_comments()
{
	# caveat: the following assumes gcc is present ...	
	gcc -x c -E -P -ansi -DOPSYS_UNIX $1 | awk '{ 
		line = $0
		if (match(line, "\\(\\*")) {
			while (match($0, "\\(\\*")) {
				if (RSTART > 1) {
					print substr($0, 0, RSTART-1);
				}
				sub("^.*\\(\\*", "");
				while (!match($0, "\\*\\)")) {
					getline
				}
				$0 = substr($0, RSTART+RLENGTH);
			}
		}
		print
	}'
}

# return canonical name for a path with embedded ..'s

canonical()
{
	echo $(cd `dirname $1` && pwd)/`basename $1`
}

# initial list of CM description files
global_cm_list="$(cat ./lib/*.cm | awk '{ print $2 }')"

set -- $global_cm_list

touch $tmpfile

# process the global list
while [ $# -ge 1 ]; do

	cm_file="$1"; shift
	global_cm_list="$*"

	echo $cm_file >> $tmpfile

	cm_dir=`dirname $cm_file`
	cm_new=$(strip_comments $cm_file | grep '\.cm' | \
		awk '{ print $1 }')

	# append new CM files to current global list
	for i in $cm_new; do
		new_cm_file=$(canonical $cm_dir/$i)
		if [ -r $new_cm_file ]; then 
			if ! grep "^$new_cm_file" $tmpfile > /dev/null; then 
				global_cm_list="$new_cm_file $global_cm_list"
				echo $new_cm_file >> $tmpfile
			fi
		fi
	done 

	set -- $global_cm_list
done

# output to stdout
sort -u < $tmpfile | sed -e "s,^$work_dir/,,"
@


1.1
log
@Move get-cm custom script to the files/ directory
@
text
@@

