~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Minix Cross Reference
Minix/Solaris/mcc


  1 #!/bin/sh
  2 # $Id: mcc,v 1.6 1998/06/29 02:23:02 paul Exp $
  3 
  4 # This script is used in compiling all smx .c and .s files to .o files, and 
  5 # in linking all user programs except init.  The four programs that are
  6 # combined to form image have custom ld command lines in their make files.
  7 # The script tries to provide standard cc options, but the emulation
  8 # is not 100% accurate.  Some options are special to mcc:
  9 #
 10 #     -N - if linking occurs, do not delete the SunOS executable
 11 #     -v - echo all compile and link commands rather than executing them
 12 #     -S - specifies the size of the space to left at smx run-time for the
 13 #          heap and stack.
 14 
 15 # 1997/01/21 Coverted to sh (PJA)
 16 
 17 #       -fnocommon is included as without the elf files produced contain
 18 #       sections that smx2elf can't handle.
 19 stdgccopts="-nostdinc -funsigned-char -fno-common -O2"
 20 
 21 #       Elf executables are statically linked.  The standard library list
 22 #       (specified by -Y) is $MX_LIB.
 23 stdldopts="-dn -e _crtso -M $MX_LIB/smx_userprog.map -Y P,$MX_LIB"
 24 
 25 #       The various EM defines are needed because the ack compiler
 26 #       (which is assumed) defines them
 27 stdcompileopts="-I$MX_INCL -D_EM_WSIZE=4 -D_EM_PSIZE=4 -D_EM_LSIZE=4"
 28 compileopts=
 29 
 30 ofile=a.out       # -o overrides this
 31 nolink=0
 32 delete=1
 33 minusc=0
 34 compiledobjs=
 35 srcfiles=
 36 libs=
 37 stksize=4kw      # 16Kb is the default.
 38 
 39 runcmd=
 40 
 41 # Process everything on the command line, setting the variables listed
 42 # above as needed.
 43 while [ $# != 0 ]
 44 do
 45     case $1 in
 46         "-N")
 47             delete=0
 48             ;;
 49         "-o")
 50             ofile=$2
 51             shift
 52             ;;
 53         "-v")
 54             runcmd="echo"
 55             ;;
 56         "-c")
 57             nolink=1
 58             minusc=1
 59             ;;
 60         -l*)
 61             libs="$libs $1"
 62             ;;
 63         "-S")
 64             stksize=$2
 65             shift
 66             ;;
 67         "-E")
 68             nolink=1      # Don't try linking with -E
 69             compileopts="$compileopts -E"
 70             ;;
 71         -*)
 72             compileopts="$compileopts $1"
 73             ;;
 74         *)
 75             srcfiles="$srcfiles $1"
 76             ;;
 77     esac
 78     shift
 79 done
 80 
 81 # Process all source files.  Compile .c and .s files.  All other files
 82 # are justed passed through to ld.
 83 
 84 if [ $minusc = 1 -a $ofile != "a.out" ]
 85     then
 86         compileopts="-o $ofile $compileopts"
 87 fi
 88 objfiles=
 89 for f in $srcfiles
 90 do
 91     if [ `basename $f .c` != `basename $f` ]
 92         then          # a .c file
 93             echo $f":"
 94             objfile=`basename $f .c`.o
 95             $runcmd rm -f $objfile
 96             $runcmd gcc $stdgccopts $compileopts $stdcompileopts -c $f
 97             objfiles="$objfiles $objfile"
 98             compiledobjs="$objfiles $objfile"
 99 
100         elif [ `basename $f .s` != `basename $f` ] 
101             then      # a .s file
102                 echo $f":"
103                 objfile=`basename $f .s`.o
104                 $runcmd rm -f $objfile
105                 $runcmd as -P $compileopts $stdcompileopts $f
106                 objfiles="$objfiles $objfile"
107                 compiledobjs="$objfiles $objfile"
108 
109         else
110             objfiles="$objfiles $f"
111     fi
112 done
113 
114 if [ $nolink = 1 ]
115     then
116         exit 0;
117 fi
118 
119 if [ "$objfiles" != "" ]
120     then
121 # Linking involves using ld to create an elf executable, then elf2smx
122 # to create the smx executable.
123         echo "Linking:" 
124         $runcmd rm -f $ofile
125         $runcmd ld $stdldopts \-o $ofile.elf $MX_LIB/crtso.o $objfiles $libs $MX_LIB/libc.a
126         $runcmd elf2smx -S $stksize $ofile.elf $ofile
127         if [ $delete = 1 ]
128             then
129                 $runcmd rm $ofile.elf
130         fi
131 fi
132 
133 if [ $minusc = 0 -a "$compiledobjs" != "" ]
134     then
135         $runcmd rm -f $compiledobjs
136 fi

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.