OSDN Git Service

gcc/ChangeLog:
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygwin.h
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, 2008, 2009 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
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)
11 any later version.
12
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.
17
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/>.  */
21
22 #define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
23
24 #define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
25
26 #undef CPP_SPEC
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}}\
33 "
34
35 #undef STARTFILE_SPEC
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}\
39   %{pg:gcrt0%O%s}}}\
40   crtbegin.o%s"
41
42 #undef ENDFILE_SPEC
43 #define ENDFILE_SPEC \
44   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\
45    crtend.o%s"
46
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.  */
51
52 #ifdef ENABLE_SHARED_LIBGCC
53 #define SHARED_LIBGCC_SPEC " \
54  %{static|static-libgcc:-lgcc -lgcc_eh} \
55  %{!static: \
56    %{!static-libgcc: \
57      %{!shared: \
58        %{!shared-libgcc:-lgcc -lgcc_eh} \
59        %{shared-libgcc:-lgcc_s -lgcc} \
60       } \
61      %{shared:-lgcc_s -lgcc} \
62     } \
63   } "
64 #else
65 #define SHARED_LIBGCC_SPEC " -lgcc "
66 #endif
67
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}"
73
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.  */
79
80 #undef LIB_SPEC
81 #define LIB_SPEC "\
82   %{pg:-lgmon} \
83   %{!mno-cygwin:-lcygwin} \
84   %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
85   %{mwindows:-lgdi32 -lcomdlg32} \
86   -luser32 -lkernel32 -ladvapi32 -lshell32"
87
88 /* To implement C++ function replacement we always wrap the cxx
89    malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
90 #define CXX_WRAP_SPEC_LIST "%{!static: %{!static-libstdc++: \
91   --wrap _Znwj \
92   --wrap _Znaj \
93   --wrap _ZdlPv \
94   --wrap _ZdaPv \
95   --wrap _ZnwjRKSt9nothrow_t \
96   --wrap _ZnajRKSt9nothrow_t \
97   --wrap _ZdlPvRKSt9nothrow_t \
98   --wrap _ZdaPvRKSt9nothrow_t \
99   }}"
100
101 #if defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)
102
103 #if USE_CYGWIN_LIBSTDCXX_WRAPPERS
104 /* Default on, only explict -mno disables.  */
105 #define CXX_WRAP_SPEC_OPT "!mno-use-libstdc-wrappers"
106 #else
107 /* Default off, only explict -m enables.  */
108 #define CXX_WRAP_SPEC_OPT "muse-libstdc-wrappers"
109 #endif
110
111 #define CXX_WRAP_SPEC "%{" CXX_WRAP_SPEC_OPT ":" CXX_WRAP_SPEC_LIST "}"
112
113 #else /* !defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)  */
114
115 #define CXX_WRAP_SPEC ""
116
117 #endif /* ?defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
118
119 #define LINK_SPEC "\
120   %{mwindows:--subsystem windows} \
121   %{mconsole:--subsystem console} \
122   " CXX_WRAP_SPEC " \
123   %{shared: %{mdll: %eshared and mdll are not compatible}} \
124   %{shared: --shared} %{mdll:--dll} \
125   %{static:-Bstatic} %{!static:-Bdynamic} \
126   %{shared|mdll: --enable-auto-image-base -e \
127     %{mno-cygwin:_DllMainCRTStartup@12} \
128     %{!mno-cygwin:__cygwin_dll_entry@12}}\
129   %{!mno-cygwin:--dll-search-prefix=cyg -tsaware}"
130
131 /* Allocate space for all of the machine-spec-specific stuff.
132    Allocate enough space for cygwin -> mingw32  munging plus
133    possible addition of "/mingw".  */
134
135 #ifndef CYGWIN_MINGW_SUBDIR
136 #define CYGWIN_MINGW_SUBDIR "/mingw"
137 #endif
138 #define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
139
140 #ifdef GPLUSPLUS_INCLUDE_DIR
141 char cygwin_gplusplus_include_dir[sizeof (GPLUSPLUS_INCLUDE_DIR) + 1
142                                   + (CYGWIN_MINGW_SUBDIR_LEN)]
143   = GPLUSPLUS_INCLUDE_DIR;
144 #undef GPLUSPLUS_INCLUDE_DIR
145 #define GPLUSPLUS_INCLUDE_DIR ((const char *) cygwin_gplusplus_include_dir)
146 #ifndef GEN_CVT_ARRAY
147 #define GEN_CVT_ARRAY
148 #endif
149 #endif
150
151 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
152 char cygwin_gplusplus_tool_include_dir[sizeof (GPLUSPLUS_TOOL_INCLUDE_DIR) + 1
153                                        + CYGWIN_MINGW_SUBDIR_LEN]
154   = GPLUSPLUS_TOOL_INCLUDE_DIR;
155 #undef GPLUSPLUS_TOOL_INCLUDE_DIR
156 #define GPLUSPLUS_TOOL_INCLUDE_DIR ((const char *) cygwin_gplusplus_tool_include_dir)
157 #ifndef GEN_CVT_ARRAY
158 #define GEN_CVT_ARRAY
159 #endif
160 #endif
161
162 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
163 char cygwin_gplusplus_backward_include_dir[sizeof (GPLUSPLUS_BACKWARD_INCLUDE_DIR)  + 1
164                                            + CYGWIN_MINGW_SUBDIR_LEN]
165   = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
166 #undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
167 #define GPLUSPLUS_BACKWARD_INCLUDE_DIR ((const char *) cygwin_gplusplus_backward_include_dir)
168 #ifndef GEN_CVT_ARRAY
169 #define GEN_CVT_ARRAY
170 #endif
171 #endif
172
173 #ifdef LOCAL_INCLUDE_DIR
174 char cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR)  + 1
175                               + CYGWIN_MINGW_SUBDIR_LEN]
176   = LOCAL_INCLUDE_DIR;
177 #undef LOCAL_INCLUDE_DIR
178 #define LOCAL_INCLUDE_DIR ((const char *) cygwin_local_include_dir)
179 #ifndef GEN_CVT_ARRAY
180 #define GEN_CVT_ARRAY
181 #endif
182 #endif
183
184 #ifdef CROSS_INCLUDE_DIR
185 char cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
186                               + CYGWIN_MINGW_SUBDIR_LEN]
187   = CROSS_INCLUDE_DIR;
188 #undef CROSS_INCLUDE_DIR
189 #define CROSS_INCLUDE_DIR ((const char *) cygwin_cross_include_dir)
190 #ifndef GEN_CVT_ARRAY
191 #define GEN_CVT_ARRAY
192 #endif
193 #endif
194
195 #ifdef TOOL_INCLUDE_DIR
196 char cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
197                              + CYGWIN_MINGW_SUBDIR_LEN]
198   = TOOL_INCLUDE_DIR;
199 #undef TOOL_INCLUDE_DIR
200 #define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
201
202 #ifndef CROSS_DIRECTORY_STRUCTURE
203 #undef STANDARD_INCLUDE_DIR
204 #define STANDARD_INCLUDE_DIR "/usr/include"
205 char cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
206                                  + CYGWIN_MINGW_SUBDIR_LEN]
207   = STANDARD_INCLUDE_DIR;
208 #undef STANDARD_INCLUDE_DIR
209 #define STANDARD_INCLUDE_DIR ((const char *) cygwin_standard_include_dir)
210 #endif
211
212 #ifndef GEN_CVT_ARRAY
213 #define GEN_CVT_ARRAY
214 #endif
215 #endif
216
217 #ifndef GEN_CVT_ARRAY
218 extern char *cvt_to_mingw[];
219 #else
220 char *cvt_to_mingw[] =
221   {
222 #ifdef GPLUSPLUS_INCLUDE_DIR
223     cygwin_gplusplus_include_dir,
224 #endif
225
226 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
227     cygwin_gplusplus_tool_include_dir,
228 #endif
229
230 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
231     cygwin_gplusplus_backward_include_dir,
232 #endif
233
234 #ifdef LOCAL_INCLUDE_DIR
235     cygwin_local_include_dir,
236 #endif
237
238 #ifdef CROSS_INCLUDE_DIR
239     cygwin_cross_include_dir,
240 #endif
241
242 #ifdef TOOL_INCLUDE_DIR
243     cygwin_tool_include_dir,
244 #endif
245
246 #ifdef STANDARD_INCLUDE_DIR
247     cygwin_standard_include_dir,
248 #endif
249
250     NULL
251   };
252 #undef GEN_CVT_ARRAY
253 #endif /*GEN_CVT_ARRAY*/
254
255 void mingw_scan (int, const char * const *, const char **);
256 #if 1
257 #define GCC_DRIVER_HOST_INITIALIZATION \
258 do \
259 { \
260   mingw_scan(argc, (const char * const *) argv, &spec_machine); \
261   } \
262 while (0)
263 #else
264 #define GCC_DRIVER_HOST_INITIALIZATION \
265 do \
266 { \
267   char *cprefix = concat (tooldir_base_prefix, spec_machine, \
268                           dir_separator_str, NULL); \
269   if (!IS_ABSOLUTE_PATH (cprefix)) \
270     cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
271                       spec_version, dir_separator_str, tooldir_prefix, NULL); \
272   add_prefix (&exec_prefixes,\
273               concat (cprefix, "../../../../", spec_machine, "/bin/", NULL), \
274               "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
275   add_prefix (&exec_prefixes, cprefix, \
276               "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
277   add_prefix (&startfile_prefixes,\
278               concat (standard_startfile_prefix, "w32api", NULL),\
279               "GCC", PREFIX_PRIORITY_LAST, 0, NULL);\
280   mingw_scan(argc, (const char * const *) argv, &spec_machine); \
281   } \
282 while (0)
283 #endif
284
285 /* Binutils does not handle weak symbols from dlls correctly.  For now,
286    do not use them unnecessarily in gthr-posix.h.  */
287 #define GTHREAD_USE_WEAK 0
288
289 /* Every program on cygwin links against cygwin1.dll which contains 
290    the pthread routines.  There is no need to explicitly link them
291    and the -pthread flag is not recognized.  */
292 #undef GOMP_SELF_SPECS
293 #define GOMP_SELF_SPECS ""
294
295 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
296 #if DWARF2_UNWIND_INFO
297 #define LIBGCC_EH_EXTN ""
298 #else
299 #define LIBGCC_EH_EXTN "-sjlj"
300 #endif
301 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"
302
303 /* We should find a way to not have to update this manually.  */
304 #define LIBGCJ_SONAME "cyggcj" /*LIBGCC_EH_EXTN*/ "-11.dll"
305