1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // Copyright (C) 2019 Intel Corporation. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #if 0 |
6 | #pragma qt_class(QtSystemDetection) |
7 | #pragma qt_sync_skip_header_check |
8 | #pragma qt_sync_stop_processing |
9 | #endif |
10 | |
11 | #ifndef QSYSTEMDETECTION_H |
12 | #define QSYSTEMDETECTION_H |
13 | |
14 | /* |
15 | The operating system, must be one of: (Q_OS_x) |
16 | |
17 | DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS) |
18 | MACOS - macOS |
19 | IOS - iOS |
20 | WATCHOS - watchOS |
21 | TVOS - tvOS |
22 | WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) |
23 | CYGWIN - Cygwin |
24 | SOLARIS - Sun Solaris |
25 | HPUX - HP-UX |
26 | LINUX - Linux [has variants] |
27 | FREEBSD - FreeBSD [has variants] |
28 | NETBSD - NetBSD |
29 | OPENBSD - OpenBSD |
30 | INTERIX - Interix |
31 | AIX - AIX |
32 | HURD - GNU Hurd |
33 | QNX - QNX [has variants] |
34 | QNX6 - QNX RTP 6.1 |
35 | LYNX - LynxOS |
36 | BSD4 - Any BSD 4.4 system |
37 | UNIX - Any UNIX BSD/SYSV system |
38 | ANDROID - Android platform |
39 | HAIKU - Haiku |
40 | WEBOS - LG WebOS |
41 | |
42 | The following operating systems have variants: |
43 | LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android |
44 | - only Q_OS_LINUX is defined if building for other Linux systems |
45 | MACOS - both Q_OS_BSD4 and Q_OS_IOS are defined when building for iOS |
46 | - both Q_OS_BSD4 and Q_OS_MACOS are defined when building for macOS |
47 | FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland |
48 | - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU |
49 | */ |
50 | |
51 | #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__)) |
52 | # include <TargetConditionals.h> |
53 | # define Q_OS_APPLE |
54 | # if defined(TARGET_OS_MAC) && TARGET_OS_MAC |
55 | # define Q_OS_DARWIN |
56 | # define Q_OS_BSD4 |
57 | # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
58 | # define QT_PLATFORM_UIKIT |
59 | # if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH |
60 | # define Q_OS_WATCHOS |
61 | # elif defined(TARGET_OS_TV) && TARGET_OS_TV |
62 | # define Q_OS_TVOS |
63 | # else |
64 | # // TARGET_OS_IOS is only available in newer SDKs, |
65 | # // so assume any other iOS-based platform is iOS for now |
66 | # define Q_OS_IOS |
67 | # endif |
68 | # else |
69 | # // TARGET_OS_OSX is only available in newer SDKs, |
70 | # // so assume any non iOS-based platform is macOS for now |
71 | # define Q_OS_MACOS |
72 | # endif |
73 | # else |
74 | # error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers" |
75 | # endif |
76 | #elif defined(__WEBOS__) |
77 | # define Q_OS_WEBOS |
78 | # define Q_OS_LINUX |
79 | #elif defined(__ANDROID__) || defined(ANDROID) |
80 | # define Q_OS_ANDROID |
81 | # define Q_OS_LINUX |
82 | #elif defined(__CYGWIN__) |
83 | # define Q_OS_CYGWIN |
84 | #elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) |
85 | # define Q_OS_WIN32 |
86 | # define Q_OS_WIN64 |
87 | #elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) |
88 | # define Q_OS_WIN32 |
89 | #elif defined(__sun) || defined(sun) |
90 | # define Q_OS_SOLARIS |
91 | #elif defined(hpux) || defined(__hpux) |
92 | # define Q_OS_HPUX |
93 | #elif defined(__native_client__) |
94 | # define Q_OS_NACL |
95 | #elif defined(__EMSCRIPTEN__) |
96 | # define Q_OS_WASM |
97 | #elif defined(__linux__) || defined(__linux) |
98 | # define Q_OS_LINUX |
99 | #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) |
100 | # ifndef __FreeBSD_kernel__ |
101 | # define Q_OS_FREEBSD |
102 | # endif |
103 | # define Q_OS_FREEBSD_KERNEL |
104 | # define Q_OS_BSD4 |
105 | #elif defined(__NetBSD__) |
106 | # define Q_OS_NETBSD |
107 | # define Q_OS_BSD4 |
108 | #elif defined(__OpenBSD__) |
109 | # define Q_OS_OPENBSD |
110 | # define Q_OS_BSD4 |
111 | #elif defined(__INTERIX) |
112 | # define Q_OS_INTERIX |
113 | # define Q_OS_BSD4 |
114 | #elif defined(_AIX) |
115 | # define Q_OS_AIX |
116 | #elif defined(__Lynx__) |
117 | # define Q_OS_LYNX |
118 | #elif defined(__GNU__) |
119 | # define Q_OS_HURD |
120 | #elif defined(__QNXNTO__) |
121 | # define Q_OS_QNX |
122 | #elif defined(__INTEGRITY) |
123 | # define Q_OS_INTEGRITY |
124 | #elif defined(__rtems__) |
125 | # define Q_OS_RTEMS |
126 | #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */ |
127 | # define Q_OS_VXWORKS |
128 | #elif defined(__HAIKU__) |
129 | # define Q_OS_HAIKU |
130 | #elif defined(__MAKEDEPEND__) |
131 | #else |
132 | # error "Qt has not been ported to this OS - see http://www.qt-project.org/" |
133 | #endif |
134 | |
135 | #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) |
136 | # define Q_OS_WINDOWS |
137 | # define Q_OS_WIN |
138 | // On Windows, pointers to dllimport'ed variables are not constant expressions, |
139 | // so to keep to certain initializations (like QMetaObject) constexpr, we need |
140 | // to use functions instead. |
141 | # define QT_NO_DATA_RELOCATION |
142 | #endif |
143 | |
144 | #if defined(Q_OS_WIN) |
145 | # undef Q_OS_UNIX |
146 | #elif !defined(Q_OS_UNIX) |
147 | # define Q_OS_UNIX |
148 | #endif |
149 | |
150 | // Compatibility synonyms |
151 | #ifdef Q_OS_DARWIN |
152 | # pragma clang diagnostic push |
153 | # pragma clang diagnostic ignored "-Wunknown-pragmas" |
154 | # define Q_OS_MAC // FIXME: Deprecate |
155 | # ifdef __LP64__ |
156 | # define Q_OS_DARWIN64 |
157 | # pragma clang deprecated(Q_OS_DARWIN64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") |
158 | # define Q_OS_MAC64 |
159 | # pragma clang deprecated(Q_OS_MAC64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") |
160 | # else |
161 | # define Q_OS_DARWIN32 |
162 | # pragma clang deprecated(Q_OS_DARWIN32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") |
163 | # define Q_OS_MAC32 |
164 | # pragma clang deprecated(Q_OS_MAC32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead") |
165 | # endif |
166 | # ifdef Q_OS_MACOS |
167 | # define Q_OS_MACX |
168 | # pragma clang deprecated(Q_OS_MACX, "use Q_OS_MACOS instead") |
169 | # define Q_OS_OSX |
170 | # pragma clang deprecated(Q_OS_OSX, "use Q_OS_MACOS instead") |
171 | # endif |
172 | # pragma clang diagnostic pop |
173 | #endif |
174 | |
175 | #ifdef Q_OS_DARWIN |
176 | # include <Availability.h> |
177 | # include <AvailabilityMacros.h> |
178 | |
179 | # define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \ |
180 | ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \ |
181 | (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \ |
182 | (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \ |
183 | (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos)) |
184 | |
185 | # define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \ |
186 | ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \ |
187 | (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \ |
188 | (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \ |
189 | (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos)) |
190 | |
191 | # define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \ |
192 | QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA) |
193 | # define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \ |
194 | QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA) |
195 | # define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \ |
196 | QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA) |
197 | # define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \ |
198 | QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA) |
199 | # define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \ |
200 | QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos) |
201 | |
202 | # define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \ |
203 | QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA) |
204 | # define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \ |
205 | QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA) |
206 | # define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \ |
207 | QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA) |
208 | # define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \ |
209 | QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA) |
210 | # define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \ |
211 | QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos) |
212 | |
213 | #else // !Q_OS_DARWIN |
214 | |
215 | #define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) (0) |
216 | #define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) (0) |
217 | #define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) (0) |
218 | #define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) (0) |
219 | #define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) (0) |
220 | #define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) (0) |
221 | |
222 | #endif // Q_OS_DARWIN |
223 | |
224 | #ifdef __LSB_VERSION__ |
225 | # if __LSB_VERSION__ < 40 |
226 | # error "This version of the Linux Standard Base is unsupported" |
227 | # endif |
228 | #ifndef QT_LINUXBASE |
229 | # define QT_LINUXBASE |
230 | #endif |
231 | #endif |
232 | |
233 | #if defined (__ELF__) |
234 | # define Q_OF_ELF |
235 | #endif |
236 | #if defined (__MACH__) && defined (__APPLE__) |
237 | # define Q_OF_MACH_O |
238 | #endif |
239 | |
240 | #endif // QSYSTEMDETECTION_H |
241 | |