summaryrefslogtreecommitdiff
path: root/utils/config.h
blob: 0227f41773bed1f822b0ca55ce69a34af330f475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
 * Copyright 2003-7 John M Bell <jmb202@ecs.soton.ac.uk>
 *
 * This file is part of NetSurf, http://www.netsurf-browser.org/
 *
 * NetSurf is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * NetSurf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NETSURF_UTILS_CONFIG_H_
#define NETSURF_UTILS_CONFIG_H_

#include <stddef.h>

#if defined(__NetBSD__)
#include <sys/param.h>
#if (defined(__NetBSD_Version__) && __NetBSD_Prereq__(8,0,0))
#define NetBSD_v8
#endif
#endif

/* Try to detect which features the target OS supports */

#if (defined(_GNU_SOURCE) && \
     !defined(__APPLE__) || \
     defined(__amigaos4__) || \
     defined(__HAIKU__) || \
     (defined(_POSIX_C_SOURCE) && ((_POSIX_C_SOURCE - 0) >= 200809L)) && \
     !defined(__riscos__))
#define HAVE_STRNDUP
#else
#undef HAVE_STRNDUP
char *strndup(const char *s, size_t n);
#endif

#if ((defined(_GNU_SOURCE) ||			\
      defined(__APPLE__) ||			\
      defined(__HAIKU__) ||			\
      defined(__NetBSD__) ||			\
      defined(__OpenBSD__)) &&			\
     !defined(__serenity__))
#define HAVE_STRCASESTR
#else
#undef HAVE_STRCASESTR
char *strcasestr(const char *haystack, const char *needle);
#endif

/* Although these platforms might have strftime or strptime they
 *  appear not to support the time_t seconds format specifier.
 */
#if (defined(_WIN32) ||	      \
     defined(__riscos__) ||   \
     defined(__HAIKU__) ||    \
     defined(__BEOS__) ||     \
     defined(__amigaos4__) || \
     defined(__AMIGA__) ||    \
     defined(__MINT__))
#undef HAVE_STRPTIME
#undef HAVE_STRFTIME
#else
#define HAVE_STRPTIME
#define HAVE_STRFTIME
#endif

/* For some reason, UnixLib defines this unconditionally. Assume we're using
 *  UnixLib if building for RISC OS.
 */
#if ((defined(_GNU_SOURCE) && !defined(__APPLE__)) ||	\
     defined(__riscos__) || \
     defined(NetBSD_v8))
#define HAVE_STRCHRNUL
#else
#undef HAVE_STRCHRNUL
char *strchrnul(const char *s, int c);
#endif

/*
 * amigaos3 declares this but does not have it in its actual library
 */
#define HAVE_STRTOULL
#if !defined(__amigaos4__) && defined(__AMIGA__)
#undef HAVE_STRTOULL
#endif

#define HAVE_SYS_SELECT
#define HAVE_POSIX_INET_HEADERS
#if (defined(_WIN32))
#undef HAVE_SYS_SELECT
#undef HAVE_POSIX_INET_HEADERS
#endif

#define HAVE_INETATON
#if (defined(_WIN32) || \
     defined(__serenity__))
#undef HAVE_INETATON
#endif

#define HAVE_INETPTON
#if (defined(_WIN32))
#undef HAVE_INETPTON
#endif

#define HAVE_UTSNAME
#if (defined(_WIN32))
#undef HAVE_UTSNAME
#endif

#define HAVE_REALPATH
#if (defined(_WIN32))
#undef HAVE_REALPATH
char *realpath(const char *path, char *resolved_path);
#endif

#define HAVE_MKDIR
#if (defined(_WIN32))
#undef HAVE_MKDIR
#endif

#define HAVE_SIGPIPE
#if (defined(_WIN32))
#undef HAVE_SIGPIPE
#endif

#define HAVE_STDOUT
#if (defined(_WIN32))
#undef HAVE_STDOUT
#endif

#define HAVE_MMAP
#if (defined(_WIN32) || defined(__riscos__) || defined(__HAIKU__) || defined(__BEOS__) || defined(__amigaos4__) || defined(__AMIGA__) || defined(__MINT__))
#undef HAVE_MMAP
#endif

#define HAVE_SCANDIR
#if (defined(_WIN32) ||				\
     defined(__serenity__))
#undef HAVE_SCANDIR
#endif

#define HAVE_REGEX
#if (defined(__serenity__))
#undef HAVE_REGEX
#endif

/* execinfo available for backtrace */
#if ((defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)) || \
     defined(__APPLE__))
#define HAVE_EXECINFO
#endif

/* This section toggles build options on and off.
 * Simply undefine a symbol to turn the relevant feature off.
 *
 * IF ADDING A FEATURE HERE, ADD IT TO Docs/Doxyfile's "PREDEFINED" DEFINITION AS WELL.
 */

/* Platform specific features */
#if defined(riscos)
    /* Theme auto-install */
    #define WITH_THEME_INSTALL
#elif defined(__HAIKU__) || defined(__BEOS__)
    /* for intptr_t */
    #include <inttypes.h>
    #if defined(__HAIKU__)
        /*not yet: #define WITH_MMAP*/
    #endif
    #if defined(__BEOS__)
    	/* Not even BONE has it. */
    	#define NO_IPV6 1
    #endif
#else
    /* We're likely to have a working mmap() */
    #define WITH_MMAP
#endif

/* IPv6 */
#if (defined(__amigaos4__) ||			\
     defined(__AMIGA__) ||			\
     defined(nsatari) ||			\
     defined(__serenity__))
	#define NO_IPV6
#endif

#endif