You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2012/06/12 17:51:36 UTC

[1/50] git commit: Replace ax_lua.m4 with lua.m4 from httpd

Updated Branches:
  refs/heads/jpeach/lua c2e9b63f7 -> 03eedc134 (forced update)


Replace ax_lua.m4 with lua.m4 from httpd


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f015b965
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f015b965
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f015b965

Branch: refs/heads/jpeach/lua
Commit: f015b965dde8bbad952c73fc6247d4cfd120de08
Parents: 4ada423
Author: James Peach <jp...@apache.org>
Authored: Fri Apr 27 20:55:16 2012 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue Jun 12 08:48:39 2012 -0700

----------------------------------------------------------------------
 build/ax_lua.m4         |  199 ------------------------------------------
 build/lua.m4            |  140 +++++++++++++++++++++++++++++
 configure.ac            |   13 ++--
 plugins/lua/Makefile.am |    4 +-
 4 files changed, 149 insertions(+), 207 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f015b965/build/ax_lua.m4
----------------------------------------------------------------------
diff --git a/build/ax_lua.m4 b/build/ax_lua.m4
deleted file mode 100644
index 5ee0915..0000000
--- a/build/ax_lua.m4
+++ /dev/null
@@ -1,199 +0,0 @@
-# ===========================================================================
-#          http://www.gnu.org/software/autoconf-archive/ax_lua.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_WITH_LUA
-#   AX_PROG_LUA [(MIN-VERSION, [TOO-BIG-VERSION])]
-#   AX_LUA_VERSION (MIN-VERSION, [TOO-BIG-VERSION])
-#   AX_LUA_HEADERS
-#   AX_LUA_HEADERS_VERSION (MIN-VERSION, [TOO-BIG-VERSION])
-#   AX_LUA_LIBS
-#   AX_LUA_READLINE
-#
-# DESCRIPTION
-#
-#   Detect Lua interpreter, headers and libraries, optionally enforcing a
-#   particular range of versions. If only one version is given, then exactly
-#   this version is required.
-#
-#   AX_WITH_LUA searches for a Lua interpreter and defines LUA if found.
-#
-#   AX_PROG_LUA searches for a Lua interpreter in the given version range,
-#   if any, and defines LUA if found, or stops with an error if not.
-#
-#   AX_LUA_VERSION checks that the version of Lua is at least MIN-VERSION
-#   and less than TOO-BIG-VERSION, if given.
-#
-#   AX_LUA_HEADERS searches for Lua headers and defines HAVE_LUA_H and
-#   HAVE_LUALIB_H if found, and defines LUA_INCLUDE to the preprocessor
-#   flags needed, if any.
-#
-#   AX_LUA_HEADERS_VERSION checks that the Lua headers' version is at least
-#   MIN-VERSION, and less than TOO-BIG-VERSION, if given.
-#
-#   AX_LUA_LIBS searches for Lua libraries and defines LUA_LIB if found.
-#
-#   AX_LUA_READLINE configures Lua to be built with readline support, if
-#   available. This macro requires AX_LIB_READLINE.
-#
-#   Versions are specified as three-digit integers whose first digit is the
-#   major version and last two are the minor version (the same format as
-#   LUA_VERSION_NUM in lua.h); e.g. 501 for Lua 5.1. The revision (e.g. the
-#   "3" in "5.1.3") is ignored.
-#
-#   The following options are added by these macros:
-#
-#     --with-lua-suffix=ARG     Lua binaries and library files are
-#                               suffixed with ARG.
-#
-# LICENSE
-#
-#   Copyright (c) 2011 Reuben Thomas <rr...@sc3d.org>
-#   Copyright (c) 2009 Matthieu Moy <Ma...@imag.fr>
-#   Copyright (c) 2009 Tom Payne <tw...@gmail.com>
-#
-#   This program is free software: you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation, either version 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program is distributed in the hope that it will be useful, but
-#   WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 16
-
-dnl Helper function to declare extra options
-AC_DEFUN([_AX_LUA_OPTS],
-   [AC_ARG_WITH([lua-suffix],
-     [AS_HELP_STRING([--with-lua-suffix=ARG],
-        [Lua binary and library files are suffixed with ARG])])])dnl
-
-AC_DEFUN([AX_WITH_LUA],
-  [_AX_LUA_OPTS
-  if test "x$LUA" = x; then
-    AC_PATH_PROG(LUA, lua$with_lua_suffix)
-  fi])dnl
-
-AC_DEFUN([AX_PROG_LUA],
-  [AX_WITH_LUA
-  if test -z "$LUA"; then
-    AC_MSG_FAILURE([Lua not found])
-  fi
-  if test -n "$1"; then
-    AX_LUA_VERSION($1, $2)
-  fi
-  AC_SUBST(LUA)])dnl
-
-dnl Helper function to parse minimum & maximum versions
-AC_DEFUN([_AX_LUA_VERSIONS],
-  [lua_min_version=$1
-  lua_max_version=$2
-  if test "x$lua_min_version" = x; then
-    lua_min_version=0
-  fi
-  if test "x$lua_max_version" = x; then
-    lua_max_version=$(($lua_min_version + 1))
-  fi])
-
-AC_DEFUN([AX_LUA_VERSION],
-  [_AX_LUA_OPTS
-  _AX_LUA_VERSIONS($1, $2)
-  AC_MSG_CHECKING([Lua version is in range $lua_min_version <= v < $lua_max_version])
-  if test "x$LUA" != x; then
-    lua_text_version=$(LUA_INIT= $LUA -e 'print(_VERSION)' 2>&1 | cut -d' ' -f2)
-    case $lua_text_version in
-    5.2*)
-      lua_version=502
-      ;;
-    5.1*)
-      lua_version=501
-      ;;
-    5.0*)
-      lua_version=500
-      ;;
-    4.0*)
-      lua_version=400
-      ;;
-    *)
-      lua_version=-1
-      ;;
-    esac
-    if test $lua_version -ge "$lua_min_version" && test $lua_version -lt "$lua_max_version"; then
-      AC_MSG_RESULT([yes])
-    else
-      AC_MSG_RESULT([no])
-      AC_MSG_FAILURE([Lua version not in desired range.])
-    fi
-  else
-    AC_MSG_RESULT([no])
-    AC_MSG_FAILURE([Lua version not in desired range.])
-  fi])dnl
-
-AC_DEFUN([AX_LUA_HEADERS],
-  [_AX_LUA_OPTS
-  LUA_OLD_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
-  AC_CHECK_HEADERS([lua.h lualib.h])
-  CPPFLAGS="$LUA_OLD_CPPFLAGS"])dnl
-
-AC_DEFUN([AX_LUA_LIBS],
-  [_AX_LUA_OPTS
-  AC_CHECK_LIB([m], [exp], [lua_extra_libs="$lua_extra_libs -lm"], [])
-  AC_CHECK_LIB([dl], [dlopen], [lua_extra_libs="$lua_extra_libs -ldl"], [])
-  AC_CHECK_LIB([lua$with_lua_suffix],
-    [lua_load],
-    [LUA_LIB="$LUA_LIB -llua$with_lua_suffix $lua_extra_libs"],
-    [],
-    [$LUA_LIB $lua_extra_libs])])dnl
-
-AC_DEFUN([AX_LUA_HEADERS_VERSION],
-  [_AX_LUA_OPTS
-  _AX_LUA_VERSIONS($1, $2)
-  AC_MSG_CHECKING([lua.h version is in range $lua_min_version <= v < $lua_max_version])
-  LUA_OLD_LIBS="$LIBS"
-  LIBS="$LIBS $LUA_LIB"
-  LUA_OLD_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <lua.h>
-#include <stdlib.h>
-#include <stdio.h>
-int main()
-{
-  printf("(found %s, %d)... ", LUA_VERSION, LUA_VERSION_NUM);
-  if (LUA_VERSION_NUM >= $lua_min_version && LUA_VERSION_NUM < $lua_max_version)
-    exit(EXIT_SUCCESS);
-  exit(EXIT_FAILURE);
-}
-]])],
-  [AC_MSG_RESULT([yes])],
-  [AC_MSG_RESULT([no])
-  AC_MSG_FAILURE([lua.h version not in desired range])])
-  LIBS="$LUA_OLD_LIBS"
-  CPPFLAGS="$LUA_OLD_CPPFLAGS"])dnl
-
-AC_DEFUN([AX_LUA_READLINE],
-  [AX_LIB_READLINE
-  if test -n "$ac_cv_header_readline_readline_h" && test -n "$ac_cv_header_readline_history_h"; then
-    LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS"
-  fi])dnl

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f015b965/build/lua.m4
----------------------------------------------------------------------
diff --git a/build/lua.m4 b/build/lua.m4
new file mode 100644
index 0000000..71e4e29
--- /dev/null
+++ b/build/lua.m4
@@ -0,0 +1,140 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements.  See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License.  You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+dnl Check for Lua 5.1 Libraries
+dnl
+dnl CHECK_LUA(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
+dnl Sets:
+dnl  LUA_CFLAGS
+dnl  LUA_LIBS
+AC_DEFUN([CHECK_LUA],
+[dnl
+
+AC_ARG_WITH(
+    lua,
+    [AC_HELP_STRING([--with-lua=PATH],[Path to the Lua 5.1 prefix])],
+    lua_path="$withval",
+    :)
+
+dnl # Determine lua lib directory
+if test -z "$lua_path"; then
+    test_paths=". /usr/local /usr"
+else
+    test_paths="${lua_path}"
+fi
+
+AC_CHECK_LIB(m, pow, lib_m="-lm")
+AC_CHECK_LIB(m, sqrt, lib_m="-lm")
+for x in $test_paths ; do
+  if test "x$x" = "x."; then
+    AC_CHECK_HEADER(lua.h,[
+        save_CFLAGS=$CFLAGS
+        save_LDFLAGS=$LDFLAGS
+        CFLAGS="$CFLAGS"
+        LDFLAGS="$LDFLAGS $lib_m"
+        AC_CHECK_LIB(lua5.1, luaL_newstate, [
+            LUA_LIBS="-llua5.1 $lib_m"
+        ],[
+            AC_CHECK_LIB(lua-5.1, luaL_newstate, [
+                LUA_LIBS="-llua-5.1 $lib_m"
+            ],[
+                AC_CHECK_LIB(lua, luaL_newstate, [
+                    LUA_LIBS="-llua $lib_m"
+                ])
+            ])
+        ])
+        LUA_CFLAGS=
+        CFLAGS=$save_CFLAGS
+        LDFLAGS=$save_LDFLAGS
+        break
+    ])
+  else
+    AC_MSG_CHECKING([for lua.h in ${x}/include/lua5.1])
+    if test -f ${x}/include/lua5.1/lua.h; then
+        AC_MSG_RESULT([yes])
+        save_CFLAGS=$CFLAGS
+        save_LDFLAGS=$LDFLAGS
+        CFLAGS="$CFLAGS"
+        LDFLAGS="-L$x/lib $LDFLAGS $lib_m"
+        AC_CHECK_LIB(lua5.1, luaL_newstate, [
+            LUA_LIBS="-L$x/lib -llua5.1 $lib_m"
+            LUA_CFLAGS="-I$x/include/lua5.1"
+            ])
+        CFLAGS=$save_CFLAGS
+        LDFLAGS=$save_LDFLAGS
+        break
+    else
+        AC_MSG_RESULT([no])
+    fi
+    AC_MSG_CHECKING([for lua.h in ${x}/include/lua51])
+    if test -f ${x}/include/lua51/lua.h; then
+        AC_MSG_RESULT([yes])
+        save_CFLAGS=$CFLAGS
+        save_LDFLAGS=$LDFLAGS
+        CFLAGS="$CFLAGS"
+        LDFLAGS="-L$x/lib/lua51 $LDFLAGS $lib_m"
+        AC_CHECK_LIB(lua, luaL_newstate, [
+            LUA_LIBS="-L$x/lib/lua51 -llua $lib_m"
+            LUA_CFLAGS="-I$x/include/lua51"
+            ])
+        CFLAGS=$save_CFLAGS
+        LDFLAGS=$save_LDFLAGS
+        break
+    else
+        AC_MSG_RESULT([no])
+    fi
+    AC_MSG_CHECKING([for lua.h in ${x}/include])
+    if test -f ${x}/include/lua.h; then
+        AC_MSG_RESULT([yes])
+        save_CFLAGS=$CFLAGS
+        save_LDFLAGS=$LDFLAGS
+        CFLAGS="$CFLAGS"
+        LDFLAGS="-L$x/lib $LDFLAGS $lib_m"
+        AC_CHECK_LIB(lua, luaL_newstate, [
+            LUA_LIBS="-L$x/lib -llua $lib_m"
+            LUA_CFLAGS="-I$x/include"
+            ])
+        CFLAGS=$save_CFLAGS
+        LDFLAGS=$save_LDFLAGS
+        break
+    else
+        AC_MSG_RESULT([no])
+    fi
+  fi
+done
+
+AC_SUBST(LUA_LIBS)
+AC_SUBST(LUA_CFLAGS)
+
+if test -z "${LUA_LIBS}"; then
+  AC_MSG_WARN([*** Lua 5.1 library not found.])
+  ifelse([$2], ,
+    enable_lua="no"
+    if test -z "${lua_path}"; then
+        AC_MSG_WARN([Lua 5.1 library is required])
+    else
+        AC_MSG_ERROR([Lua 5.1 library is required])
+    fi,
+    $2)
+else
+  AC_MSG_NOTICE([using '${LUA_LIBS}' for Lua Library])
+  AC_ARG_ENABLE(luajit,
+    APACHE_HELP_STRING(--enable-luajit,Enable LuaJit Support),
+    TS_ADDTO(CPPFLAGS, ["-DTS_ENABLE_LUAJIT"]))
+  ifelse([$1], , , $1) 
+fi 
+])
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f015b965/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index dfe0f59..ab30adf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1064,12 +1064,13 @@ AC_SUBST(arg_max)
 AX_LIB_READLINE
 
 #
-# Check for Lua, at least version 5.1
-AX_LUA_HEADERS_VERSION(501)
-AX_LUA_LIBS
-AC_SUBST(LUA_LIB)
-AC_SUBST(LUA_INCLUDE)
-AM_CONDITIONAL([BUILD_LUA_SUPPORT], [test -n "$LUA_LIB"])
+# Check for Lua, at least version 5.1, sets LUA_CFLAGS and LUA_LIBS.
+CHECK_LUA(
+  [ enable_lua_support="yes" ],
+  [ enable_lua_support="no" ]
+)
+
+AM_CONDITIONAL([BUILD_LUA_SUPPORT], [ test "x${enable_lua_support}" = "xyes" ])
 
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f015b965/plugins/lua/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/lua/Makefile.am b/plugins/lua/Makefile.am
index 5806e16..81fb201 100644
--- a/plugins/lua/Makefile.am
+++ b/plugins/lua/Makefile.am
@@ -19,14 +19,14 @@ pkglibdir = ${pkglibexecdir}
 if BUILD_LUA_SUPPORT
 
 AM_CXXFLAGS = \
-  ${LUA_INCLUDE} \
+  ${LUA_CFLAGS} \
   -I$(top_builddir)/proxy/api \
   -I$(top_srcdir)/proxy/api
 
 
 pkglib_LTLIBRARIES = lua.la
 
-lua_la_LIBADD = ${LUA_LIB}
+lua_la_LIBADD = ${LUA_LIBS}
 lua_la_SOURCES = lua.cc lapi.cc lutil.cc
 lua_la_LDFLAGS = -module -avoid-version -shared