How to do it in portable way

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to do it in portable way

Milan Obuch
Hi,

my first and the only, for now, project using Lua is Lua plugin for
Claws Mail. I did develop it on FreeBSD with some hardwired paths for
Lua library location and similar, using Lua 5.2. I'd like to ask how to
make it portable for other platform, using other version of Lua if
desired, and avoid hardwired paths.

Currently, I have Makefile.am containing two targets with hardwired
items, namely

lua_la_LIBADD = $(cygwin_export_lib) \
        $(GTK_LIBS) \
        -L/usr/local/lib -llua-5.2

lua_la_CPPFLAGS = \
        -I$(top_srcdir)/src \
        -I$(top_builddir)/src/common \
        -I$(top_srcdir)/src/common \
        -I$(top_srcdir)/src/gtk \
        $(GLIB_CFLAGS) \
        $(GTK_CFLAGS) \
        $(ENCHANT_CFLAGS) \
        -I/usr/local/include/lua52

In global configure, I added --disable-lua-plugin and
--enable-lua-plugin options, but they are doing just this, allowing my
plugin to build, but I'd like to add there some logic (I am tempted to
write magic) to define $(LUA_LIBS) and $(LUA_CFLAGS) so I can use them
in Makefile.am instead of hardwired values.

I know it is not directly related to Lua itself, please accept my
apology, but I think here should be many doing some projects with
similar requirements.

Regards,
Milan
Reply | Threaded
Open this post in threaded view
|

Re: How to do it in portable way

Fontana Nicola
Il giorno dom, 07/02/2021 alle 09.57 +0100, Milan Obuch ha scritto:

> Hi,
>
> my first and the only, for now, project using Lua is Lua plugin for
> Claws Mail. I did develop it on FreeBSD with some hardwired paths for
> Lua library location and similar, using Lua 5.2. I'd like to ask how to
> make it portable for other platform, using other version of Lua if
> desired, and avoid hardwired paths.
>
> Currently, I have Makefile.am containing two targets with hardwired
> items, namely
>
> lua_la_LIBADD = $(cygwin_export_lib) \
>         $(GTK_LIBS) \
>         -L/usr/local/lib -llua-5.2
>
> lua_la_CPPFLAGS = \
>         -I$(top_srcdir)/src \
>         -I$(top_builddir)/src/common \
>         -I$(top_srcdir)/src/common \
>         -I$(top_srcdir)/src/gtk \
>         $(GLIB_CFLAGS) \
>         $(GTK_CFLAGS) \
>         $(ENCHANT_CFLAGS) \
>         -I/usr/local/include/lua52
>
> In global configure, I added --disable-lua-plugin and
> --enable-lua-plugin options, but they are doing just this, allowing my
> plugin to build, but I'd like to add there some logic (I am tempted to
> write magic) to define $(LUA_LIBS) and $(LUA_CFLAGS) so I can use them
> in Makefile.am instead of hardwired values.

Hi Milan,

if you are using autoconf you can check ax_lua:

https://github.com/autoconf-archive/autoconf-archive/blob/master/m4/ax_lua.m4

This will define the `LUA_INCLUDE` precious variable that can be used
in the same way you are using `GTK_CFLAGS`.

It is far from perfect (there are some hardcoded values in that script
that try to circumvent the incompatibilities between distros) but IMO
it is the best workaround we have right now.

Ciao.
--
Nicola

Reply | Threaded
Open this post in threaded view
|

Re: How to do it in portable way

Milan Obuch
On Sun, 07 Feb 2021 16:27:04 +0100, Fontana Nicola <[hidden email]>
wrote:

> Il giorno dom, 07/02/2021 alle 09.57 +0100, Milan Obuch ha scritto:
> > Hi,
> >
> > my first and the only, for now, project using Lua is Lua plugin for
> > Claws Mail. I did develop it on FreeBSD with some hardwired paths
> > for Lua library location and similar, using Lua 5.2. I'd like to
> > ask how to make it portable for other platform, using other version
> > of Lua if desired, and avoid hardwired paths.
> >
> > Currently, I have Makefile.am containing two targets with hardwired
> > items, namely
> >
> > lua_la_LIBADD = $(cygwin_export_lib) \
> >         $(GTK_LIBS) \
> >         -L/usr/local/lib -llua-5.2
> >
> > lua_la_CPPFLAGS = \
> >         -I$(top_srcdir)/src \
> >         -I$(top_builddir)/src/common \
> >         -I$(top_srcdir)/src/common \
> >         -I$(top_srcdir)/src/gtk \
> >         $(GLIB_CFLAGS) \
> >         $(GTK_CFLAGS) \
> >         $(ENCHANT_CFLAGS) \
> >         -I/usr/local/include/lua52
> >
> > In global configure, I added --disable-lua-plugin and
> > --enable-lua-plugin options, but they are doing just this, allowing
> > my plugin to build, but I'd like to add there some logic (I am
> > tempted to write magic) to define $(LUA_LIBS) and $(LUA_CFLAGS) so
> > I can use them in Makefile.am instead of hardwired values.  
>
> Hi Milan,
>
> if you are using autoconf you can check ax_lua:
>
> https://github.com/autoconf-archive/autoconf-archive/blob/master/m4/ax_lua.m4
>
> This will define the `LUA_INCLUDE` precious variable that can be used
> in the same way you are using `GTK_CFLAGS`.
>
> It is far from perfect (there are some hardcoded values in that script
> that try to circumvent the incompatibilities between distros) but IMO
> it is the best workaround we have right now.
>
> Ciao.

Big thanks. I'll check this. It takes me some time to do so, but I hope
this could enhance my configure.ac part of plugin.

Regards,
Milan