cygwin.h revision 169689
190075Sobrien/* Operating system specific defines to be used when targeting GCC for
2169689Skan   hosting on Windows32, using a Unix style C library and tools.
390075Sobrien   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
490075Sobrien   Free Software Foundation, Inc.
590075Sobrien
690075SobrienThis file is part of GCC.
790075Sobrien
890075SobrienGCC is free software; you can redistribute it and/or modify
990075Sobrienit under the terms of the GNU General Public License as published by
1090075Sobrienthe Free Software Foundation; either version 2, or (at your option)
1190075Sobrienany later version.
1290075Sobrien
1390075SobrienGCC is distributed in the hope that it will be useful,
1490075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1590075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1690075SobrienGNU General Public License for more details.
1790075Sobrien
1890075SobrienYou should have received a copy of the GNU General Public License
19169689Skanalong with GCC; see the file COPYING.  If not, write to
20169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
2190075SobrienBoston, MA 02110-1301, USA.  */
2290075Sobrien
2390075Sobrien#define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
2490075Sobrien
2590075Sobrien#define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
26132718Skan
27132718Skan#undef CPP_SPEC
2890075Sobrien#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
2990075Sobrien  %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
3090075Sobrien  %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}}\
3190075Sobrien  %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix }\
3290075Sobrien  %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
3390075Sobrien  %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
3490075Sobrien"
3590075Sobrien
3690075Sobrien#undef STARTFILE_SPEC
3790075Sobrien#define STARTFILE_SPEC "\
3890075Sobrien  %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
3990075Sobrien  %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
4090075Sobrien  %{pg:gcrt0%O%s}}}\
4190075Sobrien"
42117395Skan
43132718Skan/* Normally, -lgcc is not needed since everything in it is in the DLL, but we
4490075Sobrien   want to allow things to be added to it when installing new versions of
4590075Sobrien   GCC without making a new CYGWIN.DLL, so we leave it.  Profiling is handled
46132718Skan   by calling the init function from main.  */
47132718Skan
4890075Sobrien#undef LIBGCC_SPEC
4990075Sobrien#define LIBGCC_SPEC \
5090075Sobrien  "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc	\
5190075Sobrien   %{mno-cygwin:-lmoldname -lmingwex -lmsvcrt}"
5290075Sobrien
5390075Sobrien/* We have to dynamic link to get to the system DLLs.  All of libc, libm and
5490075Sobrien   the Unix stuff is in cygwin.dll.  The import library is called
5590075Sobrien   'libcygwin.a'.  For Windows applications, include more libraries, but
5690075Sobrien   always include kernel32.  We'd like to specific subsystem windows to
5790075Sobrien   ld, but that doesn't work just yet.  */
5890075Sobrien
59132718Skan#undef LIB_SPEC
6090075Sobrien#define LIB_SPEC "\
6190075Sobrien  %{pg:-lgmon} \
6290075Sobrien  %{!mno-cygwin:-lcygwin} \
6390075Sobrien  %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
64169689Skan  %{mwindows:-lgdi32 -lcomdlg32} \
6590075Sobrien  -luser32 -lkernel32 -ladvapi32 -lshell32"
6690075Sobrien
6790075Sobrien#define LINK_SPEC "\
6890075Sobrien  %{mwindows:--subsystem windows} \
6990075Sobrien  %{mconsole:--subsystem console} \
70169689Skan  %{shared: %{mdll: %eshared and mdll are not compatible}} \
71169689Skan  %{shared: --shared} %{mdll:--dll} \
72169689Skan  %{static:-Bstatic} %{!static:-Bdynamic} \
73169689Skan  %{shared|mdll: -e \
74169689Skan    %{mno-cygwin:_DllMainCRTStartup@12} \
75169689Skan    %{!mno-cygwin:__cygwin_dll_entry@12}}\
76169689Skan  %{!mno-cygwin:--dll-search-prefix=cyg}"
77169689Skan
78169689Skan/* Allocate space for all of the machine-spec-specific stuff.
79169689Skan   Allocate enough space for cygwin -> mingw32  munging plus
80169689Skan   possible addition of "/mingw".  */
8190075Sobrien
8290075Sobrien#ifndef CYGWIN_MINGW_SUBDIR
8390075Sobrien#define CYGWIN_MINGW_SUBDIR "/mingw"
8490075Sobrien#endif
85169689Skan#define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
8690075Sobrien
87#ifdef GPLUSPLUS_INCLUDE_DIR
88char cygwin_gplusplus_include_dir[sizeof (GPLUSPLUS_INCLUDE_DIR) + 1
89				  + (CYGWIN_MINGW_SUBDIR_LEN)]
90  = GPLUSPLUS_INCLUDE_DIR;
91#undef GPLUSPLUS_INCLUDE_DIR
92#define GPLUSPLUS_INCLUDE_DIR ((const char *) cygwin_gplusplus_include_dir)
93#ifndef GEN_CVT_ARRAY
94#define GEN_CVT_ARRAY
95#endif
96#endif
97
98#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
99char cygwin_gplusplus_tool_include_dir[sizeof (GPLUSPLUS_TOOL_INCLUDE_DIR) + 1
100				       + CYGWIN_MINGW_SUBDIR_LEN]
101  = GPLUSPLUS_TOOL_INCLUDE_DIR;
102#undef GPLUSPLUS_TOOL_INCLUDE_DIR
103#define GPLUSPLUS_TOOL_INCLUDE_DIR ((const char *) cygwin_gplusplus_tool_include_dir)
104#ifndef GEN_CVT_ARRAY
105#define GEN_CVT_ARRAY
106#endif
107#endif
108
109#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
110char cygwin_gplusplus_backward_include_dir[sizeof (GPLUSPLUS_BACKWARD_INCLUDE_DIR)  + 1
111					   + CYGWIN_MINGW_SUBDIR_LEN]
112  = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
113#undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
114#define GPLUSPLUS_BACKWARD_INCLUDE_DIR ((const char *) cygwin_gplusplus_backward_include_dir)
115#ifndef GEN_CVT_ARRAY
116#define GEN_CVT_ARRAY
117#endif
118#endif
119
120#ifdef LOCAL_INCLUDE_DIR
121char cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR)  + 1
122			      + CYGWIN_MINGW_SUBDIR_LEN]
123  = LOCAL_INCLUDE_DIR;
124#undef LOCAL_INCLUDE_DIR
125#define LOCAL_INCLUDE_DIR ((const char *) cygwin_local_include_dir)
126#ifndef GEN_CVT_ARRAY
127#define GEN_CVT_ARRAY
128#endif
129#endif
130
131#ifdef CROSS_INCLUDE_DIR
132char cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
133			      + CYGWIN_MINGW_SUBDIR_LEN]
134  = CROSS_INCLUDE_DIR;
135#undef CROSS_INCLUDE_DIR
136#define CROSS_INCLUDE_DIR ((const char *) cygwin_cross_include_dir)
137#ifndef GEN_CVT_ARRAY
138#define GEN_CVT_ARRAY
139#endif
140#endif
141
142#ifdef TOOL_INCLUDE_DIR
143char cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
144			     + CYGWIN_MINGW_SUBDIR_LEN]
145  = TOOL_INCLUDE_DIR;
146#undef TOOL_INCLUDE_DIR
147#define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
148
149#ifndef CROSS_COMPILE
150#undef STANDARD_INCLUDE_DIR
151#define STANDARD_INCLUDE_DIR "/usr/include"
152char cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
153				 + CYGWIN_MINGW_SUBDIR_LEN]
154  = STANDARD_INCLUDE_DIR;
155#undef STANDARD_INCLUDE_DIR
156#define STANDARD_INCLUDE_DIR ((const char *) cygwin_standard_include_dir)
157#endif
158
159#ifndef GEN_CVT_ARRAY
160#define GEN_CVT_ARRAY
161#endif
162#endif
163
164#ifndef GEN_CVT_ARRAY
165extern char *cvt_to_mingw[];
166#else
167char *cvt_to_mingw[] =
168  {
169#ifdef GPLUSPLUS_INCLUDE_DIR
170    cygwin_gplusplus_include_dir,
171#endif
172
173#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
174    cygwin_gplusplus_tool_include_dir,
175#endif
176
177#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
178    cygwin_gplusplus_backward_include_dir,
179#endif
180
181#ifdef LOCAL_INCLUDE_DIR
182    cygwin_local_include_dir,
183#endif
184
185#ifdef CROSS_INCLUDE_DIR
186    cygwin_cross_include_dir,
187#endif
188
189#ifdef TOOL_INCLUDE_DIR
190    cygwin_tool_include_dir,
191#endif
192
193#ifdef STANDARD_INCLUDE_DIR
194    cygwin_standard_include_dir,
195#endif
196
197    NULL
198  };
199#undef GEN_CVT_ARRAY
200#endif /*GEN_CVT_ARRAY*/
201
202void mingw_scan (int, const char * const *, char **);
203#if 1
204#define GCC_DRIVER_HOST_INITIALIZATION \
205do \
206{ \
207  mingw_scan(argc, (const char * const *) argv, (char **) &spec_machine); \
208  } \
209while (0)
210#else
211#define GCC_DRIVER_HOST_INITIALIZATION \
212do \
213{ \
214  char *cprefix = concat (tooldir_base_prefix, spec_machine, \
215			  dir_separator_str, NULL); \
216  if (!IS_ABSOLUTE_PATH (cprefix)) \
217    cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
218		      spec_version, dir_separator_str, tooldir_prefix, NULL); \
219  add_prefix (&exec_prefixes,\
220	      concat (cprefix, "../../../../", spec_machine, "/bin/", NULL), \
221	      "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
222  add_prefix (&exec_prefixes, cprefix, \
223	      "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
224  add_prefix (&startfile_prefixes,\
225	      concat (standard_startfile_prefix, "w32api", NULL),\
226	      "GCC", PREFIX_PRIORITY_LAST, 0, NULL);\
227  mingw_scan(argc, (const char * const *) argv, &spec_machine); \
228  } \
229while (0)
230#endif
231
232/* Binutils does not handle weak symbols from dlls correctly.  For now,
233   do not use them unnecessarily in gthr-posix.h.  */
234#define GTHREAD_USE_WEAK 0
235
236/* Every program on cygwin links against cygwin1.dll which contains
237   the pthread routines.  There is no need to explicitly link them
238   and the -pthread flag is not recognized.  */
239#undef GOMP_SELF_SPECS
240#define GOMP_SELF_SPECS ""
241