Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mingw « utils « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e270fda9813fc70b0aa4cca5b70b1cc10bf94d8 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
# Front-end kludge to cause a Cygwin gcc to default to
# an installed version of the MinGW components.

#
# Find the path to the compiler.
#
compiler=$1; shift
dir=$(cd $(dirname $("$compiler" -print-prog-name=ld))/../..; pwd)

#
# The mingw32 directory should live somewhere close by to the
# compiler.  Search for it.
#
[ "$dir" = '/' ] && dir=''
mingw_dir=''
for d in "$dir"/*-mingw32 "$dir"/usr/*-mingw32 "$dir"/*-mingw* "$dir"/usr/*-mingw* \
         /*-mingw32 /usr/*-mingw32 /*-mingw* /usr/*-mingw*; do
    case "$d" in
	*\**)	continue ;;
	*)	if [ -d "$d"/sys-root/mingw ]; then
		    mingw_dir=$d/sys-root/mingw
		else
		    mingw_dir=$d;
		fi; break;
    esac
done

if [ -z "$mingw_dir" ]; then
    echo "$0: couldn't find i686-pc-mingw32 directory" 1>&2
    exit 1
fi

#
# Inspect each argument throwing away ones that seem to try to include the
# Cygwin environment.
#
newargs=()
sawcomp() { return 1; }
sawcfile() { return 1; }
sawofile() { return 1; }
sawshared() { return 1; }
sawnostdinc() { return 1; }
sawnostdlib() { return 1; }
eatnext() { return 1; }
pushnext() { return 1; }
for f do
    if eatnext; then
	eatnext() { return 1; }
	continue;
    fi
    if pushnext; then
	pushnext() { return 1; }
    else
	case "$f" in
	    *cygwin/include*|*newlib|-mno-cygwin) continue ;;
	    -c|-E)		sawcomp() { return 0; } ;;
	    -xc*)		sawcfile() { return 0; } ;;
	    -isystem)	eatnext() { return 0; }; continue ;;
	    -o)		pushnext() { return 0; } ;;
	    -nostdinc*)	sawnostdinc() { return 0; } ;;
	    -nostdlib)	sawnostdlib() { return 0; } ;;
	    -shared|-Wl,-shared)	sawshared() { return 0; } ;;
	    -*)		;;
	    *.cc|*.c|*.s|*.S|*.i|*.ii)	sawcfile() { return 0; } ;;
	    *.o)		sawofile() { return 0; };;
	esac
    fi
    newargs[${#newargs[*]}]="$f"
done

# Set up a new set of arguments + also search the installed mingw
# directory.
set -- -B"$mingw_dir"/lib/ "${newargs[@]}"

# Add some default options depending on whether this looks like
# an attempt to link, compile, or both.
if sawcomp || sawcfile; then
    ccdir=$(dirname $($compiler -print-libgcc-file-name))
    sawnostdinc || set -- -isystem "$ccdir"/include -I"${mingw_dir}"/include  "$@"
    set -- -D__MINGW32__ -D__MSVCRT__ -DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ -U__CYGWIN__ -Uunix -U__unix__ -U__unix -U __CYGWIN32__ "$@"
    if ! sawnostdinc; then
	case "$compiler" in
	    *++*) set -- -nostdinc++ "$@" ;;
	    *) set -- -nostdinc "$@" ;;
	esac
    fi
fi

if sawofile || ! sawcfile || ! sawcomp; then
    w32api=$($compiler -print-file-name=libc.a)
    w32api=$(cd $(dirname "$w32api")/w32api; pwd)
    set -- -Wl,-nostdlib -L"${w32api}" "$@"
    ! sawnostdlib && set -- -nostdlib "$@" -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -lmingw32 -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
    ! sawnostdlib && ! sawshared && { sawofile || sawcfile; } && set -- "$mingw_dir"/lib/crt2.o "$@"
fi

# Execute the compiler with new mingw-specific options.
exec $compiler "$@"