depends on settimeofday which needs _GNU_SOURCE feature test
[musl] / tools / gen-musl-gcc.sh
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`"
14
15 gcc -wrapper sh,-c,'
16 x= ; 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
25 done
26 exec "$0" "$@"
27 ' -std=gnu99 -nostdinc -nostdlib \
28   -isystem "$libc_inc" -isystem "$gcc_inc" \
29   -Wl,-xxxxxx "$@" -L"$libc_lib" -lc "$libgcc" -Lxxxxxx -Wl,-nostdlib
30 EOF