OSDN Git Service

Update Copyright years for files modified in 2008 and/or 2009.
[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 #define LINK_SPEC "\
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} \
94   %{shared|mdll: -e \
95     %{mno-cygwin:_DllMainCRTStartup@12} \
96     %{!mno-cygwin:__cygwin_dll_entry@12}}\
97   %{!mno-cygwin:--dll-search-prefix=cyg}"
98
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".  */
102
103 #ifndef CYGWIN_MINGW_SUBDIR
104 #define CYGWIN_MINGW_SUBDIR "/mingw"
105 #endif
106 #define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
107
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
116 #endif
117 #endif
118
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
127 #endif
128 #endif
129
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
138 #endif
139 #endif
140
141 #ifdef LOCAL_INCLUDE_DIR
142 char cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR)  + 1
143                               + CYGWIN_MINGW_SUBDIR_LEN]
144   = LOCAL_INCLUDE_DIR;
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
149 #endif
150 #endif
151
152 #ifdef CROSS_INCLUDE_DIR
153 char cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
154                               + CYGWIN_MINGW_SUBDIR_LEN]
155   = CROSS_INCLUDE_DIR;
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
160 #endif
161 #endif
162
163 #ifdef TOOL_INCLUDE_DIR
164 char cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
165                              + CYGWIN_MINGW_SUBDIR_LEN]
166   = TOOL_INCLUDE_DIR;
167 #undef TOOL_INCLUDE_DIR
168 #define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
169
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)
178 #endif
179
180 #ifndef GEN_CVT_ARRAY
181 #define GEN_CVT_ARRAY
182 #endif
183 #endif
184
185 #ifndef GEN_CVT_ARRAY
186 extern char *cvt_to_mingw[];
187 #else
188 char *cvt_to_mingw[] =
189   {
190 #ifdef GPLUSPLUS_INCLUDE_DIR
191     cygwin_gplusplus_include_dir,
192 #endif
193
194 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
195     cygwin_gplusplus_tool_include_dir,
196 #endif
197
198 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
199     cygwin_gplusplus_backward_include_dir,
200 #endif
201
202 #ifdef LOCAL_INCLUDE_DIR
203     cygwin_local_include_dir,
204 #endif
205
206 #ifdef CROSS_INCLUDE_DIR
207     cygwin_cross_include_dir,
208 #endif
209
210 #ifdef TOOL_INCLUDE_DIR
211     cygwin_tool_include_dir,
212 #endif
213
214 #ifdef STANDARD_INCLUDE_DIR
215     cygwin_standard_include_dir,
216 #endif
217
218     NULL
219   };
220 #undef GEN_CVT_ARRAY
221 #endif /*GEN_CVT_ARRAY*/
222
223 void mingw_scan (int, const char * const *, const char **);
224 #if 1
225 #define GCC_DRIVER_HOST_INITIALIZATION \
226 do \
227 { \
228   mingw_scan(argc, (const char * const *) argv, &spec_machine); \
229   } \
230 while (0)
231 #else
232 #define GCC_DRIVER_HOST_INITIALIZATION \
233 do \
234 { \
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); \
249   } \
250 while (0)
251 #endif
252
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
256
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 ""
262
263 /* This matches SHLIB_SONAME and SHLIB_SOVERSION in t-cygwin. */
264 #if DWARF2_UNWIND_INFO
265 #define LIBGCC_EH_EXTN ""
266 #else
267 #define LIBGCC_EH_EXTN "-sjlj"
268 #endif
269 #define LIBGCC_SONAME "cyggcc_s" LIBGCC_EH_EXTN "-1.dll"