Home
       gcc-scc.sh - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       gcc-scc.sh (1096B)
       ---
            1 #!/bin/sh
            2 
            3 set -e
            4 
            5 for i
            6 do
            7         case "$i" in
            8         -r)
            9                 root=$2
           10                 shift 2
           11                 ;;
           12         -a)
           13                 abi=$2
           14                 shift 2
           15                 ;;
           16         -s)
           17                 sys=$2
           18                 shift 2
           19                 ;;
           20         -o)
           21                 out=$2
           22                 shift 2
           23                 ;;
           24         -c)
           25                 onlycc=1;
           26                 shift
           27                 ;;
           28         -*)
           29                 echo usage: gcc-scc [-o outfile][-c][-r root][-a abi][-s sys] file
           30                 exit 1
           31                 ;;
           32         esac
           33 done
           34 
           35 sys=${sys:-`uname | tr 'A-Z' 'a-z'`}
           36 abi=${abi:-amd64}
           37 out=${out:-a.out}
           38 root=${root:-${SCCPREFIX:-`dirname $0`/..}}
           39 inc=$root/include
           40 arch_inc=$inc/bits/$abi
           41 sys_inc=$inc/bits/$sys
           42 sys_arch_inc=$inc/bits/$sys/$abi
           43 lib=$root/lib/scc/${abi}-${sys}
           44 crt=$root/lib/scc/${abi}-${sys}/crt.o
           45 obj=${1%.c}.o
           46 cc=${CROSS_COMPILE}cc
           47 ld=${CROSS_COMPILE}ld
           48 
           49 case `uname` in
           50 OpenBSD)
           51         nopie=-no-pie
           52         ;;
           53 esac
           54 
           55 includes="-nostdinc -I$inc -I$arch_inc -I$sys_inc -I$sys_arch_inc"
           56 cflags="-std=c99 -g -w -fno-pie -fno-stack-protector -ffreestanding -static"
           57 ldflags="-g -z nodefaultlib -static -L$lib"
           58 
           59 if test ${onlycc:-0} -eq 1
           60 then
           61         $cc $cflags $includes -c $@
           62 else
           63         for i
           64         do
           65                 case $i in
           66                 *.c)
           67                         $cc $cflags $includes -c $i
           68                         ;;
           69                 esac
           70         done
           71         $ld $ldflags $nopie `echo $@ | sed 's/\.c$/.o/g'` $crt -lc -lcrt -o $out
           72 fi