1/****************************************************************************
2**
3** Copyright (C) 2019 The Qt Company Ltd.
4** Copyright (C) 2019 Intel Corporation.
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QGLOBAL_H
42# include <QtCore/qglobal.h>
43#endif
44
45#ifndef QSYSTEMDETECTION_H
46#define QSYSTEMDETECTION_H
47
48/*
49 The operating system, must be one of: (Q_OS_x)
50
51 DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS)
52 MACOS - macOS
53 IOS - iOS
54 WATCHOS - watchOS
55 TVOS - tvOS
56 WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
57 WINRT - WinRT (Windows Runtime)
58 CYGWIN - Cygwin
59 SOLARIS - Sun Solaris
60 HPUX - HP-UX
61 LINUX - Linux [has variants]
62 FREEBSD - FreeBSD [has variants]
63 NETBSD - NetBSD
64 OPENBSD - OpenBSD
65 INTERIX - Interix
66 AIX - AIX
67 HURD - GNU Hurd
68 QNX - QNX [has variants]
69 QNX6 - QNX RTP 6.1
70 LYNX - LynxOS
71 BSD4 - Any BSD 4.4 system
72 UNIX - Any UNIX BSD/SYSV system
73 ANDROID - Android platform
74 HAIKU - Haiku
75
76 The following operating systems have variants:
77 LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android
78 - only Q_OS_LINUX is defined if building for other Linux systems
79 FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland
80 - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU
81*/
82
83#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
84# include <TargetConditionals.h>
85# if defined(TARGET_OS_MAC) && TARGET_OS_MAC
86# define Q_OS_DARWIN
87# define Q_OS_BSD4
88# ifdef __LP64__
89# define Q_OS_DARWIN64
90# else
91# define Q_OS_DARWIN32
92# endif
93# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
94# define QT_PLATFORM_UIKIT
95# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
96# define Q_OS_WATCHOS
97# elif defined(TARGET_OS_TV) && TARGET_OS_TV
98# define Q_OS_TVOS
99# else
100# // TARGET_OS_IOS is only available in newer SDKs,
101# // so assume any other iOS-based platform is iOS for now
102# define Q_OS_IOS
103# endif
104# else
105# // TARGET_OS_OSX is only available in newer SDKs,
106# // so assume any non iOS-based platform is macOS for now
107# define Q_OS_MACOS
108# endif
109# else
110# error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers"
111# endif
112#elif defined(__ANDROID__) || defined(ANDROID)
113# define Q_OS_ANDROID
114# define Q_OS_LINUX
115#elif defined(__CYGWIN__)
116# define Q_OS_CYGWIN
117#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
118# define Q_OS_WIN32
119# define Q_OS_WIN64
120#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
121# if defined(WINAPI_FAMILY)
122# ifndef WINAPI_FAMILY_PC_APP
123# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
124# endif
125# if defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
126# define Q_OS_WINRT
127# elif WINAPI_FAMILY==WINAPI_FAMILY_PC_APP
128# define Q_OS_WINRT
129# else
130# define Q_OS_WIN32
131# endif
132# else
133# define Q_OS_WIN32
134# endif
135#elif defined(__sun) || defined(sun)
136# define Q_OS_SOLARIS
137#elif defined(hpux) || defined(__hpux)
138# define Q_OS_HPUX
139#elif defined(__native_client__)
140# define Q_OS_NACL
141#elif defined(__EMSCRIPTEN__)
142# define Q_OS_WASM
143#elif defined(__linux__) || defined(__linux)
144# define Q_OS_LINUX
145#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
146# ifndef __FreeBSD_kernel__
147# define Q_OS_FREEBSD
148# endif
149# define Q_OS_FREEBSD_KERNEL
150# define Q_OS_BSD4
151#elif defined(__NetBSD__)
152# define Q_OS_NETBSD
153# define Q_OS_BSD4
154#elif defined(__OpenBSD__)
155# define Q_OS_OPENBSD
156# define Q_OS_BSD4
157#elif defined(__INTERIX)
158# define Q_OS_INTERIX
159# define Q_OS_BSD4
160#elif defined(_AIX)
161# define Q_OS_AIX
162#elif defined(__Lynx__)
163# define Q_OS_LYNX
164#elif defined(__GNU__)
165# define Q_OS_HURD
166#elif defined(__QNXNTO__)
167# define Q_OS_QNX
168#elif defined(__INTEGRITY)
169# define Q_OS_INTEGRITY
170#elif defined(__rtems__)
171# define Q_OS_RTEMS
172#elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
173# define Q_OS_VXWORKS
174#elif defined(__HAIKU__)
175# define Q_OS_HAIKU
176#elif defined(__MAKEDEPEND__)
177#else
178# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
179#endif
180
181#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
182# define Q_OS_WINDOWS
183# define Q_OS_WIN
184# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
185// On Windows, pointers to dllimport'ed variables are not constant expressions,
186// so to keep to certain initializations (like QMetaObject) constexpr, we need
187// to use functions instead.
188# define QT_NO_DATA_RELOCATION
189# endif
190#endif
191
192#if defined(Q_OS_WIN)
193# undef Q_OS_UNIX
194#elif !defined(Q_OS_UNIX)
195# define Q_OS_UNIX
196#endif
197
198// Compatibility synonyms
199#ifdef Q_OS_DARWIN
200#define Q_OS_MAC
201#endif
202#ifdef Q_OS_DARWIN32
203#define Q_OS_MAC32
204#endif
205#ifdef Q_OS_DARWIN64
206#define Q_OS_MAC64
207#endif
208#ifdef Q_OS_MACOS
209#define Q_OS_MACX
210#define Q_OS_OSX
211#endif
212
213#ifdef Q_OS_DARWIN
214# include <Availability.h>
215# include <AvailabilityMacros.h>
216#
217# ifdef Q_OS_MACOS
218# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
219# undef __MAC_OS_X_VERSION_MIN_REQUIRED
220# define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_6
221# endif
222# if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
223# undef MAC_OS_X_VERSION_MIN_REQUIRED
224# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
225# endif
226# endif
227#
228# // Numerical checks are preferred to named checks, but to be safe
229# // we define the missing version names in case Qt uses them.
230#
231# if !defined(__MAC_10_11)
232# define __MAC_10_11 101100
233# endif
234# if !defined(__MAC_10_12)
235# define __MAC_10_12 101200
236# endif
237# if !defined(__MAC_10_13)
238# define __MAC_10_13 101300
239# endif
240# if !defined(__MAC_10_14)
241# define __MAC_10_14 101400
242# endif
243# if !defined(MAC_OS_X_VERSION_10_11)
244# define MAC_OS_X_VERSION_10_11 101100
245# endif
246# if !defined(MAC_OS_X_VERSION_10_12)
247# define MAC_OS_X_VERSION_10_12 101200
248# endif
249# if !defined(MAC_OS_X_VERSION_10_13)
250# define MAC_OS_X_VERSION_10_13 101300
251# endif
252# if !defined(MAC_OS_X_VERSION_10_14)
253# define MAC_OS_X_VERSION_10_14 101400
254# endif
255#
256# if !defined(__IPHONE_10_0)
257# define __IPHONE_10_0 100000
258# endif
259# if !defined(__IPHONE_10_1)
260# define __IPHONE_10_1 100100
261# endif
262# if !defined(__IPHONE_10_2)
263# define __IPHONE_10_2 100200
264# endif
265# if !defined(__IPHONE_10_3)
266# define __IPHONE_10_3 100300
267# endif
268# if !defined(__IPHONE_11_0)
269# define __IPHONE_11_0 110000
270# endif
271# if !defined(__IPHONE_12_0)
272# define __IPHONE_12_0 120000
273# endif
274#endif
275
276#ifdef __LSB_VERSION__
277# if __LSB_VERSION__ < 40
278# error "This version of the Linux Standard Base is unsupported"
279# endif
280#ifndef QT_LINUXBASE
281# define QT_LINUXBASE
282#endif
283#endif
284
285#endif // QSYSTEMDETECTION_H
286