Index: trunk/php/luasandbox/m4/pkg.m4 |
— | — | @@ -0,0 +1,159 @@ |
| 2 | +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- |
| 3 | +# serial 1 (pkg-config-0.24) |
| 4 | +# |
| 5 | +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. |
| 6 | +# |
| 7 | +# This program is free software; you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU General Public License as published by |
| 9 | +# the Free Software Foundation; either version 2 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, but |
| 13 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +# General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU General Public License |
| 18 | +# along with this program; if not, write to the Free Software |
| 19 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | +# |
| 21 | +# As a special exception to the GNU General Public License, if you |
| 22 | +# distribute this file as part of a program that contains a |
| 23 | +# configuration script generated by Autoconf, you may include it under |
| 24 | +# the same distribution terms that you use for the rest of that program. |
| 25 | + |
| 26 | +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) |
| 27 | +# ---------------------------------- |
| 28 | +AC_DEFUN([PKG_PROG_PKG_CONFIG], |
| 29 | +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) |
| 30 | +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) |
| 31 | +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) |
| 32 | +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) |
| 33 | +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) |
| 34 | +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) |
| 35 | + |
| 36 | +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then |
| 37 | + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) |
| 38 | +fi |
| 39 | +if test -n "$PKG_CONFIG"; then |
| 40 | + _pkg_min_version=m4_default([$1], [0.9.0]) |
| 41 | + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) |
| 42 | + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then |
| 43 | + AC_MSG_RESULT([yes]) |
| 44 | + else |
| 45 | + AC_MSG_RESULT([no]) |
| 46 | + PKG_CONFIG="" |
| 47 | + fi |
| 48 | +fi[]dnl |
| 49 | +])# PKG_PROG_PKG_CONFIG |
| 50 | + |
| 51 | +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
| 52 | +# |
| 53 | +# Check to see whether a particular set of modules exists. Similar |
| 54 | +# to PKG_CHECK_MODULES(), but does not set variables or print errors. |
| 55 | +# |
| 56 | +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
| 57 | +# only at the first occurence in configure.ac, so if the first place |
| 58 | +# it's called might be skipped (such as if it is within an "if", you |
| 59 | +# have to call PKG_CHECK_EXISTS manually |
| 60 | +# -------------------------------------------------------------- |
| 61 | +AC_DEFUN([PKG_CHECK_EXISTS], |
| 62 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
| 63 | +if test -n "$PKG_CONFIG" && \ |
| 64 | + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then |
| 65 | + m4_default([$2], [:]) |
| 66 | +m4_ifvaln([$3], [else |
| 67 | + $3])dnl |
| 68 | +fi]) |
| 69 | + |
| 70 | +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) |
| 71 | +# --------------------------------------------- |
| 72 | +m4_define([_PKG_CONFIG], |
| 73 | +[if test -n "$$1"; then |
| 74 | + pkg_cv_[]$1="$$1" |
| 75 | + elif test -n "$PKG_CONFIG"; then |
| 76 | + PKG_CHECK_EXISTS([$3], |
| 77 | + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` |
| 78 | + test "x$?" != "x0" && pkg_failed=yes ], |
| 79 | + [pkg_failed=yes]) |
| 80 | + else |
| 81 | + pkg_failed=untried |
| 82 | +fi[]dnl |
| 83 | +])# _PKG_CONFIG |
| 84 | + |
| 85 | +# _PKG_SHORT_ERRORS_SUPPORTED |
| 86 | +# ----------------------------- |
| 87 | +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], |
| 88 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) |
| 89 | +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then |
| 90 | + _pkg_short_errors_supported=yes |
| 91 | +else |
| 92 | + _pkg_short_errors_supported=no |
| 93 | +fi[]dnl |
| 94 | +])# _PKG_SHORT_ERRORS_SUPPORTED |
| 95 | + |
| 96 | + |
| 97 | +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], |
| 98 | +# [ACTION-IF-NOT-FOUND]) |
| 99 | +# |
| 100 | +# |
| 101 | +# Note that if there is a possibility the first call to |
| 102 | +# PKG_CHECK_MODULES might not happen, you should be sure to include an |
| 103 | +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac |
| 104 | +# |
| 105 | +# |
| 106 | +# -------------------------------------------------------------- |
| 107 | +AC_DEFUN([PKG_CHECK_MODULES], |
| 108 | +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
| 109 | +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl |
| 110 | +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl |
| 111 | + |
| 112 | +pkg_failed=no |
| 113 | +AC_MSG_CHECKING([for $1]) |
| 114 | + |
| 115 | +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) |
| 116 | +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) |
| 117 | + |
| 118 | +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS |
| 119 | +and $1[]_LIBS to avoid the need to call pkg-config. |
| 120 | +See the pkg-config man page for more details.]) |
| 121 | + |
| 122 | +if test $pkg_failed = yes; then |
| 123 | + AC_MSG_RESULT([no]) |
| 124 | + _PKG_SHORT_ERRORS_SUPPORTED |
| 125 | + if test $_pkg_short_errors_supported = yes; then |
| 126 | + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` |
| 127 | + else |
| 128 | + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` |
| 129 | + fi |
| 130 | + # Put the nasty error message in config.log where it belongs |
| 131 | + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD |
| 132 | + |
| 133 | + m4_default([$4], [AC_MSG_ERROR( |
| 134 | +[Package requirements ($2) were not met: |
| 135 | + |
| 136 | +$$1_PKG_ERRORS |
| 137 | + |
| 138 | +Consider adjusting the PKG_CONFIG_PATH environment variable if you |
| 139 | +installed software in a non-standard prefix. |
| 140 | + |
| 141 | +_PKG_TEXT])[]dnl |
| 142 | + ]) |
| 143 | +elif test $pkg_failed = untried; then |
| 144 | + AC_MSG_RESULT([no]) |
| 145 | + m4_default([$4], [AC_MSG_FAILURE( |
| 146 | +[The pkg-config script could not be found or is too old. Make sure it |
| 147 | +is in your PATH or set the PKG_CONFIG environment variable to the full |
| 148 | +path to pkg-config. |
| 149 | + |
| 150 | +_PKG_TEXT |
| 151 | + |
| 152 | +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl |
| 153 | + ]) |
| 154 | +else |
| 155 | + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS |
| 156 | + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS |
| 157 | + AC_MSG_RESULT([yes]) |
| 158 | + $3 |
| 159 | +fi[]dnl |
| 160 | +])# PKG_CHECK_MODULES |
Index: trunk/php/luasandbox/config.m4 |
— | — | @@ -11,49 +11,23 @@ |
12 | 12 | dnl -- TS |
13 | 13 | |
14 | 14 | if test "$PHP_LUASANDBOX" != "no"; then |
15 | | - SEARCH_PREFIX="/usr/local /usr" |
16 | | - SEARCH_INCLUDE_SUBDIR="lua5.1 lua" |
17 | | - LUA_LIB_NAME=lua5.1 |
18 | | - LUA_LIB_FILE=liblua5.1.so |
| 15 | + dnl Include pkg-config macros definitions: |
| 16 | + m4_include([m4/pkg.m4]) |
| 17 | + PKG_PROG_PKG_CONFIG |
19 | 18 | |
20 | | - SEARCH_INCLUDE= |
21 | | - for prefix in $SEARCH_PREFIX; do |
22 | | - for subdir in $SEARCH_INCLUDE_SUBDIR; do |
23 | | - SEARCH_INCLUDE="$SEARCH_INCLUDE $prefix/include/$subdir" |
24 | | - done |
25 | | - done |
| 19 | + dnl We need lua5.1 or fallback to luajit: |
| 20 | + PKG_CHECK_MODULES([LUA], [lua5.1],, [ |
| 21 | + PKG_CHECK_MODULES([LUA], [luajit]) |
| 22 | + ]) |
26 | 23 | |
27 | | - LUA_INCLUDE_DIR= |
28 | | - AC_MSG_CHECKING([for lua include files in default path]) |
29 | | - for i in $SEARCH_INCLUDE; do |
30 | | - if test -r "$i/lua.h"; then |
31 | | - LUA_INCLUDE_DIR=$i |
32 | | - AC_MSG_RESULT(found in $i) |
33 | | - fi |
34 | | - done |
| 24 | + dnl LUA_LIBS and LUA_CFLAGS interprets them: |
| 25 | + PHP_EVAL_INCLINE($LUA_CFLAGS) |
| 26 | + PHP_EVAL_LIBLINE($LUA_LIBS, LUASANDBOX_SHARED_LIBADD) |
35 | 27 | |
36 | | - if test -z "$LUA_INCLUDE_DIR"; then |
37 | | - AC_MSG_RESULT([not found]) |
38 | | - AC_MSG_ERROR([Please reinstall the lua distribution]) |
39 | | - fi |
40 | | - |
41 | | - PHP_ADD_INCLUDE($LUA_INCLUDE_DIR) |
| 28 | + dnl Output results for debugging purposes: |
| 29 | + AC_MSG_NOTICE(LUA: found LUA_CFLAGS: $LUA_CFLAGS) |
| 30 | + AC_MSG_NOTICE(LUA: found LUA_LIBS: $LUA_LIBS) |
42 | 31 | |
43 | | - LUA_LIB_PREFIX= |
44 | | - AC_MSG_CHECKING([for lua library files]) |
45 | | - for i in $SEARCH_PREFIX; do |
46 | | - if test -r "$i/lib/$LUA_LIB_FILE"; then |
47 | | - AC_MSG_RESULT([found in $i]) |
48 | | - LUA_LIB_PREFIX=$i |
49 | | - fi |
50 | | - done |
51 | | - |
52 | | - if test -z "$LUA_LIB_PREFIX"; then |
53 | | - AC_MSG_RESULT([not found]) |
54 | | - AC_MSG_ERROR([Please reinstall the lua distribution]) |
55 | | - fi |
56 | | - |
57 | | - PHP_ADD_LIBRARY_WITH_PATH($LUA_LIB_NAME, $LUA_LIB_PREFIX/lib, LUASANDBOX_SHARED_LIBADD) |
58 | 32 | PHP_SUBST(LUASANDBOX_SHARED_LIBADD) |
59 | 33 | PHP_NEW_EXTENSION(luasandbox, luasandbox.c, $ext_shared) |
60 | 34 | fi |