Checking for lua in the configure script

7 messages Options
Embed this post
Permalink
Sebastian Harl

Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Hi,

In configure.ac, I found the following shell snippet:

  lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
  # same binaries?
  if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
      # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
      LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
      LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
      LUA_INSTALL_CMOD=`$PKGCONFIG --variable=INSTALL_CMOD $f 2>/dev/null`
      LUA_INSTALL_LMOD=`$PKGCONFIG --variable=INSTALL_LMOD $f 2>/dev/null`
      break
  fi

What's the reason for that check? Debian ships multiple versions of lua
and lets the user chose the default version (through the "alternatives"
system). A symlink /usr/bin/lua is then created pointing to the chosen
version. For the Debian packing of RRDtool I'd like to specify an exact
version though (i.e. LUA=/usr/bin/lua5.1) - in that case, that check
fails though and, thus, LUA_CFLAGS and LUA_LDFLAGS are empty causing a
build failure because the lua header files cannot be found.

TIA,
Sebastian

--
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin



_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

signature.asc (204 bytes) Download Attachment
Fidelis Assis

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Hi Sebastian,

Sebastian Harl escreveu:

> Hi,
>
> In configure.ac, I found the following shell snippet:
>
>   lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
>   # same binaries?
>   if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
>       # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
>       LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
>       LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
>       LUA_INSTALL_CMOD=`$PKGCONFIG --variable=INSTALL_CMOD $f 2>/dev/null`
>       LUA_INSTALL_LMOD=`$PKGCONFIG --variable=INSTALL_LMOD $f 2>/dev/null`
>       break
>   fi
>
> What's the reason for that check?

The reason is that pkg-config can only be used with the proper binary
version, and I could not find a better way to guarantee that. For instance,
if one downloads and installs a newer version directly from Lua site, not
yet available in the distro, there will be a build failure without that
check (pkg-config would report wrong paths). Now I see that I fixed one but
broke other non standard cases, like yours :(.

 Debian ships multiple versions of lua
> and lets the user chose the default version (through the "alternatives"
> system). A symlink /usr/bin/lua is then created pointing to the chosen
> version. For the Debian packing of RRDtool I'd like to specify an exact
> version though (i.e. LUA=/usr/bin/lua5.1)

That's already the one to be used in first place. Only if lua5.1 is not
found, or if you install another version from sources (tar.gz), you'll get
different version.

 - in that case, that check
> fails though and, thus, LUA_CFLAGS and LUA_LDFLAGS are empty causing a
> build failure because the lua header files cannot be found.

Sorry for the inconvenience, I'll think more on how to do a better check and
not break your case. Suggestions are welcome :).

--
Fidelis Assis

_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
Sebastian Harl

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Hi Fidelis,

On Mon, Sep 28, 2009 at 11:22:19AM -0300, Fidelis Assis wrote:

> Sebastian Harl escreveu:
> > In configure.ac, I found the following shell snippet:
> >
> >   lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
> >   # same binaries?
> >   if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
> >       # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
> >       LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
> >       LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
> >       LUA_INSTALL_CMOD=`$PKGCONFIG --variable=INSTALL_CMOD $f 2>/dev/null`
> >       LUA_INSTALL_LMOD=`$PKGCONFIG --variable=INSTALL_LMOD $f 2>/dev/null`
> >       break
> >   fi
> >
> > What's the reason for that check?
>
> The reason is that pkg-config can only be used with the proper binary
> version, and I could not find a better way to guarantee that. For instance,
> if one downloads and installs a newer version directly from Lua site, not
> yet available in the distro, there will be a build failure without that
> check (pkg-config would report wrong paths).
Hrm … I'm not sure, I understood that correctly? What kind of wrong
paths does it return? That sounds like a bug in lua to me that should be
fixed. Since you're checking for an appropriate version (>= 5.1), that
should make sure that an appropriate version is available. Could you
please provide an example how that fails? Maybe someone can come up with
a better solution.

> Now I see that I fixed one but broke other non standard cases, like
> yours :(.

Hrm … not sure if having multiple versions installed in parallel should
be called a "non standard case" ;-)

>  Debian ships multiple versions of lua
> > and lets the user chose the default version (through the "alternatives"
> > system). A symlink /usr/bin/lua is then created pointing to the chosen
> > version. For the Debian packing of RRDtool I'd like to specify an exact
> > version though (i.e. LUA=/usr/bin/lua5.1)
>
> That's already the one to be used in first place. Only if lua5.1 is not
> found, or if you install another version from sources (tar.gz), you'll get
> different version.

Well, no - Debian provides, e.g. lua50 as well - depending on the user
configuration, /usr/bin/lua either points to lua50 or lua5.1 …

>  - in that case, that check
> > fails though and, thus, LUA_CFLAGS and LUA_LDFLAGS are empty causing a
> > build failure because the lua header files cannot be found.
>
> Sorry for the inconvenience, I'll think more on how to do a better check and
> not break your case. Suggestions are welcome :).

I'm pretty sure, we'll find a solution ;-) In the worst case, I'd have
to build-conflict with any other lua version to make sure /usr/bin/lua
points to lua5.1 - that's quite ugly though and I'd have to touch the
package any time a new version of lua has been uploaded, so I'd like to
avoid that.

Cheers,
Sebastian

--
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin



_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

signature.asc (204 bytes) Download Attachment
Fidelis Assis

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Hi Sebastian,

Sebastian Harl escreveu:

> I'm pretty sure, we'll find a solution ;-) In the worst case, I'd have
> to build-conflict with any other lua version to make sure /usr/bin/lua
> points to lua5.1 - that's quite ugly though and I'd have to touch the
> package any time a new version of lua has been uploaded, so I'd like to
> avoid that.

Please, check if this will do. It'll force lua5.1, if available, even if
/usr/bin/lua points elsewhere.

--- program-rev1919/configure.ac 2009-09-29 14:01:36.000000000 -0300
+++ program-rev1919-new/configure.ac 2009-09-29 14:58:35.000000000 -0300
@@ -659,7 +659,7 @@
 AC_SUBST(COMP_RUBY)

 dnl Check for Lua.
-AC_PATH_PROG(LUA, lua, no)
+AC_PATH_PROGS(LUA, lua5.1 lua, no)

 AC_ARG_ENABLE(lua,AS_HELP_STRING([--disable-lua],[do not build the lua
modules]),
 [],[enable_lua=yes])
@@ -737,10 +737,11 @@
             lua_pkg_prefix=lua
           fi
           # try with dot, without dot and finally without version
+  lua_dirname=`dirname $LUA`
           for f in $lua_pkg_prefix$lua_vdot $lua_pkg_prefix$lua_vndot
$lua_pkg_prefix; do
-            lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
+            lua_pkg_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
             # same binaries?
-            if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
+            if test "$lua_pkg_prefix/bin" = "$lua_dirname"; then
                 # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
                 LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
                 LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`

--
Fidelis

_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
oetiker

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Fidelis,
Sebastian,

Tuesday Fidelis Assis wrote:

> Hi Sebastian,
>
> Sebastian Harl escreveu:
>
> > I'm pretty sure, we'll find a solution ;-) In the worst case, I'd have
> > to build-conflict with any other lua version to make sure /usr/bin/lua
> > points to lua5.1 - that's quite ugly though and I'd have to touch the
> > package any time a new version of lua has been uploaded, so I'd like to
> > avoid that.
>
> Please, check if this will do. It'll force lua5.1, if available, even if
> /usr/bin/lua points elsewhere.
>
> --- program-rev1919/configure.ac 2009-09-29 14:01:36.000000000 -0300
> +++ program-rev1919-new/configure.ac 2009-09-29 14:58:35.000000000 -0300
> @@ -659,7 +659,7 @@
>  AC_SUBST(COMP_RUBY)
>
>  dnl Check for Lua.
> -AC_PATH_PROG(LUA, lua, no)
> +AC_PATH_PROGS(LUA, lua5.1 lua, no)
>
>  AC_ARG_ENABLE(lua,AS_HELP_STRING([--disable-lua],[do not build the lua
> modules]),
>  [],[enable_lua=yes])
> @@ -737,10 +737,11 @@
>              lua_pkg_prefix=lua
>            fi
>            # try with dot, without dot and finally without version
> +  lua_dirname=`dirname $LUA`
>            for f in $lua_pkg_prefix$lua_vdot $lua_pkg_prefix$lua_vndot
> $lua_pkg_prefix; do
> -            lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
> +            lua_pkg_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
>              # same binaries?
> -            if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
> +            if test "$lua_pkg_prefix/bin" = "$lua_dirname"; then
>                  # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
>                  LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
>                  LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
>

what is the status on lua ... did you find a portable solution ?

tobi

>

--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch [hidden email] ++41 62 775 9902 / sb: -9900

_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
Fidelis Assis

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
Hi Tobi,

Tobias Oetiker escreveu:

> Fidelis,
> Sebastian,
>
> Tuesday Fidelis Assis wrote:
>
>> Hi Sebastian,
>>
>> Sebastian Harl escreveu:
>>
>>> I'm pretty sure, we'll find a solution ;-) In the worst case, I'd have
>>> to build-conflict with any other lua version to make sure /usr/bin/lua
>>> points to lua5.1 - that's quite ugly though and I'd have to touch the
>>> package any time a new version of lua has been uploaded, so I'd like to
>>> avoid that.
>> Please, check if this will do. It'll force lua5.1, if available, even if
>> /usr/bin/lua points elsewhere.
>>
>> --- program-rev1919/configure.ac 2009-09-29 14:01:36.000000000 -0300
>> +++ program-rev1919-new/configure.ac 2009-09-29 14:58:35.000000000 -0300
>> @@ -659,7 +659,7 @@
>>  AC_SUBST(COMP_RUBY)
>>
>>  dnl Check for Lua.
>> -AC_PATH_PROG(LUA, lua, no)
>> +AC_PATH_PROGS(LUA, lua5.1 lua, no)
>>
>>  AC_ARG_ENABLE(lua,AS_HELP_STRING([--disable-lua],[do not build the lua
>> modules]),
>>  [],[enable_lua=yes])
>> @@ -737,10 +737,11 @@
>>              lua_pkg_prefix=lua
>>            fi
>>            # try with dot, without dot and finally without version
>> +  lua_dirname=`dirname $LUA`
>>            for f in $lua_pkg_prefix$lua_vdot $lua_pkg_prefix$lua_vndot
>> $lua_pkg_prefix; do
>> -            lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
>> +            lua_pkg_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
>>              # same binaries?
>> -            if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
>> +            if test "$lua_pkg_prefix/bin" = "$lua_dirname"; then
>>                  # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
>>                  LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
>>                  LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
>>
>
> what is the status on lua ... did you find a portable solution ?

I think the patch above does what Sebastian suggested: uses binary
lua5.1 if available, independently of what /usr/bin/lua points to. If
lua5.1 is not available, it searches for binary "lua" as before.

Let me know if that's OK.

Regards,
--
Fidelis

_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
Sebastian Harl

Re: Checking for lua in the configure script

Reply Threaded More More options
Print post
Permalink
In reply to this post by oetiker
Hi Tobi and Fidelis,

On Mon, Oct 05, 2009 at 08:36:36AM +0200, Tobias Oetiker wrote:

> Tuesday Fidelis Assis wrote:
> > Sebastian Harl escreveu:
> > > I'm pretty sure, we'll find a solution ;-) In the worst case, I'd have
> > > to build-conflict with any other lua version to make sure /usr/bin/lua
> > > points to lua5.1 - that's quite ugly though and I'd have to touch the
> > > package any time a new version of lua has been uploaded, so I'd like to
> > > avoid that.
> >
> > Please, check if this will do. It'll force lua5.1, if available, even if
> > /usr/bin/lua points elsewhere.
> >
> > --- program-rev1919/configure.ac 2009-09-29 14:01:36.000000000 -0300
> > +++ program-rev1919-new/configure.ac 2009-09-29 14:58:35.000000000 -0300
[…]
> what is the status on lua ... did you find a portable solution ?

Sorry, I did not have any time yet to have another look at that. For
now, we're build-conflicting with lua50 in the Debian package to work
around that. I might have some time to look at that issue tomorrow.

Cheers,
Sebastian

--
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin



_______________________________________________
rrd-developers mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

signature.asc (204 bytes) Download Attachment