blob: bf20c1f63ce1d19b68e67faec90f05a8cb0bbd7c [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`"
Rich Felker71df8b22011-03-01 12:04:36 -050014libgcc=${libgcc%libgcc.a}
Rich Felker0b44a032011-02-12 00:22:29 -050015
16gcc -wrapper sh,-c,'
17x= ; 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
26done
27exec "$0" "$@"
28' -std=gnu99 -nostdinc -nostdlib \
29 -isystem "$libc_inc" -isystem "$gcc_inc" \
Rich Felker71df8b22011-03-01 12:04:36 -050030 -Wl,-xxxxxx "$@" -L"$libc_lib" -lc -L"$libgcc" -lgcc -Lxxxxxx -Wl,-nostdlib
Rich Felker0b44a032011-02-12 00:22:29 -050031EOF