From bf94de28f6f02f1131bf899a66f4c8adaf42199e Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 20 Mar 2016 01:38:36 +0300 Subject: [PATCH] Support building with bundled LuaJIT. --- Makefile.am | 4 ++-- autogen.sh | 10 ---------- configure.ac | 3 ++- m4/sb_luajit.m4 | 9 ++++++--- sysbench/scripting/Makefile.am | 4 +--- sysbench/sysbench.c | 8 +++++--- third_party/luajit/Makefile.am | 29 +++++++++++++++++++++++++++++ 7 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 third_party/luajit/Makefile.am diff --git a/Makefile.am b/Makefile.am index d92d993..ed4f9d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # Copyright (C) 2004 MySQL AB -# Copyright (C) 2004-2009 Alexey Kopytov +# Copyright (C) 2004-2016 Alexey Kopytov # # 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 @@ -17,6 +17,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc sysbench +SUBDIRS = doc third_party/luajit sysbench EXTRA_DIST = autogen.sh README README-WIN.txt ChangeLog diff --git a/autogen.sh b/autogen.sh index 806b23b..e55907c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -85,14 +85,6 @@ if test x$AUTOHEADER = x; then fi fi -if test x$PKG_CONFIG = x; then - PKG_CONFIG="pkg-config" -fi - -$PKG_CONFIG --version >/dev/null 2>&1 || die \ -"$PKG_CONFIG wasn't found, exiting. \ -You must have pkg-config installed to compile sysbench" - run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal" run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize" run $AUTOHEADER || die "Can't execute autoheader" @@ -104,5 +96,3 @@ echo -n "Automade with: " $AUTOMAKE --version | head -1 echo -n "Configured with: " $AUTOCONF --version | head -1 -echo -n "pkg-config version: " -$PKG_CONFIG --version | head -1 diff --git a/configure.ac b/configure.ac index 02d6a0b..12ba640 100644 --- a/configure.ac +++ b/configure.ac @@ -434,7 +434,7 @@ fi AM_CFLAGS="${CC_WARNINGS} ${AM_CFLAGS} ${PTHREAD_CFLAGS}" -AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/sysbench" +AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/sysbench ${LUAJIT_CFLAGS}" AM_LDFLAGS="$PTHREAD_LIBS" @@ -447,6 +447,7 @@ Makefile doc/xsl/Makefile doc/xsl/catalog.xml doc/Makefile +third_party/luajit/Makefile sysbench/Makefile sysbench/drivers/Makefile sysbench/drivers/mysql/Makefile diff --git a/m4/sb_luajit.m4 b/m4/sb_luajit.m4 index 4c60968..ba2304e 100644 --- a/m4/sb_luajit.m4 +++ b/m4/sb_luajit.m4 @@ -32,11 +32,15 @@ AC_CACHE_CHECK([whether to build with system or bundled LuaJIT], AC_MSG_RESULT([system]) PKG_CHECK_MODULES([LUAJIT], [luajit]) ], [ - AC_MSG_RESULT([bunled]) - AC_MSG_ERROR([Building with bundled LuaJIT is not yet implemented, use --with-system-luajit]) + AC_MSG_RESULT([bundled]) + LUAJIT_CFLAGS="-I\$(abs_top_builddir)/third_party/luajit/inc" + LUAJIT_LIBS="\$(abs_top_builddir)/third_party/luajit/lib/libluajit-5.1.a" ]) ]) +AC_DEFINE_UNQUOTED([SB_WITH_LUAJIT], ["$sb_use_luajit"], + [Whether system or bundled LuaJIT is used]) + # Add extra flags when building a 64-bit application on OS X, # http://luajit.org/install.html AS_CASE([$host_os:$host_cpu], @@ -45,4 +49,3 @@ AS_CASE([$host_os:$host_cpu], AC_SUBST([LUAJIT_LDFLAGS]) ]) - diff --git a/sysbench/scripting/Makefile.am b/sysbench/scripting/Makefile.am index 5db0f3e..0f8a9c5 100644 --- a/sysbench/scripting/Makefile.am +++ b/sysbench/scripting/Makefile.am @@ -1,5 +1,5 @@ # Copyright (C) 2006 MySQL AB -# Copyright (C) 2006-2008 Alexey Kopytov +# Copyright (C) 2006-2016 Alexey Kopytov # # 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 @@ -18,5 +18,3 @@ noinst_LIBRARIES = libsbscript.a libsbscript_a_SOURCES = sb_script.c sb_script.h script_lua.c script_lua.h - -libsbscript_a_CPPFLAGS = $(LUAJIT_CFLAGS) $(AM_CPPFLAGS) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 3b3c32a..5050330 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -1,5 +1,5 @@ /* Copyright (C) 2004 MySQL AB - Copyright (C) 2004-2015 Alexey Kopytov + Copyright (C) 2004-2016 Alexey Kopytov 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 @@ -70,6 +70,7 @@ #include "db_driver.h" #include "sb_rnd.h" #include "sb_thread.h" +#include "luajit.h" #define VERSION_STRING PACKAGE" "PACKAGE_VERSION @@ -263,8 +264,9 @@ static int register_tests(void) void print_header(void) { - log_text(LOG_NOTICE, VERSION_STRING - ": multi-threaded system evaluation benchmark\n"); + log_text(LOG_NOTICE, + "%s (using %s %s)\n", + VERSION_STRING, SB_WITH_LUAJIT, LUAJIT_VERSION); } diff --git a/third_party/luajit/Makefile.am b/third_party/luajit/Makefile.am new file mode 100644 index 0000000..e84ec24 --- /dev/null +++ b/third_party/luajit/Makefile.am @@ -0,0 +1,29 @@ +# Copyright (C) 2016 Alexey Kopytov +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +EXTRA_DIST = luajit + +all-local: $(builddir)/lib/libluajit-5.1.a +$(builddir)/lib/libluajit-5.1.a: luajit/src + $(MAKE) -C $(srcdir)/luajit + $(MAKE) -C $(srcdir)/luajit \ + PREFIX=$(abs_top_builddir)/third_party/luajit \ + INSTALL_INC=$(abs_top_builddir)/third_party/luajit/inc \ + install + +clean-local: + $(MAKE) -C luajit clean + rm -rf bin inc lib share