[Asterisk-cvs] asterisk/contrib/scripts astxs,NONE,1.1

anthm at lists.digium.com anthm at lists.digium.com
Mon Apr 26 19:16:28 CDT 2004


Update of /usr/cvsroot/asterisk/contrib/scripts
In directory mongoose.digium.com:/tmp/cvs-serv31609/contrib/scripts

Added Files:
	astxs 
Log Message:
applied final release of bug 1353 per Mark's permission


--- NEW FILE: astxs ---
#!/usr/bin/perl

my $astdir = $ENV{ASTSRC} or "/usr/src/asterisk";


sub esystem($) {
  my $cmd = shift;
  print "$cmd\n";
  system($cmd);
}
sub usage($) {
  my $str = shift;
  print "\n$str\n\n";
  print "Usage $0 [ <module.c> [-set=<varname>:<value>] [-append=<varname>:<value>] [-install] ] | [-help]  \n\n";

  print "varnames of interest:
===============================================================================
'INCLUDES' 'ASTLIBDIR' 'AGI_DIR' 'ASTVARRUNDIR' 'CC' 'ASTETCDIR' 'EXTOBJ'
'ASTSPOOLDIR' 'ASTLOGDIR' 'MODULES_DIR' 'ASTSBINDIR' 'ASTHEADERDIR' 'LDFLAGS'
'ASTVARLIBDIR' 'ASTBINDIR' 'INSTALL_PREFIX' 'ASTCONFPATH' 'ASTSRC' 'CFLAGS'
===============================================================================
";

  exit;

}


my %avars = ();
my %svars = ();
my %vars = ();




my %args = ();


foreach(@ARGV) {

  if(/^\-set=([^\:]+):(.*)/) {
    $svars{$1} = $2;
  }
  elsif(/^\-append=([^\:]+):(.*)/) {
    $avars{$1} .= " $2";
  }
  elsif(/^\-([^\=]+)=(.*)/) {
    $args{$1} = $2;
  }
  elsif(/^\-([^\=]+)$/) {
    $args{$1}++;
  }
  else {
    push(@{$args{plain}},$_);
  }
}

if($args{help} or $args{h}) {
  usage "Help";
}


my $pwd = `/bin/pwd`;
chomp($pwd);

$vars{astdir} ||= $astdir;

chdir($vars{astdir});
my $type = $args{type} || "apps";
my $env = `make ${type}_env`;
chdir($pwd);

foreach(split("\n",$env)) {
    my($var,$val) = /([^\=]+)\=(.*)/;
    $vars{$var} = $val;
}




foreach(keys %svars) {
    $vars{$_} = $svars{$_};
}

foreach(keys %avars) {
    $vars{$_} .= $avars{$_};
}


if($args{print}) {
    print "$vars{$args{print}}";
    exit;
}


my($base,$ext);
my $cfile = $args{plain}->[0];
if($cfile) {
  ($base,$ext) = $cfile =~ /^([^\.]+)\.(.)/;
}

if($ext ne "c") {
  usage "Bad Input File";
}

my $bad=0;

$bad = esystem("$vars{CC} $vars{CFLAGS} -c ${base}.c -o ${base}.o");
$bad = esystem("$vars{CC} $vars{SOLINK} -o $vars{LDFLAGS} ${base}.so $base.o $vars{EXTOBJ}") if(!$bad);

if($args{install} and $vars{MODULES_DIR}) {
  $bad = esystem("/bin/cp -p ${base}.so $vars{MODULES_DIR}") if(!$bad);
}





More information about the svn-commits mailing list