#-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.2 1996/11/21 16:49:10 simonm Exp $
+# $Id: Makefile,v 1.3 1997/03/13 09:10:17 sof Exp $
-TOP=../../..
-include $(TOP)/ghc/mk/ghc.mk
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
DYN_LOADABLE_BITS = \
parse-gcstats.prl \
process-gcstats.prl
-PROG=stat2resid
-SRC=stat2resid.prl
+SCRIPT_PROG=stat2resid
+SCRIPT_OBJS=stat2resid.prl
+
+#
+# Could be overridden from the cmd line (see install rule below).
+#
+INSTALLING=0
+
+SCRIPT_SUBST_VARS=TMPDIR SCRIPT_PATH
+
INTERP=$(PERL)
-DESTDIR=$(INSTBINDIR_GHC)
+CLEAN_FILES += $(SCRIPT_PROG)
+
+#
+# The stat2resid script is configured with a different
+# path to the supporting perl scripts, depending on whether it
+# is to be installed or not.
+#
+ifeq "$(INSTALLING)" "1"
+SCRIPT_PATH:=$(libdir)
+else
+SCRIPT_PATH:=$(FPTOOLS_TOP_ABS)/ghc/utils/stat2resid
+endif
+#
+# install setup
+#
+INSTALL_LIBS += $(DYN_LOADABLE_BITS)
+INSTALL_PROGS += $(SCRIPT_PROG)
+
+
+#
+# Before really installing the script, we have to
+# reconfigure it such that the paths it refers to,
+# point to the installed utils.
+#
install ::
- $(INSTALL) $(INSTDATAFLAGS) $(DYN_LOADABLE_BITS) $(INSTLIBDIR_GHC)
+ $(RM) $(SCRIPT_PROG)
+ $(MAKE) $(MFLAGS) INSTALLING=1 $(SCRIPT_PROG)
-include $(TOP)/mk/script.mk
+include $(TOP)/mk/target.mk
+
+# Hack to re-create the in-situ build tree script after
+# having just installed it.
+#
+install ::
+ @$(RM) $(SCRIPT_PROG)
+ @$(MAKE) $(MFLAGS) $(SCRIPT_PROG)
local($statsfile, $line, $row, $col, $val);
local(@stats, @hdr1, @hdr2, @line_vals);
local(%the_stats);
+ local(*STATS);
- open($statsfile, $filename) || die "Cant open $filename \n";
- @stats = <$statsfile>;
+ open(STATS, $filename) || die "Cant open $filename \n";
+ @stats = <STATS>;
do {$line = shift(@stats);} until ($line !~ /^$/);
chop($line);
print STDERR "Unmatched line: $_";
}
- close($statsfile);
+ close(STATS);
%the_stats;
}
#
# (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
#
-# *** MSUB does some substitutions here ***
-# *** grep for $( ***
+# Perl script expect bindings for the following variables to be prepended
+#
+# TMPDIR SCRIPT_PATH
#
$debug = 0;
if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
$tmpfile = $ENV{'TMPDIR'} . "/$$.resid.data";
} else {
- $tmpfile ="$(TMPDIR)/$$.resid.data";
- $ENV{'TMPDIR'} = '$(TMPDIR)'; # set the env var as well
+ $tmpfile ="${TMPDIR}/$$.resid.data";
+ $ENV{'TMPDIR'} = ${TMPDIR}; # set the env var as well
}
-@INC = ( ( $(INSTALLING) ) ? '$(INSTLIBDIR_GHC)'
- : '$(TOP_PWD)/$(CURRENT_DIR)' );
+@INC = ( ${SCRIPT_PATH} );
require('parse-gcstats.prl') || die "Can't load parse-gcstats.prl!\n";
require('process-gcstats.prl') || die "Can't load process-gcstats.prl!\n";