unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* gnu: Have lua-5.1 compile a .so
@ 2014-09-10 22:31 lemonnierk
  2014-09-10 22:42 ` Cyril Roelandt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: lemonnierk @ 2014-09-10 22:31 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 3453 bytes --]

Hi,

While working on getting weechat to build with the lua plugin enabled,
I noticed the lua package doesn't produce a liblua.so file. So here is
a patch to make it do so. It's basically the same patch as in ArchLinux,
with a few differences like actually installing the .so file.

From 85a422fb581650542644b711b180bc95a47c990d Mon Sep 17 00:00:00 2001
From: Kevin Lemonnier <lemonnierk@ulrar.net>
Date: Thu, 11 Sep 2014 02:22:10 +0200
Subject: [PATCH] gnu: Have lua-5.1 compile a .so

* gnu/packages/patches/lua51-liblua-so.patch: New file
* gnu/packages/lua.scm: Use of lua51-liblua-so.patch in lua-5.1
---
 gnu/packages/lua.scm                       |  4 +-
 gnu/packages/patches/lua51-liblua-so.patch | 59 ++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/lua51-liblua-so.patch

diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index a85c120..7d68dba 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -75,7 +75,9 @@ for configuration, scripting, and rapid prototyping.")
              (uri (string-append "http://www.lua.org/ftp/lua-"
                                  version ".tar.gz"))
              (sha256
-              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))))))
+              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
+             (patches (list (search-patch "lua51-liblua-so.patch")))
+             (patch-flags '("-p1"))))))
 
 (define-public luajit
   (package
diff --git a/gnu/packages/patches/lua51-liblua-so.patch b/gnu/packages/patches/lua51-liblua-so.patch
new file mode 100644
index 0000000..9cfcb93
--- /dev/null
+++ b/gnu/packages/patches/lua51-liblua-so.patch
@@ -0,0 +1,59 @@
+diff -ruN lua-5.1.5/Makefile lua-5.1.5-new/Makefile
+--- lua-5.1.5/Makefile	2012-02-10 10:50:23.000000000 +0100
++++ lua-5.1.5-new/Makefile	2014-09-10 20:17:28.913951433 +0200
+@@ -43,7 +43,7 @@
+ # What to install.
+ TO_BIN= lua luac
+ TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+-TO_LIB= liblua.a
++TO_LIB= liblua.a liblua.so liblua.so.${V}
+ TO_MAN= lua.1 luac.1
+ 
+ # Lua version and release.
+@@ -53,7 +53,7 @@
+ all:	$(PLAT)
+ 
+ $(PLATS) clean:
+-	cd src && $(MAKE) $@
++	cd src && $(MAKE) $@ V=$(V) R=$(R)
+ 
+ test:	dummy
+ 	src/lua test/hello.lua
+diff -ruN lua-5.1.5/src/Makefile lua-5.1.5-new/src/Makefile
+--- lua-5.1.5/src/Makefile	2012-02-13 21:41:22.000000000 +0100
++++ lua-5.1.5-new/src/Makefile	2014-09-10 20:16:09.982952152 +0200
+@@ -8,7 +8,7 @@
+ PLAT= none
+ 
+ CC= gcc
+-CFLAGS= -O2 -Wall $(MYCFLAGS)
++CFLAGS= -O2 -Wall $(MYCFLAGS) -fPIC
+ AR= ar rcu
+ RANLIB= ranlib
+ RM= rm -f
+@@ -34,9 +34,10 @@
+ 
+ LUAC_T=	luac
+ LUAC_O=	luac.o print.o
++LUA_SO= liblua.so
+ 
+ ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
++ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
+ ALL_A= $(LUA_A)
+ 
+ default: $(PLAT)
+@@ -57,6 +58,13 @@
+ $(LUAC_T): $(LUAC_O) $(LUA_A)
+ 	$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+ 
++$(LUA_SO): $(CORE_O) $(LIB_O)
++	$(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO)
++
++
++
+ clean:
+ 	$(RM) $(ALL_T) $(ALL_O)
+ 
-- 
1.8.4


-- 
Kevin Lemonnier
PGP Fingerprint : C123 47CA 9E64 FCF0 3907

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-10 22:31 gnu: Have lua-5.1 compile a .so lemonnierk
@ 2014-09-10 22:42 ` Cyril Roelandt
  2014-09-10 23:09 ` Eric Bavier
  2014-09-11  8:02 ` Ludovic Courtès
  2 siblings, 0 replies; 7+ messages in thread
From: Cyril Roelandt @ 2014-09-10 22:42 UTC (permalink / raw)
  To: guix-devel

On 09/11/2014 12:31 AM, lemonnierk@ulrar.net wrote:
> Hi,
> 

Hi,

> While working on getting weechat to build with the lua plugin enabled,
> I noticed the lua package doesn't produce a liblua.so file. So here is
> a patch to make it do so. It's basically the same patch as in ArchLinux,
> with a few differences like actually installing the .so file.
> 

Maybe you could mention in the diff header that the patch comes from
Arch, and give credit to the author :) Also, it would make it easier for
us to track newer versions of this patch, should it be modified in Arch.

Cyril.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-10 22:31 gnu: Have lua-5.1 compile a .so lemonnierk
  2014-09-10 22:42 ` Cyril Roelandt
@ 2014-09-10 23:09 ` Eric Bavier
  2014-09-11  8:02 ` Ludovic Courtès
  2 siblings, 0 replies; 7+ messages in thread
From: Eric Bavier @ 2014-09-10 23:09 UTC (permalink / raw)
  To: lemonnierk; +Cc: guix-devel


lemonnierk@ulrar.net writes:

> --- a/gnu/packages/lua.scm
> +++ b/gnu/packages/lua.scm
> @@ -75,7 +75,9 @@ for configuration, scripting, and rapid prototyping.")
>               (uri (string-append "http://www.lua.org/ftp/lua-"
>                                   version ".tar.gz"))
>               (sha256
> -              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))))))
> +              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
> +             (patches (list (search-patch "lua51-liblua-so.patch")))
> +             (patch-flags '("-p1"))))))

Is the 'patch-flags' really necessary here?  I believe the default is to
use -p1.

-- 
Eric Bavier

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-10 22:31 gnu: Have lua-5.1 compile a .so lemonnierk
  2014-09-10 22:42 ` Cyril Roelandt
  2014-09-10 23:09 ` Eric Bavier
@ 2014-09-11  8:02 ` Ludovic Courtès
  2014-09-11  8:12   ` lemonnierk
  2 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2014-09-11  8:02 UTC (permalink / raw)
  To: lemonnierk; +Cc: guix-devel

Hello!

lemonnierk@ulrar.net skribis:

> While working on getting weechat to build with the lua plugin enabled,
> I noticed the lua package doesn't produce a liblua.so file. So here is
> a patch to make it do so. It's basically the same patch as in ArchLinux,
> with a few differences like actually installing the .so file.

I think the comments of Eric and Cyril need to be addressed.

Other than that, I’m wondering: is there a reason why upstream Lua
doesn’t install a shared library by default?  Is it because the normal
way to use it is to include the source in the package that uses it?

IOW, is it OK to diverge from upstream?

If in doubt, it’s probably fine, IMO, but I just wanted to make sure.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-11  8:02 ` Ludovic Courtès
@ 2014-09-11  8:12   ` lemonnierk
  2014-09-11 10:02     ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: lemonnierk @ 2014-09-11  8:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 4462 bytes --]

Hi,

According to someone on stackoverflow, "The lua team does not include support for
shared libraries by default because doing so in a portable manner is not simple."
http://stackoverflow.com/questions/20848275/compiling-lua-create-so-files
But I believe all distributions have some kind of way of getting that .so.
Here is the patch :

From 81f659884cf02d0d63846b45be5f93d794a9e092 Mon Sep 17 00:00:00 2001
From: Kevin Lemonnier <lemonnierk@ulrar.net>
Date: Thu, 11 Sep 2014 03:12:39 +0200
Subject: [PATCH] gnu: Have lua-5.1 compile a .so

* gnu/packages/patches/lua51-liblua-so.patch: New file
* gnu/packages/lua.scm: Use of lua51-liblua-so.patch in lua-5.1
---
 gnu/packages/lua.scm                       |  3 +-
 gnu/packages/patches/lua51-liblua-so.patch | 65 ++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/lua51-liblua-so.patch

diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index a85c120..92ffc22 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -75,7 +75,8 @@ for configuration, scripting, and rapid prototyping.")
              (uri (string-append "http://www.lua.org/ftp/lua-"
                                  version ".tar.gz"))
              (sha256
-              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))))))
+              (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
+             (patches (list (search-patch "lua51-liblua-so.patch")))))))
 
 (define-public luajit
   (package
diff --git a/gnu/packages/patches/lua51-liblua-so.patch b/gnu/packages/patches/lua51-liblua-so.patch
new file mode 100644
index 0000000..4442858
--- /dev/null
+++ b/gnu/packages/patches/lua51-liblua-so.patch
@@ -0,0 +1,65 @@
+
+Patch the two Makefile to also create liblua.so
+Original patch by Allan McRae <allan@archlinux.org>
+for Archlinux
+
+
+diff -ruN lua-5.1.5/Makefile lua-5.1.5-new/Makefile
+--- lua-5.1.5/Makefile	2012-02-10 10:50:23.000000000 +0100
++++ lua-5.1.5-new/Makefile	2014-09-10 20:17:28.913951433 +0200
+@@ -43,7 +43,7 @@
+ # What to install.
+ TO_BIN= lua luac
+ TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
+-TO_LIB= liblua.a
++TO_LIB= liblua.a liblua.so liblua.so.${V}
+ TO_MAN= lua.1 luac.1
+ 
+ # Lua version and release.
+@@ -53,7 +53,7 @@
+ all:	$(PLAT)
+ 
+ $(PLATS) clean:
+-	cd src && $(MAKE) $@
++	cd src && $(MAKE) $@ V=$(V) R=$(R)
+ 
+ test:	dummy
+ 	src/lua test/hello.lua
+diff -ruN lua-5.1.5/src/Makefile lua-5.1.5-new/src/Makefile
+--- lua-5.1.5/src/Makefile	2012-02-13 21:41:22.000000000 +0100
++++ lua-5.1.5-new/src/Makefile	2014-09-10 20:16:09.982952152 +0200
+@@ -8,7 +8,7 @@
+ PLAT= none
+ 
+ CC= gcc
+-CFLAGS= -O2 -Wall $(MYCFLAGS)
++CFLAGS= -O2 -Wall $(MYCFLAGS) -fPIC
+ AR= ar rcu
+ RANLIB= ranlib
+ RM= rm -f
+@@ -34,9 +34,10 @@
+ 
+ LUAC_T=	luac
+ LUAC_O=	luac.o print.o
++LUA_SO= liblua.so
+ 
+ ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
+-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
++ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
+ ALL_A= $(LUA_A)
+ 
+ default: $(PLAT)
+@@ -57,6 +58,13 @@
+ $(LUAC_T): $(LUAC_O) $(LUA_A)
+ 	$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+ 
++$(LUA_SO): $(CORE_O) $(LIB_O)
++	$(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO)
++
++
++
+ clean:
+ 	$(RM) $(ALL_T) $(ALL_O)
+ 
-- 
1.8.4


On Thu, Sep 11, 2014 at 10:02:08AM +0200, Ludovic Courtès wrote:
> Hello!
> 
> lemonnierk@ulrar.net skribis:
> 
> > While working on getting weechat to build with the lua plugin enabled,
> > I noticed the lua package doesn't produce a liblua.so file. So here is
> > a patch to make it do so. It's basically the same patch as in ArchLinux,
> > with a few differences like actually installing the .so file.
> 
> I think the comments of Eric and Cyril need to be addressed.
> 
> Other than that, I’m wondering: is there a reason why upstream Lua
> doesn’t install a shared library by default?  Is it because the normal
> way to use it is to include the source in the package that uses it?
> 
> IOW, is it OK to diverge from upstream?
> 
> If in doubt, it’s probably fine, IMO, but I just wanted to make sure.
> 
> Thanks,
> Ludo’.

-- 
Kevin Lemonnier
PGP Fingerprint : C123 47CA 9E64 FCF0 3907

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-11  8:12   ` lemonnierk
@ 2014-09-11 10:02     ` Ludovic Courtès
  2014-09-11 10:12       ` lemonnierk
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2014-09-11 10:02 UTC (permalink / raw)
  To: lemonnierk; +Cc: guix-devel

lemonnierk@ulrar.net skribis:

> According to someone on stackoverflow, "The lua team does not include support for
> shared libraries by default because doing so in a portable manner is not simple."
> http://stackoverflow.com/questions/20848275/compiling-lua-create-so-files

Heh, Libtool to the rescue!  ;-)

> From 81f659884cf02d0d63846b45be5f93d794a9e092 Mon Sep 17 00:00:00 2001
> From: Kevin Lemonnier <lemonnierk@ulrar.net>
> Date: Thu, 11 Sep 2014 03:12:39 +0200
> Subject: [PATCH] gnu: Have lua-5.1 compile a .so
>
> * gnu/packages/patches/lua51-liblua-so.patch: New file
> * gnu/packages/lua.scm: Use of lua51-liblua-so.patch in lua-5.1

I’ve applied it, but I realized that liblua.a is now populated with
-fPIC object files, which doesn’t make much sense.

Perhaps we could remove lib/liblua.a altogether?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnu: Have lua-5.1 compile a .so
  2014-09-11 10:02     ` Ludovic Courtès
@ 2014-09-11 10:12       ` lemonnierk
  0 siblings, 0 replies; 7+ messages in thread
From: lemonnierk @ 2014-09-11 10:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

Didn't think of that, indeed. I know I'm not using the .a, don't know about others though.

On Thu, Sep 11, 2014 at 12:02:49PM +0200, Ludovic Courtès wrote:
> lemonnierk@ulrar.net skribis:
> 
> > According to someone on stackoverflow, "The lua team does not include support for
> > shared libraries by default because doing so in a portable manner is not simple."
> > http://stackoverflow.com/questions/20848275/compiling-lua-create-so-files
> 
> Heh, Libtool to the rescue!  ;-)
> 
> > From 81f659884cf02d0d63846b45be5f93d794a9e092 Mon Sep 17 00:00:00 2001
> > From: Kevin Lemonnier <lemonnierk@ulrar.net>
> > Date: Thu, 11 Sep 2014 03:12:39 +0200
> > Subject: [PATCH] gnu: Have lua-5.1 compile a .so
> >
> > * gnu/packages/patches/lua51-liblua-so.patch: New file
> > * gnu/packages/lua.scm: Use of lua51-liblua-so.patch in lua-5.1
> 
> I’ve applied it, but I realized that liblua.a is now populated with
> -fPIC object files, which doesn’t make much sense.
> 
> Perhaps we could remove lib/liblua.a altogether?
> 
> Thanks,
> Ludo’.

-- 
Kevin Lemonnier
PGP Fingerprint : C123 47CA 9E64 FCF0 3907

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-11 10:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-10 22:31 gnu: Have lua-5.1 compile a .so lemonnierk
2014-09-10 22:42 ` Cyril Roelandt
2014-09-10 23:09 ` Eric Bavier
2014-09-11  8:02 ` Ludovic Courtès
2014-09-11  8:12   ` lemonnierk
2014-09-11 10:02     ` Ludovic Courtès
2014-09-11 10:12       ` lemonnierk

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).