From fb1661f43586388050fd42b9702c7beefaae08f3 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 20 Oct 2016 15:47:22 +0200 Subject: [PATCH] configure: improve checks for funcs not in stdlib --- config.m4 | 42 +++++++++++++++++++++--------------------- m4/posix/ndbm.m4 | 35 +++++++++++++++++++---------------- m4/posix/signal.m4 | 12 ++++++------ m4/posix/stdlib.m4 | 6 +----- m4/posix/time.m4 | 24 ++++++++++++------------ m4/posix/unistd.m4 | 12 ++---------- m4/psi/psi.m4 | 17 ++++++++++------- m4/psi/psi_decl.m4 | 44 +++++++++++++++++++++++++++++++++++--------- 8 files changed, 106 insertions(+), 86 deletions(-) diff --git a/config.m4 b/config.m4 index df18db6..cece1cb 100644 --- a/config.m4 +++ b/config.m4 @@ -46,19 +46,19 @@ m4_foreach(incfile, [ PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support, [ --enable-psi Enable PHP System Interface support]) -PHP_ARG_ENABLE(psi-posix, whether to pre-define POSIX decls, -[ --enable-psi-posix=... PSI: pre-define POSIX decls], [ ], [ ]) +if test "$PHP_PSI" != no; then + PHP_CONFIGURE_PART(Configuring PSI) -PHP_ARG_WITH(psi-libjit, where to find libjit, -[ --with-psi-libjit=DIR PSI: path to libjit], [ ], [ ]) + PHP_ARG_ENABLE(psi-posix, whether to pre-define POSIX decls, + [ --enable-psi-posix=... PSI: pre-define POSIX decls], [ ], [ ]) -PHP_ARG_WITH(psi-libffi, where to find libffi, -[ --with-psi-libffi=DIR PSI: path to libffi], [ ], [ ]) + PHP_ARG_WITH(psi-libjit, where to find libjit, + [ --with-psi-libjit=DIR PSI: path to libjit], [ ], [ ]) -if test "$PHP_PSI" != no; then - PHP_CONFIGURE_PART(Configuring PSI) + PHP_ARG_WITH(psi-libffi, where to find libffi, + [ --with-psi-libffi=DIR PSI: path to libffi], [ ], [ ]) - save_LIBS=$LIBS + psi_save_LIBS=$LIBS LIBS= PSI_LEMON @@ -99,22 +99,22 @@ if test "$PHP_PSI" != no; then PSI_CHECK_WCTYPE PSI_CONFIG_DONE - eval_LIBS=$LIBS - LIBS=$save_LIBS - PHP_EVAL_LIBLINE($eval_LIBS, PSI_SHARED_LIBADD) + psi_eval_LIBS=$LIBS + LIBS=$psi_save_LIBS + PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD) PHP_SUBST(PSI_SHARED_LIBADD) AC_DEFINE_UNQUOTED(PHP_PSI_SHLIB_SUFFIX, ["$SHLIB_SUFFIX_NAME"], DL suffix) - AC_DEFINE_UNQUOTED([PSI_STDINC], [$PSI_STDINC], [Standard includes]) - AC_DEFINE_UNQUOTED([PSI_TYPES], [$PSI_TYPES], [Predefined types]) - AC_DEFINE_UNQUOTED([PSI_STRUCTS], [$PSI_STRUCTS], [Predefined structs]) - AC_DEFINE_UNQUOTED([PSI_UNIONS], [$PSI_UNIONS], [Predefined structs]) - AC_DEFINE_UNQUOTED([PSI_CONSTS], [$PSI_CONSTS], [Predefined constants]) - AC_DEFINE_UNQUOTED([PSI_MACROS], [$PSI_MACROS], [Redirected Macros]) - AC_DEFINE_UNQUOTED([PSI_REDIRS], [$PSI_REDIRS], [Redirected functions]) - AC_DEFINE_UNQUOTED([PSI_DECLS], [$PSI_DECLS], [Predefined functions]) - AC_DEFINE_UNQUOTED([PSI_VA_DECLS], [$PSI_VA_DECLS], [Predefined vararg functions]) + AC_DEFINE_UNQUOTED([PSI_STDINC], ["$PSI_STDINC"], [Standard includes]) + AC_DEFINE_UNQUOTED([PSI_TYPES], ["$PSI_TYPES"], [Predefined types]) + AC_DEFINE_UNQUOTED([PSI_STRUCTS], ["$PSI_STRUCTS"], [Predefined structs]) + AC_DEFINE_UNQUOTED([PSI_UNIONS], ["$PSI_UNIONS"], [Predefined structs]) + AC_DEFINE_UNQUOTED([PSI_CONSTS], ["$PSI_CONSTS"], [Predefined constants]) + AC_DEFINE_UNQUOTED([PSI_MACROS], ["$PSI_MACROS"], [Redirected Macros]) + AC_DEFINE_UNQUOTED([PSI_REDIRS], ["$PSI_REDIRS"], [Redirected functions]) + AC_DEFINE_UNQUOTED([PSI_DECLS], ["$PSI_DECLS"], [Predefined functions]) + AC_DEFINE_UNQUOTED([PSI_VA_DECLS], ["$PSI_VA_DECLS"], [Predefined vararg functions]) PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src) PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src/types) diff --git a/m4/posix/ndbm.m4 b/m4/posix/ndbm.m4 index 7b04504..ee71591 100644 --- a/m4/posix/ndbm.m4 +++ b/m4/posix/ndbm.m4 @@ -1,11 +1,9 @@ PSI_CHECK_NDBM() { - PSI_CONFIG_POSIX(ndbm, ndbm.h gdbm-ndbm.h) - - PHP_CHECK_FUNC(dbm_open, gdbm_compat) - # See http://www.gnu.org.ua/software/gdbm/manual/html_section/gdbm_19.html - if expr X"$LIBS" : "X.*-lgdbm_compat" >/dev/null; then - LIBS="-lgdbm $LIBS" - fi + PSI_CONFIG_POSIX(ndbm, dnl + ndbm.h dnl posix + relic.h dnl qdbm + gdbm-ndbm.h dnl gdbm + ) PSI_STRUCT(datum, [ void *dptr, @@ -17,13 +15,18 @@ PSI_CHECK_NDBM() { PSI_CONST(DBM_INSERT, int) PSI_CONST(DBM_REPLACE, int) - PSI_DECL(void dbm_clearerr, [(DBM *db)]) - PSI_DECL(void dbm_close, [(DBM *db)]) - PSI_DECL(int dbm_delete, [(DBM *db, datum key)]) - PSI_DECL(int dbm_error, [(DBM *db)]) - PSI_DECL(datum dbm_fetch, [(DBM *db, datum key)]) - PSI_DECL(datum dbm_firstkey, [(DBM *db)]) - PSI_DECL(datum dbm_nextkey, [(DBM *db)]) - PSI_DECL(DBM *dbm_open, [(char *file, int open_flags, mode_t file_mode)]) - PSI_DECL(int dbm_store, [(DBM *db, datum key, datum content, int store_mode)]) + PSI_DECL(void dbm_clearerr, [(DBM *db)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(void dbm_close, [(DBM *db)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(int dbm_delete, [(DBM *db, datum key)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(int dbm_error, [(DBM *db)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(datum dbm_fetch, [(DBM *db, datum key)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(datum dbm_firstkey, [(DBM *db)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(datum dbm_nextkey, [(DBM *db)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(DBM *dbm_open, [(char *file, int open_flags, mode_t file_mode)], [], [-lqdbm -lgdbm_compat]) + PSI_DECL(int dbm_store, [(DBM *db, datum key, datum content, int store_mode)], [], [-lqdbm -lgdbm_compat]) + + # See http://www.gnu.org.ua/software/gdbm/manual/html_section/gdbm_19.html + if expr X"$LIBS" : "X.*-lgdbm_compat" >/dev/null; then + LIBS="-lgdbm $LIBS" + fi } \ No newline at end of file diff --git a/m4/posix/signal.m4 b/m4/posix/signal.m4 index a9225ce..fe0c545 100644 --- a/m4/posix/signal.m4 +++ b/m4/posix/signal.m4 @@ -123,14 +123,14 @@ PSI_CHECK_SIGNAL() { int ss_flags] ) - PSI_FUNCTOR_TYPE(void sa_handler, [(int signo)]) - PSI_FUNCTOR_TYPE(void sa_sigaction, [(int signo, siginfo_t *info, ucontext_t *context)]) + PSI_FUNCTOR_TYPE(void sighandler_t, [(int signo)]) + PSI_FUNCTOR_TYPE(void sigaction_t, [(int signo, siginfo_t *info, ucontext_t *context)]) PSI_STRUCT(struct sigaction, [ - sa_handler sa_handler, + sighandler_t sa_handler, sigset_t sa_mask, int sa_flags, - sa_sigaction sa_sigaction] + sigaction_t sa_sigaction] ) PSI_STRUCT(ucontext_t, [ @@ -173,13 +173,13 @@ PSI_CHECK_SIGNAL() { PSI_DECL(int sigignore, [(int sig)]) PSI_DECL(int siginterrupt, [(int sig, int flag)]) PSI_DECL(int sigismember, [(const sigset_t *set, int signum)]) - PSI_DECL(void *signal, [(int sig, void *func)]) + PSI_DECL(sighandler_t signal, [(int sig, sighandler_t *func)]) PSI_DECL(int sigpause, [(int sig)]) PSI_DECL(int sigpending, [(sigset_t *set)]) PSI_DECL(int sigprocmask, [(int how, const sigset_t *set, sigset_t *oset)]) PSI_DECL(int sigqueue, [(pid_t pid, int sig, const union sigval value)]) PSI_DECL(int sigrelse, [(int sig)]) - PSI_DECL(void *sigset, [(int sig, void *disp)]) + PSI_DECL(sighandler_t sigset, [(int sig, sighandler_t disp)]) PSI_DECL(int sigsuspend, [(const sigset_t *sigmask)]) PSI_DECL(int sigtimedwait, [(const sigset_t *set, siginfo_t *info, const struct timespec *timeout)]) PSI_DECL(int sigwait, [(const sigset_t *set, int *sig)]) diff --git a/m4/posix/stdlib.m4 b/m4/posix/stdlib.m4 index 60a3015..f1a0c95 100644 --- a/m4/posix/stdlib.m4 +++ b/m4/posix/stdlib.m4 @@ -57,11 +57,7 @@ PSI_CHECK_STDLIB() { PSI_DECL(char *realpath, [(char *path, char *resolved)]) PSI_DECL(unsigned short *seed48, [(unsigned short seed16v@<:@3@:>@)]) PSI_DECL(int setenv, [(char *var, char *val, int overwrite)]) - - AC_SEARCH_LIBS(setkey, crypt, [ - PSI_DECL(void setkey, [(char *key)]) - ]) - + PSI_DECL(void setkey, [(char *key)], [], [-lcrypt]) PSI_DECL(char *setstate, [(char *state)]) PSI_DECL(void srand, [(unsigned seed)]) PSI_DECL(void srand48, [(long seed)]) diff --git a/m4/posix/time.m4 b/m4/posix/time.m4 index e1b4011..250e3c9 100644 --- a/m4/posix/time.m4 +++ b/m4/posix/time.m4 @@ -27,15 +27,15 @@ PSI_CHECK_TIME() { struct timespec it_interval, struct timespec it_value] ) - + PSI_DECL(char *asctime, [(struct tm *tm)]) PSI_DECL(char *asctime_r, [(struct tm *tm, char *buf)]) PSI_DECL(clock_t clock, [()]) - PSI_DECL(int clock_getcpuclockid, [(pid_t pid, clockid_t *clock_id)]) - PSI_DECL(int clock_getres, [(clockid_t clk_id, struct timespec *res)]) - PSI_DECL(int clock_gettime, [(clockid_t clk_id, struct timespec *tp)]) - PSI_DECL(int clock_nanosleep, [(clockid_t clk_id, int flags, struct timespec *rqtp, struct timespec *rmtp)]) - PSI_DECL(int clock_settime, [(clockid_t clk_id, struct timespec *tp)]) + PSI_DECL(int clock_getcpuclockid, [(pid_t pid, clockid_t *clock_id)], [], [-lrt]) + PSI_DECL(int clock_getres, [(clockid_t clk_id, struct timespec *res)], [], [-lrt]) + PSI_DECL(int clock_gettime, [(clockid_t clk_id, struct timespec *tp)], [], [-lrt]) + PSI_DECL(int clock_nanosleep, [(clockid_t clk_id, int flags, struct timespec *rqtp, struct timespec *rmtp)], [], [-lrt]) + PSI_DECL(int clock_settime, [(clockid_t clk_id, struct timespec *tp)], [], [-lrt]) PSI_DECL(char *ctime, [(time_t *t)]) PSI_DECL(char *ctime_r, [(time_t *t, char *buf)]) PSI_DECL(double difftime, [(time_t time1, time_t time0)]) @@ -47,14 +47,14 @@ PSI_CHECK_TIME() { PSI_DECL(time_t mktime, [(struct tm *tm)]) PSI_DECL(int nanosleep, [(struct timespec *rqts, struct timespec *rmts)]) PSI_DECL(size_t strftime, [(char *s, size_t max, char *fmt, struct tm *tm)]) - dnl PSI_DECL(size_t strftime_l, [(char *s, size_t max, char *fmt, struct tm *tm, locale_t l)]) + PSI_DECL(size_t strftime_l, [(char *s, size_t max, char *fmt, struct tm *tm, locale_t l)]) PSI_DECL(char *strptime, [(char *s, char *fmt, struct tm *tm)]) PSI_DECL(time_t time, [(time_t *t)]) - dnl PSI_DECL(int timer_create, [(clockid_t clk_id, struct sigevent *se, timer_t *t)]) - PSI_DECL(int timer_delete, [(timer_t t)]) - PSI_DECL(int timer_getoverrun, [(timer_t t)]) - PSI_DECL(int timer_gettime, [(timer_t t, struct itimerspec *ts)]) - PSI_DECL(int timer_settime, [(timer_t t, int flags, struct itimerspec *value, struct itimerspec *ovalue)]) + PSI_DECL(int timer_create, [(clockid_t clk_id, struct sigevent *se, timer_t *t)], [], [-lrt]) + PSI_DECL(int timer_delete, [(timer_t t)], [], [-lrt]) + PSI_DECL(int timer_getoverrun, [(timer_t t)], [], [-lrt]) + PSI_DECL(int timer_gettime, [(timer_t t, struct itimerspec *ts)], [], [-lrt]) + PSI_DECL(int timer_settime, [(timer_t t, int flags, struct itimerspec *value, struct itimerspec *ovalue)], [], [-lrt]) PSI_DECL(void tzset, [()]) PSI_EXTVAR(int daylight) diff --git a/m4/posix/unistd.m4 b/m4/posix/unistd.m4 index 2126500..fde0fe9 100644 --- a/m4/posix/unistd.m4 +++ b/m4/posix/unistd.m4 @@ -289,18 +289,10 @@ PSI_CHECK_UNISTD() { PSI_DECL(int chown, [(const char *path, uid_t owner, gid_t group)]) PSI_DECL(int close, [(int fildes)]) PSI_DECL(size_t confstr, [(int name, char *buf, size_t len)]) - - AC_SEARCH_LIBS(crypt, crypt, [ - PSI_DECL(char *crypt, [(const char *key, const char *salt)]) - ]) - + PSI_DECL(char *crypt, [(const char *key, const char *salt)], [], [-lcrypt]) PSI_DECL(int dup, [(int fildes)]) PSI_DECL(int dup2, [(int fildes, int fildes2)]) - - AC_SEARCH_LIBS(encrypt, crypt, [ - PSI_DECL(void encrypt, [(char block@<:@64@:>@, int edflag)]) - ]) - + PSI_DECL(void encrypt, [(char block@<:@64@:>@, int edflag)], [], [-lcrypt]) PSI_DECL(void _exit, [(int status)]) PSI_DECL(int execl, [(const char *path, const char *arg)], vararg) PSI_DECL(int execle, [(const char *path, const char *arg)], vararg) diff --git a/m4/psi/psi.m4 b/m4/psi/psi.m4 index 6b3668e..b0bbbf3 100644 --- a/m4/psi/psi.m4 +++ b/m4/psi/psi.m4 @@ -11,13 +11,11 @@ PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h PSI_FN_DECLS=$PHP_PSI_SRCDIR/php_psi_fn_decls.h -PSI_CONFIG_APPEND= - dnl PSI_CONFIG_INIT() dnl Creates stubs of the headers with pre-defined types etc. dnl These headers are included by src/context.c. dnl This macro must be called prior any checks for a type, struct, decl etc. -AC_DEFUN(PSI_CONFIG_INIT, [ +AC_DEFUN(PSI_CONFIG_INIT, [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_MACROS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do cat >$i < @@ -208,7 +209,9 @@ AC_INCLUDES_DEFAULT() #ifdef HAVE_FCNTL_H # include #endif -#ifdef HAVE_NDBM_H +#ifdef HAVE_RELIC_H +# include +#elif HAVE_NDBM_H # include #elif HAVE_GDBM_NDBM_H # include diff --git a/m4/psi/psi_decl.m4 b/m4/psi/psi_decl.m4 index fa2bf55..c5b90de 100644 --- a/m4/psi/psi_decl.m4 +++ b/m4/psi/psi_decl.m4 @@ -77,25 +77,51 @@ AC_DEFUN(PSI_DECL_ARG, [ psi_decl_args="[$psi_decl_args{]PSI_TYPE_PAIR(member_type)[, \"]member_name[\",] $pl, $as[}]" ]) -dnl PSI_DECL(type func, args, flags) +dnl PSI_DECL(type func, args, flags, libs) dnl Check for a function or macro declaration and a possible asm redirection. dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS/$PSI_DECLS. dnl Calls PSI_MACRO if PSI_FUNC fails. AC_DEFUN(PSI_DECL, [ - AC_REQUIRE([PSI_FUNC_LIBC_MAIN]) + AC_REQUIRE([PSI_FUNC_LIBC_MAIN])dnl + PSI_DECL_ARGS($1, $2) psi_symbol="PSI_VAR_NAME($1)" AC_CACHE_CHECK(for PSI_VAR_NAME($1), [psi_cv_fn_]PSI_VAR_NAME($1), [ + psi_decl_check= psi_symbol_redirect= - AC_TRY_LINK(PSI_INCLUDES, [ - void (*fn)(void) = (void (*)(void)) $psi_symbol; (*fn)() - ], [ - psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'` - ]) - [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_symbol_redirect + for lib in "" $4; do + decl_save_LIBS=$LIBS + LIBS=$lib + AC_TRY_LINK(PSI_INCLUDES, [ + void (*fn)(void) = (void (*)(void)) $psi_symbol; (*fn)() + ], [ + psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'` + ]) + LIBS=$decl_save_LIBS + + if test -n "$psi_symbol_redirect"; then + if test -n "$lib"; then + psi_decl_check="$psi_symbol_redirect in $lib" + else + psi_decl_check="$psi_symbol_redirect" + fi + break + fi + done + [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_decl_check ]) - case "$[psi_cv_fn_]PSI_VAR_NAME($1)" in + + psi_symbol_redirect=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]1}'` + psi_symbol_libflag=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]2}'` + + if test -n "$psi_symbol_libflag"; then + if ! expr "X$LIBS" : "X.*\b$psi_symbol_libflag\b" >/dev/null; then + LIBS="$psi_symbol_libflag $LIBS" + fi + fi + + case "$psi_symbol_redirect" in "$psi_symbol"|"_$psi_symbol") case "$PHP_DEBUG-$3" in "1-") -- 2.30.2