diff options
Diffstat (limited to 'GNUmakefile')
-rw-r--r-- | GNUmakefile | 203 |
1 files changed, 14 insertions, 189 deletions
diff --git a/GNUmakefile b/GNUmakefile index 46be0cc6..cb0f72dd 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
@@ -1,197 +1,22 @@ | |||
1 | MAKEFLAGS += --jobs=1 | ||
2 | 1 | ||
3 | -include config.unix | 2 | CC = gcc |
3 | MKDIR = mkdir | ||
4 | MYLIBS = -llua -lz -lbz2 -lssl -lcrypto | ||
4 | 5 | ||
5 | datarootdir = $(prefix)/share | 6 | ZLIB_INCDIR = /usr/include |
6 | bindir = $(prefix)/bin | 7 | BZ2_INCDIR = /usr/include |
7 | INSTALL = install | 8 | OPENSSL_INCDIR = /usr/include |
8 | INSTALL_DATA = $(INSTALL) -m 644 | ||
9 | BINARY_PLATFORM = unix | ||
10 | 9 | ||
11 | SHEBANG = \#!$(LUA) | 10 | all: luarocks |
12 | luarocksconfdir = $(sysconfdir)/luarocks | ||
13 | luadir = $(datarootdir)/lua/$(LUA_VERSION) | ||
14 | builddir = ./build | ||
15 | buildbinarydir = ./build-binary | ||
16 | 11 | ||
17 | LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua') | 12 | -include Makefile.vendor |
18 | 13 | ||
19 | LUA_ENV_VARS = LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4 LUA_CPATH LUA_CPATH_5_2 LUA_CPATH_5_3 LUA_CPATH_5_4 | 14 | luarocks: src/main.c gen/gen.h gen/libraries.h gen/main.h $(VENDOR_LIBS) |
15 | $(CC) -o luarocks $(MYLIBS) -I. src/main.c $(VENDOR_LIBS) | ||
20 | 16 | ||
21 | all: build | 17 | clean: |
18 | rm -rf gen target | ||
22 | 19 | ||
23 | # ---------------------------------------- | 20 | gen: clean |
24 | # Base build | 21 | ./bootstrap.tl |
25 | # ---------------------------------------- | ||
26 | 22 | ||
27 | build: config.unix $(builddir)/config-$(LUA_VERSION).lua $(builddir)/luarocks $(builddir)/luarocks-admin | ||
28 | |||
29 | config.unix: | ||
30 | @echo Please run the "./configure" script before building. | ||
31 | @echo | ||
32 | @exit 1 | ||
33 | |||
34 | $(builddir)/config-$(LUA_VERSION).lua: config.unix | ||
35 | mkdir -p "$(@D)" | ||
36 | @printf -- '-- LuaRocks configuration\n\n'\ | ||
37 | 'rocks_trees = {\n'\ | ||
38 | ' { name = "user", root = home .. "/.luarocks" };\n'\ | ||
39 | "$$([ "$(rocks_tree)" != "$(HOME)/.luarocks" ] && printf ' { name = "system", root = "'"$(rocks_tree)"'" };\\n')"\ | ||
40 | '}\n'\ | ||
41 | 'variables = {\n'\ | ||
42 | "$$([ -n "$(LUA_DIR)" ] && printf ' LUA_DIR = "%s";\\n' "$(LUA_DIR)")"\ | ||
43 | "$$([ -n "$(LUA_INCDIR)" ] && printf ' LUA_INCDIR = "%s";\\n' "$(LUA_INCDIR)")"\ | ||
44 | "$$([ -n "$(LUA_BINDIR)" ] && printf ' LUA_BINDIR = "%s";\\n' "$(LUA_BINDIR)")"\ | ||
45 | "$$([ -n "$(LUA_LIBDIR)" ] && printf ' LUA_LIBDIR = "%s";\\n' "$(LUA_LIBDIR)")"\ | ||
46 | "$$([ -n "$(LUA_VERSION)" ] && printf ' LUA_VERSION = "%s";\\n' "$(LUA_VERSION)")"\ | ||
47 | "$$([ -n "$(LUA)" ] && printf ' LUA = "%s";\\n' "$(LUA)")"\ | ||
48 | '}\n'\ | ||
49 | > $@ | ||
50 | |||
51 | luarocks: config.unix $(builddir)/config-$(LUA_VERSION).lua | ||
52 | mkdir -p .luarocks | ||
53 | cp $(builddir)/config-$(LUA_VERSION).lua .luarocks/config-$(LUA_VERSION).lua | ||
54 | rm -f src/luarocks/core/hardcoded.lua | ||
55 | echo "#!/bin/sh" > luarocks | ||
56 | echo "unset $(LUA_ENV_VARS)" >> luarocks | ||
57 | echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks | ||
58 | chmod +rx ./luarocks | ||
59 | ./luarocks init | ||
60 | |||
61 | luarocks-admin: config.unix | ||
62 | rm -f src/luarocks/core/hardcoded.lua | ||
63 | echo "#!/bin/sh" > luarocks-admin | ||
64 | echo "unset $(LUA_ENV_VARS)" >> luarocks-admin | ||
65 | echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin | ||
66 | chmod +rx ./luarocks-admin | ||
67 | |||
68 | $(builddir)/luarocks: src/bin/luarocks config.unix | ||
69 | mkdir -p "$(@D)" | ||
70 | (printf '$(SHEBANG)\n'\ | ||
71 | 'package.loaded["luarocks.core.hardcoded"] = { '\ | ||
72 | "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\ | ||
73 | 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ | ||
74 | 'package.path=[[$(luadir)/?.lua;]] .. package.path\n'\ | ||
75 | 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \ | ||
76 | tail -n +2 src/bin/luarocks \ | ||
77 | )> "$@" | ||
78 | |||
79 | $(builddir)/luarocks-admin: src/bin/luarocks-admin config.unix | ||
80 | mkdir -p "$(@D)" | ||
81 | (printf '$(SHEBANG)\n'\ | ||
82 | 'package.loaded["luarocks.core.hardcoded"] = { '\ | ||
83 | "$$([ -n "$(FORCE_CONFIG)" ] && printf 'FORCE_CONFIG = true, ')"\ | ||
84 | 'SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ | ||
85 | 'package.path=[[$(luadir)/?.lua;]] .. package.path\n'\ | ||
86 | 'local list = package.searchers or package.loaders; table.insert(list, 1, function(name) if name:match("^luarocks%%.") then return loadfile([[$(luadir)/]] .. name:gsub([[%%.]], [[/]]) .. [[.lua]]) end end)\n'; \ | ||
87 | tail -n +2 src/bin/luarocks-admin \ | ||
88 | )> "$@" | ||
89 | |||
90 | # ---------------------------------------- | ||
91 | # Base build | ||
92 | # ---------------------------------------- | ||
93 | |||
94 | binary: luarocks $(buildbinarydir)/luarocks.exe $(buildbinarydir)/luarocks-admin.exe | ||
95 | |||
96 | $(buildbinarydir)/luarocks.exe: src/bin/luarocks $(LUAROCKS_FILES) | ||
97 | (unset $(LUA_ENV_VARS); \ | ||
98 | "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/admin/" "$(luarocksconfdir)" "$(@D)" "$(FORCE_CONFIG)" $(BINARY_PLATFORM) $(CC) $(NM) $(BINARY_SYSROOT)) | ||
99 | |||
100 | $(buildbinarydir)/luarocks-admin.exe: src/bin/luarocks-admin $(LUAROCKS_FILES) | ||
101 | (unset $(LUA_ENV_VARS); \ | ||
102 | "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(luarocksconfdir)" "$(@D)" "$(FORCE_CONFIG)" $(BINARY_PLATFORM) $(CC) $(NM) $(BINARY_SYSROOT)) | ||
103 | |||
104 | # ---------------------------------------- | ||
105 | # Regular install | ||
106 | # ---------------------------------------- | ||
107 | |||
108 | INSTALL_FILES = | ||
109 | |||
110 | install: all install-config | ||
111 | mkdir -p '$(DESTDIR)$(bindir)/' | ||
112 | $(INSTALL) '$(builddir)/luarocks' '$(DESTDIR)$(bindir)/luarocks' | ||
113 | $(INSTALL) '$(builddir)/luarocks-admin' '$(DESTDIR)$(bindir)/luarocks-admin' | ||
114 | find src/luarocks/ -type d | while read f; \ | ||
115 | do \ | ||
116 | mkdir -p '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ | ||
117 | done | ||
118 | find src/luarocks/ -type f -name '*.lua' | while read f; \ | ||
119 | do \ | ||
120 | $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ | ||
121 | done | ||
122 | ifeq (,$(findstring $(LUA_VERSION),"5.3" "5.4")) | ||
123 | find src/compat53/ -type d | while read f; \ | ||
124 | do \ | ||
125 | mkdir -p '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ | ||
126 | done | ||
127 | find src/compat53/ -type f -name '*.lua' | while read f; \ | ||
128 | do \ | ||
129 | $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ | ||
130 | done | ||
131 | endif | ||
132 | |||
133 | install-config: | ||
134 | mkdir -p '$(DESTDIR)$(luarocksconfdir)/' | ||
135 | $(INSTALL_DATA) '$(builddir)/config-$(LUA_VERSION).lua' '$(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua' | ||
136 | |||
137 | uninstall: | ||
138 | rm -rf $(DESTDIR)$(bindir)/luarocks \ | ||
139 | $(DESTDIR)$(bindir)/luarocks-admin \ | ||
140 | $(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua \ | ||
141 | $(patsubst src/%, $(DESTDIR)$(luadir)/%, $(LUAROCKS_FILES)) | ||
142 | |||
143 | # ---------------------------------------- | ||
144 | # Binary install | ||
145 | # ---------------------------------------- | ||
146 | |||
147 | install-binary: binary install-config | ||
148 | mkdir -p '$(DESTDIR)$(bindir)/' | ||
149 | $(INSTALL) "$(buildbinarydir)/luarocks.exe" "$(DESTDIR)$(bindir)/luarocks" | ||
150 | $(INSTALL) "$(buildbinarydir)/luarocks-admin.exe" "$(DESTDIR)$(bindir)/luarocks-admin" | ||
151 | mkdir -p '$(DESTDIR)$(luadir)/luarocks/core' | ||
152 | for f in src/luarocks/core/*.lua src/luarocks/loader.lua; \ | ||
153 | do \ | ||
154 | $(INSTALL_DATA) "$$f" '$(DESTDIR)$(luadir)'/`echo $$f | sed 's,^src/,,'`; \ | ||
155 | done | ||
156 | |||
157 | # ---------------------------------------- | ||
158 | # Bootstrap install | ||
159 | # ---------------------------------------- | ||
160 | |||
161 | bootstrap: luarocks install-config | ||
162 | ./luarocks make --tree="$(DESTDIR)$(rocks_tree)" | ||
163 | |||
164 | # ---------------------------------------- | ||
165 | # Windows binary build | ||
166 | # ---------------------------------------- | ||
167 | |||
168 | windows-binary: windows-binary-32 windows-binary-64 | ||
169 | |||
170 | windows-clean: windows-clean-32 windows-clean-64 | ||
171 | |||
172 | windows-binary-32: luarocks | ||
173 | $(MAKE) -f binary/Makefile.windows windows-binary MINGW_PREFIX=i686-w64-mingw32 OPENSSL_PLATFORM=mingw | ||
174 | |||
175 | windows-clean-32: | ||
176 | $(MAKE) -f binary/Makefile.windows windows-clean MINGW_PREFIX=i686-w64-mingw32 OPENSSL_PLATFORM=mingw | ||
177 | |||
178 | windows-binary-64: luarocks | ||
179 | $(MAKE) -f binary/Makefile.windows windows-binary MINGW_PREFIX=x86_64-w64-mingw32 OPENSSL_PLATFORM=mingw64 | ||
180 | |||
181 | windows-clean-64: | ||
182 | $(MAKE) -f binary/Makefile.windows windows-clean MINGW_PREFIX=x86_64-w64-mingw32 OPENSSL_PLATFORM=mingw64 | ||
183 | |||
184 | # ---------------------------------------- | ||
185 | # Clean | ||
186 | # ---------------------------------------- | ||
187 | |||
188 | clean: windows-clean | ||
189 | rm -rf ./config.unix \ | ||
190 | ./luarocks \ | ||
191 | ./luarocks-admin \ | ||
192 | $(builddir)/ \ | ||
193 | $(buildbinarydir)/ \ | ||
194 | ./.luarocks \ | ||
195 | ./lua_modules | ||
196 | |||
197 | .PHONY: all build install install-config binary install-binary bootstrap clean windows-binary windows-clean | ||