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