use File::Basename;
+# Extract information from enviroment variables set by nescc
+$ctarget = $ENV{NESCC_CFILE};
+$conly = $ENV{NESCC_CONLY} eq "yes";
+$deputy = $ENV{NESCC_DEPUTY} eq "yes";
+@deputy_args = split(" ", $ENV{NESCC_DEPUTY_ARGS});
+$gcc = $ENV{NESCC_GCC};
+
+push @nesc_args, "-fnesc-gcc=$gcc";
+
for ($i = 0; $i <= $#ARGV; $i++) {
$_ = $ARGV[$i];
$nocompile = 1;
}
- if (/^-_?fnesc-conly$/) {
- $conly = 1;
- }
-
- if (/^-[_WwvpfmD]/ || /^-pedantic$/ || /^-ansi$/) {
- push @nesc_args, $_ unless /^-_?fnesc-.*cfile=/;
+ if (/^-[_WwvpfmH]/ || /^-pedantic$/ || /^-ansi$/) {
+ push @nesc_args, $_;
$verbose = 1 if /^-v/;
}
- if (/^-I/) {
- ($i, $idir) = &extractarg($i);
- push @nesc_args, "-I$idir";
+ if (/^-([IDUA])/) {
+ $opt = $1;
+ ($i, $val) = &extractarg($i);
+ push @nesc_args, "-$opt$val";
}
elsif (/^-o/) {
($i, $objtarget) = &extractarg($i);
elsif (/^-S$/) {
$asmonly = 1;
}
- elsif (/^-_?fnesc-/) {
- if (/^-_?fnesc-cfile=(.*)$/) {
- $ctarget = $1;
- }
- if (/^-_?fnesc-tmpcfile=(.*)$/) {
- $ctarget = $1;
- $delcfile = 1;
- }
- if (/^-_?fnesc-gcc=(.*)$/) {
- $gcc = $1;
- }
- if (/^-_?fnesc-deputy$/) {
- $deputy = 1;
- }
- if (/^-_?fnesc-deputy-args=(.*)$/) {
- @deputy_args = split(" ", $1);
- }
+ elsif (/^-fnesc-tmpcfile=(.*)$/) {
+ if ($ctarget eq "") {
+ $ctarget = $1;
+ $delcfile = 1;
+ }
}
- elsif (!(/^-D/)) {
- if (!(/^-_?W(no-)?nesc/)) {
- push @gcc_args, $_;
- }
+ else {
+ push @gcc_args, $_;
}
}
else {
}
}
+# Split on spaces not preceded by \, then unquote.
+push @nesc_args, split(/(?<!\\) /, $ENV{NESCC_ARGS});
+foreach (@nesc_args) {
+ s/\\(.)/\1/g;
+}
+
if ($source eq "") {
printf STDERR "no source file specified\n";
exit 2;
}
# Deputy annotations
-if($deputy) {
+if ($deputy) {
unshift @nesc_args, "-fnesc-include=deputy_stage1";
unshift @nesc_args, "-fnesc-genprefix=#include \"$ENV{NCDIR}/deputy_stage2.h\"";
}
}
exit 0 if $nocompile || $conly;
-if($deputy) {
+if ($deputy) {
push @deputy_args, "--gcc=$gcc";
push @gcc_args, @deputy_args;
$gcc = "deputy";