[project @ 1997-03-13 09:10:17 by sof]
authorsof <unknown>
Thu, 13 Mar 1997 09:10:19 +0000 (09:10 +0000)
committersof <unknown>
Thu, 13 Mar 1997 09:10:19 +0000 (09:10 +0000)
make perl5 friendly plus new Makefile setup

ghc/utils/stat2resid/Makefile
ghc/utils/stat2resid/parse-gcstats.prl
ghc/utils/stat2resid/stat2resid.prl

index 13afc5d..9c8c4e6 100644 (file)
@@ -1,19 +1,58 @@
 #-----------------------------------------------------------------------------
-# $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)
index 3b5dab5..4167d81 100644 (file)
@@ -36,9 +36,10 @@ sub parse_stats {
     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);
@@ -181,7 +182,7 @@ arg: while($_ = $stats[0]) {
     print STDERR "Unmatched line: $_";
     }
 
-    close($statsfile);
+    close(STATS);
     %the_stats;
 }
 
index 048981a..f1b3c9e 100644 (file)
@@ -1,8 +1,9 @@
 #
 # (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;
@@ -11,12 +12,11 @@ $outsuffix = ".resid.ps";   # change as appropriate
 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";