Annotation of uae/src/od-amiga/scc, revision 1.1.1.2

1.1       root        1: #!/bin/perl
                      2: #
                      3: # This is a small perl script that emulates gcc with the
                      4: # SAS/C compiler. It is mainly created to compile UAE
1.1.1.2 ! root        5: # with SAS/C to test 68060 optimisations. This scripts also
        !             6: # manages so that links are properly handled by SAS/C.
1.1       root        7: #
                      8: # (c) 1997 by Samuel Devulder.
                      9: #
                     10: 
                     11: # dir used so that links are properly handled by SAS/C
                     12: $LNDIR = "scc-idir";
                     13: 
                     14: # replace all filenames that actually are links
                     15: for($i=0;$i<=$#ARGV;++$i) {
                     16:     $_ = $ARGV[$i];
1.1.1.2 ! root       17:     $_=readlink($_) if -l $_;
1.1       root       18:     if(/\/[^\/]+$/ && -l $`) {
                     19:         $_=readlink($`).$&;
1.1.1.2 ! root       20:        s/.*\/src\///;
        !            21:        s/^\/([^\/]+)\//$1:/;
1.1       root       22:     }
                     23:     $ARGV[$i] = $_;
                     24: }
                     25: 
                     26: # create link-dir so that SAS/C can handle header files stored
                     27: # in linked directories.
                     28: if(! -d $LNDIR) {
                     29:      mkdir($LNDIR,0777);
                     30:      while(<*>) {
                     31:          next if ! -l $_;
                     32:          $linkname = $_;
1.1.1.2 ! root       33:          $realname = readlink($_);
        !            34:         $realname =~ s/^\/([^\/]+)\//$1:/; $realname =~ s/[.][.]//g;
1.1       root       35:          if(-d $linkname) {
                     36:              mkdir("$LNDIR/$linkname",0777);
                     37:              while(<$linkname/*.h>) {
                     38:                 open(OUT,">$LNDIR/$_");
                     39:                 s/^.*\///;
                     40:                 print OUT "#include \"$realname/$_\"\n";
                     41:                 close OUT;
                     42:              }
                     43:          } else {
                     44:             open(OUT,">$LNDIR/$linkname");
                     45:             print OUT "#include \"$realname\"\n";
                     46:             close OUT;
                     47:          }
                     48:      }
                     49: }
                     50: 
                     51: # build general command-line
                     52: $_ = " @ARGV";
                     53: 
                     54: # if preprocess, then use gnu/cpp since pponly in SAS/C
                     55: # does not signal missing .h files.
                     56: if(/\s+-E/) {
                     57:          exit system("cpp -DAMIGA -nostdinc -I\/include -D__SASC$_");
                     58: }
                     59: 
                     60: # fast but not perfect unix-to-amiga path translation 
                     61: s/[.][.]//g;
                     62: s/[.][\/]//g;
                     63: 
                     64: # if no destination, then assume a.out
                     65: $_ .= " -o a.out" if !/\s-[cEo]/;
                     66: 
                     67: # command-line modification
                     68: s/\s+-I\s*/ IDIR=/g;                # process include dirs
                     69: s/\s+-o/ OBJNAME/g;                 # process output file
                     70: s/\s+-g/ DBG FF/g;                  # process debug 
                     71: s/\s+-lm/ MATH=STD/g;               # math library
                     72: s/\s+-l\s*(\w+)/ LIB=LIB:$1.lib/g;  # other librarys
                     73: s/\s+-D\s*/ DEF=/g;                 # preprocessor defines
                     74: s/\s+-traditional-cpp//g;           # 
                     75: s/\s+-m(\w+)/ CPU=$1/g;          # specific cpu code generation
1.1.1.2 ! root       76: s/\s+-O(\d?)/ OPT OPTSCHED OPTTIME/g;   # optimize ?
1.1       root       77: 
                     78: # use NOLINK (-c was found) or LINK TO ?
                     79: !s/\s+-E/ PPONLY/g && !s/\s+-c/ NOLINK/g && s/OBJNAME/LINK TO/;
                     80: 
                     81: # build amigaos command-line with extra defs
1.1.1.2 ! root       82: $_ = "sc IDIR=$LNDIR$_ DEF=__GNU_LIBRARY__ DEF=AMIGA DEF=_OFF_T DEF=off_t=long DATA=FAR CODE=FAR PARAM=B NOSTKCHK NOICON NOVERBOSE IGN=64,84,85,93,100,181,306,315,316 BATCH";
        !            83: #$_ = "sc IDIR=$LNDIR$_ DEF=AMIGA DEF=_OFF_T DEF=off_t=long DATA=FAR CODE=FAR PARAM=B NOSTKCHK NOICON NOVERBOSE IGN=64,84,85,93,100,181,306,315,316 BATCH";
1.1       root       84: 
                     85: # if -d is present, display the executed command-line
                     86: s/\s+-d//g && print STDERR "=> $_\n";
                     87: 
                     88: # call SAS/C
                     89: $res = system("$_")/256;
                     90: 
                     91: # Link failed, say something so that configure script can
                     92: # see it.
                     93: if($res == 3) {print STDERR "link failed\n";$res=21;}
                     94: 
                     95: exit $res;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.