]> oss.titaniummirror.com Git - nesc.git/blobdiff - src/nesc-compile
Merge tag 'upstream/1.3.4'
[nesc.git] / src / nesc-compile
index cdcfe1234590c5ddb98ce0aed118e46ea4c62280..cdda7760ab1fa42ccdf3e92fa3b1ee9cd0374380 100755 (executable)
 
 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];
 
@@ -33,18 +42,15 @@ for ($i = 0; $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);
@@ -61,28 +67,14 @@ for ($i = 0; $i <= $#ARGV; $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 {
@@ -94,6 +86,12 @@ for ($i = 0; $i <= $#ARGV; $i++) {
     }
 }
 
+# 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;
@@ -121,7 +119,7 @@ if ($objtarget eq "") {
 }
 
 # Deputy annotations
-if($deputy) {
+if ($deputy) {
     unshift @nesc_args, "-fnesc-include=deputy_stage1";
     unshift @nesc_args, "-fnesc-genprefix=#include \"$ENV{NCDIR}/deputy_stage2.h\"";
 }
@@ -153,7 +151,7 @@ if ($? != 0) {
 }
 exit 0 if $nocompile || $conly;
 
-if($deputy) {
+if ($deputy) {
     push @deputy_args, "--gcc=$gcc";
     push @gcc_args, @deputy_args;
     $gcc = "deputy";