Remove path name from test case
[binutils-gdb.git] / sim / m4 / sim_ac_platform.m4
1 dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
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.
21 dnl NB: We use gnulib from ../gnulib/, so we don't probe headers it provides.
22 AC_CHECK_HEADERS_ONCE(m4_flatten([
23 dlfcn.h
24 fcntl.h
25 fpu_control.h
26 termios.h
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
36 sys/mount.h
37 sys/param.h
38 sys/resource.h
39 sys/socket.h
40 sys/statfs.h
41 sys/termio.h
42 sys/termios.h
43 sys/types.h
44 sys/vfs.h
45 ]))
46 AC_HEADER_DIRENT
47
48 dnl NB: We use gnulib from ../gnulib/, so we don't probe functions it provides.
49 AC_CHECK_FUNCS_ONCE(m4_flatten([
50 __setfpucw
51 access
52 aint
53 anint
54 cfgetispeed
55 cfgetospeed
56 cfsetispeed
57 cfsetospeed
58 chdir
59 chmod
60 dup
61 dup2
62 execv
63 execve
64 fcntl
65 fork
66 fstat
67 fstatfs
68 ftruncate
69 getdirentries
70 getegid
71 geteuid
72 getgid
73 getpid
74 getppid
75 getrusage
76 gettimeofday
77 getuid
78 ioctl
79 kill
80 link
81 lseek
82 lstat
83 mkdir
84 mmap
85 munmap
86 pipe
87 posix_fallocate
88 pread
89 rmdir
90 setregid
91 setreuid
92 setgid
93 setuid
94 sigaction
95 sigprocmask
96 sqrt
97 stat
98 strsignal
99 symlink
100 tcdrain
101 tcflow
102 tcflush
103 tcgetattr
104 tcgetpgrp
105 tcsendbreak
106 tcsetattr
107 tcsetpgrp
108 time
109 truncate
110 umask
111 unlink
112 utime
113 ]))
114
115 AC_STRUCT_ST_BLKSIZE
116 AC_STRUCT_ST_BLOCKS
117 AC_STRUCT_ST_RDEV
118 AC_STRUCT_TIMEZONE
119
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
128 #include <sys/stat.h>]])
129
130 AC_CHECK_TYPES([__int128])
131 AC_CHECK_TYPES(socklen_t, [], [],
132 [#include <sys/types.h>
133 #include <sys/socket.h>
134 ])
135
136 dnl Types used by common code
137 AC_TYPE_GETGROUPS
138 AC_TYPE_MODE_T
139 AC_TYPE_OFF_T
140 AC_TYPE_PID_T
141 AC_TYPE_SIGNAL
142 AC_TYPE_SIZE_T
143 AC_TYPE_UID_T
144
145 LT_INIT
146
147 dnl Libraries.
148 AC_SEARCH_LIBS([bind], [socket])
149 AC_SEARCH_LIBS([gethostbyname], [nsl])
150 AC_SEARCH_LIBS([fabs], [m])
151 AC_SEARCH_LIBS([log2], [m])
152
153 AC_SEARCH_LIBS([dlopen], [dl])
154 if test "${ac_cv_lib_dl_dlopen}" = "yes"; then
155 PKG_CHECK_MODULES(SDL, sdl2, [dnl
156 SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=2"
157 ], [
158 PKG_CHECK_MODULES(SDL, sdl, [dnl
159 SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=1"
160 ], [:])
161 ])
162 dnl If we use SDL, we need dlopen support.
163 AS_IF([test -n "$SDL_CFLAGS"], [dnl
164 AS_IF([test "$ac_cv_search_dlopen" = no], [dnl
165 AC_MSG_WARN([SDL support requires dlopen support])
166 ])
167 ])
168 else
169 SDL_CFLAGS=
170 fi
171 dnl We dlopen the libs at runtime, so never pass down SDL_LIBS.
172 SDL_LIBS=
173 AC_SUBST(SDL_CFLAGS)
174
175 dnl In the Cygwin environment, we need some additional flags.
176 AC_CACHE_CHECK([for cygwin], sim_cv_os_cygwin,
177 [AC_EGREP_CPP(lose, [
178 #ifdef __CYGWIN__
179 lose
180 #endif],[sim_cv_os_cygwin=yes],[sim_cv_os_cygwin=no])])
181
182 dnl Keep in sync with gdb's configure.ac list.
183 AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses],
184 [TERMCAP_LIB=$ac_cv_search_tgetent], [TERMCAP_LIB=""])
185 if test x$sim_cv_os_cygwin = xyes; then
186 TERMCAP_LIB="${TERMCAP_LIB} -luser32"
187 fi
188 AC_SUBST(TERMCAP_LIB)
189
190 dnl We prefer the in-tree readline. Top-level dependencies make sure
191 dnl src/readline (if it's there) is configured before src/sim.
192 if test -r ../readline/Makefile; then
193 READLINE_LIB=../readline/readline/libreadline.a
194 READLINE_CFLAGS='-I$(READLINE_SRC)/..'
195 else
196 AC_CHECK_LIB(readline, readline, READLINE_LIB=-lreadline,
197 AC_ERROR([the required "readline" library is missing]), $TERMCAP_LIB)
198 READLINE_CFLAGS=
199 fi
200 AC_SUBST(READLINE_LIB)
201 AC_SUBST(READLINE_CFLAGS)
202
203 dnl Determine whether we have a known getopt prototype in unistd.h
204 dnl to make sure that we have correct getopt declaration on
205 dnl include/getopt.h. The purpose of this is to sync with other Binutils
206 dnl components and this logic is copied from ld/configure.ac.
207 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
208 AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h,
209 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
210 sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)])
211 AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h)
212 if test $sim_cv_decl_getopt_unistd_h = yes; then
213 AC_DEFINE([HAVE_DECL_GETOPT], 1,
214 [Is the prototype for getopt in <unistd.h> in the expected format?])
215 fi
216 ])