Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 1 | ################################################################################ |
| 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 Schampheleire | 60714bb | 2014-07-24 20:07:02 +0200 | [diff] [blame] | 15 | # the .mk file to only specify metadata information about the |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 16 | # 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 Schampheleire | 5bd9ed6 | 2014-07-24 20:57:41 +0200 | [diff] [blame] | 27 | # argument 2 is the uppercase package name, including a HOST_ prefix |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 28 | # for host packages |
| 29 | # argument 3 is the uppercase package name, without the HOST_ prefix |
| 30 | # for host packages |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 31 | # argument 4 is the type (target or host) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 32 | ################################################################################ |
| 33 | |
| 34 | define inner-luarocks-package |
| 35 | |
Thomas De Schampheleire | a603eb1 | 2014-09-27 21:32:45 +0200 | [diff] [blame] | 36 | $(2)_BUILD_OPTS ?= |
Arnout Vandecappelle | 75cf694 | 2017-02-23 18:00:40 +0100 | [diff] [blame] | 37 | $(2)_NAME_UPSTREAM ?= $(1) |
| 38 | $(2)_SUBDIR ?= $$($(2)_NAME_UPSTREAM)-$$(shell echo "$$($(2)_VERSION)" | sed -e "s/-[0-9]$$$$//") |
Arnout Vandecappelle | 01372b0 | 2017-02-23 18:00:42 +0100 | [diff] [blame] | 39 | $(2)_ROCKSPEC ?= $$(call LOWERCASE,$$($(2)_NAME_UPSTREAM))-$$($(2)_VERSION).rockspec |
| 40 | $(2)_SOURCE ?= $$(call LOWERCASE,$$($(2)_NAME_UPSTREAM))-$$($(2)_VERSION).src.rock |
Thomas De Schampheleire | 54456cc | 2014-06-11 21:12:24 +0200 | [diff] [blame] | 41 | $(2)_SITE ?= $$(call qstrip,$$(BR2_LUAROCKS_MIRROR)) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 42 | |
| 43 | # Since we do not support host-luarocks-package, we know this is |
| 44 | # a target package, and can just add the required dependencies |
| 45 | $(2)_DEPENDENCIES += host-luarocks luainterpreter |
| 46 | |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 47 | # |
Arnout Vandecappelle | 55d74b8 | 2017-02-23 18:00:38 +0100 | [diff] [blame] | 48 | # Extract step. Extract into a temporary dir and move the relevant part to the |
| 49 | # source dir. |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 50 | # |
| 51 | ifndef $(2)_EXTRACT_CMDS |
| 52 | define $(2)_EXTRACT_CMDS |
Arnout Vandecappelle | 55d74b8 | 2017-02-23 18:00:38 +0100 | [diff] [blame] | 53 | mkdir -p $$($(2)_DIR)/luarocks-extract |
| 54 | cd $$($(2)_DIR)/luarocks-extract && \ |
Fabio Porcedda | 22b327f | 2015-07-01 10:10:47 +0200 | [diff] [blame] | 55 | $$(LUAROCKS_RUN_ENV) $$(LUAROCKS_RUN_CMD) unpack --force $$(DL_DIR)/$$($(2)_SOURCE) |
Arnout Vandecappelle | 55d74b8 | 2017-02-23 18:00:38 +0100 | [diff] [blame] | 56 | mv $$($(2)_DIR)/luarocks-extract/*/* $$($(2)_DIR) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 57 | endef |
| 58 | endif |
| 59 | |
| 60 | # |
| 61 | # Build/install step. |
| 62 | # |
| 63 | ifndef $(2)_INSTALL_TARGET_CMDS |
| 64 | define $(2)_INSTALL_TARGET_CMDS |
Fabio Porcedda | 22b327f | 2015-07-01 10:10:47 +0200 | [diff] [blame] | 65 | cd $$($(2)_SRCDIR) && $$(LUAROCKS_RUN_ENV) flock $$(TARGET_DIR) \ |
| 66 | $$(LUAROCKS_RUN_CMD) make --keep $$($(2)_ROCKSPEC) $$($(2)_BUILD_OPTS) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 67 | endef |
| 68 | endif |
| 69 | |
| 70 | # Call the generic package infrastructure to generate the necessary |
| 71 | # make targets |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 72 | $(call inner-generic-package,$(1),$(2),$(3),$(4)) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 73 | |
Fabio Porcedda | 207d2ac | 2014-04-01 11:12:50 +0200 | [diff] [blame] | 74 | # $(2)_DEPENDENCIES are handled for configure step (too late) |
| 75 | # but host-luarocks is required to do the extract |
| 76 | $$($(2)_TARGET_EXTRACT): | host-luarocks |
| 77 | |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 78 | endef |
| 79 | |
| 80 | ################################################################################ |
| 81 | # luarocks-package -- the target generator macro for LuaRocks packages |
| 82 | ################################################################################ |
| 83 | |
Thomas De Schampheleire | 26aef88 | 2014-02-05 10:44:03 +0100 | [diff] [blame] | 84 | luarocks-package = $(call inner-luarocks-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) |
Francois Perrad | 72afb29 | 2014-01-11 16:42:07 +0100 | [diff] [blame] | 85 | # host-luarocks-package not supported |