From: Michael Wallner Date: Thu, 2 Feb 2017 15:00:02 +0000 (+0100) Subject: configure: add --enable-psi-maintainer-mode X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3ef8c66ab1300801bcdb15b43f9f28e77b6487b6;p=m6w6%2Fext-psi configure: add --enable-psi-maintainer-mode --- diff --git a/Makefile.frag b/Makefile.frag index c31b9d9..2898211 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -62,11 +62,11 @@ $(PHP_PSI_SRCDIR)/src/context.c: $(PHP_PSI_SRCDIR)/php_psi_consts.h $(PHP_PSI_SR # -- deps -PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep)) +PHP_PSI_DEPEND = $(PHP_PSI_BUILDDIR)/php_psi.dep $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep)) .PHONY: psi-clean-depend psi-clean-depend: - -rm -f $(PHP_PSI_DEPEND) $(PHP_PSI_BUILDDIR)/php_psi.dep + -rm -f $(PHP_PSI_DEPEND) psi-clean: psi-clean-depend @@ -75,10 +75,10 @@ $(PHP_PSI_BUILDDIR)/%.dep: $(PHP_PSI_SRCDIR)/%.c $(CPPFLAGS) $(DEFS) $(INCLUDES) $< \ || touch $@ -DEPS = -ifneq ($(DEPS),) +ifneq ($(findstring clean,$(MAKECMDGOALS)),clean) +ifneq ($(PSI_DEPS),) -include $(PHP_PSI_DEPEND) --include $(PHP_PSI_BUILDDIR)/php_psi.dep +endif endif diff --git a/config.m4 b/config.m4 index fa20964..a873ab9 100644 --- a/config.m4 +++ b/config.m4 @@ -1,5 +1,11 @@ PHP_PSI_SRCDIR=PHP_EXT_SRCDIR(psi) -PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi) + +case "PHP_EXT_BUILDDIR(psi)" in +""|.) PHP_PSI_BUILDDIR=$PHP_PSI_SRCDIR + ;; +*) PHP_PSI_BUILDDIR=PHP_EXT_BUILDDIR(psi) + ;; +esac m4_foreach(incfile, [ [ax/ax_check_sign.m4], @@ -44,13 +50,18 @@ m4_foreach(incfile, [ ]) PHP_ARG_ENABLE(psi, whether to enable PHP System Interface support, -[ --enable-psi Enable PHP System Interface support]) +[ --enable-psi Enable PSI (PHP System Interface) support]) if test "$PHP_PSI" != no; then - PHP_CONFIGURE_PART(Configuring PSI) - PHP_ARG_ENABLE(psi-posix, whether to pre-define POSIX decls, - [ --enable-psi-posix=... PSI: pre-define POSIX decls], [ ], [ ]) + [ --enable-psi-posix=... PSI: pre-define POSIX decls], [all], [no]) + + PHP_ARG_ENABLE(psi-maintainer-mode, whether to enable maintainer mode, + [ --enable-psi-maintainer-mode + PSI: enable maintainer mode + . parallel configure + . source dependencies + . extra decl wrappers], [no], [no]) PHP_ARG_WITH(psi-libjit, where to find libjit, [ --with-psi-libjit=DIR PSI: path to libjit], [ ], [ ]) @@ -69,14 +80,11 @@ if test "$PHP_PSI" != no; then #endif ], [ AC_MSG_RESULT([needs define]) - AC_DEFINE([_GNU_SOURCE], [], [ ]) + AC_DEFINE([_GNU_SOURCE], [1], [ ]) ], [ AC_MSG_RESULT([already defined]) ]) - psi_save_LIBS=$LIBS - LIBS= - PSI_LEMON PSI_CHECK_LIBJIT PSI_CHECK_LIBFFI @@ -86,39 +94,47 @@ if test "$PHP_PSI" != no; then AC_FUNC_MMAP PSI_CONFIG_INIT + + dnl basics, one-by-one PSI_CHECK_STD_TYPES PSI_CHECK_STDINT PSI_CHECK_SYS_TYPES PSI_CHECK_STDDEF - PSI_CHECK_ERRNO - PSI_CHECK_FCNTL - PSI_CHECK_GLOB - PSI_CHECK_LOCALE - PSI_CHECK_STDIO - PSI_CHECK_STDLIB - PSI_CHECK_UNISTD - PSI_CHECK_TIME - PSI_CHECK_SYS_SELECT - PSI_CHECK_SYS_SOCKET - PSI_CHECK_SYS_TIME - PSI_CHECK_SYS_TIMES - PSI_CHECK_SYS_STAT - PSI_CHECK_SYS_UIO - PSI_CHECK_SYS_UTSNAME - PSI_CHECK_NDBM - PSI_CHECK_NETDB - PSI_CHECK_NETINET_IN - PSI_CHECK_NETINET_TCP - PSI_CHECK_POLL - PSI_CHECK_SIGNAL - PSI_CHECK_SYSLOG - PSI_CHECK_WCHAR - PSI_CHECK_WCTYPE + + dnl parallel + AC_MSG_CHECKING([for POSIX modules: $PHP_PSI_POSIX]) + + PSI_CONFIG_POSIX(errno, errno.h) + PSI_CONFIG_POSIX(fcntl, fcntl.h) + PSI_CONFIG_POSIX(glob, glob.h) + PSI_CONFIG_POSIX(locale, locale.h xlocale.h) + PSI_CONFIG_POSIX(stdio, stdio.h) + PSI_CONFIG_POSIX(stdlib, stdlib.h) + PSI_CONFIG_POSIX(unistd, unistd.h) + PSI_CONFIG_POSIX(time, time.h) + PSI_CONFIG_POSIX(sys/select, sys/select.h) + PSI_CONFIG_POSIX(sys/socket, sys/socket.h) + PSI_CONFIG_POSIX(sys/time, sys/time.h) + PSI_CONFIG_POSIX(sys/times, sys/times.h) + PSI_CONFIG_POSIX(sys/stat, sys/stat.h) + PSI_CONFIG_POSIX(sys/uio, sys/uio.h) + PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h) + PSI_CONFIG_POSIX(ndbm, dnl + ndbm.h dnl posix + relic.h dnl qdbm + gdbm-ndbm.h dnl gdbm + ) + PSI_CONFIG_POSIX(netdb, netdb.h) + PSI_CONFIG_POSIX(netinet/in, netinet/in.h) + PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h) + PSI_CONFIG_POSIX(poll, poll.h) + PSI_CONFIG_POSIX(signal, signal.h) + PSI_CONFIG_POSIX(syslog, syslog.h) + PSI_CONFIG_POSIX(wchar, wchar.h) + PSI_CONFIG_POSIX(wctype, wctype.h) + PSI_CONFIG_DONE - 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) diff --git a/m4/posix/errno.m4 b/m4/posix/errno.m4 index 4d28b8b..540918d 100644 --- a/m4/posix/errno.m4 +++ b/m4/posix/errno.m4 @@ -1,5 +1,4 @@ PSI_CHECK_ERRNO() { - PSI_CONFIG_POSIX(errno, errno.h) PSI_EXTVAR(int errno) diff --git a/m4/posix/fcntl.m4 b/m4/posix/fcntl.m4 index 9e992cc..0d35efa 100644 --- a/m4/posix/fcntl.m4 +++ b/m4/posix/fcntl.m4 @@ -1,6 +1,4 @@ PSI_CHECK_FCNTL() { - PSI_CONFIG_POSIX(fcntl, fcntl.h) - PSI_CONST(F_DUPFD, int) PSI_CONST(F_DUPFD_CLOEXEC, int) PSI_CONST(F_GETFD, int) diff --git a/m4/posix/glob.m4 b/m4/posix/glob.m4 index f727d5e..942428e 100644 --- a/m4/posix/glob.m4 +++ b/m4/posix/glob.m4 @@ -1,5 +1,4 @@ PSI_CHECK_GLOB() { - PSI_CONFIG_POSIX(glob, glob.h) PSI_STRUCT(glob_t, [ size_t gl_pathc, diff --git a/m4/posix/locale.m4 b/m4/posix/locale.m4 index 3459101..64cd66f 100644 --- a/m4/posix/locale.m4 +++ b/m4/posix/locale.m4 @@ -1,6 +1,4 @@ PSI_CHECK_LOCALE() { - PSI_CONFIG_POSIX(locale, locale.h xlocale.h) - PSI_STRUCT(struct lconv, [ char *currency_symbol, char *decimal_point, diff --git a/m4/posix/ndbm.m4 b/m4/posix/ndbm.m4 index ee71591..9cbd648 100644 --- a/m4/posix/ndbm.m4 +++ b/m4/posix/ndbm.m4 @@ -1,9 +1,4 @@ PSI_CHECK_NDBM() { - PSI_CONFIG_POSIX(ndbm, dnl - ndbm.h dnl posix - relic.h dnl qdbm - gdbm-ndbm.h dnl gdbm - ) PSI_STRUCT(datum, [ void *dptr, diff --git a/m4/posix/netdb.m4 b/m4/posix/netdb.m4 index 8d5b49a..7f42126 100644 --- a/m4/posix/netdb.m4 +++ b/m4/posix/netdb.m4 @@ -1,5 +1,4 @@ PSI_CHECK_NETDB() { - PSI_CONFIG_POSIX(netdb, netdb.h) PSI_STRUCT(struct hostent, [ char *h_name, diff --git a/m4/posix/netinet_in.m4 b/m4/posix/netinet_in.m4 index 88f054b..7b26e8c 100644 --- a/m4/posix/netinet_in.m4 +++ b/m4/posix/netinet_in.m4 @@ -1,5 +1,4 @@ PSI_CHECK_NETINET_IN() { - PSI_CONFIG_POSIX(netinet/in, netinet/in.h) PSI_TYPE(in_port_t, uint) PSI_TYPE(in_addr_t, uint) diff --git a/m4/posix/netinet_tcp.m4 b/m4/posix/netinet_tcp.m4 index 4e10420..5731002 100644 --- a/m4/posix/netinet_tcp.m4 +++ b/m4/posix/netinet_tcp.m4 @@ -1,5 +1,3 @@ PSI_CHECK_NETINET_TCP() { - PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h) - PSI_CONST(TCP_NODELAY, int) } diff --git a/m4/posix/poll.m4 b/m4/posix/poll.m4 index bbbb221..b53e11b 100644 --- a/m4/posix/poll.m4 +++ b/m4/posix/poll.m4 @@ -1,5 +1,4 @@ PSI_CHECK_POLL() { - PSI_CONFIG_POSIX(poll, poll.h) PSI_STRUCT(struct pollfd, [ int fd, diff --git a/m4/posix/signal.m4 b/m4/posix/signal.m4 index ac266ac..4d954b6 100644 --- a/m4/posix/signal.m4 +++ b/m4/posix/signal.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SIGNAL() { - PSI_CONFIG_POSIX(signal, signal.h) PSI_PTHREAD diff --git a/m4/posix/stdio.m4 b/m4/posix/stdio.m4 index a2b40b5..b1307cc 100644 --- a/m4/posix/stdio.m4 +++ b/m4/posix/stdio.m4 @@ -1,6 +1,4 @@ PSI_CHECK_STDIO() { - PSI_CONFIG_POSIX(stdio, stdio.h) - PSI_STRUCT(FILE) PSI_STRUCT(fpos_t) diff --git a/m4/posix/stdlib.m4 b/m4/posix/stdlib.m4 index a2a85be..0840883 100644 --- a/m4/posix/stdlib.m4 +++ b/m4/posix/stdlib.m4 @@ -1,6 +1,4 @@ PSI_CHECK_STDLIB() { - AC_CHECK_HEADERS(stdlib.h) - PSI_STRUCT(div_t, [ int quot, int rem diff --git a/m4/posix/sys_select.m4 b/m4/posix/sys_select.m4 index 0390299..3b82f96 100644 --- a/m4/posix/sys_select.m4 +++ b/m4/posix/sys_select.m4 @@ -1,6 +1,4 @@ PSI_CHECK_SYS_SELECT() { - PSI_CONFIG_POSIX(sys/select, sys/select.h) - PSI_STRUCT(fd_set, []) PSI_CONST(FD_SETSIZE, int) diff --git a/m4/posix/sys_socket.m4 b/m4/posix/sys_socket.m4 index 6d1eaf3..bcadf33 100644 --- a/m4/posix/sys_socket.m4 +++ b/m4/posix/sys_socket.m4 @@ -1,6 +1,4 @@ PSI_CHECK_SYS_SOCKET() { - PSI_CONFIG_POSIX(sys/socket, sys/socket.h) - PSI_TYPE(socklen_t, int) PSI_TYPE(sa_family_t, uint) diff --git a/m4/posix/sys_stat.m4 b/m4/posix/sys_stat.m4 index fb44945..f89a232 100644 --- a/m4/posix/sys_stat.m4 +++ b/m4/posix/sys_stat.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SYS_STAT() { - PSI_CONFIG_POSIX(sys/stat, sys/stat.h) PSI_STRUCT(struct stat, [ dev_t st_dev, diff --git a/m4/posix/sys_time.m4 b/m4/posix/sys_time.m4 index 7dfecfd..c498c12 100644 --- a/m4/posix/sys_time.m4 +++ b/m4/posix/sys_time.m4 @@ -1,6 +1,4 @@ PSI_CHECK_SYS_TIME() { - PSI_CONFIG_POSIX(sys/time, sys/time.h) - PSI_CONST(ITIMER_REAL, int) PSI_CONST(ITIMER_VIRTUAL, int) PSI_CONST(ITIMER_PROF, int) diff --git a/m4/posix/sys_times.m4 b/m4/posix/sys_times.m4 index 3301070..0ae593c 100644 --- a/m4/posix/sys_times.m4 +++ b/m4/posix/sys_times.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SYS_TIMES() { - PSI_CONFIG_POSIX(sys/times, sys/times.h) PSI_STRUCT(struct tms, [ clock_t tms_utime, diff --git a/m4/posix/sys_uio.m4 b/m4/posix/sys_uio.m4 index 7cd4c3c..d82d9a7 100644 --- a/m4/posix/sys_uio.m4 +++ b/m4/posix/sys_uio.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SYS_UIO() { - PSI_CONFIG_POSIX(sys/uio, sys/uio.h) PSI_STRUCT(struct iovec, [ void *iov_base, diff --git a/m4/posix/sys_utsname.m4 b/m4/posix/sys_utsname.m4 index 36f49d3..a268f81 100644 --- a/m4/posix/sys_utsname.m4 +++ b/m4/posix/sys_utsname.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SYS_UTSNAME() { - PSI_CONFIG_POSIX(sys/utsname, sys/utsname.h) PSI_STRUCT(struct utsname, [ char sysname@<:@0@:>@, diff --git a/m4/posix/syslog.m4 b/m4/posix/syslog.m4 index 3547f75..2c3764c 100644 --- a/m4/posix/syslog.m4 +++ b/m4/posix/syslog.m4 @@ -1,5 +1,4 @@ PSI_CHECK_SYSLOG() { - PSI_CONFIG_POSIX(syslog, syslog.h) PSI_CONST(LOG_PID, int) PSI_CONST(LOG_CONS, int) diff --git a/m4/posix/time.m4 b/m4/posix/time.m4 index 63906e5..ea39f95 100644 --- a/m4/posix/time.m4 +++ b/m4/posix/time.m4 @@ -1,6 +1,4 @@ PSI_CHECK_TIME() { - PSI_CONFIG_POSIX(time, time.h) - PSI_CONST(CLOCKS_PER_SEC, int) PSI_CONST(CLOCK_MONOTONIC, int) PSI_CONST(CLOCK_PROCESS_CPUTIME_ID, int) @@ -35,7 +33,7 @@ PSI_CHECK_TIME() { 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(int clock_settime, [(clockid_t clk_id, const 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)]) @@ -60,5 +58,5 @@ PSI_CHECK_TIME() { PSI_MACRO(int getdate_err) PSI_EXTVAR(int daylight) PSI_EXTVAR(long timezone) - PSI_EXTVAR(char **tzname) + PSI_EXTVAR(char *tzname@<:@2@:>@) } diff --git a/m4/posix/unistd.m4 b/m4/posix/unistd.m4 index 0da8665..94be1ad 100644 --- a/m4/posix/unistd.m4 +++ b/m4/posix/unistd.m4 @@ -1,6 +1,4 @@ PSI_CHECK_UNISTD() { - PSI_CONFIG_POSIX(unistd, unistd.h) - PSI_CONST(F_LOCK, int) PSI_CONST(F_TEST, int) PSI_CONST(F_TLOCK, int) diff --git a/m4/posix/wchar.m4 b/m4/posix/wchar.m4 index f1a7026..f5932ef 100644 --- a/m4/posix/wchar.m4 +++ b/m4/posix/wchar.m4 @@ -1,5 +1,4 @@ PSI_CHECK_WCHAR() { - PSI_CONFIG_POSIX(wchar, wchar.h) PSI_TYPE(wint_t, int) PSI_STRUCT(mbstate_t) diff --git a/m4/posix/wctype.m4 b/m4/posix/wctype.m4 index 319dada..530c165 100644 --- a/m4/posix/wctype.m4 +++ b/m4/posix/wctype.m4 @@ -1,5 +1,4 @@ PSI_CHECK_WCTYPE() { - PSI_CONFIG_POSIX(wctype, wctype.h) PSI_TYPE(wctype_t, int) PSI_TYPE(wctrans_t, int) diff --git a/m4/psi/psi.m4 b/m4/psi/psi.m4 index c8eec18..b979719 100644 --- a/m4/psi/psi.m4 +++ b/m4/psi/psi.m4 @@ -16,6 +16,27 @@ 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, [ + psi_save_LIBS=$LIBS + LIBS= + + if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then + PSI_FAST_CONFIG=true + PSI_DEPS=true + PSI_EXTRA_REDIRS=true + + PHP_SUBST(PSI_DEPS) + + PSI_CONFIG_TMP=$(mktemp -d) + else + PSI_FAST_CONFIG=false + PSI_DEPS=false + if test "$PHP_DEBUG" = "1"; then + PSI_EXTRA_REDIRS=true + else + PSI_EXTRA_REDIRS=false + fi + fi + cat >$PHP_PSI_BUILDDIR/php_psi.dep <$PSI_STDINC <&AS_MESSAGE_FD + exec AS_MESSAGE_FD>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stdout.log + exec 2>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stderr.log + + dnl check for headers? + ifelse([$2],,:,[AC_CHECK_HEADERS($2)]) + + dnl chaway + cd $PSI_CONFIG_TMP/AS_TR_SH([$1]) + + dnl run checks + AS_TR_CPP([PSI_CHECK_$1]) + + dnl save libs + cat >$PSI_CONFIG_TMP/AS_TR_SH([$1])/conf.env <&66 + ) & +]) + AC_DEFUN(PSI_PTHREAD_ONCE, [ AX_PTHREAD([ LIBS="$PTHREAD_LIBS $LIBS" diff --git a/m4/psi/psi_const.m4 b/m4/psi/psi_const.m4 index 6c3cf6b..f0345ad 100644 --- a/m4/psi/psi_const.m4 +++ b/m4/psi/psi_const.m4 @@ -1,7 +1,7 @@ # psi_add_str_const(name, value) # Add a pre-defined string constant to $PSI_CONSTS psi_add_str_const() { - grep -q "\"psi\\\\\\\\$1\"" $PSI_CONSTS \ + grep -Fq "\"psi\\\\$1\"" $PSI_CONSTS \ || cat >>$PSI_CONSTS <>$PSI_CONSTS <>$PSI_FN_DECLS < unsigned char*. AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [^\(const \)?\(.*\) \([*]*\)[^ ]+$], [\2\3])]) +dnl PSI_VAR_TYPE_RETURN(decl arg) +dnl Extracts the type of a decl arg usable for return types, e.g. dnl unsigned char* buf[16] -> unsigned char**. +AC_DEFUN(PSI_VAR_TYPE_RETURN, [PSI_VAR_TYPE(m4_bpatsubst([$1], [\([^ ]+\) *@<:@[0-9]+@:>@], [* \1]))]) + dnl PSI_VAR_NAME(decl arg) dnl Extracts the var name of a decl arg, e.g. unsigned char* buf[16] -> buf. AC_DEFUN(PSI_VAR_NAME, [m4_bregexp(m4_bregexp([$1], [\([^ ]+\)$], [\1]), [\w+], [\&])]) diff --git a/psi.d/getopt.psi b/psi.d/getopt.psi index fcf1db7..ac7fd73 100644 --- a/psi.d/getopt.psi +++ b/psi.d/getopt.psi @@ -1,12 +1,12 @@ function psi\opterr(int $value) : void { - let _v = intval($value); + let opterr = intval($value); return void(opterr_set); } function psi\optind\get() : int { return to_int(optind_get); } function psi\optind\set(int $v) : void { - let _v = intval($v); + let optind = intval($v); return void(optind_set); } function psi\optopt() : int {