summary refs log tree commit diff
path: root/pkgs-ng/stdenv/generic/gcc-wrapper.sh
blob: f68612d2c1e779c7de2a4683aa94ccfb1270b569 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/sh

IFS=

justcompile=0
for i in $@; do
    if test "$i" == "-c"; then
        justcompile=1
    elif test "$i" == "-S"; then
        justcompile=1
    elif test "$i" == "-E"; then
        justcompile=1
    elif test "$i" == "-E"; then
        justcompile=1
    elif test "$i" == "-M"; then
        justcompile=1
    elif test "$i" == "-MM"; then
        justcompile=1
    fi
done

IFS=" "
extra=($NIX_CFLAGS_COMPILE)
if test "$justcompile" != "1"; then
    extra=(${extra[@]} $NIX_CFLAGS_LINK)
    for i in $NIX_LDFLAGS; do
        extra=(${extra[@]} "-Wl,$i")
    done
    if test "$NIX_STRIP_DEBUG" == "1"; then
        extra=(${extra[@]} -g0 -Wl,-s)
    fi
fi

if test "$NIX_DEBUG" == "1"; then
  echo "extra flags to @GCC@:" >&2
  for i in ${extra[@]}; do
      echo "  $i" >&2
  done
fi

IFS=
exec @GCC@ $@ ${extra[@]}