Skip to content

Commit

Permalink
chore(build): Overhaul LuaRocks depnedncy checking in preparation for…
Browse files Browse the repository at this point in the history
… upstreaming
  • Loading branch information
alerque committed Nov 16, 2024
1 parent 9196111 commit 0f31bcb
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 25 deletions.
42 changes: 19 additions & 23 deletions build-aux/ax_luarocks_rock.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,34 @@
#
# LICENSE
#
# Copyright (c) 2024 Caleb Maclennan <[email protected]>
# Copyright (c) 2016 Reuben Thomas <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 2
#serial 3

AC_DEFUN([AX_LUAROCKS_ROCK], [
# Make sure we have luarocks
if test -z "$LUAROCKS"; then
AC_PATH_PROG(LUAROCKS, luarocks)
if test -z "$LUAROCKS"; then
AC_MSG_ERROR([can't find luarocks])
fi
fi
AC_DEFUN([AX_LUAROCKS_ROCK],[
# Make sure we have luarocks
if test -z "$LUAROCKS"; then
AX_WITH_PROG(LUAROCKS,luarocks)
if test -z "$LUAROCKS"; then
AC_MSG_ERROR([can't find luarocks])
fi
fi
AC_PREREQ([2.61])
AC_PREREQ([2.61])
pushdef([ROCK],$1)
AC_MSG_CHECKING(whether LuaRock ROCK is installed)
AS_IF(["$LUAROCKS" --lua-version 5.1 show ROCK > /dev/null],[
AC_MSG_RESULT(yes)
], [
AX_PROG_LUA([5.1], [], [], [], always)
AS_IF(["$LUA" -v -l ROCK > /dev/null],[
AC_MSG_RESULT(yes)
], [
AC_MSG_FAILURE([LuaRock ROCK not found])
])
])
pushdef([ROCK],$1)
AC_MSG_CHECKING(whether LuaRock ROCK is installed)
AS_IF(["$LUAROCKS"${LUA_VERSION+ --lua-version $LUA_VERSION} show ROCK > /dev/null],[
AC_MSG_RESULT(yes)
],[
AC_MSG_FAILURE([LuaRock ROCK not found])
])
popdef([ROCK])
popdef([ROCK])
])
70 changes: 70 additions & 0 deletions build-aux/ax_with_prog.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_with_prog.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH])
#
# DESCRIPTION
#
# Locates an installed program binary, placing the result in the precious
# variable VARIABLE. Accepts a present VARIABLE, then --with-program, and
# failing that searches for program in the given path (which defaults to
# the system path). If program is found, VARIABLE is set to the full path
# of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND
# if provided, unchanged otherwise.
#
# A typical example could be the following one:
#
# AX_WITH_PROG(PERL,perl)
#
# NOTE: This macro is based upon the original AX_WITH_PYTHON macro from
# Dustin J. Mitchell <[email protected]>.
#
# LICENSE
#
# Copyright (c) 2008 Francesco Salvestrini <[email protected]>
# Copyright (c) 2008 Dustin J. Mitchell <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 17

AC_DEFUN([AX_WITH_PROG],[
AC_PREREQ([2.61])
pushdef([VARIABLE],$1)
pushdef([EXECUTABLE],$2)
pushdef([VALUE_IF_NOT_FOUND],$3)
pushdef([PATH_PROG],$4)
AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable)
AS_IF(test -z "$VARIABLE",[
AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided)
AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[PATH]]]],absolute path to EXECUTABLE executable), [
AS_IF([test "$withval" != yes && test "$withval" != no],[
VARIABLE="$withval"
AC_MSG_RESULT($VARIABLE)
],[
VARIABLE=""
AC_MSG_RESULT([no])
AS_IF([test "$withval" != no], [
AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[])
])
])
],[
AC_MSG_RESULT([no])
AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[])
])
])
popdef([PATH_PROG])
popdef([VALUE_IF_NOT_FOUND])
popdef([EXECUTABLE])
popdef([VARIABLE])
])
5 changes: 3 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ AM_COND_IF([DEPENDENCY_CHECKS], [
AC_MSG_FAILURE([pandoc must have sile writer support])
])
AX_PROG_LUA(5.1, [], [], AC_MSG_ERROR([lua interpreter is required]), always)
# We actually need both 5.1 and 5.4 for most of these, but for now assume this is good enough
AX_PROG_LUA(5.1, [], [], AC_MSG_ERROR([lua interpreter matching SILE's version is required]), always)
AX_LUAROCKS_ROCK(cldr)
AX_LUAROCKS_ROCK(cosmo)
AX_LUAROCKS_ROCK(decasify)
AX_LUAROCKS_ROCK(fluent)
AX_LUAROCKS_ROCK(lpeg)
AX_LUAROCKS_ROCK(lua-utf8)
AX_LUAROCKS_ROCK(luautf8)
AX_LUAROCKS_ROCK(yaml)
AX_LUAROCKS_ROCK(decasify.sile)
Expand Down

0 comments on commit 0f31bcb

Please sign in to comment.