AC_INIT(system.c) |
AC_CONFIG_HEADER(system_machine.h) |
|
AC_MODULE_INIT(_system) |
|
AC_CHECK_LIB(bind, __inet_ntoa) |
AC_CHECK_LIB(socket, socket) |
AC_CHECK_LIB(nsl, gethostbyname) |
AC_CHECK_LIB(net, __get_socket_descriptor) |
|
dnl For Cygwin |
AC_CHECK_LIB(cygipc, shmget) |
|
PIKE_AC_CHECK_OS() |
|
if test x"$pike_cv_sys_os" = xWindows_NT ; then |
# FIXME: These look suspiciously much like 32bit versions. |
# We probably want to use 64bit versions on IA64. |
LIBS="-lshell32 -lkernel32 -lws2_32 -ladvapi32 -lole32 $LIBS" |
fi |
|
AC_CHECK_HEADERS(syslog.h sys/syslog.h sys/types.h errno.h unistd.h pwd.h \ |
sys/socket.h netinet/in.h arpa/inet.h netdb.h stdarg.h winsock2.h \ |
sys/utsname.h pwd.h passwd.h shadow.h grp.h sys/stat.h winsock.h \ |
sys/systeminfo.h windows.h sys/param.h utime.h sys/utime.h sys/id.h \ |
sys/time.h sys/shm.h sys/mman.h fcntl.h sys/fcntl.h netinfo/ni.h \ |
sys/prctl.h cygwin/ipc.h cygwin/sem.h cygwin/shm.h ws2tcpip.h \ |
NewAPIs.h sys/loadavg.h) |
|
# some Linux systems have a broken resource.h that compiles anyway /Mirar |
AC_MSG_CHECKING([for working sys/resource.h]) |
AC_CACHE_VAL(pike_cv_sys_resource_h, |
[AC_TRY_COMPILE([#include <sys/resource.h>],[], |
[pike_cv_sys_resource_h=yes],[pike_cv_sys_resource_h=no])]) |
if test "x$pike_cv_sys_resource_h" = "xyes"; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_SYS_RESOURCE_H) |
else |
AC_MSG_RESULT(no) |
fi |
|
# some systems have a broken sys/user.h that doesn't compile /Mirar |
AC_MSG_CHECKING([for working sys/user.h]) |
AC_CACHE_VAL(pike_cv_sys_user_h, |
[AC_TRY_COMPILE([ |
#ifdef HAVE_UNISTD_H |
#include <unistd.h> |
#endif |
#ifdef HAVE_SYS_MMAN_H |
#include <sys/mman.h> |
#endif |
#include <sys/user.h>],[], |
[pike_cv_sys_user_h=yes],[pike_cv_sys_user_h=no])]) |
if test "x$pike_cv_sys_user_h" = "xyes"; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_SYS_USER_H) |
else |
AC_MSG_RESULT(no) |
fi |
|
if test "`uname`" = "AIX"; then |
# Pike's use of getaddrinfo SIGSEGVs for some users on some releases of |
# AIX 5L 5.1. |
# |
# AIX 5L getaddrinfo is broken prior to |
# AIX 5100-06 Recommended Maintenance |
# |
# getaddrinfo is implemented in /usr/lib/ia64l64/libc.so.1, |
# which is part of the bos.rte.libc. AIX 5100-06 contains |
# U496907 bos.rte.libc 5.1.0.59 |
# |
# Suspected causes: |
# IY29763 2 submodule getaddrinfo gets wrong sin6_len |
# IY44782 2 malloc struct sockaddr_in6 in getaddrinfo() needs to be bzero |
# IY51966 2 THIRD PARTY IMAPD CORE DUMP WHEN CALLING GETADDRINFO |
|
# Path:Fileset:Level:PTF Id:State:Type:Description |
libc_ver="`lslpp -qcl bos.rte.libc 2>/dev/null| awk -F: '{ print $3 }'`" |
case "$libc_ver" in |
5.1.0.*) |
if test "`echo $libc_ver | awk -F. '{ print $4 }'`" -lt 59; then |
AC_MSG_WARN([AIX 5.1 with libc older than 5.1.0.59 detected ($libc_ver) |
Disabling use of getaddrinfo.]) |
ac_cv_func_getaddrinfo=broken |
fi |
;; |
esac |
fi |
|
AC_HAVE_FUNCS(syslog link symlink readlink resolvepath realpath chown lchown \ |
initgroups setgroups getgroups seteuid setresuid setegid setresgid \ |
geteuid getpgrp getpgid getppid getuid getgid setuid setgid setpgrp \ |
setpgid getsid setsid \ |
getpwnam getspnam getgrnam getpwuid getgrgid \ |
getgrent setgrent endgrent getpwent setpwent endpwent \ |
gethostname gethostbyname getservbyname \ |
chroot fchroot uname sysinfo sync \ |
getgrnam_r getgrent_r getgrgid_r \ |
getpwnam_r getpwent_r getpwuid_r \ |
getspnam_r innetgr utime _utime lutimes sleep usleep nanosleep \ |
getrlimit setrlimit setproctitle \ |
setitimer getitimer mmap munmap \ |
gettimeofday settimeofday prctl inet_ntoa inet_ntop getaddrinfo \ |
getloadavg daemon) |
|
if test "x$ac_cv_func_setpgrp" = "xyes"; then |
AC_MSG_CHECKING([if setpgrp takes two arguments (BSD)]) |
AC_CACHE_VAL(pike_cv_setprgp_bsd, [ |
AC_TRY_COMPILE([ |
#include <sys/types.h> |
#ifdef HAVE_UNISTD_H |
#include <unistd.h> |
#endif /* HAVE_UNISTD_H */ |
], [ |
int prgp = setprgp(0, 0); |
], [ pike_cv_setprgp_bsd=yes ], [ pike_cv_setprgp_bsd=no ]) |
]) |
if test "x$pike_cv_setpgrp_bsd" = "xyes"; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_SETPGRP_BSD) |
else |
AC_MSG_RESULT(no) |
fi |
fi |
|
AC_MSG_CHECKING(for solaris style gethostbyname_r) |
|
AC_CACHE_VAL(pike_cv_have_solaris_gethostbyname_r, |
[ |
AC_TRY_LINK([ |
#define _REENTRANT |
#define _THREAD_SAFE |
#include <netdb.h> |
],[ |
char data[2000]; |
int h_errno; |
struct hostent result,*bar; |
gethostbyname_r("foo",&result, data, sizeof(data), h_errno)->h_name; |
],pike_cv_have_solaris_gethostbyname_r=yes, |
pike_cv_have_solaris_gethostbyname_r=no) |
]) |
|
AC_MSG_RESULT($pike_cv_have_solaris_gethostbyname_r) |
|
if test $pike_cv_have_solaris_gethostbyname_r = yes; then |
AC_DEFINE(HAVE_SOLARIS_GETHOSTBYNAME_R) |
fi |
|
|
AC_MSG_CHECKING(for OSF1 style gethostbyname_r) |
|
AC_CACHE_VAL(pike_cv_have_osf1_gethostbyname_r, |
[ |
AC_TRY_LINK([ |
#define _REENTRANT |
#define _THREAD_SAFE |
#include <netdb.h> |
],[ |
int bar; |
struct hostent result; |
struct hostent_data data; |
bar=gethostbyname_r("foo",&result, &data); |
],pike_cv_have_osf1_gethostbyname_r=yes, |
pike_cv_have_osf1_gethostbyname_r=no) |
]) |
|
AC_MSG_RESULT($pike_cv_have_osf1_gethostbyname_r) |
|
if test $pike_cv_have_osf1_gethostbyname_r = yes; then |
AC_DEFINE(HAVE_OSF1_GETHOSTBYNAME_R) |
fi |
|
AC_MSG_CHECKING(for solaris style getservbyname_r) |
|
AC_CACHE_VAL(pike_cv_have_solaris_getservbyname_r, |
[ |
AC_TRY_LINK([ |
#define _REENTRANT |
#define _THREAD_SAFE |
#include <netdb.h> |
],[ |
char data[2000]; |
struct servent result,*bar; |
getservbyname_r("foo","bar",&result, data, sizeof(data))->s_port; |
],pike_cv_have_solaris_getservbyname_r=yes, |
pike_cv_have_solaris_getservbyname_r=no) |
]) |
|
AC_MSG_RESULT($pike_cv_have_solaris_getservbyname_r) |
|
if test $pike_cv_have_solaris_getservbyname_r = yes; then |
AC_DEFINE(HAVE_SOLARIS_GETSERVBYNAME_R) |
fi |
|
|
AC_MSG_CHECKING(for OSF1 style getservbyname_r) |
|
AC_CACHE_VAL(pike_cv_have_osf1_getservbyname_r, |
[ |
AC_TRY_LINK([ |
#define _REENTRANT |
#define _THREAD_SAFE |
#include <netdb.h> |
],[ |
int bar; |
struct servent result; |
struct servent_data data; |
bar=getservbyname_r("foo","bar",&result, &data); |
],pike_cv_have_osf1_getservbyname_r=yes, |
pike_cv_have_osf1_getservbyname_r=no) |
]) |
|
AC_MSG_RESULT($pike_cv_have_osf1_getservbyname_r) |
|
if test $pike_cv_have_osf1_getservbyname_r = yes; then |
AC_DEFINE(HAVE_OSF1_GETSERVBYNAME_R) |
fi |
|
if test "$ac_cv_func_getspnam_r" = "yes"; then |
AC_MSG_CHECKING([if getspnam_r takes 4 (Solaris) or 5 (Linux) arguments]) |
AC_CACHE_VAL(pike_cv_have_solaris_getspnam_r, [ |
AC_TRY_LINK([ |
#define _REENTRANT |
#define _THREAD_SAFE |
#ifdef HAVE_PASSWD_H |
# include <passwd.h> |
# include <group.h> |
#endif /* HAVE_PASSWD_H */ |
|
#ifdef HAVE_PWD_H |
# include <pwd.h> |
#endif /* HAVE_PWD_H */ |
|
#ifdef HAVE_GRP_H |
# include <grp.h> |
#endif /* HAVE_GRP_H */ |
|
#ifdef HAVE_SHADOW_H |
# include <shadow.h> |
#endif /* HAVE_SHADOW_H */ |
], [ |
struct spwd sbuf; |
char buf[2048]; |
char *foo = getspnam_r("root", &sbuf, buf, sizeof(buf))->sp_pwdp; |
return 0; |
], [ |
pike_cv_have_solaris_getspnam_r="yes" |
], [ |
pike_cv_have_solaris_getspnam_r="no" |
]) |
]) |
if test "$pike_cv_have_solaris_getspnam_r" = "yes"; then |
AC_MSG_RESULT([4 - Solaris]) |
AC_DEFINE(HAVE_SOLARIS_GETSPNAM_R) |
else |
AC_MSG_RESULT([5 - Linux]) |
fi |
else :; fi |
|
AC_MSG_CHECKING(for h_addr_list) |
AC_CACHE_VAL(pike_cv_struct_has_h_addr_list, |
[ |
AC_TRY_COMPILE([ |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <netinet/in.h> |
#include <arpa/inet.h> |
#include <netdb.h> |
],[ |
struct hostent foo; |
foo.h_addr_list[0]; |
],pike_cv_struct_has_h_addr_list=yes,pike_cv_struct_has_h_addr_list=no) |
]) |
|
if test "$pike_cv_struct_has_h_addr_list" = yes; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_H_ADDR_LIST) |
else |
AC_MSG_RESULT(no) |
fi |
|
AC_MSG_CHECKING(for in_addr_t) |
AC_CACHE_VAL(pike_cv_type_in_addr_t, |
[ |
AC_TRY_COMPILE([ |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <netinet/in.h> |
#include <arpa/inet.h> |
#include <netdb.h> |
],[ |
in_addr_t foo; |
],pike_cv_type_in_addr_t=yes,pike_cv_type_in_addr_t=no) |
]) |
|
if test "$pike_cv_type_in_addr_t" = yes; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_IN_ADDR_T) |
else |
AC_MSG_RESULT(no) |
fi |
|
AC_MSG_CHECKING(whether struct passwd has the pw_gecos field) |
AC_CACHE_VAL(pike_cv_struct_has_pw_gecos, |
[ |
AC_TRY_COMPILE([ |
#ifdef HAVE_PASSWD_H |
# include <passwd.h> |
# include <group.h> |
#endif /* HAVE_PASSWD_H */ |
|
#ifdef HAVE_PWD_H |
# include <pwd.h> |
#endif /* HAVE_PWD_H */ |
|
#ifdef HAVE_GRP_H |
# include <grp.h> |
#endif /* HAVE_GRP_H */ |
|
#ifdef HAVE_SHADOW_H |
# include <shadow.h> |
#endif /* HAVE_SHADOW_H */ |
], [ |
static struct passwd ent; |
char *gecos; |
gecos = ent.pw_gecos; |
], pike_cv_struct_has_pw_gecos=yes, pike_cv_struct_has_pw_gecos=no) |
]) |
|
if test "$pike_cv_struct_has_pw_gecos" = yes; then |
AC_MSG_RESULT(yes) |
AC_DEFINE(HAVE_PW_GECOS) |
else |
AC_MSG_RESULT(no) |
fi |
|
AC_MSG_CHECKING(for GNU libc) |
AC_CACHE_VAL(pike_cv_glibc, [ |
AC_EGREP_CPP(no_glibc, [ |
#include <features.h> |
#ifndef __GLIBC__ |
no_glibc |
#endif |
], pike_cv_glibc=no, pike_cv_glibc=yes) |
]) |
if test "$pike_cv_glibc" = yes; then |
AC_MSG_RESULT(yes - disabling unlocked syslog calls) |
AC_DEFINE(MIGHT_HAVE_SYSLOG_RACES) |
else |
AC_MSG_RESULT(no) |
fi |
|
|
AC_MSG_CHECKING(setrlimit syntax) |
AC_CACHE_VAL(pike_cv_setrlimit_syntax_bsd43, |
[ |
AC_TRY_COMPILE([ |
#include <unistd.h> |
#ifdef HAVE_SYS_RESOURCE_H |
#include <sys/resource.h> |
#endif |
],[ |
struct rlimit rl; |
int res; |
rl.rlim_cur=60; |
rl.rlim_max=60; |
#ifdef RLIMIT_CPU |
res=setrlimit(RLIMIT_CPU,&rl); |
res=getrlimit(RLIMIT_CPU,&rl); |
#else |
res=setrlimit(0,&rl); |
res=getrlimit(0,&rl); |
#endif |
],pike_cv_setrlimit_syntax_bsd43=yes,pike_cv_setrlimit_syntax_bsd43=no) |
]) |
|
AC_CACHE_VAL(pike_cv_setrlimit_syntax_solaris, |
[ |
AC_TRY_COMPILE([ |
#include <unistd.h> |
#ifdef HAVE_SYS_RESOURCE_H |
#include <sys/resource.h> |
#endif HAVE_SYS_RESOURCE_H |
],[ |
struct rlimit rl; |
int res; |
rlim_t dummy=(rlim_t)17; |
rl.rlim_cur=(rlim_t)60; |
rl.rlim_max=(rlim_t)60; |
#ifdef RLIMIT_CPU |
res=setrlimit(RLIMIT_CPU,&rl); |
res=getrlimit(RLIMIT_CPU,&rl); |
#else |
res=setrlimit(0,&rl); |
res=getrlimit(0,&rl); |
#endif |
],pike_cv_setrlimit_syntax_standard=yes,pike_cv_setrlimit_syntax_standard=no) |
]) |
|
if test "$pike_cv_setrlimit_syntax_standard" = yes; then |
AC_MSG_RESULT(standard) |
AC_DEFINE(SETRLIMIT_SYNTAX_STANDARD) |
else if test "$pike_cv_setrlimit_syntax_bsd43" = yes; then |
AC_MSG_RESULT(BSD 4.3) |
AC_DEFINE(SETRLIMIT_SYNTAX_BSD43) |
else |
AC_MSG_RESULT(unknown) |
AC_DEFINE(SETRLIMIT_SYNTAX_UNKNOWN) |
fi |
fi |
|
|
AC_MSG_CHECKING(if get/setitimer 'which' type is tInt02) |
|
AC_CACHE_VAL(pike_cv_itimer_type_is_02, |
[ |
AC_TRY_RUN([ |
#include <sys/time.h> |
|
int main() |
{ |
if (ITIMER_REAL>=0 && ITIMER_REAL<=2 && |
ITIMER_VIRTUAL>=0 && ITIMER_VIRTUAL<=2 && |
ITIMER_PROF>=0 && ITIMER_PROF<=2) |
return 0; |
return 1; |
} |
],pike_cv_itimer_type_is_02=yes, |
pike_cv_itimer_type_is_02="not certain", |
pike_cv_itimer_type_is_02="not certain",) |
]) |
|
AC_MSG_RESULT($pike_cv_itimer_type_is_02) |
|
if test "$pike_cv_itimer_type_is_02" = yes; then |
AC_DEFINE(ITIMER_TYPE_IS_02) |
fi |
|
AC_HAVE_FUNCS(GetUserName AllocConsole AttachConsole FreeConsole) |
|
AC_OUTPUT(Makefile,echo FOO >stamp-h ) |
|