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