aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile56
-rw-r--r--binary/Makefile.windows2
-rwxr-xr-xbinary/all_in_one2
3 files changed, 32 insertions, 28 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 45eb38b1..a8e2a01e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -8,6 +8,7 @@ bindir ?= $(prefix)/bin
8sysconfdir ?= $(prefix)/etc 8sysconfdir ?= $(prefix)/etc
9INSTALL ?= install 9INSTALL ?= install
10INSTALL_DATA ?= $(INSTALL) -m 644 10INSTALL_DATA ?= $(INSTALL) -m 644
11BINARY_PLATFORM ?= unix
11 12
12LUA_INTERPRETER ?= lua 13LUA_INTERPRETER ?= lua
13ifdef LUA_BINDIR 14ifdef LUA_BINDIR
@@ -21,6 +22,8 @@ LUA_VERSION ?= $(shell $(LUA) -e 'print(_VERSION:match(" (5%.[1234])$$"))')
21rocks_tree ?= $(prefix) 22rocks_tree ?= $(prefix)
22luarocksconfdir ?= $(sysconfdir)/luarocks 23luarocksconfdir ?= $(sysconfdir)/luarocks
23luadir ?= $(datarootdir)/lua/$(LUA_VERSION) 24luadir ?= $(datarootdir)/lua/$(LUA_VERSION)
25builddir ?= ./build
26buildbinarydir ?= ./build-binary
24 27
25 28
26LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua') 29LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua')
@@ -31,7 +34,7 @@ all: build
31# Base build 34# Base build
32# ---------------------------------------- 35# ----------------------------------------
33 36
34build: luarocks luarocks-admin ./build/luarocks ./build/luarocks-admin 37build: luarocks luarocks-admin $(builddir)/luarocks $(builddir)/luarocks-admin
35 38
36config.unix: 39config.unix:
37 @echo Please run the "./configure" script before building. 40 @echo Please run the "./configure" script before building.
@@ -70,7 +73,7 @@ luarocks-admin: config.unix
70 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin 73 echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin
71 chmod +rx ./luarocks-admin 74 chmod +rx ./luarocks-admin
72 75
73./build/luarocks: src/bin/luarocks config.unix 76$(builddir)/luarocks: src/bin/luarocks config.unix
74 mkdir -p "$(@D)" 77 mkdir -p "$(@D)"
75 (printf '$(SHEBANG)\n'\ 78 (printf '$(SHEBANG)\n'\
76 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ 79 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\
@@ -78,7 +81,7 @@ luarocks-admin: config.unix
78 tail -n +2 src/bin/luarocks \ 81 tail -n +2 src/bin/luarocks \
79 )> "$@" 82 )> "$@"
80 83
81./build/luarocks-admin: src/bin/luarocks-admin config.unix 84$(builddir)/luarocks-admin: src/bin/luarocks-admin config.unix
82 mkdir -p "$(@D)" 85 mkdir -p "$(@D)"
83 (printf '$(SHEBANG)\n'\ 86 (printf '$(SHEBANG)\n'\
84 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ 87 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\
@@ -87,6 +90,20 @@ luarocks-admin: config.unix
87 )> "$@" 90 )> "$@"
88 91
89# ---------------------------------------- 92# ----------------------------------------
93# Base build
94# ----------------------------------------
95
96binary: luarocks $(buildbinarydir)/luarocks.exe $(buildbinarydir)/luarocks-admin.exe
97
98$(buildbinarydir)/luarocks.exe: src/bin/luarocks $(LUAROCKS_FILES)
99 (unset $(LUA_ENV_VARS); \
100 "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/admin/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT))
101
102$(buildbinarydir)/luarocks-admin.exe: src/bin/luarocks-admin $(LUAROCKS_FILES)
103 (unset $(LUA_ENV_VARS); \
104 "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT))
105
106# ----------------------------------------
90# Regular install 107# Regular install
91# ---------------------------------------- 108# ----------------------------------------
92 109
@@ -97,45 +114,32 @@ INSTALL_FILES = $(DESTDIR)$(bindir)/luarocks \
97 114
98install: $(INSTALL_FILES) 115install: $(INSTALL_FILES)
99 116
100$(DESTDIR)$(bindir)/luarocks: ./build/luarocks 117$(DESTDIR)$(bindir)/luarocks: $(builddir)/luarocks
101 $(INSTALL) -D "$<" "$@" 118 $(INSTALL) -D "$<" "$@"
102 119
103$(DESTDIR)$(bindir)/luarocks-admin: ./build/luarocks-admin 120$(DESTDIR)$(bindir)/luarocks-admin: $(builddir)/luarocks-admin
104 $(INSTALL) -D "$<" "$@" 121 $(INSTALL) -D "$<" "$@"
105 122
106$(DESTDIR)$(luadir)/luarocks/%.lua: src/luarocks/%.lua 123$(DESTDIR)$(luadir)/luarocks/%.lua: src/luarocks/%.lua
107 $(INSTALL_DATA) -D "$<" "$@" 124 $(INSTALL_DATA) -D "$<" "$@"
108 125
109$(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua: ./build/config-$(LUA_VERSION).lua 126$(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua: $(builddir)/config-$(LUA_VERSION).lua
110 $(INSTALL_DATA) -D "$<" "$@" 127 $(INSTALL_DATA) -D "$<" "$@"
111 128
112uninstall: 129uninstall:
113 rm -rf $(INSTALL_FILES) 130 rm -rf $(INSTALL_FILES)
114 131
115# ---------------------------------------- 132# ----------------------------------------
116# Binary build
117# ----------------------------------------
118
119binary: build-binary/luarocks.exe build-binary/luarocks-admin.exe
120
121build-binary/luarocks.exe: src/bin/luarocks $(LUAROCKS_FILES)
122 (unset $(LUA_ENV_VARS); \
123 "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/admin/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT))
124
125build-binary/luarocks-admin.exe: src/bin/luarocks-admin $(LUAROCKS_FILES)
126 (unset $(LUA_ENV_VARS); \
127 "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT))
128
129# ----------------------------------------
130# Binary install 133# Binary install
131# ---------------------------------------- 134# ----------------------------------------
132 135
133LUAROCKS_CORE_FILES = $(wildcard src/luarocks/core/* src/luarocks/loader.lua) 136LUAROCKS_CORE_FILES = $(wildcard src/luarocks/core/* src/luarocks/loader.lua)
134INSTALL_BINARY_FILES = $(patsubst src/%, $(DESTDIR)$(luadir)/%, $(LUAROCKS_CORE_FILES)) 137INSTALL_BINARY_FILES = $(patsubst src/%, $(DESTDIR)$(luadir)/%, $(LUAROCKS_CORE_FILES)) \
138 $(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua
135 139
136install-binary: $(INSTALL_BINARY_FILES) build-binary/luarocks.exe build-binary/luarocks-admin.exe 140install-binary: $(INSTALL_BINARY_FILES)
137 $(INSTALL) -D build-binary/luarocks.exe "$(DESTDIR)$(bindir)/luarocks" 141 $(INSTALL) -D "$(buildbinarydir)/luarocks.exe" "$(DESTDIR)$(bindir)/luarocks"
138 $(INSTALL) -D build-binary/luarocks-admin.exe "$(DESTDIR)$(bindir)/luarocks-admin" 142 $(INSTALL) -D "$(buildbinarydir)/luarocks-admin.exe" "$(DESTDIR)$(bindir)/luarocks-admin"
139 143
140# ---------------------------------------- 144# ----------------------------------------
141# Bootstrap install 145# Bootstrap install
@@ -162,8 +166,8 @@ clean: windows-clean
162 rm -rf ./config.unix \ 166 rm -rf ./config.unix \
163 ./luarocks \ 167 ./luarocks \
164 ./luarocks-admin \ 168 ./luarocks-admin \
165 ./build/ \ 169 $(builddir)/ \
166 build-binary \ 170 $(buildbinarydir)/ \
167 ./.luarocks \ 171 ./.luarocks \
168 ./lua_modules 172 ./lua_modules
169 173
diff --git a/binary/Makefile.windows b/binary/Makefile.windows
index e7a5ea3b..e7bcca27 100644
--- a/binary/Makefile.windows
+++ b/binary/Makefile.windows
@@ -16,7 +16,7 @@ windows-binary: windows-deps/lib/liblua.a windows-deps/lib/libssl.a windows-deps
16 STATIC_GCC_RANLIB=$(MINGW_PREFIX)-ranlib \ 16 STATIC_GCC_RANLIB=$(MINGW_PREFIX)-ranlib \
17 STATIC_GCC_CC=$(MINGW_PREFIX)-gcc \ 17 STATIC_GCC_CC=$(MINGW_PREFIX)-gcc \
18 LUAROCKS_CROSS_COMPILING=1 \ 18 LUAROCKS_CROSS_COMPILING=1 \
19 $(MAKE) binary LUA_DIR=$(CURDIR)/windows-deps CC=$(MINGW_PREFIX)-gcc NM=$(MINGW_PREFIX)-nm BINARY_PLATFORM=windows BINARY_TARGET=build-windows-binary BINARY_SYSROOT=$(MINGW_SYSROOT) 19 $(MAKE) binary LUA_DIR=$(CURDIR)/windows-deps CC=$(MINGW_PREFIX)-gcc NM=$(MINGW_PREFIX)-nm BINARY_PLATFORM=windows buildbinarydir=build-windows-binary BINARY_SYSROOT=$(MINGW_SYSROOT)
20 20
21build-windows-deps/lua-$(LIBLUA_VERSION).tar.gz: 21build-windows-deps/lua-$(LIBLUA_VERSION).tar.gz:
22 mkdir -p $(@D) 22 mkdir -p $(@D)
diff --git a/binary/all_in_one b/binary/all_in_one
index f1c2e0a1..d6517d79 100755
--- a/binary/all_in_one
+++ b/binary/all_in_one
@@ -29,7 +29,7 @@ local MAIN_PROGRAM = arg[1] or "src/bin/luarocks"
29local LUA_DIR = arg[2] or "/usr" 29local LUA_DIR = arg[2] or "/usr"
30local EXCLUDE = arg[3] or "^src/luarocks/admin/" 30local EXCLUDE = arg[3] or "^src/luarocks/admin/"
31local SYSCONFDIR = arg[4] or "/etc/luarocks" 31local SYSCONFDIR = arg[4] or "/etc/luarocks"
32local TARGET = arg[5] or "binary-build" 32local TARGET = arg[5] or "build-binary"
33local MY_PLATFORM = arg[6] or "unix" 33local MY_PLATFORM = arg[6] or "unix"
34local CC = arg[7] or "gcc" 34local CC = arg[7] or "gcc"
35local NM = arg[8] or "nm" 35local NM = arg[8] or "nm"