blob: f0fb73d0aa9190ce2e379e0fd4a6b8845d6719a4 [file] [log] [blame]
Francois Perrad72afb292014-01-11 16:42:07 +01001################################################################################
2# LuaRocks package infrastructure
3# see http://luarocks.org/
4#
5# This file implements an infrastructure that eases development of
6# package .mk files for LuaRocks packages.
7# LuaRocks supports various build.type : builtin, make, cmake.
8# This luarocks infrastructure supports only the builtin mode,
9# the make & cmake modes could be directly handled by generic & cmake infrastructure.
10#
11# See the Buildroot documentation for details on the usage of this
12# infrastructure
13#
14# In terms of implementation, this LuaRocks infrastructure requires
Thomas De Schampheleire60714bb2014-07-24 20:07:02 +020015# the .mk file to only specify metadata information about the
Francois Perrad72afb292014-01-11 16:42:07 +010016# package: name, version, etc.
17#
18################################################################################
19
20################################################################################
21# inner-luarocks-package -- defines how the configuration, compilation and
22# installation of a LuaRocks package should be done, implements a few hooks to
23# tune the build process and calls the generic package infrastructure to
24# generate the necessary make targets
25#
26# argument 1 is the lowercase package name
Thomas De Schampheleire5bd9ed62014-07-24 20:57:41 +020027# argument 2 is the uppercase package name, including a HOST_ prefix
Francois Perrad72afb292014-01-11 16:42:07 +010028# for host packages
29# argument 3 is the uppercase package name, without the HOST_ prefix
30# for host packages
Thomas De Schampheleire26aef882014-02-05 10:44:03 +010031# argument 4 is the type (target or host)
Francois Perrad72afb292014-01-11 16:42:07 +010032################################################################################
33
34define inner-luarocks-package
35
Thomas De Schampheleirea603eb12014-09-27 21:32:45 +020036$(2)_BUILD_OPTS ?=
Thomas De Schampheleire54456cc2014-06-11 21:12:24 +020037$(2)_SUBDIR ?= $(1)-$$(shell echo "$$($(3)_VERSION)" | sed -e "s/-[0-9]$$$$//")
38$(2)_ROCKSPEC ?= $(1)-$$($(3)_VERSION).rockspec
39$(2)_SOURCE ?= $(1)-$$($(3)_VERSION).src.rock
40$(2)_SITE ?= $$(call qstrip,$$(BR2_LUAROCKS_MIRROR))
Francois Perrad72afb292014-01-11 16:42:07 +010041
42# Since we do not support host-luarocks-package, we know this is
43# a target package, and can just add the required dependencies
44$(2)_DEPENDENCIES += host-luarocks luainterpreter
45
Francois Perrad72afb292014-01-11 16:42:07 +010046#
47# Extract step
48#
49ifndef $(2)_EXTRACT_CMDS
50define $(2)_EXTRACT_CMDS
51 cd $$($(2)_DIR)/.. && \
Thomas De Schampheleire54456cc2014-06-11 21:12:24 +020052 $$(LUAROCKS_RUN) unpack --force $$(DL_DIR)/$$($(2)_SOURCE)
Francois Perrad72afb292014-01-11 16:42:07 +010053endef
54endif
55
56#
57# Build/install step.
58#
59ifndef $(2)_INSTALL_TARGET_CMDS
60define $(2)_INSTALL_TARGET_CMDS
61 cd $$($(2)_SRCDIR) && \
Thomas De Schampheleirea603eb12014-09-27 21:32:45 +020062 $$(LUAROCKS_RUN) make --keep $$($(2)_ROCKSPEC) $$($(2)_BUILD_OPTS)
Francois Perrad72afb292014-01-11 16:42:07 +010063endef
64endif
65
66# Call the generic package infrastructure to generate the necessary
67# make targets
Thomas De Schampheleire26aef882014-02-05 10:44:03 +010068$(call inner-generic-package,$(1),$(2),$(3),$(4))
Francois Perrad72afb292014-01-11 16:42:07 +010069
Fabio Porcedda207d2ac2014-04-01 11:12:50 +020070# $(2)_DEPENDENCIES are handled for configure step (too late)
71# but host-luarocks is required to do the extract
72$$($(2)_TARGET_EXTRACT): | host-luarocks
73
Francois Perrad72afb292014-01-11 16:42:07 +010074endef
75
76################################################################################
77# luarocks-package -- the target generator macro for LuaRocks packages
78################################################################################
79
Thomas De Schampheleire26aef882014-02-05 10:44:03 +010080luarocks-package = $(call inner-luarocks-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
Francois Perrad72afb292014-01-11 16:42:07 +010081# host-luarocks-package not supported