gnu: luajit: Update to 2.1.0-beta3.
[jackhill/guix/guix.git] / gnu / packages / lua.scm
CommitLineData
712e6e68
CR
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
924cd631 3;;; Copyright © 2014 Raimon Grau <raimonster@gmail.com>
a2c03fb1 4;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
90f80bf2 5;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
864a9590 6;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
07cbe28e 7;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
03d8505f 8;;; Copyright © 2016 doncatnip <gnopap@gmail.com>
cb31a524 9;;; Copyright © 2016, 2017 Clément Lassieur <clement@lassieur.org>
35cdc267 10;;; Copyright © 2016 José Miguel Sánchez García <jmi2k@openmailbox.org>
906f1b48 11;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
ce577655 12;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
712e6e68
CR
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages lua)
572e433f 30 #:use-module ((guix licenses) #:prefix license:)
712e6e68
CR
31 #:use-module (guix packages)
32 #:use-module (guix download)
ce577655 33 #:use-module (guix git-download)
35cdc267 34 #:use-module (guix utils)
ce577655 35 #:use-module (guix build utils)
712e6e68 36 #:use-module (guix build-system gnu)
ce577655 37 #:use-module (guix build-system cmake)
712e6e68 38 #:use-module (gnu packages)
fd07a6a6 39 #:use-module (gnu packages readline)
d62dc2ae 40 #:use-module (gnu packages tls)
03d8505f 41 #:use-module (gnu packages xml)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages libffi)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages xorg)
46 #:use-module (gnu packages gtk))
712e6e68
CR
47
48(define-public lua
49 (package
50 (name "lua")
233a0c94 51 (version "5.3.4")
712e6e68
CR
52 (source (origin
53 (method url-fetch)
6dbf1fec 54 (uri (string-append "https://www.lua.org/ftp/lua-"
712e6e68
CR
55 version ".tar.gz"))
56 (sha256
233a0c94 57 (base32 "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn"))
fc1adab1 58 (patches (search-patches "lua-pkgconfig.patch"
6dbf1fec 59 "lua-liblua-so.patch"))))
712e6e68 60 (build-system gnu-build-system)
b3546174 61 (inputs `(("readline" ,readline)))
712e6e68
CR
62 (arguments
63 '(#:modules ((guix build gnu-build-system)
07cbe28e
RW
64 (guix build utils)
65 (srfi srfi-1))
712e6e68 66 #:test-target "test"
07cbe28e 67 #:make-flags
c0d47cad 68 '("MYCFLAGS=-fPIC -DLUA_DL_DLOPEN"
07cbe28e 69 "linux")
a4349e7a
EF
70 #:phases
71 (modify-phases %standard-phases
72 (delete 'configure)
a4349e7a
EF
73 (replace 'install
74 (lambda* (#:key outputs #:allow-other-keys)
75 (let ((out (assoc-ref outputs "out")))
76 (zero? (system* "make" "install"
77 (string-append "INSTALL_TOP=" out)
78 (string-append "INSTALL_MAN=" out
79 "/share/man/man1")))))))))
6dbf1fec 80 (home-page "https://www.lua.org/")
9e771e3b 81 (synopsis "Embeddable scripting language")
712e6e68
CR
82 (description
83 "Lua is a powerful, fast, lightweight, embeddable scripting language. Lua
84combines simple procedural syntax with powerful data description constructs
35b9e423 85based on associative arrays and extensible semantics. Lua is dynamically typed,
712e6e68
CR
86runs by interpreting bytecode for a register-based virtual machine, and has
87automatic memory management with incremental garbage collection, making it ideal
88for configuration, scripting, and rapid prototyping.")
572e433f 89 (license license:x11)))
924cd631 90
6dbf1fec
MB
91(define-public lua-5.2
92 (package (inherit lua)
93 (version "5.2.4")
94 (source
95 (origin
96 (method url-fetch)
97 (uri (string-append "https://www.lua.org/ftp/lua-"
98 version ".tar.gz"))
99 (sha256
100 (base32 "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr"))
101 (patches (search-patches "lua-pkgconfig.patch"
102 "lua-liblua-so.patch"))))))
103
01d3f19b
AE
104(define-public lua-5.1
105 (package (inherit lua)
106 (version "5.1.5")
107 (source (origin
108 (method url-fetch)
6dbf1fec 109 (uri (string-append "https://www.lua.org/ftp/lua-"
01d3f19b
AE
110 version ".tar.gz"))
111 (sha256
c361d075 112 (base32 "0cskd4w0g6rdm2q8q3i4n1h3j8kylhs3rq8mxwl9vwlmlxbgqh16"))
32fddd8e 113 (patches (search-patches "lua51-liblua-so.patch"
a287fafe
DM
114 "lua-CVE-2014-5461.patch"
115 "lua51-pkgconfig.patch"))))))
01d3f19b 116
924cd631
RG
117(define-public luajit
118 (package
119 (name "luajit")
906f1b48 120 (version "2.1.0-beta3")
924cd631
RG
121 (source (origin
122 (method url-fetch)
123 (uri (string-append "http://luajit.org/download/LuaJIT-"
124 version ".tar.gz"))
125 (sha256
906f1b48
TGR
126 (base32 "1hyrhpkwjqsv54hnnx4cl8vk44h9d6c9w0fz1jfjz00w255y7lhs"))
127 (patches (search-patches "luajit-no_ldconfig.patch"))))
924cd631
RG
128 (build-system gnu-build-system)
129 (arguments
130 '(#:tests? #f ;luajit is distributed without tests
dc1d3cde 131 #:phases (modify-phases %standard-phases (delete 'configure))
924cd631
RG
132 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))))
133 (home-page "http://www.luajit.org/")
134 (synopsis "Just in time compiler for Lua programming language version 5.1")
135 (description
136 "LuaJIT is a Just-In-Time Compiler (JIT) for the Lua
137programming language. Lua is a powerful, dynamic and light-weight programming
138language. It may be embedded or used as a general-purpose, stand-alone
139language.")
572e433f 140 (license license:x11)))
fd07a6a6
RW
141
142(define-public lua5.1-expat
143 (package
144 (name "lua5.1-expat")
145 (version "1.3.0")
146 (source (origin
147 (method url-fetch)
148 (uri (string-append "https://matthewwild.co.uk/projects/"
149 "luaexpat/luaexpat-" version ".tar.gz"))
150 (sha256
151 (base32
152 "1hvxqngn0wf5642i5p3vcyhg3pmp102k63s9ry4jqyyqc1wkjq6h"))))
153 (build-system gnu-build-system)
154 (arguments
155 `(#:make-flags
156 (let ((out (assoc-ref %outputs "out")))
157 (list "CC=gcc"
158 (string-append "LUA_LDIR=" out "/share/lua/$(LUA_V)")
159 (string-append "LUA_CDIR=" out "/lib/lua/$(LUA_V)")))
160 #:phases
161 (modify-phases %standard-phases
162 (delete 'configure)
163 (replace 'check
164 (lambda _
165 (setenv "LUA_CPATH" "src/?.so;;")
166 (setenv "LUA_PATH" "src/?.lua;;")
167 (and (zero? (system* "lua" "tests/test.lua"))
168 (zero? (system* "lua" "tests/test-lom.lua"))))))))
169 (inputs
170 `(("lua" ,lua-5.1)
171 ("expat" ,expat)))
172 (home-page "http://matthewwild.co.uk/projects/luaexpat/")
173 (synopsis "SAX XML parser based on the Expat library")
174 (description "LuaExpat is a SAX XML parser based on the Expat library.")
175 (license (package-license lua-5.1))))
c21b8261
RW
176
177(define-public lua5.1-socket
178 (package
179 (name "lua5.1-socket")
50269c01 180 (version "3.0-rc1")
c21b8261
RW
181 (source (origin
182 (method url-fetch)
50269c01
CL
183 (uri (string-append
184 "https://github.com/diegonehab/luasocket/archive/v"
185 version ".tar.gz"))
a6888fe3 186 (file-name (string-append name "-" version ".tar.gz"))
c21b8261
RW
187 (sha256
188 (base32
50269c01 189 "0j8jx8bjicvp9khs26xjya8c495wrpb7parxfnabdqa5nnsxjrwb"))))
c21b8261
RW
190 (build-system gnu-build-system)
191 (arguments
192 `(#:make-flags
193 (let ((out (assoc-ref %outputs "out")))
50269c01 194 (list (string-append "INSTALL_TOP=" out)))
c21b8261
RW
195 #:phases
196 (modify-phases %standard-phases
197 (delete 'configure)
198 (replace 'check
199 (lambda _
200 (setenv "LUA_CPATH" (string-append "src/?.so." ,version ";;"))
201 (setenv "LUA_PATH" "src/?.lua;;")
202 (when (zero? (primitive-fork))
203 (system* "lua" "test/testsrvr.lua"))
204 (zero? (system* "lua" "test/testclnt.lua")))))))
205 (inputs
206 `(("lua" ,lua-5.1)))
207 (home-page "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/")
208 (synopsis "Socket library for Lua")
209 (description "LuaSocket is a Lua extension library that is composed by two
210parts: a C core that provides support for the TCP and UDP transport layers,
211and a set of Lua modules that add support for functionality commonly needed by
212applications that deal with the Internet.
213
214Among the supported modules, the most commonly used implement the
215SMTP (sending e-mails), HTTP (WWW access) and FTP (uploading and downloading
216files) client protocols. These provide a very natural and generic interface
217to the functionality defined by each protocol. In addition, you will find
218that the MIME (common encodings), URL (anything you could possible want to do
219with one) and LTN12 (filters, sinks, sources and pumps) modules can be very
220handy.")
221 (license (package-license lua-5.1))))
182de8fc
RW
222
223(define-public lua5.1-filesystem
224 (package
225 (name "lua5.1-filesystem")
226 (version "1.6.3")
227 (source (origin
228 (method url-fetch)
229 (uri (string-append "https://github.com/keplerproject/"
230 "luafilesystem/archive/v_"
231 "1_6_3" ".tar.gz"))
232 (file-name (string-append name "-" version ".tar.gz"))
233 (sha256
234 (base32
235 "0s10ckxin0bysd6gaywqhxkpw3ybjhprr8m655b8cx3pxjwd49am"))))
236 (build-system gnu-build-system)
237 (arguments
238 `(#:make-flags
239 (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
240 #:test-target "test"
241 #:phases
242 (modify-phases %standard-phases
243 (delete 'configure))))
244 (inputs
245 `(("lua" ,lua-5.1)))
246 (home-page "https://keplerproject.github.io/luafilesystem/index.html")
247 (synopsis "File system library for Lua")
248 (description "LuaFileSystem is a Lua library developed to complement the
249set of functions related to file systems offered by the standard Lua
250distribution. LuaFileSystem offers a portable way to access the underlying
251directory structure and file attributes.")
252 (license (package-license lua-5.1))))
d62dc2ae
RW
253
254(define-public lua5.1-sec
255 (package
256 (name "lua5.1-sec")
257 (version "0.6")
258 (source (origin
259 (method url-fetch)
260 (uri (string-append "https://github.com/brunoos/luasec/archive/"
261 "luasec-" version ".tar.gz"))
262 (sha256
263 (base32
264 "0pgd1anzznl4s0h16wg8dlw9mgdb9h52drlcki6sbf5y31fa7wyf"))))
265 (build-system gnu-build-system)
266 (arguments
267 `(#:make-flags
268 (let ((out (assoc-ref %outputs "out")))
269 (list "linux"
270 "CC=gcc"
271 "LD=gcc"
272 (string-append "LUAPATH=" out "/share/lua/5.1")
273 (string-append "LUACPATH=" out "/lib/lua/5.1")))
274 #:tests? #f ; no tests included
275 #:phases
276 (modify-phases %standard-phases
277 (delete 'configure))))
278 (inputs
279 `(("lua" ,lua-5.1)
280 ("openssl" ,openssl)))
281 (propagated-inputs
282 `(("lua-socket" ,lua5.1-socket)))
283 (home-page "https://github.com/brunoos/luasec/wiki")
284 (synopsis "OpenSSL bindings for Lua")
285 (description "LuaSec is a binding for OpenSSL library to provide TLS/SSL
286communication. It takes an already established TCP connection and creates a
287secure session between the peers.")
288 (license (package-license lua-5.1))))
03d8505f 289
290(define-public lua-lgi
291 (package
292 (name "lua-lgi")
293 (version "0.9.1")
294 (source
295 (origin
296 (method url-fetch)
297 (uri (string-append
298 "https://github.com/pavouk/lgi/archive/"
299 version ".tar.gz"))
300 (file-name (string-append name "-" version ".tar.gz"))
301 (sha256
302 (base32
303 "1fmgdl5y4ph3yc6ycg865s3vai1rjkyda61cgqxk6zd13hmznw0c"))))
304 (build-system gnu-build-system)
305 (arguments
306 '(#:make-flags (list "CC=gcc"
307 (string-append "PREFIX=" (assoc-ref %outputs "out")))
308 #:phases
309 (modify-phases %standard-phases
310 (delete 'configure) ; no configure script
311 (add-before 'build 'set-env
312 (lambda* (#:key inputs #:allow-other-keys)
313 ;; we need to load cairo dynamically
314 (let* ((cairo (string-append
315 (assoc-ref inputs "cairo") "/lib" )))
316 (setenv "LD_LIBRARY_PATH" cairo)
317 #t)))
318 (add-before 'build 'set-lua-version
319 (lambda _
320 ;; lua version and therefore install directories are hardcoded
321 ;; FIXME: This breaks when we update lua to >=5.3
322 (substitute* "./lgi/Makefile"
323 (("LUA_VERSION=5.1") "LUA_VERSION=5.2"))
324 #t))
325 (add-before 'check 'skip-test-gtk
326 (lambda _
327 ;; FIXME: Skip GTK tests:
328 ;; gtk3 - can't get it to run with the xorg-server config below
329 ;; and some non-gtk tests will also fail
330 ;; gtk2 - lots of functions aren't implemented
331 ;; We choose gtk2 as the lesser evil and simply skip the test.
332 ;; Currently, awesome is the only package that uses lua-lgi but
333 ;; it doesn't need or interact with GTK using lua-lgi.
334 (substitute* "./tests/test.lua"
335 (("'gtk.lua',") "-- 'gtk.lua',"))
336 #t))
337 (add-before 'check 'start-xserver-instance
338 (lambda* (#:key inputs #:allow-other-keys)
339 ;; There must be a running X server during tests.
340 (system (format #f "~a/bin/Xvfb :1 &"
341 (assoc-ref inputs "xorg-server")))
342 (setenv "DISPLAY" ":1")
343 #t)))))
344 (inputs
345 `(("gobject-introspection" ,gobject-introspection)
346 ("glib" ,glib)
347 ("pango", pango)
348 ("gtk", gtk+-2)
349 ("lua" ,lua)
350 ("cairo" ,cairo)
351 ("libffi" ,libffi)
352 ("xorg-server", xorg-server)))
353 (native-inputs
354 `(("pkg-config" ,pkg-config)))
355 (home-page "https://github.com/pavouk/lgi/")
356 (synopsis "Lua bridge to GObject based libraries")
357 (description
358 "LGI is gobject-introspection based dynamic Lua binding to GObject
359based libraries. It allows using GObject-based libraries directly from Lua.
360Notable examples are GTK+, GStreamer and Webkit.")
361 (license license:expat)))
35cdc267 362
149b2c43 363(define (make-lua-lpeg name lua)
35cdc267 364 (package
149b2c43 365 (name name)
139c8f94 366 (version "1.0.1")
35cdc267
JMSG
367 (source (origin
368 (method url-fetch)
369 (uri (string-append "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-"
370 version ".tar.gz"))
371 (sha256
139c8f94 372 (base32 "0sq25z3r324a324ky73izgq9mbf66j2xvjp0fxf227rwxalzgnb2"))))
35cdc267
JMSG
373 (build-system gnu-build-system)
374 (arguments
375 `(#:phases
376 (modify-phases %standard-phases
377 (delete 'configure)
378 ;; `make install` isn't available, so we have to do it manually
379 (replace 'install
380 (lambda* (#:key outputs #:allow-other-keys)
381 (let ((out (assoc-ref outputs "out"))
382 (lua-version ,(version-major+minor (package-version lua))))
383 (install-file "lpeg.so"
384 (string-append out "/lib/lua/" lua-version))
385 (install-file "re.lua"
386 (string-append out "/share/lua/" lua-version))
387 #t))))
388 #:test-target "test"))
389 (inputs `(("lua", lua)))
390 (synopsis "Pattern-matching library for Lua")
391 (description
392 "LPeg is a pattern-matching library for Lua, based on Parsing Expression
393Grammars (PEGs).")
394 (home-page "http://www.inf.puc-rio.br/~roberto/lpeg")
395 (license license:expat)))
cf9a788d 396
149b2c43
CL
397(define-public lua-lpeg
398 (make-lua-lpeg "lua-lpeg" lua))
399
d9ed1779 400(define-public lua5.2-lpeg
149b2c43 401 (make-lua-lpeg "lua5.2-lpeg" lua-5.2))
d9ed1779 402
cf9a788d 403;; Lua 5.3 is not supported.
cb31a524 404(define (make-lua-bitop name lua)
cf9a788d 405 (package
cb31a524 406 (name name)
cf9a788d
RW
407 (version "1.0.2")
408 (source (origin
409 (method url-fetch)
410 (uri (string-append "http://bitop.luajit.org/download/"
411 "LuaBitOp-" version ".tar.gz"))
412 (sha256
413 (base32
414 "16fffbrgfcw40kskh2bn9q7m3gajffwd2f35rafynlnd7llwj1qj"))))
415 (build-system gnu-build-system)
416 (arguments
417 `(#:test-target "test"
418 #:make-flags
419 (list "INSTALL=install -pD"
420 (string-append "INSTALLPATH=printf "
421 (assoc-ref %outputs "out")
422 "/lib/lua/"
cb31a524 423 ,(version-major+minor (package-version lua))
cf9a788d
RW
424 "/bit/bit.so"))
425 #:phases
426 (modify-phases %standard-phases
427 (delete 'configure))))
cb31a524 428 (inputs `(("lua", lua)))
cf9a788d
RW
429 (home-page "http://bitop.luajit.org/index.html")
430 (synopsis "Bitwise operations on numbers for Lua")
431 (description
432 "Lua BitOp is a C extension module for Lua which adds bitwise operations
433on numbers.")
434 (license license:expat)))
cb31a524
CL
435
436(define-public lua5.2-bitop
437 (make-lua-bitop "lua5.2-bitop" lua-5.2))
438
439(define-public lua5.1-bitop
440 (make-lua-bitop "lua5.1-bitop" lua-5.1))
ce577655
FT
441
442(define-public selene
443 (package
444 (name "selene")
445 (version "2017.08.25")
446 (source (origin
447 (method git-fetch)
448 (uri (git-reference
449 (url "https://github.com/jeremyong/Selene.git")
450 ;; The release is quite old.
451 (commit "ffe1ade2568d4cff5894552be8f43e63e379a4c9")))
452 (file-name "Selene")
453 (sha256
454 (base32
455 "1axrgv3rxxdsaf807lwvklfzicn6x6gpf35narllrnz9lg6hn508"))))
456 (build-system cmake-build-system)
457 (arguments
458 `(#:configure-flags
459 ;; lua pc file in CMakeLists.txt is lua5.3.pc
460 '("-DLUA_PC_CFG=lua;lua-5.3;lua-5.1")
461 #:test-target "all"
462 #:phases
463 ;; This is a header only library
464 (modify-phases %standard-phases
465 (delete 'build)
466 (replace 'install
467 (lambda* (#:key inputs outputs #:allow-other-keys)
468 (let* ((output (assoc-ref outputs "out"))
469 (source (assoc-ref inputs "source"))
470 (includedir (string-append output "/include")))
471 (copy-recursively
472 (string-append source "/include")
473 includedir))
474 #t))
475 ;; The path of test files are hard coded.
476 (replace 'check
477 (lambda* (#:key inputs outputs #:allow-other-keys)
478 (let* ((output (assoc-ref outputs "out"))
479 (source (assoc-ref inputs "source"))
480 (builddir (getcwd))
481 (testdir (string-append builddir "/test")))
482 (copy-recursively (string-append source "/test") testdir)
483 (invoke "make")
484 (mkdir-p "runner")
485 (copy-file "./test_runner" "./runner/test_runner")
486 (chdir "./runner")
487 (invoke "./test_runner")))))))
488 (native-inputs
489 `(("lua" ,lua)
490 ("pkg-config" ,pkg-config)))
491 (home-page "https://github.com/jeremyong/Selene")
492 (synopsis "Lua C++11 bindings")
493 (description
494 "Selene is a simple C++11 header-only library enabling seamless
495 interoperability between C++ and Lua programming language.")
496 (license license:zlib)))