1 /* Base configuration file for all NetBSD targets.
2    Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10 
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets.  */
21 #define NETBSD_OS_CPP_BUILTINS_COMMON()		\
22   do						\
23     {						\
24       builtin_define ("__NetBSD__");		\
25       builtin_define ("__unix__");		\
26       builtin_assert ("system=bsd");		\
27       builtin_assert ("system=unix");		\
28       builtin_assert ("system=NetBSD");		\
29     }						\
30   while (0)
31 
32 /* CPP_SPEC parts common to all NetBSD targets.  */
33 #define NETBSD_CPP_SPEC				\
34   "%{posix:-D_POSIX_SOURCE} \
35    %{pthread:-D_REENTRANT -D_PTHREADS}"
36 
37 /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
38    source tree so it can be configured appropriately without using
39    the GNU configure/build mechanism.  */
40 
41 #ifdef NETBSD_NATIVE
42 
43 /* Look for the include files in the system-defined places.  */
44 
45 #undef GPLUSPLUS_INCLUDE_DIR
46 #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
47 
48 #undef GCC_INCLUDE_DIR
49 #define GCC_INCLUDE_DIR "/usr/include"
50 
51 #undef INCLUDE_DEFAULTS
52 #define INCLUDE_DEFAULTS			\
53   {						\
54     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },	\
55     { GCC_INCLUDE_DIR, "GCC", 0, 0 },		\
56     { 0, 0, 0, 0 }				\
57   }
58 
59 /* Under NetBSD, the normal location of the compiler back ends is the
60    /usr/libexec directory.  */
61 
62 #undef STANDARD_EXEC_PREFIX
63 #define STANDARD_EXEC_PREFIX		"/usr/libexec/"
64 
65 /* Under NetBSD, the normal location of the various *crt*.o files is the
66    /usr/lib directory.  */
67 
68 #undef STANDARD_STARTFILE_PREFIX
69 #define STANDARD_STARTFILE_PREFIX	"/usr/lib/"
70 
71 #endif /* NETBSD_NATIVE */
72 
73 
74 /* Provide a LIB_SPEC appropriate for NetBSD.  Here we:
75 
76    1. Select the appropriate set of libs, depending on whether we're
77       profiling.
78 
79    2. Include the pthread library if -pthread is specified (only
80       if threads are enabled).
81 
82    3. Include the posix library if -posix is specified.
83 
84    FIXME: Could eliminate the duplication here if we were allowed to
85    use string concatenation.  */
86 
87 #define NETBSD_LIB_SPEC		\
88   "%{pthread:			\
89      %{!p:			\
90        %{!pg:-lpthread}}	\
91      %{p:-lpthread_p}		\
92      %{pg:-lpthread_p}}		\
93    %{posix:			\
94      %{!p:			\
95        %{!pg:-lposix}}		\
96      %{p:-lposix_p}		\
97      %{pg:-lposix_p}}		\
98    %{shared:-lc}		\
99    %{!shared:			\
100      %{!symbolic:		\
101        %{!p:			\
102 	 %{!pg:-lc}}		\
103        %{p:-lc_p}		\
104        %{pg:-lc_p}}}"
105 
106 #undef LIB_SPEC
107 #define LIB_SPEC NETBSD_LIB_SPEC
108 
109 /* Provide a LIBGCC_SPEC appropriate for NetBSD.  */
110 
111 #ifdef NETBSD_NATIVE
112 #define NETBSD_LIBGCC_SPEC	\
113   "%{!symbolic:			\
114      %{!shared:			\
115        %{!p:			\
116 	 %{!pg: -lgcc}}}	\
117      %{shared: -lgcc_pic}	\
118      %{p: -lgcc_p}		\
119      %{pg: -lgcc_p}}"
120 #else
121 #define NETBSD_LIBGCC_SPEC "-lgcc"
122 #endif
123 
124 #undef LIBGCC_SPEC
125 #define LIBGCC_SPEC NETBSD_LIBGCC_SPEC
126 
127 #if defined(HAVE_LD_EH_FRAME_HDR)
128 #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
129 #endif
130 
131 #undef TARGET_LIBC_HAS_FUNCTION
132 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
133 
134 /* When building shared libraries, the initialization and finalization
135    functions for the library are .init and .fini respectively.  */
136 
137 #define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC)				\
138   do {									\
139     fprintf ((STREAM), "void __init() __asm__ (\".init\");");		\
140     fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC));	\
141   } while (0)
142 
143 #define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC)				\
144   do {									\
145     fprintf ((STREAM), "void __fini() __asm__ (\".fini\");");		\
146     fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC));	\
147   } while (0)
148 
149 #undef TARGET_POSIX_IO
150 #define TARGET_POSIX_IO
151 
152 /* Don't assume anything about the header files.  */
153 #undef  NO_IMPLICIT_EXTERN_C
154 #define NO_IMPLICIT_EXTERN_C    1
155 
156 /* Define some types that are the same on all NetBSD platforms,
157    making them agree with <machine/ansi.h>.  */
158 
159 #undef WCHAR_TYPE
160 #define WCHAR_TYPE "int"
161 
162 #undef WCHAR_TYPE_SIZE
163 #define WCHAR_TYPE_SIZE 32
164 
165 #undef WINT_TYPE
166 #define WINT_TYPE "int"
167 
168 #undef  SUBTARGET_INIT_BUILTINS
169 #define SUBTARGET_INIT_BUILTINS						\
170   do {									\
171     netbsd_patch_builtins ();						\
172   } while(0)
173