diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 90 |
1 files changed, 47 insertions, 43 deletions
@@ -4,6 +4,7 @@ include config.unix | |||
4 | 4 | ||
5 | DESTDIR = | 5 | DESTDIR = |
6 | PREFIX ?= /usr/local | 6 | PREFIX ?= /usr/local |
7 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks | ||
7 | BINDIR ?= $(PREFIX)/bin | 8 | BINDIR ?= $(PREFIX)/bin |
8 | LUADIR ?= $(PREFIX)/share/lua/5.1/ | 9 | LUADIR ?= $(PREFIX)/share/lua/5.1/ |
9 | LUA_DIR ?= /usr/local | 10 | LUA_DIR ?= /usr/local |
@@ -19,62 +20,61 @@ remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua \ | |||
19 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ | 20 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ |
20 | help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua | 21 | help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua |
21 | 22 | ||
22 | |||
23 | CONFIG_FILE = $(SYSCONFDIR)/config.lua | 23 | CONFIG_FILE = $(SYSCONFDIR)/config.lua |
24 | 24 | ||
25 | all: built | 25 | all: built |
26 | 26 | ||
27 | built: | 27 | src/luarocks/config.lua: config.unix |
28 | for f in $(BIN_FILES) ;\ | 28 | rm -f src/luarocks/config.lua |
29 | do \ | 29 | echo 'module("luarocks.config")' >> src/luarocks/config.lua |
30 | sed "1d" src/bin/$$f >> src/bin/$$f.bak ;\ | ||
31 | echo "#!$(LUA_BINDIR)/lua$(LUA_SUFFIX)" > src/bin/$$f ;\ | ||
32 | echo "package.path = [[$(LUADIR)/?.lua;$(LUADIR)/?/init.lua;]]..package.path" >> src/bin/$$f ;\ | ||
33 | cat src/bin/$$f.bak >> src/bin/$$f ;\ | ||
34 | rm src/bin/$$f.bak ;\ | ||
35 | done | ||
36 | sed -i.bak "/^local LUA/d" src/luarocks/cfg.lua | ||
37 | rm src/luarocks/cfg.lua.bak | ||
38 | cp src/luarocks/cfg.lua src/luarocks/cfg.lua.bak | ||
39 | rm src/luarocks/cfg.lua | ||
40 | if [ -n "$(PREFIX)" ] ;\ | 30 | if [ -n "$(PREFIX)" ] ;\ |
41 | then \ | 31 | then \ |
42 | echo "local LUAROCKS_PREFIX=[[$(PREFIX)]]" >> src/luarocks/cfg.lua ;\ | 32 | echo "LUAROCKS_PREFIX=[[$(PREFIX)]]" >> src/luarocks/config.lua ;\ |
43 | fi | 33 | fi |
44 | if [ -n "$(LUA_INCDIR)" ] ;\ | 34 | if [ -n "$(LUA_INCDIR)" ] ;\ |
45 | then \ | 35 | then \ |
46 | echo "local LUA_INCDIR=[[$(LUA_INCDIR)]]" >> src/luarocks/cfg.lua ;\ | 36 | echo "LUA_INCDIR=[[$(LUA_INCDIR)]]" >> src/luarocks/config.lua ;\ |
47 | fi | 37 | fi |
48 | if [ -n "$(LUA_LIBDIR)" ] ;\ | 38 | if [ -n "$(LUA_LIBDIR)" ] ;\ |
49 | then \ | 39 | then \ |
50 | echo "local LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> src/luarocks/cfg.lua ;\ | 40 | echo "LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> src/luarocks/config.lua ;\ |
51 | fi | 41 | fi |
52 | if [ -n "$(LUA_BINDIR)" ] ;\ | 42 | if [ -n "$(LUA_BINDIR)" ] ;\ |
53 | then \ | 43 | then \ |
54 | echo "local LUA_BINDIR=[[$(LUA_BINDIR)]]" >> src/luarocks/cfg.lua ;\ | 44 | echo "LUA_BINDIR=[[$(LUA_BINDIR)]]" >> src/luarocks/config.lua ;\ |
55 | fi | 45 | fi |
56 | if [ -n "$(LUA_SUFFIX)" ] ;\ | 46 | if [ -n "$(LUA_SUFFIX)" ] ;\ |
57 | then \ | 47 | then \ |
58 | echo "local LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> src/luarocks/cfg.lua ;\ | 48 | echo "LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> src/luarocks/config.lua ;\ |
59 | fi | 49 | fi |
60 | if [ -n "$(SYSCONFDIR)" ] ;\ | 50 | if [ -n "$(SYSCONFDIR)" ] ;\ |
61 | then \ | 51 | then \ |
62 | echo "local LUAROCKS_SYSCONFIG=[[$(SYSCONFDIR)/config.lua]]" >> src/luarocks/cfg.lua ;\ | 52 | echo "LUAROCKS_SYSCONFIG=[[$(SYSCONFDIR)/config.lua]]" >> src/luarocks/config.lua ;\ |
63 | fi | 53 | fi |
64 | if [ -n "$(ROCKS_TREE)" ] ;\ | 54 | if [ -n "$(ROCKS_TREE)" ] ;\ |
65 | then \ | 55 | then \ |
66 | echo "local LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> src/luarocks/cfg.lua ;\ | 56 | echo "LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> src/luarocks/config.lua ;\ |
67 | fi | 57 | fi |
68 | if [ -n "$(FORCE_CONFIG)" ] ;\ | 58 | if [ -n "$(FORCE_CONFIG)" ] ;\ |
69 | then \ | 59 | then \ |
70 | echo "local LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/cfg.lua ;\ | 60 | echo "LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/config.lua ;\ |
71 | fi | 61 | fi |
72 | echo "local LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> src/luarocks/cfg.lua | 62 | echo "LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> src/luarocks/config.lua |
73 | echo "local LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/cfg.lua | 63 | echo "LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/config.lua |
74 | echo "local LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/cfg.lua | 64 | echo "LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/config.lua |
75 | echo "local LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/cfg.lua | 65 | echo "LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/config.lua |
76 | cat src/luarocks/cfg.lua.bak >> src/luarocks/cfg.lua | 66 | |
77 | rm src/luarocks/cfg.lua.bak | 67 | build_bins: |
68 | for f in $(BIN_FILES) ;\ | ||
69 | do \ | ||
70 | sed "1d" src/bin/$$f >> src/bin/$$f.bak ;\ | ||
71 | echo "#!$(LUA_BINDIR)/lua$(LUA_SUFFIX)" > src/bin/$$f ;\ | ||
72 | echo "package.path = [[$(LUADIR)/?.lua;$(LUADIR)/?/init.lua;]]..package.path" >> src/bin/$$f ;\ | ||
73 | cat src/bin/$$f.bak >> src/bin/$$f ;\ | ||
74 | rm src/bin/$$f.bak ;\ | ||
75 | done | ||
76 | |||
77 | built: src/luarocks/config.lua build_bins | ||
78 | touch built | 78 | touch built |
79 | @echo | 79 | @echo |
80 | @echo "Done. Type 'make install' to install into $(PREFIX)." | 80 | @echo "Done. Type 'make install' to install into $(PREFIX)." |
@@ -102,14 +102,22 @@ clean: | |||
102 | sed -i.bak "s,^#!.*lua.*,#!/usr/bin/env lua,;/^package.path/d" src/bin/$$f ;\ | 102 | sed -i.bak "s,^#!.*lua.*,#!/usr/bin/env lua,;/^package.path/d" src/bin/$$f ;\ |
103 | rm src/bin/$$f.bak ;\ | 103 | rm src/bin/$$f.bak ;\ |
104 | done | 104 | done |
105 | sed -i.bak "/^local LUA/d" src/luarocks/cfg.lua | 105 | rm -f src/luarocks/config.lua |
106 | rm src/luarocks/cfg.lua.bak | 106 | rm -f built |
107 | 107 | ||
108 | install: built | 108 | install_bins: |
109 | mkdir -p "$(DESTDIR)$(BINDIR)" | 109 | mkdir -p "$(DESTDIR)$(BINDIR)" |
110 | cd src/bin && cp $(BIN_FILES) "$(DESTDIR)$(BINDIR)" | 110 | cd src/bin && cp $(BIN_FILES) "$(DESTDIR)$(BINDIR)" |
111 | |||
112 | install_luas: | ||
111 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" | 113 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" |
112 | cd src/luarocks && for f in $(LUAROCKS_FILES); do d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"`; mkdir -p "$$d"; cp "$$f" "$$d"; done | 114 | cd src/luarocks && for f in $(LUAROCKS_FILES); do d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"`; mkdir -p "$$d"; cp "$$f" "$$d"; done |
115 | |||
116 | install_config: | ||
117 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" | ||
118 | cd src/luarocks && cp config.lua "$(DESTDIR)$(LUADIR)/luarocks" | ||
119 | |||
120 | write_sysconfig: | ||
113 | mkdir -p "$(DESTDIR)$(ROCKS_TREE)" | 121 | mkdir -p "$(DESTDIR)$(ROCKS_TREE)" |
114 | if [ ! -f "$(DESTDIR)$(CONFIG_FILE)" ] ;\ | 122 | if [ ! -f "$(DESTDIR)$(CONFIG_FILE)" ] ;\ |
115 | then \ | 123 | then \ |
@@ -124,17 +132,13 @@ install: built | |||
124 | fi ;\ | 132 | fi ;\ |
125 | echo ' [[$(ROCKS_TREE)]]' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | 133 | echo ' [[$(ROCKS_TREE)]]' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ |
126 | echo '}' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | 134 | echo '}' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ |
127 | if [ -n "$(SCRIPTS_DIR)" ] ;\ | ||
128 | then \ | ||
129 | echo "scripts_dir = [[$(SCRIPTS_DIR)]]" >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
130 | fi ;\ | ||
131 | if [ -n "$(LUA_MODULES_DIR)" ] ;\ | ||
132 | then \ | ||
133 | echo "lua_modules_dir = [[$(LUA_MODULES_DIR)]]" >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
134 | fi ;\ | ||
135 | if [ -n "$(BIN_MODULES_DIR)" ] ;\ | ||
136 | then \ | ||
137 | echo "bin_modules_dir = [[$(BIN_MODULES_DIR)]]" >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
138 | fi ;\ | ||
139 | fi | 135 | fi |
140 | 136 | ||
137 | install: built install_bins install_luas install_config write_sysconfig | ||
138 | |||
139 | bootstrap: src/luarocks/config.lua install_config write_sysconfig | ||
140 | LUA_PATH="$$PWD/src/?.lua;$$LUA_PATH" src/bin/luarocks make rockspec | ||
141 | |||
142 | #build_rock: build_bins | ||
143 | |||
144 | install_rock: install_bins install_luas | ||