]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | dnl Copyright (C) 1997-2024 Free Software Foundation, Inc. |
b15c5d7a MF |
2 | dnl |
3 | dnl This program is free software; you can redistribute it and/or modify | |
4 | dnl it under the terms of the GNU General Public License as published by | |
5 | dnl the Free Software Foundation; either version 3 of the License, or | |
6 | dnl (at your option) any later version. | |
7 | dnl | |
8 | dnl This program is distributed in the hope that it will be useful, | |
9 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | dnl GNU General Public License for more details. | |
12 | dnl | |
13 | dnl You should have received a copy of the GNU General Public License | |
14 | dnl along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | dnl | |
16 | dnl Check for various platform settings. | |
17 | AC_DEFUN([SIM_AC_PLATFORM], | |
18 | [dnl | |
19 | dnl Check for common headers. | |
20 | dnl NB: You can assume C11 headers exist. | |
4cd7de78 | 21 | dnl NB: We use gnulib from ../gnulib/, so we don't probe headers it provides. |
b15c5d7a MF |
22 | AC_CHECK_HEADERS_ONCE(m4_flatten([ |
23 | dlfcn.h | |
24 | fcntl.h | |
25 | fpu_control.h | |
26 | termios.h | |
b15c5d7a MF |
27 | utime.h |
28 | linux/if_tun.h | |
29 | linux/mii.h | |
30 | linux/types.h | |
31 | net/if.h | |
32 | netinet/in.h | |
33 | netinet/tcp.h | |
34 | sys/ioctl.h | |
35 | sys/mman.h | |
a48ff3ef | 36 | sys/mount.h |
b15c5d7a MF |
37 | sys/param.h |
38 | sys/resource.h | |
b15c5d7a | 39 | sys/socket.h |
a48ff3ef MF |
40 | sys/statfs.h |
41 | sys/termio.h | |
42 | sys/termios.h | |
43 | sys/types.h | |
44 | sys/vfs.h | |
b15c5d7a | 45 | ])) |
a48ff3ef | 46 | AC_HEADER_DIRENT |
b15c5d7a | 47 | |
4cd7de78 | 48 | dnl NB: We use gnulib from ../gnulib/, so we don't probe functions it provides. |
b15c5d7a MF |
49 | AC_CHECK_FUNCS_ONCE(m4_flatten([ |
50 | __setfpucw | |
a48ff3ef | 51 | access |
b15c5d7a MF |
52 | aint |
53 | anint | |
a48ff3ef MF |
54 | cfgetispeed |
55 | cfgetospeed | |
56 | cfsetispeed | |
57 | cfsetospeed | |
58 | chdir | |
b15c5d7a | 59 | chmod |
a48ff3ef MF |
60 | dup |
61 | dup2 | |
b15c5d7a MF |
62 | execv |
63 | execve | |
a48ff3ef | 64 | fcntl |
b15c5d7a | 65 | fork |
a48ff3ef MF |
66 | fstat |
67 | fstatfs | |
b15c5d7a | 68 | ftruncate |
a48ff3ef | 69 | getdirentries |
b15c5d7a | 70 | getegid |
a48ff3ef | 71 | geteuid |
b15c5d7a | 72 | getgid |
a48ff3ef MF |
73 | getpid |
74 | getppid | |
b15c5d7a | 75 | getrusage |
a48ff3ef | 76 | gettimeofday |
b15c5d7a | 77 | getuid |
a48ff3ef | 78 | ioctl |
b15c5d7a | 79 | kill |
a48ff3ef MF |
80 | link |
81 | lseek | |
95955095 MF |
82 | lstat |
83 | mkdir | |
b15c5d7a MF |
84 | mmap |
85 | munmap | |
a48ff3ef | 86 | pipe |
b15c5d7a MF |
87 | posix_fallocate |
88 | pread | |
a48ff3ef MF |
89 | rmdir |
90 | setregid | |
91 | setreuid | |
b15c5d7a | 92 | setgid |
a48ff3ef | 93 | setuid |
b15c5d7a | 94 | sigaction |
a48ff3ef | 95 | sigprocmask |
b15c5d7a | 96 | sqrt |
a48ff3ef | 97 | stat |
b15c5d7a | 98 | strsignal |
a48ff3ef MF |
99 | symlink |
100 | tcdrain | |
101 | tcflow | |
102 | tcflush | |
103 | tcgetattr | |
104 | tcgetpgrp | |
105 | tcsendbreak | |
106 | tcsetattr | |
107 | tcsetpgrp | |
b15c5d7a MF |
108 | time |
109 | truncate | |
a48ff3ef MF |
110 | umask |
111 | unlink | |
b15c5d7a MF |
112 | utime |
113 | ])) | |
114 | ||
a48ff3ef MF |
115 | AC_STRUCT_ST_BLKSIZE |
116 | AC_STRUCT_ST_BLOCKS | |
117 | AC_STRUCT_ST_RDEV | |
118 | AC_STRUCT_TIMEZONE | |
119 | ||
b15c5d7a MF |
120 | AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino], |
121 | [struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid], | |
122 | [struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size], | |
123 | [struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime], | |
124 | [struct stat.st_mtime], [struct stat.st_ctime]], [], [], | |
125 | [[#ifdef HAVE_SYS_TYPES_H | |
126 | #include <sys/types.h> | |
127 | #endif | |
da8c9663 | 128 | #include <sys/stat.h>]]) |
b15c5d7a MF |
129 | |
130 | AC_CHECK_TYPES([__int128]) | |
131 | AC_CHECK_TYPES(socklen_t, [], [], | |
132 | [#include <sys/types.h> | |
133 | #include <sys/socket.h> | |
134 | ]) | |
135 | ||
08a7937f MF |
136 | AC_CHECK_SIZEOF([void *]) |
137 | ||
d43207b0 MF |
138 | dnl Check for struct statfs. |
139 | AC_CACHE_CHECK([for struct statfs], | |
140 | [sim_cv_struct_statfs], | |
141 | [AC_TRY_COMPILE([ | |
142 | #include <sys/types.h> | |
143 | #ifdef HAVE_SYS_PARAM_H | |
144 | #include <sys/param.h> | |
145 | #endif | |
146 | #ifdef HAVE_SYS_MOUNT_H | |
147 | #include <sys/mount.h> | |
148 | #endif | |
149 | #ifdef HAVE_SYS_VFS_H | |
150 | #include <sys/vfs.h> | |
151 | #endif | |
152 | #ifdef HAVE_SYS_STATFS_H | |
153 | #include <sys/statfs.h> | |
154 | #endif], [ | |
155 | struct statfs s; | |
156 | ], [sim_cv_struct_statfs="yes"], [sim_cv_struct_statfs="no"])]) | |
157 | AS_IF([test x"sim_cv_struct_statfs" = x"yes"], [dnl | |
158 | AC_DEFINE(HAVE_STRUCT_STATFS, 1, | |
159 | [Define if struct statfs is defined in <sys/mount.h>]) | |
160 | ]) | |
161 | ||
d4720664 MF |
162 | dnl Some System V related checks. |
163 | AC_CACHE_CHECK([if union semun defined], | |
164 | [sim_cv_has_union_semun], | |
165 | [AC_TRY_COMPILE([ | |
166 | #include <sys/types.h> | |
167 | #include <sys/ipc.h> | |
168 | #include <sys/sem.h>], [ | |
169 | union semun arg; | |
170 | ], [sim_cv_has_union_semun="yes"], [sim_cv_has_union_semun="no"])]) | |
171 | AS_IF([test x"$sim_cv_has_union_semun" = x"yes"], [dnl | |
172 | AC_DEFINE(HAVE_UNION_SEMUN, 1, | |
173 | [Define if union semun is defined in <sys/sem.h>]) | |
174 | ]) | |
175 | ||
176 | AC_CACHE_CHECK([whether System V semaphores are supported], | |
177 | [sim_cv_sysv_sem], | |
178 | [AC_TRY_COMPILE([ | |
179 | #include <sys/types.h> | |
180 | #include <sys/ipc.h> | |
181 | #include <sys/sem.h> | |
182 | #ifndef HAVE_UNION_SEMUN | |
183 | union semun { | |
184 | int val; | |
185 | struct semid_ds *buf; | |
186 | ushort *array; | |
187 | }; | |
188 | #endif], [ | |
189 | union semun arg; | |
190 | int id = semget(IPC_PRIVATE, 1, IPC_CREAT|0400); | |
191 | if (id == -1) | |
192 | return 1; | |
193 | arg.val = 0; /* avoid implicit type cast to union */ | |
194 | if (semctl(id, 0, IPC_RMID, arg) == -1) | |
195 | return 1; | |
196 | ], [sim_cv_sysv_sem="yes"], [sim_cv_sysv_sem="no"])]) | |
197 | AS_IF([test x"$sim_cv_sysv_sem" = x"yes"], [dnl | |
198 | AC_DEFINE(HAVE_SYSV_SEM, 1, [Define if System V semaphores are supported]) | |
199 | ]) | |
200 | ||
201 | AC_CACHE_CHECK([whether System V shared memory is supported], | |
202 | [sim_cv_sysv_shm], | |
203 | [AC_TRY_COMPILE([ | |
204 | #include <sys/types.h> | |
205 | #include <sys/ipc.h> | |
206 | #include <sys/shm.h>], [ | |
207 | int id = shmget(IPC_PRIVATE, 1, IPC_CREAT|0400); | |
208 | if (id == -1) | |
209 | return 1; | |
210 | if (shmctl(id, IPC_RMID, 0) == -1) | |
211 | return 1; | |
212 | ], [sim_cv_sysv_shm="yes"], [sim_cv_sysv_shm="no"])]) | |
213 | AS_IF([test x"$sim_cv_sysv_shm" = x"yes"], [dnl | |
214 | AC_DEFINE(HAVE_SYSV_SHM, 1, [Define if System V shared memory is supported]) | |
215 | ]) | |
216 | ||
6bf212a8 MF |
217 | dnl Figure out what type of termio/termios support there is |
218 | AC_CACHE_CHECK([for struct termios], | |
219 | [sim_cv_termios_struct], | |
220 | [AC_TRY_COMPILE([ | |
221 | #include <sys/types.h> | |
222 | #include <sys/termios.h>], [ | |
223 | static struct termios x; | |
224 | x.c_iflag = 0; | |
225 | x.c_oflag = 0; | |
226 | x.c_cflag = 0; | |
227 | x.c_lflag = 0; | |
228 | x.c_cc[NCCS] = 0; | |
229 | ], [sim_cv_termios_struct="yes"], [sim_cv_termios_struct="no"])]) | |
230 | if test $sim_cv_termios_struct = yes; then | |
231 | AC_DEFINE([HAVE_TERMIOS_STRUCTURE], 1, [Define if struct termios exists.]) | |
232 | fi | |
233 | ||
234 | if test "$sim_cv_termios_struct" = "yes"; then | |
235 | AC_CACHE_VAL([sim_cv_termios_cline]) | |
236 | AC_CHECK_MEMBER( | |
237 | [struct termios.c_line], | |
238 | [sim_cv_termios_cline="yes"], | |
239 | [sim_cv_termios_cline="no"], [ | |
240 | #include <sys/types.h> | |
241 | #include <sys/termios.h> | |
242 | ]) | |
243 | if test $sim_cv_termios_cline = yes; then | |
244 | AC_DEFINE([HAVE_TERMIOS_CLINE], 1, [Define if struct termios has c_line.]) | |
245 | fi | |
246 | else | |
247 | sim_cv_termios_cline=no | |
248 | fi | |
249 | ||
250 | if test "$sim_cv_termios_struct" != "yes"; then | |
251 | AC_CACHE_CHECK([for struct termio], | |
252 | [sim_cv_termio_struct], | |
253 | [AC_TRY_COMPILE([ | |
254 | #include <sys/types.h> | |
255 | #include <sys/termio.h>], [ | |
256 | static struct termio x; | |
257 | x.c_iflag = 0; | |
258 | x.c_oflag = 0; | |
259 | x.c_cflag = 0; | |
260 | x.c_lflag = 0; | |
261 | x.c_cc[NCC] = 0; | |
262 | ], [sim_cv_termio_struct="yes"], [sim_cv_termio_struct="no"])]) | |
263 | if test $sim_cv_termio_struct = yes; then | |
264 | AC_DEFINE([HAVE_TERMIO_STRUCTURE], 1, [Define if struct termio exists.]) | |
265 | fi | |
266 | else | |
267 | sim_cv_termio_struct=no | |
268 | fi | |
269 | ||
270 | if test "$sim_cv_termio_struct" = "yes"; then | |
271 | AC_CACHE_VAL([sim_cv_termio_cline]) | |
272 | AC_CHECK_MEMBER( | |
273 | [struct termio.c_line], | |
274 | [sim_cv_termio_cline="yes"], | |
275 | [sim_cv_termio_cline="no"], [ | |
276 | #include <sys/types.h> | |
277 | #include <sys/termio.h> | |
278 | ]) | |
279 | if test $sim_cv_termio_cline = yes; then | |
280 | AC_DEFINE([HAVE_TERMIO_CLINE], 1, [Define if struct termio has c_line.]) | |
281 | fi | |
282 | else | |
283 | sim_cv_termio_cline=no | |
284 | fi | |
285 | ||
b15c5d7a | 286 | dnl Types used by common code |
a48ff3ef MF |
287 | AC_TYPE_GETGROUPS |
288 | AC_TYPE_MODE_T | |
289 | AC_TYPE_OFF_T | |
290 | AC_TYPE_PID_T | |
b15c5d7a | 291 | AC_TYPE_SIGNAL |
a48ff3ef MF |
292 | AC_TYPE_SIZE_T |
293 | AC_TYPE_UID_T | |
07490bf8 | 294 | |
89cf99a9 | 295 | LT_INIT |
b5689863 | 296 | |
07490bf8 | 297 | dnl Libraries. |
05108158 MF |
298 | AC_SEARCH_LIBS([bind], [socket]) |
299 | AC_SEARCH_LIBS([gethostbyname], [nsl]) | |
300 | AC_SEARCH_LIBS([fabs], [m]) | |
301 | AC_SEARCH_LIBS([log2], [m]) | |
d57b6533 | 302 | |
05108158 | 303 | AC_SEARCH_LIBS([dlopen], [dl]) |
708aee5e | 304 | if test "${ac_cv_search_dlopen}" = "none required" || test "${ac_cv_lib_dl_dlopen}" = "yes"; then |
f050cfdd MF |
305 | PKG_CHECK_MODULES(SDL, sdl2, [dnl |
306 | SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=2" | |
f050cfdd MF |
307 | ], [ |
308 | PKG_CHECK_MODULES(SDL, sdl, [dnl | |
309 | SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=1" | |
f050cfdd MF |
310 | ], [:]) |
311 | ]) | |
c55c1f6e MF |
312 | dnl If we use SDL, we need dlopen support. |
313 | AS_IF([test -n "$SDL_CFLAGS"], [dnl | |
314 | AS_IF([test "$ac_cv_search_dlopen" = no], [dnl | |
315 | AC_MSG_WARN([SDL support requires dlopen support]) | |
316 | ]) | |
317 | ]) | |
f050cfdd MF |
318 | else |
319 | SDL_CFLAGS= | |
f050cfdd | 320 | fi |
c55c1f6e MF |
321 | dnl We dlopen the libs at runtime, so never pass down SDL_LIBS. |
322 | SDL_LIBS= | |
d57b6533 | 323 | AC_SUBST(SDL_CFLAGS) |
5d0b3088 MF |
324 | |
325 | dnl In the Cygwin environment, we need some additional flags. | |
326 | AC_CACHE_CHECK([for cygwin], sim_cv_os_cygwin, | |
327 | [AC_EGREP_CPP(lose, [ | |
328 | #ifdef __CYGWIN__ | |
329 | lose | |
330 | #endif],[sim_cv_os_cygwin=yes],[sim_cv_os_cygwin=no])]) | |
331 | ||
332 | dnl Keep in sync with gdb's configure.ac list. | |
333 | AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses], | |
334 | [TERMCAP_LIB=$ac_cv_search_tgetent], [TERMCAP_LIB=""]) | |
335 | if test x$sim_cv_os_cygwin = xyes; then | |
336 | TERMCAP_LIB="${TERMCAP_LIB} -luser32" | |
337 | fi | |
338 | AC_SUBST(TERMCAP_LIB) | |
339 | ||
340 | dnl We prefer the in-tree readline. Top-level dependencies make sure | |
341 | dnl src/readline (if it's there) is configured before src/sim. | |
342 | if test -r ../readline/Makefile; then | |
5a988617 | 343 | READLINE_LIB=../readline/readline/libreadline.a |
5d0b3088 MF |
344 | READLINE_CFLAGS='-I$(READLINE_SRC)/..' |
345 | else | |
346 | AC_CHECK_LIB(readline, readline, READLINE_LIB=-lreadline, | |
347 | AC_ERROR([the required "readline" library is missing]), $TERMCAP_LIB) | |
348 | READLINE_CFLAGS= | |
349 | fi | |
350 | AC_SUBST(READLINE_LIB) | |
351 | AC_SUBST(READLINE_CFLAGS) | |
9f046489 TO |
352 | |
353 | dnl Determine whether we have a known getopt prototype in unistd.h | |
354 | dnl to make sure that we have correct getopt declaration on | |
355 | dnl include/getopt.h. The purpose of this is to sync with other Binutils | |
356 | dnl components and this logic is copied from ld/configure.ac. | |
357 | AC_MSG_CHECKING(for a known getopt prototype in unistd.h) | |
358 | AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h, | |
359 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])], | |
360 | sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)]) | |
361 | AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h) | |
362 | if test $sim_cv_decl_getopt_unistd_h = yes; then | |
363 | AC_DEFINE([HAVE_DECL_GETOPT], 1, | |
364 | [Is the prototype for getopt in <unistd.h> in the expected format?]) | |
365 | fi | |
b15c5d7a | 366 | ]) |