ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/MakeInterface.pm
Revision: 1.2
Committed: Fri Dec 10 13:41:37 2004 UTC (20 years, 4 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: v102p1, V1_0_1, V1_0_0
Changes since 1.1: +84 -0 lines
Log Message:
Merged V1_0 branch to HEAD

File Contents

# User Rev Content
1 sashby 1.2 #____________________________________________________________________
2     # File: MakeInterface.pm
3     #____________________________________________________________________
4     #
5     # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6     # Update: 2004-06-22 14:49:43+0200
7     # Revision: $Id: MakeInterface.pm,v 1.1.2.3 2004/09/23 17:55:28 sashby Exp $
8     #
9     # Copyright: 2004 (C) Shaun Ashby
10     #
11     #--------------------------------------------------------------------
12     package BuildSystem::MakeInterface;
13     require 5.004;
14    
15     use Exporter;
16     @ISA=qw(Exporter);
17     @EXPORT_OK=qw( );
18    
19     sub new()
20     ###############################################################
21     # new #
22     ###############################################################
23     # modified : Tue Jun 22 14:49:46 2004 / SFA #
24     # params : #
25     # : #
26     # function : #
27     # : #
28     ###############################################################
29     {
30     my $proto=shift;
31     my $class=ref($proto) || $proto;
32     my $self={ GMAKECMD => '/usr/bin/gmake', CMDOPTS => ' -r' };
33     bless $self,$class;
34     $|=1;
35    
36     # Useful help strings for the options we're supporting:
37     # %help = (
38     # "s" => " do not print any output",
39     # "j <n>" => " the number of processes to run simultaneously",
40     # "d" => " run gmake in debug mode",
41     # "k" => " continue for as long as possible after an error",
42     # "w" => " print the working directory before and after entering it",
43     # "n" => " print the commands that would be executed but do not run them",
44     # "p" => " print the data base of rules after scanning makefiles, then build as normal"
45     # );
46    
47     # The options. These are collected in CMDOPTS:
48     my %options =
49     (
50     "make" => sub { }, # dummy so we can use help opt just for MakeInterface
51     "s" => sub { $self->{CMDOPTS}.=" -s" },
52     "j=s" => sub { $self->{CMDOPTS}.=" -j ".$_[1] },
53     "d" => sub { $self->{CMDOPTS}.=" -d" },
54     "k" => sub { $self->{CMDOPTS}.=" -k" },
55     "printdir" => sub { $self->{CMDOPTS}.=" -w" },
56     "n" => sub { $self->{CMDOPTS}.=" -n" },
57     "printdb" => sub { $self->{CMDOPTS}.=" -p" }
58     );
59    
60     Getopt::Long::config qw(default no_ignore_case require_order);
61    
62     if (! Getopt::Long::GetOptions(\%opts, %options))
63     {
64     print "SCRAM Warning: Ignoring unknown option.","\n";
65     }
66    
67     return $self;
68     }
69    
70     sub exec()
71     {
72     my $self=shift;
73     my ($makefile)=@_;
74     my $PID;
75     my $makecmd=$self->{GMAKECMD}.$self->{CMDOPTS}." -f ".$makefile." ".join(" ",@ARGV);
76    
77     print "SCRAM MakeInterface::exec(): going to exec \"",$makecmd,"\"\n",if ($ENV{SCRAM_DEBUG});
78    
79     # Try without forking:
80     exec "$makecmd" || die "SCRAM MakeInterface::exec(): Unable to exec()...$!","\n";
81     }
82    
83     1;
84