cygwin.h revision 258428
155714Skris/* Operating system specific defines to be used when targeting GCC for
255714Skris   hosting on Windows32, using a Unix style C library and tools.
355714Skris   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
455714Skris   Free Software Foundation, Inc.
559191Skris
659191SkrisThis file is part of GCC.
755714Skris
855714SkrisGCC is free software; you can redistribute it and/or modify
955714Skrisit under the terms of the GNU General Public License as published by
1079998Skristhe Free Software Foundation; either version 2, or (at your option)
1155714Skrisany later version.
1255714Skris
1379998SkrisGCC is distributed in the hope that it will be useful,
1479998Skrisbut WITHOUT ANY WARRANTY; without even the implied warranty of
1555714SkrisMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1655714SkrisGNU General Public License for more details.
1755714Skris
1855714SkrisYou should have received a copy of the GNU General Public License
1955714Skrisalong with GCC; see the file COPYING.  If not, write to
2055714Skristhe Free Software Foundation, 51 Franklin Street, Fifth Floor,
2155714SkrisBoston, MA 02110-1301, USA.  */
2255714Skris
2355714Skris#define TARGET_VERSION fprintf (stderr, " (x86 Cygwin)");
2455714Skris
2555714Skris#define EXTRA_OS_CPP_BUILTINS()  /* Nothing.  */
2655714Skris
2755714Skris#undef CPP_SPEC
2855714Skris#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
2955714Skris  %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
3055714Skris  %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}}\
3155714Skris  %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix }\
3255714Skris  %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
3355714Skris  %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter ../../include/w32api%s}}\
3455714Skris"
3555714Skris
3655714Skris#undef STARTFILE_SPEC
3755714Skris#define STARTFILE_SPEC "\
3855714Skris  %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
3959191Skris  %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
4059191Skris  %{pg:gcrt0%O%s}}}\
4155714Skris"
4255714Skris
4355714Skris/* Normally, -lgcc is not needed since everything in it is in the DLL, but we
4455714Skris   want to allow things to be added to it when installing new versions of
4555714Skris   GCC without making a new CYGWIN.DLL, so we leave it.  Profiling is handled
4655714Skris   by calling the init function from main.  */
4755714Skris
4855714Skris#undef LIBGCC_SPEC
4955714Skris#define LIBGCC_SPEC \
5055714Skris  "%{mno-cygwin: %{mthreads:-lmingwthrd} -lmingw32} -lgcc	\
5155714Skris   %{mno-cygwin:-lmoldname -lmingwex -lmsvcrt}"
5255714Skris
5355714Skris/* We have to dynamic link to get to the system DLLs.  All of libc, libm and
5455714Skris   the Unix stuff is in cygwin.dll.  The import library is called
5555714Skris   'libcygwin.a'.  For Windows applications, include more libraries, but
5668651Skris   always include kernel32.  We'd like to specific subsystem windows to
5768651Skris   ld, but that doesn't work just yet.  */
5868651Skris
5968651Skris#undef LIB_SPEC
6068651Skris#define LIB_SPEC "\
6168651Skris  %{pg:-lgmon} \
6255714Skris  %{!mno-cygwin:-lcygwin} \
6355714Skris  %{mno-cygwin:%{mthreads:-lmingwthrd} -lmingw32} \
6455714Skris  %{mwindows:-lgdi32 -lcomdlg32} \
6555714Skris  -luser32 -lkernel32 -ladvapi32 -lshell32"
6655714Skris
6755714Skris#define LINK_SPEC "\
6855714Skris  %{mwindows:--subsystem windows} \
6955714Skris  %{mconsole:--subsystem console} \
7055714Skris  %{shared: %{mdll: %eshared and mdll are not compatible}} \
7155714Skris  %{shared: --shared} %{mdll:--dll} \
7255714Skris  %{static:-Bstatic} %{!static:-Bdynamic} \
7355714Skris  %{shared|mdll: -e \
7455714Skris    %{mno-cygwin:_DllMainCRTStartup@12} \
7555714Skris    %{!mno-cygwin:__cygwin_dll_entry@12}}\
7655714Skris  %{!mno-cygwin:--dll-search-prefix=cyg}"
7755714Skris
7855714Skris/* Allocate space for all of the machine-spec-specific stuff.
7955714Skris   Allocate enough space for cygwin -> mingw32  munging plus
8055714Skris   possible addition of "/mingw".  */
8155714Skris
8255714Skris#ifndef CYGWIN_MINGW_SUBDIR
8355714Skris#define CYGWIN_MINGW_SUBDIR "/mingw"
8455714Skris#endif
8555714Skris#define CYGWIN_MINGW_SUBDIR_LEN (sizeof (CYGWIN_MINGW_SUBDIR) - 1)
8655714Skris
8759191Skris#ifdef GPLUSPLUS_INCLUDE_DIR
8859191Skrischar cygwin_gplusplus_include_dir[sizeof (GPLUSPLUS_INCLUDE_DIR) + 1
8959191Skris				  + (CYGWIN_MINGW_SUBDIR_LEN)]
9055714Skris  = GPLUSPLUS_INCLUDE_DIR;
9155714Skris#undef GPLUSPLUS_INCLUDE_DIR
9255714Skris#define GPLUSPLUS_INCLUDE_DIR ((const char *) cygwin_gplusplus_include_dir)
9355714Skris#ifndef GEN_CVT_ARRAY
9455714Skris#define GEN_CVT_ARRAY
9555714Skris#endif
9655714Skris#endif
9755714Skris
9855714Skris#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
9955714Skrischar cygwin_gplusplus_tool_include_dir[sizeof (GPLUSPLUS_TOOL_INCLUDE_DIR) + 1
10055714Skris				       + CYGWIN_MINGW_SUBDIR_LEN]
10155714Skris  = GPLUSPLUS_TOOL_INCLUDE_DIR;
10255714Skris#undef GPLUSPLUS_TOOL_INCLUDE_DIR
10355714Skris#define GPLUSPLUS_TOOL_INCLUDE_DIR ((const char *) cygwin_gplusplus_tool_include_dir)
10455714Skris#ifndef GEN_CVT_ARRAY
10555714Skris#define GEN_CVT_ARRAY
10655714Skris#endif
10755714Skris#endif
10855714Skris
10955714Skris#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
11055714Skrischar cygwin_gplusplus_backward_include_dir[sizeof (GPLUSPLUS_BACKWARD_INCLUDE_DIR)  + 1
11155714Skris					   + CYGWIN_MINGW_SUBDIR_LEN]
11259191Skris  = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
11359191Skris#undef GPLUSPLUS_BACKWARD_INCLUDE_DIR
11455714Skris#define GPLUSPLUS_BACKWARD_INCLUDE_DIR ((const char *) cygwin_gplusplus_backward_include_dir)
11555714Skris#ifndef GEN_CVT_ARRAY
11655714Skris#define GEN_CVT_ARRAY
11755714Skris#endif
11855714Skris#endif
11955714Skris
12055714Skris#ifdef LOCAL_INCLUDE_DIR
12155714Skrischar cygwin_local_include_dir[sizeof (LOCAL_INCLUDE_DIR)  + 1
12255714Skris			      + CYGWIN_MINGW_SUBDIR_LEN]
12355714Skris  = LOCAL_INCLUDE_DIR;
12455714Skris#undef LOCAL_INCLUDE_DIR
12555714Skris#define LOCAL_INCLUDE_DIR ((const char *) cygwin_local_include_dir)
12655714Skris#ifndef GEN_CVT_ARRAY
12768651Skris#define GEN_CVT_ARRAY
12879998Skris#endif
12968651Skris#endif
13068651Skris
13168651Skris#ifdef CROSS_INCLUDE_DIR
13268651Skrischar cygwin_cross_include_dir[sizeof (CROSS_INCLUDE_DIR) + 1
13355714Skris			      + CYGWIN_MINGW_SUBDIR_LEN]
13455714Skris  = CROSS_INCLUDE_DIR;
13559191Skris#undef CROSS_INCLUDE_DIR
13655714Skris#define CROSS_INCLUDE_DIR ((const char *) cygwin_cross_include_dir)
13755714Skris#ifndef GEN_CVT_ARRAY
13855714Skris#define GEN_CVT_ARRAY
13955714Skris#endif
14055714Skris#endif
14155714Skris
14255714Skris#ifdef TOOL_INCLUDE_DIR
14355714Skrischar cygwin_tool_include_dir[sizeof (TOOL_INCLUDE_DIR) + 1
14468651Skris			     + CYGWIN_MINGW_SUBDIR_LEN]
14568651Skris  = TOOL_INCLUDE_DIR;
14668651Skris#undef TOOL_INCLUDE_DIR
14768651Skris#define TOOL_INCLUDE_DIR ((const char *) cygwin_tool_include_dir)
14868651Skris
14968651Skris#ifndef CROSS_DIRECTORY_STRUCTURE
15068651Skris#undef STANDARD_INCLUDE_DIR
15155714Skris#define STANDARD_INCLUDE_DIR "/usr/include"
15255714Skrischar cygwin_standard_include_dir[sizeof (STANDARD_INCLUDE_DIR) + 1
15355714Skris				 + CYGWIN_MINGW_SUBDIR_LEN]
15455714Skris  = STANDARD_INCLUDE_DIR;
15555714Skris#undef STANDARD_INCLUDE_DIR
15655714Skris#define STANDARD_INCLUDE_DIR ((const char *) cygwin_standard_include_dir)
15755714Skris#endif
15855714Skris
15955714Skris#ifndef GEN_CVT_ARRAY
16055714Skris#define GEN_CVT_ARRAY
16159191Skris#endif
16259191Skris#endif
16355714Skris
16455714Skris#ifndef GEN_CVT_ARRAY
16555714Skrisextern char *cvt_to_mingw[];
16655714Skris#else
16759191Skrischar *cvt_to_mingw[] =
16855714Skris  {
16955714Skris#ifdef GPLUSPLUS_INCLUDE_DIR
17055714Skris    cygwin_gplusplus_include_dir,
17155714Skris#endif
17255714Skris
17355714Skris#ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
17455714Skris    cygwin_gplusplus_tool_include_dir,
17555714Skris#endif
17655714Skris
17755714Skris#ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
17855714Skris    cygwin_gplusplus_backward_include_dir,
17955714Skris#endif
18055714Skris
18155714Skris#ifdef LOCAL_INCLUDE_DIR
18255714Skris    cygwin_local_include_dir,
18355714Skris#endif
18455714Skris
18555714Skris#ifdef CROSS_INCLUDE_DIR
18655714Skris    cygwin_cross_include_dir,
18755714Skris#endif
18855714Skris
18955714Skris#ifdef TOOL_INCLUDE_DIR
19055714Skris    cygwin_tool_include_dir,
19155714Skris#endif
19255714Skris
19355714Skris#ifdef STANDARD_INCLUDE_DIR
19455714Skris    cygwin_standard_include_dir,
19555714Skris#endif
19655714Skris
19755714Skris    NULL
19855714Skris  };
19955714Skris#undef GEN_CVT_ARRAY
20055714Skris#endif /*GEN_CVT_ARRAY*/
20155714Skris
20255714Skrisvoid mingw_scan (int, const char * const *, char **);
20355714Skris#if 1
20455714Skris#define GCC_DRIVER_HOST_INITIALIZATION \
20555714Skrisdo \
20655714Skris{ \
20755714Skris  mingw_scan(argc, (const char * const *) argv, (char **) &spec_machine); \
20855714Skris  } \
20955714Skriswhile (0)
21055714Skris#else
21155714Skris#define GCC_DRIVER_HOST_INITIALIZATION \
21255714Skrisdo \
21355714Skris{ \
21455714Skris  char *cprefix = concat (tooldir_base_prefix, spec_machine, \
21555714Skris			  dir_separator_str, NULL); \
21655714Skris  if (!IS_ABSOLUTE_PATH (cprefix)) \
21755714Skris    cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
21855714Skris		      spec_version, dir_separator_str, tooldir_prefix, NULL); \
21955714Skris  add_prefix (&exec_prefixes,\
22055714Skris	      concat (cprefix, "../../../../", spec_machine, "/bin/", NULL), \
22155714Skris	      "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
22255714Skris  add_prefix (&exec_prefixes, cprefix, \
22355714Skris	      "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL); \
22455714Skris  add_prefix (&startfile_prefixes,\
22555714Skris	      concat (standard_startfile_prefix, "w32api", NULL),\
22655714Skris	      "GCC", PREFIX_PRIORITY_LAST, 0, NULL);\
22755714Skris  mingw_scan(argc, (const char * const *) argv, &spec_machine); \
22855714Skris  } \
22955714Skriswhile (0)
23055714Skris#endif
23155714Skris
23255714Skris/* Binutils does not handle weak symbols from dlls correctly.  For now,
23355714Skris   do not use them unnecessarily in gthr-posix.h.  */
23455714Skris#define GTHREAD_USE_WEAK 0
23555714Skris
23655714Skris/* Every program on cygwin links against cygwin1.dll which contains
23755714Skris   the pthread routines.  There is no need to explicitly link them
23855714Skris   and the -pthread flag is not recognized.  */
23955714Skris#undef GOMP_SELF_SPECS
24055714Skris#define GOMP_SELF_SPECS ""
24155714Skris