2023-01-01 20:49:04 +08:00
|
|
|
dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
|
2021-05-18 08:34:52 +08:00
|
|
|
dnl
|
|
|
|
dnl This program is free software; you can redistribute it and/or modify
|
|
|
|
dnl it under the terms of the GNU General Public License as published by
|
|
|
|
dnl the Free Software Foundation; either version 3 of the License, or
|
|
|
|
dnl (at your option) any later version.
|
|
|
|
dnl
|
|
|
|
dnl This program is distributed in the hope that it will be useful,
|
|
|
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
dnl GNU General Public License for more details.
|
|
|
|
dnl
|
|
|
|
dnl You should have received a copy of the GNU General Public License
|
|
|
|
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
dnl
|
|
|
|
dnl Check for various platform settings.
|
|
|
|
AC_DEFUN([SIM_AC_PLATFORM],
|
|
|
|
[dnl
|
|
|
|
dnl Check for common headers.
|
|
|
|
dnl NB: You can assume C11 headers exist.
|
2023-01-16 17:35:48 +08:00
|
|
|
dnl NB: We use gnulib from ../gnulib/, so we don't probe headers it provides.
|
2021-05-18 08:34:52 +08:00
|
|
|
AC_CHECK_HEADERS_ONCE(m4_flatten([
|
|
|
|
dlfcn.h
|
|
|
|
fcntl.h
|
|
|
|
fpu_control.h
|
|
|
|
termios.h
|
|
|
|
utime.h
|
|
|
|
linux/if_tun.h
|
|
|
|
linux/mii.h
|
|
|
|
linux/types.h
|
|
|
|
net/if.h
|
|
|
|
netinet/in.h
|
|
|
|
netinet/tcp.h
|
|
|
|
sys/ioctl.h
|
|
|
|
sys/mman.h
|
2021-06-13 01:18:29 +08:00
|
|
|
sys/mount.h
|
2021-05-18 08:34:52 +08:00
|
|
|
sys/param.h
|
|
|
|
sys/resource.h
|
|
|
|
sys/socket.h
|
2021-06-13 01:18:29 +08:00
|
|
|
sys/statfs.h
|
|
|
|
sys/termio.h
|
|
|
|
sys/termios.h
|
|
|
|
sys/types.h
|
|
|
|
sys/vfs.h
|
2021-05-18 08:34:52 +08:00
|
|
|
]))
|
2021-06-13 01:18:29 +08:00
|
|
|
AC_HEADER_DIRENT
|
2021-05-18 08:34:52 +08:00
|
|
|
|
2023-01-16 17:35:48 +08:00
|
|
|
dnl NB: We use gnulib from ../gnulib/, so we don't probe functions it provides.
|
2021-05-18 08:34:52 +08:00
|
|
|
AC_CHECK_FUNCS_ONCE(m4_flatten([
|
|
|
|
__setfpucw
|
2021-06-13 01:18:29 +08:00
|
|
|
access
|
2021-05-18 08:34:52 +08:00
|
|
|
aint
|
|
|
|
anint
|
2021-06-13 01:18:29 +08:00
|
|
|
cfgetispeed
|
|
|
|
cfgetospeed
|
|
|
|
cfsetispeed
|
|
|
|
cfsetospeed
|
|
|
|
chdir
|
2021-05-18 08:34:52 +08:00
|
|
|
chmod
|
2021-06-13 01:18:29 +08:00
|
|
|
dup
|
|
|
|
dup2
|
2021-05-18 08:34:52 +08:00
|
|
|
execv
|
|
|
|
execve
|
2021-06-13 01:18:29 +08:00
|
|
|
fcntl
|
2021-05-18 08:34:52 +08:00
|
|
|
fork
|
2021-06-13 01:18:29 +08:00
|
|
|
fstat
|
|
|
|
fstatfs
|
2021-05-18 08:34:52 +08:00
|
|
|
ftruncate
|
2021-06-13 01:18:29 +08:00
|
|
|
getdirentries
|
2021-05-18 08:34:52 +08:00
|
|
|
getegid
|
2021-06-13 01:18:29 +08:00
|
|
|
geteuid
|
2021-05-18 08:34:52 +08:00
|
|
|
getgid
|
2021-06-13 01:18:29 +08:00
|
|
|
getpid
|
|
|
|
getppid
|
2021-05-18 08:34:52 +08:00
|
|
|
getrusage
|
2021-06-13 01:18:29 +08:00
|
|
|
gettimeofday
|
2021-05-18 08:34:52 +08:00
|
|
|
getuid
|
2021-06-13 01:18:29 +08:00
|
|
|
ioctl
|
2021-05-18 08:34:52 +08:00
|
|
|
kill
|
2021-06-13 01:18:29 +08:00
|
|
|
link
|
|
|
|
lseek
|
2022-11-10 01:19:45 +08:00
|
|
|
lstat
|
|
|
|
mkdir
|
2021-05-18 08:34:52 +08:00
|
|
|
mmap
|
|
|
|
munmap
|
2021-06-13 01:18:29 +08:00
|
|
|
pipe
|
2021-05-18 08:34:52 +08:00
|
|
|
posix_fallocate
|
|
|
|
pread
|
2021-06-13 01:18:29 +08:00
|
|
|
rmdir
|
|
|
|
setregid
|
|
|
|
setreuid
|
2021-05-18 08:34:52 +08:00
|
|
|
setgid
|
2021-06-13 01:18:29 +08:00
|
|
|
setuid
|
2021-05-18 08:34:52 +08:00
|
|
|
sigaction
|
2021-06-13 01:18:29 +08:00
|
|
|
sigprocmask
|
2021-05-18 08:34:52 +08:00
|
|
|
sqrt
|
2021-06-13 01:18:29 +08:00
|
|
|
stat
|
2021-05-18 08:34:52 +08:00
|
|
|
strsignal
|
2021-06-13 01:18:29 +08:00
|
|
|
symlink
|
|
|
|
tcdrain
|
|
|
|
tcflow
|
|
|
|
tcflush
|
|
|
|
tcgetattr
|
|
|
|
tcgetpgrp
|
|
|
|
tcsendbreak
|
|
|
|
tcsetattr
|
|
|
|
tcsetpgrp
|
2021-05-18 08:34:52 +08:00
|
|
|
time
|
|
|
|
truncate
|
2021-06-13 01:18:29 +08:00
|
|
|
umask
|
|
|
|
unlink
|
2021-05-18 08:34:52 +08:00
|
|
|
utime
|
|
|
|
]))
|
|
|
|
|
2021-06-13 01:18:29 +08:00
|
|
|
AC_STRUCT_ST_BLKSIZE
|
|
|
|
AC_STRUCT_ST_BLOCKS
|
|
|
|
AC_STRUCT_ST_RDEV
|
|
|
|
AC_STRUCT_TIMEZONE
|
|
|
|
|
2021-05-18 08:34:52 +08:00
|
|
|
AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
|
|
|
|
[struct stat.st_mode], [struct stat.st_nlink], [struct stat.st_uid],
|
|
|
|
[struct stat.st_gid], [struct stat.st_rdev], [struct stat.st_size],
|
|
|
|
[struct stat.st_blksize], [struct stat.st_blocks], [struct stat.st_atime],
|
|
|
|
[struct stat.st_mtime], [struct stat.st_ctime]], [], [],
|
|
|
|
[[#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
2023-01-16 17:42:47 +08:00
|
|
|
#include <sys/stat.h>]])
|
2021-05-18 08:34:52 +08:00
|
|
|
|
|
|
|
AC_CHECK_TYPES([__int128])
|
|
|
|
AC_CHECK_TYPES(socklen_t, [], [],
|
|
|
|
[#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
])
|
|
|
|
|
2024-01-11 11:25:51 +08:00
|
|
|
AC_CHECK_SIZEOF([void *])
|
|
|
|
|
2024-01-02 12:32:29 +08:00
|
|
|
dnl Check for struct statfs.
|
|
|
|
AC_CACHE_CHECK([for struct statfs],
|
|
|
|
[sim_cv_struct_statfs],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_MOUNT_H
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_VFS_H
|
|
|
|
#include <sys/vfs.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_STATFS_H
|
|
|
|
#include <sys/statfs.h>
|
|
|
|
#endif], [
|
|
|
|
struct statfs s;
|
|
|
|
], [sim_cv_struct_statfs="yes"], [sim_cv_struct_statfs="no"])])
|
|
|
|
AS_IF([test x"sim_cv_struct_statfs" = x"yes"], [dnl
|
|
|
|
AC_DEFINE(HAVE_STRUCT_STATFS, 1,
|
|
|
|
[Define if struct statfs is defined in <sys/mount.h>])
|
|
|
|
])
|
|
|
|
|
2024-01-02 12:15:46 +08:00
|
|
|
dnl Some System V related checks.
|
|
|
|
AC_CACHE_CHECK([if union semun defined],
|
|
|
|
[sim_cv_has_union_semun],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/sem.h>], [
|
|
|
|
union semun arg;
|
|
|
|
], [sim_cv_has_union_semun="yes"], [sim_cv_has_union_semun="no"])])
|
|
|
|
AS_IF([test x"$sim_cv_has_union_semun" = x"yes"], [dnl
|
|
|
|
AC_DEFINE(HAVE_UNION_SEMUN, 1,
|
|
|
|
[Define if union semun is defined in <sys/sem.h>])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([whether System V semaphores are supported],
|
|
|
|
[sim_cv_sysv_sem],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/sem.h>
|
|
|
|
#ifndef HAVE_UNION_SEMUN
|
|
|
|
union semun {
|
|
|
|
int val;
|
|
|
|
struct semid_ds *buf;
|
|
|
|
ushort *array;
|
|
|
|
};
|
|
|
|
#endif], [
|
|
|
|
union semun arg;
|
|
|
|
int id = semget(IPC_PRIVATE, 1, IPC_CREAT|0400);
|
|
|
|
if (id == -1)
|
|
|
|
return 1;
|
|
|
|
arg.val = 0; /* avoid implicit type cast to union */
|
|
|
|
if (semctl(id, 0, IPC_RMID, arg) == -1)
|
|
|
|
return 1;
|
|
|
|
], [sim_cv_sysv_sem="yes"], [sim_cv_sysv_sem="no"])])
|
|
|
|
AS_IF([test x"$sim_cv_sysv_sem" = x"yes"], [dnl
|
|
|
|
AC_DEFINE(HAVE_SYSV_SEM, 1, [Define if System V semaphores are supported])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([whether System V shared memory is supported],
|
|
|
|
[sim_cv_sysv_shm],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>], [
|
|
|
|
int id = shmget(IPC_PRIVATE, 1, IPC_CREAT|0400);
|
|
|
|
if (id == -1)
|
|
|
|
return 1;
|
|
|
|
if (shmctl(id, IPC_RMID, 0) == -1)
|
|
|
|
return 1;
|
|
|
|
], [sim_cv_sysv_shm="yes"], [sim_cv_sysv_shm="no"])])
|
|
|
|
AS_IF([test x"$sim_cv_sysv_shm" = x"yes"], [dnl
|
|
|
|
AC_DEFINE(HAVE_SYSV_SHM, 1, [Define if System V shared memory is supported])
|
|
|
|
])
|
|
|
|
|
2024-01-02 12:57:12 +08:00
|
|
|
dnl Figure out what type of termio/termios support there is
|
|
|
|
AC_CACHE_CHECK([for struct termios],
|
|
|
|
[sim_cv_termios_struct],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/termios.h>], [
|
|
|
|
static struct termios x;
|
|
|
|
x.c_iflag = 0;
|
|
|
|
x.c_oflag = 0;
|
|
|
|
x.c_cflag = 0;
|
|
|
|
x.c_lflag = 0;
|
|
|
|
x.c_cc[NCCS] = 0;
|
|
|
|
], [sim_cv_termios_struct="yes"], [sim_cv_termios_struct="no"])])
|
|
|
|
if test $sim_cv_termios_struct = yes; then
|
|
|
|
AC_DEFINE([HAVE_TERMIOS_STRUCTURE], 1, [Define if struct termios exists.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$sim_cv_termios_struct" = "yes"; then
|
|
|
|
AC_CACHE_VAL([sim_cv_termios_cline])
|
|
|
|
AC_CHECK_MEMBER(
|
|
|
|
[struct termios.c_line],
|
|
|
|
[sim_cv_termios_cline="yes"],
|
|
|
|
[sim_cv_termios_cline="no"], [
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
])
|
|
|
|
if test $sim_cv_termios_cline = yes; then
|
|
|
|
AC_DEFINE([HAVE_TERMIOS_CLINE], 1, [Define if struct termios has c_line.])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
sim_cv_termios_cline=no
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$sim_cv_termios_struct" != "yes"; then
|
|
|
|
AC_CACHE_CHECK([for struct termio],
|
|
|
|
[sim_cv_termio_struct],
|
|
|
|
[AC_TRY_COMPILE([
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/termio.h>], [
|
|
|
|
static struct termio x;
|
|
|
|
x.c_iflag = 0;
|
|
|
|
x.c_oflag = 0;
|
|
|
|
x.c_cflag = 0;
|
|
|
|
x.c_lflag = 0;
|
|
|
|
x.c_cc[NCC] = 0;
|
|
|
|
], [sim_cv_termio_struct="yes"], [sim_cv_termio_struct="no"])])
|
|
|
|
if test $sim_cv_termio_struct = yes; then
|
|
|
|
AC_DEFINE([HAVE_TERMIO_STRUCTURE], 1, [Define if struct termio exists.])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
sim_cv_termio_struct=no
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$sim_cv_termio_struct" = "yes"; then
|
|
|
|
AC_CACHE_VAL([sim_cv_termio_cline])
|
|
|
|
AC_CHECK_MEMBER(
|
|
|
|
[struct termio.c_line],
|
|
|
|
[sim_cv_termio_cline="yes"],
|
|
|
|
[sim_cv_termio_cline="no"], [
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/termio.h>
|
|
|
|
])
|
|
|
|
if test $sim_cv_termio_cline = yes; then
|
|
|
|
AC_DEFINE([HAVE_TERMIO_CLINE], 1, [Define if struct termio has c_line.])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
sim_cv_termio_cline=no
|
|
|
|
fi
|
|
|
|
|
2021-05-18 08:34:52 +08:00
|
|
|
dnl Types used by common code
|
2021-06-13 01:18:29 +08:00
|
|
|
AC_TYPE_GETGROUPS
|
|
|
|
AC_TYPE_MODE_T
|
|
|
|
AC_TYPE_OFF_T
|
|
|
|
AC_TYPE_PID_T
|
2021-05-18 08:34:52 +08:00
|
|
|
AC_TYPE_SIGNAL
|
2021-06-13 01:18:29 +08:00
|
|
|
AC_TYPE_SIZE_T
|
|
|
|
AC_TYPE_UID_T
|
2021-06-18 13:58:00 +08:00
|
|
|
|
2022-11-03 15:50:32 +08:00
|
|
|
LT_INIT
|
2021-06-18 14:03:44 +08:00
|
|
|
|
2021-06-18 13:58:00 +08:00
|
|
|
dnl Libraries.
|
2022-11-03 16:21:12 +08:00
|
|
|
AC_SEARCH_LIBS([bind], [socket])
|
|
|
|
AC_SEARCH_LIBS([gethostbyname], [nsl])
|
|
|
|
AC_SEARCH_LIBS([fabs], [m])
|
|
|
|
AC_SEARCH_LIBS([log2], [m])
|
2021-06-26 22:43:27 +08:00
|
|
|
|
2022-11-03 16:21:12 +08:00
|
|
|
AC_SEARCH_LIBS([dlopen], [dl])
|
2023-12-07 11:28:40 +08:00
|
|
|
if test "${ac_cv_search_dlopen}" = "none required" || test "${ac_cv_lib_dl_dlopen}" = "yes"; then
|
2021-09-14 10:45:19 +08:00
|
|
|
PKG_CHECK_MODULES(SDL, sdl2, [dnl
|
|
|
|
SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=2"
|
|
|
|
], [
|
|
|
|
PKG_CHECK_MODULES(SDL, sdl, [dnl
|
|
|
|
SDL_CFLAGS="${SDL_CFLAGS} -DHAVE_SDL=1"
|
|
|
|
], [:])
|
|
|
|
])
|
2022-11-03 18:38:46 +08:00
|
|
|
dnl If we use SDL, we need dlopen support.
|
|
|
|
AS_IF([test -n "$SDL_CFLAGS"], [dnl
|
|
|
|
AS_IF([test "$ac_cv_search_dlopen" = no], [dnl
|
|
|
|
AC_MSG_WARN([SDL support requires dlopen support])
|
|
|
|
])
|
|
|
|
])
|
2021-09-14 10:45:19 +08:00
|
|
|
else
|
|
|
|
SDL_CFLAGS=
|
|
|
|
fi
|
2022-11-03 18:38:46 +08:00
|
|
|
dnl We dlopen the libs at runtime, so never pass down SDL_LIBS.
|
|
|
|
SDL_LIBS=
|
2021-06-26 22:43:27 +08:00
|
|
|
AC_SUBST(SDL_CFLAGS)
|
2021-06-26 22:49:32 +08:00
|
|
|
|
|
|
|
dnl In the Cygwin environment, we need some additional flags.
|
|
|
|
AC_CACHE_CHECK([for cygwin], sim_cv_os_cygwin,
|
|
|
|
[AC_EGREP_CPP(lose, [
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
lose
|
|
|
|
#endif],[sim_cv_os_cygwin=yes],[sim_cv_os_cygwin=no])])
|
|
|
|
|
|
|
|
dnl Keep in sync with gdb's configure.ac list.
|
|
|
|
AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses],
|
|
|
|
[TERMCAP_LIB=$ac_cv_search_tgetent], [TERMCAP_LIB=""])
|
|
|
|
if test x$sim_cv_os_cygwin = xyes; then
|
|
|
|
TERMCAP_LIB="${TERMCAP_LIB} -luser32"
|
|
|
|
fi
|
|
|
|
AC_SUBST(TERMCAP_LIB)
|
|
|
|
|
|
|
|
dnl We prefer the in-tree readline. Top-level dependencies make sure
|
|
|
|
dnl src/readline (if it's there) is configured before src/sim.
|
|
|
|
if test -r ../readline/Makefile; then
|
2022-11-05 22:21:31 +08:00
|
|
|
READLINE_LIB=../readline/readline/libreadline.a
|
2021-06-26 22:49:32 +08:00
|
|
|
READLINE_CFLAGS='-I$(READLINE_SRC)/..'
|
|
|
|
else
|
|
|
|
AC_CHECK_LIB(readline, readline, READLINE_LIB=-lreadline,
|
|
|
|
AC_ERROR([the required "readline" library is missing]), $TERMCAP_LIB)
|
|
|
|
READLINE_CFLAGS=
|
|
|
|
fi
|
|
|
|
AC_SUBST(READLINE_LIB)
|
|
|
|
AC_SUBST(READLINE_CFLAGS)
|
2023-01-04 09:33:29 +08:00
|
|
|
|
|
|
|
dnl Determine whether we have a known getopt prototype in unistd.h
|
|
|
|
dnl to make sure that we have correct getopt declaration on
|
|
|
|
dnl include/getopt.h. The purpose of this is to sync with other Binutils
|
|
|
|
dnl components and this logic is copied from ld/configure.ac.
|
|
|
|
AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
|
|
|
|
AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h,
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
|
|
|
|
sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)])
|
|
|
|
AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h)
|
|
|
|
if test $sim_cv_decl_getopt_unistd_h = yes; then
|
|
|
|
AC_DEFINE([HAVE_DECL_GETOPT], 1,
|
|
|
|
[Is the prototype for getopt in <unistd.h> in the expected format?])
|
|
|
|
fi
|
2021-05-18 08:34:52 +08:00
|
|
|
])
|