1 /* Operating system specific defines to be used when targeting GCC for
2 hosting on Windows32, using a Unix style C library and tools.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 2007 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
24 #define EXTRA_OS_CPP_BUILTINS() /* Nothing. */
27 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
28 %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
29 %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}}\
30 %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix }\
31 %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
32 %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
36 #define STARTFILE_SPEC "\
37 %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
38 %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
43 #define ENDFILE_SPEC \
44 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\
47 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
48 want to allow things to be added to it when installing new versions of
49 GCC without making a new CYGWIN.DLL, so we leave it. Profiling is handled
50 by calling the init function from main. */
52 #ifdef ENABLE_SHARED_LIBGCC
53 #define SHARED_LIBGCC_SPEC " \
54 %{static|static-libgcc:-lgcc -lgcc_eh} \
58 %{!shared-libgcc:-lgcc -lgcc_eh} \
59 %{shared-libgcc:-lgcc_s -lgcc} \
61 %{shared:-lgcc_s -lgcc} \
65 #define SHARED_LIBGCC_SPEC " -lgcc "
68 #undef REAL_LIBGCC_SPEC
69 #define REAL_LIBGCC_SPEC \
70 "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} \
71 " SHARED_LIBGCC_SPEC " \
72 %{mno-cygwin:-lmoldname -lmingwex -lmsvcrt}"
74 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
75 the Unix stuff is in cygwin.dll. The import library is called
76 'libcygwin.a'. For Windows applications, include more libraries, but
77 always include kernel32. We'd like to specific subsystem windows to
78 ld, but that doesn't work just yet. */
83 %{!mno-cygwin:-lcygwin} \
84 %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
85 %{mwindows:-lgdi32 -lcomdlg32} \
86 -luser32 -lkernel32 -ladvapi32 -lshell32"
89 %{mwindows:--subsystem windows} \
90 %{mconsole:--subsystem console} \
91 %{shared: %{mdll: %eshared and mdll are not compatible}} \
92 %{shared: --shared} %{mdll:--dll} \
93 %{static:-Bstatic} %{!static:-Bdynamic} \
95 %{mno-cygwin:_DllMainCRTStartup@12} \
96 %{!mno-cygwin:__cygwin_dll_entry@12}}\
97 %{!mno-cygwin:--dll-search-prefix=cyg}"
99 /* Allocate space for all of the machine-spec-specific stuff.
100 Allocate enough space for cygwin -> mingw32 munging plus
101 possible addition of "/mingw". */
103 #ifndef CYGWIN_MINGW_SUBDIR
104 #define CYGWIN_MINGW_SUBDIR "/mingw"
106 #define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
108 #ifdef GPLUSPLUS_INCLUDE_DIR
109 char cygwin_gplusplus_include_dir[sizeof (GPLUSPLUS_INCLUDE_DIR) + 1
110 + (CYGWIN_MINGW_SUBDIR_LEN)]
111 = GPLUSPLUS_INCLUDE_DIR;
112 #undef GPLUSPLUS_INCLUDE_DIR
113 #define GPLUSPLUS_INCLUDE_DIR ((const char *) cygwin_gplusplus_include_dir)
114 #ifndef GEN_CVT_ARRAY
115 #define GEN_CVT_ARRAY
119 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
120 char cygwin_gplusplus_tool_include_dir[sizeof (GPLUSPLUS_TOOL_INCLUDE_DIR) + 1
121 + CYGWIN_MINGW_SUBDIR_LEN]
122 = GPLUSPLUS_TOOL_INCLUDE_DIR;
123 #undef GPLUSPLUS_TOOL_INCLUDE_DIR
124 #define GPLUSPLUS_TOOL_INCLUDE_DIR ((const char *) cygwin_gplusplus_tool_include_dir)
125 #ifndef GEN_CVT_ARRAY
126 #define GEN_CVT_ARRAY
130 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
131 char cygwin_gplusplus_backward_include_dir[sizeof (GPLUSPLUS_BACKWARD_INCLUDE_DIR) + 1
132 + CYGWIN_MINGW_SUBDIR_LEN]
133 = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
134 #undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
135 #define GPLUSPLUS_BACKWARD_INCLUDE_DIR ((const char *) cygwin_gplusplus_backward_include_dir)
136 #ifndef GEN_CVT_ARRAY
137 #define GEN_CVT_ARRAY
141 #ifdef LOCAL_INCLUDE_DIR
142 char cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR) + 1
143 + CYGWIN_MINGW_SUBDIR_LEN]
145 #undef LOCAL_INCLUDE_DIR
146 #define LOCAL_INCLUDE_DIR ((const char *) cygwin_local_include_dir)
147 #ifndef GEN_CVT_ARRAY
148 #define GEN_CVT_ARRAY
152 #ifdef CROSS_INCLUDE_DIR
153 char cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
154 + CYGWIN_MINGW_SUBDIR_LEN]
156 #undef CROSS_INCLUDE_DIR
157 #define CROSS_INCLUDE_DIR ((const char *) cygwin_cross_include_dir)
158 #ifndef GEN_CVT_ARRAY
159 #define GEN_CVT_ARRAY
163 #ifdef TOOL_INCLUDE_DIR
164 char cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
165 + CYGWIN_MINGW_SUBDIR_LEN]
167 #undef TOOL_INCLUDE_DIR
168 #define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
170 #ifndef CROSS_DIRECTORY_STRUCTURE
171 #undef STANDARD_INCLUDE_DIR
172 #define STANDARD_INCLUDE_DIR "/usr/include"
173 char cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
174 + CYGWIN_MINGW_SUBDIR_LEN]
175 = STANDARD_INCLUDE_DIR;
176 #undef STANDARD_INCLUDE_DIR
177 #define STANDARD_INCLUDE_DIR ((const char *) cygwin_standard_include_dir)
180 #ifndef GEN_CVT_ARRAY
181 #define GEN_CVT_ARRAY
185 #ifndef GEN_CVT_ARRAY
186 extern char *cvt_to_mingw[];
188 char *cvt_to_mingw[] =
190 #ifdef GPLUSPLUS_INCLUDE_DIR
191 cygwin_gplusplus_include_dir,
194 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
195 cygwin_gplusplus_tool_include_dir,
198 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
199 cygwin_gplusplus_backward_include_dir,
202 #ifdef LOCAL_INCLUDE_DIR
203 cygwin_local_include_dir,
206 #ifdef CROSS_INCLUDE_DIR
207 cygwin_cross_include_dir,
210 #ifdef TOOL_INCLUDE_DIR
211 cygwin_tool_include_dir,
214 #ifdef STANDARD_INCLUDE_DIR
215 cygwin_standard_include_dir,
221 #endif /*GEN_CVT_ARRAY*/
223 void mingw_scan (int, const char * const *, const char **);
225 #define GCC_DRIVER_HOST_INITIALIZATION \
228 mingw_scan(argc, (const char * const *) argv, &spec_machine); \
232 #define GCC_DRIVER_HOST_INITIALIZATION \
235 char *cprefix = concat (tooldir_base_prefix, spec_machine, \
236 dir_separator_str, NULL); \
237 if (!IS_ABSOLUTE_PATH (cprefix)) \
238 cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
239 spec_version, dir_separator_str, tooldir_prefix, NULL); \
240 add_prefix (&exec_prefixes,\
241 concat (cprefix, "../../../../", spec_machine, "/bin/", NULL), \
242 "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
243 add_prefix (&exec_prefixes, cprefix, \
244 "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
245 add_prefix (&startfile_prefixes,\
246 concat (standard_startfile_prefix, "w32api", NULL),\
247 "GCC", PREFIX_PRIORITY_LAST, 0, NULL);\
248 mingw_scan(argc, (const char * const *) argv, &spec_machine); \
253 /* Binutils does not handle weak symbols from dlls correctly. For now,
254 do not use them unnecessarily in gthr-posix.h. */
255 #define GTHREAD_USE_WEAK 0
257 /* Every program on cygwin links against cygwin1.dll which contains
258 the pthread routines. There is no need to explicitly link them
259 and the -pthread flag is not recognized. */
260 #undef GOMP_SELF_SPECS
261 #define GOMP_SELF_SPECS ""
263 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
264 #if DWARF2_UNWIND_INFO
265 #define LIBGCC_EH_EXTN ""
267 #define LIBGCC_EH_EXTN "-sjlj"
269 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"