OSDN Git Service

ChangeLog/libgcc
[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    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 2, 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 COPYING.  If not, write to
20 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.  */
22
23 #define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
24
25 #define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
26
27 #undef CPP_SPEC
28 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
29   %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
30   %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}}\
31   %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix }\
32   %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
33   %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
34 "
35
36 #undef STARTFILE_SPEC
37 #define STARTFILE_SPEC "\
38   %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
39   %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
40   %{pg:gcrt0%O%s}}}\
41   crtbegin.o%s"
42
43 #undef ENDFILE_SPEC
44 #define ENDFILE_SPEC \
45   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}\
46    crtend.o%s"
47
48 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
49    want to allow things to be added to it when installing new versions of
50    GCC without making a new CYGWIN.DLL, so we leave it.  Profiling is handled
51    by calling the init function from main.  */
52
53 #undef LIBGCC_SPEC
54 #define LIBGCC_SPEC \
55   "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc       \
56    %{mno-cygwin:-lmoldname -lmingwex -lmsvcrt}"
57
58 /* We have to dynamic link to get to the system DLLs.  All of libc, libm and
59    the Unix stuff is in cygwin.dll.  The import library is called
60    'libcygwin.a'.  For Windows applications, include more libraries, but
61    always include kernel32.  We'd like to specific subsystem windows to
62    ld, but that doesn't work just yet.  */
63
64 #undef LIB_SPEC
65 #define LIB_SPEC "\
66   %{pg:-lgmon} \
67   %{!mno-cygwin:-lcygwin} \
68   %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
69   %{mwindows:-lgdi32 -lcomdlg32} \
70   -luser32 -lkernel32 -ladvapi32 -lshell32"
71
72 #define LINK_SPEC "\
73   %{mwindows:--subsystem windows} \
74   %{mconsole:--subsystem console} \
75   %{shared: %{mdll: %eshared and mdll are not compatible}} \
76   %{shared: --shared} %{mdll:--dll} \
77   %{static:-Bstatic} %{!static:-Bdynamic} \
78   %{shared|mdll: -e \
79     %{mno-cygwin:_DllMainCRTStartup@12} \
80     %{!mno-cygwin:__cygwin_dll_entry@12}}\
81   %{!mno-cygwin:--dll-search-prefix=cyg}"
82
83 /* Allocate space for all of the machine-spec-specific stuff.
84    Allocate enough space for cygwin -> mingw32  munging plus
85    possible addition of "/mingw".  */
86
87 #ifndef CYGWIN_MINGW_SUBDIR
88 #define CYGWIN_MINGW_SUBDIR "/mingw"
89 #endif
90 #define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
91
92 #ifdef GPLUSPLUS_INCLUDE_DIR
93 char cygwin_gplusplus_include_dir[sizeof (GPLUSPLUS_INCLUDE_DIR) + 1
94                                   + (CYGWIN_MINGW_SUBDIR_LEN)]
95   = GPLUSPLUS_INCLUDE_DIR;
96 #undef GPLUSPLUS_INCLUDE_DIR
97 #define GPLUSPLUS_INCLUDE_DIR ((const char *) cygwin_gplusplus_include_dir)
98 #ifndef GEN_CVT_ARRAY
99 #define GEN_CVT_ARRAY
100 #endif
101 #endif
102
103 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
104 char cygwin_gplusplus_tool_include_dir[sizeof (GPLUSPLUS_TOOL_INCLUDE_DIR) + 1
105                                        + CYGWIN_MINGW_SUBDIR_LEN]
106   = GPLUSPLUS_TOOL_INCLUDE_DIR;
107 #undef GPLUSPLUS_TOOL_INCLUDE_DIR
108 #define GPLUSPLUS_TOOL_INCLUDE_DIR ((const char *) cygwin_gplusplus_tool_include_dir)
109 #ifndef GEN_CVT_ARRAY
110 #define GEN_CVT_ARRAY
111 #endif
112 #endif
113
114 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
115 char cygwin_gplusplus_backward_include_dir[sizeof (GPLUSPLUS_BACKWARD_INCLUDE_DIR)  + 1
116                                            + CYGWIN_MINGW_SUBDIR_LEN]
117   = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
118 #undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
119 #define GPLUSPLUS_BACKWARD_INCLUDE_DIR ((const char *) cygwin_gplusplus_backward_include_dir)
120 #ifndef GEN_CVT_ARRAY
121 #define GEN_CVT_ARRAY
122 #endif
123 #endif
124
125 #ifdef LOCAL_INCLUDE_DIR
126 char cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR)  + 1
127                               + CYGWIN_MINGW_SUBDIR_LEN]
128   = LOCAL_INCLUDE_DIR;
129 #undef LOCAL_INCLUDE_DIR
130 #define LOCAL_INCLUDE_DIR ((const char *) cygwin_local_include_dir)
131 #ifndef GEN_CVT_ARRAY
132 #define GEN_CVT_ARRAY
133 #endif
134 #endif
135
136 #ifdef CROSS_INCLUDE_DIR
137 char cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
138                               + CYGWIN_MINGW_SUBDIR_LEN]
139   = CROSS_INCLUDE_DIR;
140 #undef CROSS_INCLUDE_DIR
141 #define CROSS_INCLUDE_DIR ((const char *) cygwin_cross_include_dir)
142 #ifndef GEN_CVT_ARRAY
143 #define GEN_CVT_ARRAY
144 #endif
145 #endif
146
147 #ifdef TOOL_INCLUDE_DIR
148 char cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
149                              + CYGWIN_MINGW_SUBDIR_LEN]
150   = TOOL_INCLUDE_DIR;
151 #undef TOOL_INCLUDE_DIR
152 #define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
153
154 #ifndef CROSS_DIRECTORY_STRUCTURE
155 #undef STANDARD_INCLUDE_DIR
156 #define STANDARD_INCLUDE_DIR "/usr/include"
157 char cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
158                                  + CYGWIN_MINGW_SUBDIR_LEN]
159   = STANDARD_INCLUDE_DIR;
160 #undef STANDARD_INCLUDE_DIR
161 #define STANDARD_INCLUDE_DIR ((const char *) cygwin_standard_include_dir)
162 #endif
163
164 #ifndef GEN_CVT_ARRAY
165 #define GEN_CVT_ARRAY
166 #endif
167 #endif
168
169 #ifndef GEN_CVT_ARRAY
170 extern char *cvt_to_mingw[];
171 #else
172 char *cvt_to_mingw[] =
173   {
174 #ifdef GPLUSPLUS_INCLUDE_DIR
175     cygwin_gplusplus_include_dir,
176 #endif
177
178 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
179     cygwin_gplusplus_tool_include_dir,
180 #endif
181
182 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
183     cygwin_gplusplus_backward_include_dir,
184 #endif
185
186 #ifdef LOCAL_INCLUDE_DIR
187     cygwin_local_include_dir,
188 #endif
189
190 #ifdef CROSS_INCLUDE_DIR
191     cygwin_cross_include_dir,
192 #endif
193
194 #ifdef TOOL_INCLUDE_DIR
195     cygwin_tool_include_dir,
196 #endif
197
198 #ifdef STANDARD_INCLUDE_DIR
199     cygwin_standard_include_dir,
200 #endif
201
202     NULL
203   };
204 #undef GEN_CVT_ARRAY
205 #endif /*GEN_CVT_ARRAY*/
206
207 void mingw_scan (int, const char * const *, char **);
208 #if 1
209 #define GCC_DRIVER_HOST_INITIALIZATION \
210 do \
211 { \
212   mingw_scan(argc, (const char * const *) argv, (char **) &spec_machine); \
213   } \
214 while (0)
215 #else
216 #define GCC_DRIVER_HOST_INITIALIZATION \
217 do \
218 { \
219   char *cprefix = concat (tooldir_base_prefix, spec_machine, \
220                           dir_separator_str, NULL); \
221   if (!IS_ABSOLUTE_PATH (cprefix)) \
222     cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
223                       spec_version, dir_separator_str, tooldir_prefix, NULL); \
224   add_prefix (&exec_prefixes,\
225               concat (cprefix, "../../../../", spec_machine, "/bin/", NULL), \
226               "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
227   add_prefix (&exec_prefixes, cprefix, \
228               "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
229   add_prefix (&startfile_prefixes,\
230               concat (standard_startfile_prefix, "w32api", NULL),\
231               "GCC", PREFIX_PRIORITY_LAST, 0, NULL);\
232   mingw_scan(argc, (const char * const *) argv, &spec_machine); \
233   } \
234 while (0)
235 #endif
236
237 /* Binutils does not handle weak symbols from dlls correctly.  For now,
238    do not use them unnecessarily in gthr-posix.h.  */
239 #define GTHREAD_USE_WEAK 0
240
241 /* Every program on cygwin links against cygwin1.dll which contains 
242    the pthread routines.  There is no need to explicitly link them
243    and the -pthread flag is not recognized.  */
244 #undef GOMP_SELF_SPECS
245 #define GOMP_SELF_SPECS ""