aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile90
1 files changed, 47 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 5231cec4..c10a1cb0 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ include config.unix
4 4
5DESTDIR = 5DESTDIR =
6PREFIX ?= /usr/local 6PREFIX ?= /usr/local
7SYSCONFDIR ?= $(PREFIX)/etc/luarocks
7BINDIR ?= $(PREFIX)/bin 8BINDIR ?= $(PREFIX)/bin
8LUADIR ?= $(PREFIX)/share/lua/5.1/ 9LUADIR ?= $(PREFIX)/share/lua/5.1/
9LUA_DIR ?= /usr/local 10LUA_DIR ?= /usr/local
@@ -19,62 +20,61 @@ remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua \
19manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ 20manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \
20help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua 21help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua
21 22
22
23CONFIG_FILE = $(SYSCONFDIR)/config.lua 23CONFIG_FILE = $(SYSCONFDIR)/config.lua
24 24
25all: built 25all: built
26 26
27built: 27src/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 67build_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
77built: 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
108install: built 108install_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
112install_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
116install_config:
117 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
118 cd src/luarocks && cp config.lua "$(DESTDIR)$(LUADIR)/luarocks"
119
120write_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
137install: built install_bins install_luas install_config write_sysconfig
138
139bootstrap: 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
144install_rock: install_bins install_luas