Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | printf '#!/bin/sh\n\nlibc_prefix="%s"\n' "$1" |
| 4 | |
| 5 | cat <<"EOF" |
| 6 | libc_lib=$libc_prefix/lib |
| 7 | libc_inc=$libc_prefix/include |
| 8 | libc_crt="$libc_lib/crt1.o" |
| 9 | libc_start="$libc_lib/crti.o" |
| 10 | libc_end="$libc_lib/crtn.o" |
| 11 | |
| 12 | gcc_inc=$libc_inc |
| 13 | libgcc="`gcc \"$@\" -print-file-name=libgcc.a`" |
Rich Felker | 71df8b2 | 2011-03-01 12:04:36 -0500 | [diff] [blame] | 14 | libgcc=${libgcc%libgcc.a} |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 15 | |
| 16 | gcc -wrapper sh,-c,' |
| 17 | x= ; y= ; z= ; s= ; for i ; do |
| 18 | [ "$z" ] || set -- ; z=1 |
| 19 | case "$i" in |
| 20 | -shared) s=1 ; set -- "$@" -shared ;; |
| 21 | -Lxxxxxx) x=1 ;; |
| 22 | -xxxxxx) x= ; [ "$s" ] || set -- "$@" "'"$libc_start"'" "'"$libc_crt"'" ;; |
| 23 | -l*) [ "$y" ] || set -- "$@" '"$libc_end"' ; set -- "$@" "$i" ; y=1 ;; |
| 24 | *) [ "$x" ] || set -- "$@" "$i" ;; |
| 25 | esac |
| 26 | done |
| 27 | exec "$0" "$@" |
| 28 | ' -std=gnu99 -nostdinc -nostdlib \ |
| 29 | -isystem "$libc_inc" -isystem "$gcc_inc" \ |
Rich Felker | 71df8b2 | 2011-03-01 12:04:36 -0500 | [diff] [blame] | 30 | -Wl,-xxxxxx "$@" -L"$libc_lib" -lc -L"$libgcc" -lgcc -Lxxxxxx -Wl,-nostdlib |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 31 | EOF |