#!/usr/bin/perl
###############################################################################
#
# File:         NS.Makefiles.fix.after_install
# RCS:          $Header: $
# Description:  fix INSTALLDIR in after_install
# Author:       Christian Limpach <chris@nice.ch>
# Created:      Tue Apr  4 21:13:18 1995
# Modified:     Tue Apr  4 21:43:14 1995 (Christian Limpach) chris@nice.ch
# Language:     Perl
# Package:      N/A
# Status:       Experimental (Do Not Distribute)
#
# (C) Copyright 1995, Christian Limpach, all rights reserved.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see ftp://nice.ethz.ch/users/chris/TERMS
# for details. This software comes with ABSOLUTELY NO WARRANTY.
#
###############################################################################

$dir = "/NextDeveloper/Makefiles/app";

opendir(mf, $dir);
@files = readdir(mf);
closedir(mf);
foreach $file (@files) {
    next if ($file !~ /\.make$/);
    $file = $dir . "/" . $file;
    $t=""; $match=0;
    open (f, "<$file");
    while (<f>) {
	if (/^(\t\$\(MAKE\) after_install \t)(\"DSTROOT=\$\(DSTROOT\)\" \\)$/)
	{
	    $t .= "$1\"INSTALLDIR=\$\(INSTALLDIR\)\" \\\n\t\t\t        $2\n";
	    $match++;
	} else {
	    $t .= $_;
	}
    }
    close f;
    if ($match == 1) {
	rename ($file, $file . ".orig");
	open (f, ">$file");
	print f $t;
	close f;
    }
}
	
# perl -ni.orig -e '
#   if (/^(\t\$\(MAKE\) after_install \t)(\"DSTROOT=\$\(DSTROOT\)\" \\)$/)
#     {print "$1\"INSTALLDIR=\$\(INSTALLDIR\)\" \\\n";
#      print "\t\t\t        $2\n"; next} print;' \
#   /NextDeveloper/Makefiles/app/*.make
    
