diff options
author | Peter Drahoš <drahosp@gmail.com> | 2010-10-01 03:22:32 +0200 |
---|---|---|
committer | Peter Drahoš <drahosp@gmail.com> | 2010-10-01 03:22:32 +0200 |
commit | 89d9c98af1ac352ba4d49d660e61b0853d6e1a86 (patch) | |
tree | 15c56d2ce66b4ab147171c0f674cdb4a435ff13f /Makefile | |
download | lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.gz lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.bz2 lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.zip |
Import to git
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4c0ff4b --- /dev/null +++ b/Makefile | |||
@@ -0,0 +1,229 @@ | |||
1 | # | ||
2 | # Lanes/Makefile | ||
3 | # | ||
4 | # make | ||
5 | # make test | ||
6 | # make basic|fifo|keeper|... | ||
7 | # | ||
8 | # make perftest[-odd|-even|-plain] | ||
9 | # make launchtest | ||
10 | # | ||
11 | # make install DESTDIR=path | ||
12 | # make tar|tgz VERSION=x.x | ||
13 | # make clean | ||
14 | # | ||
15 | |||
16 | MODULE = lanes | ||
17 | |||
18 | N=1000 | ||
19 | |||
20 | _SO=.so | ||
21 | _TARGET_SO=src/lua51-lanes.so | ||
22 | TIME=time | ||
23 | |||
24 | ifeq "$(findstring MINGW32,$(shell uname -s))" "MINGW32" | ||
25 | # MinGW MSYS on XP | ||
26 | # | ||
27 | LUA=lua | ||
28 | LUAC=luac | ||
29 | _SO=.dll | ||
30 | _TARGET_SO=./lua51-lanes.dll | ||
31 | TIME=timeit.exe | ||
32 | else | ||
33 | # Autodetect LUA & LUAC | ||
34 | # | ||
35 | LUA=$(word 1,$(shell which lua5.1) $(shell which lua51) lua) | ||
36 | LUAC=$(word 1,$(shell which luac5.1) $(shell which luac51) luac) | ||
37 | endif | ||
38 | |||
39 | _PREFIX=LUA_CPATH=./src/?$(_SO) LUA_PATH="src/?.lua;./tests/?.lua" | ||
40 | |||
41 | #--- | ||
42 | all: $(_TARGET_SO) | ||
43 | |||
44 | $(_TARGET_SO): src/*.lua src/*.c src/*.h | ||
45 | cd src && $(MAKE) LUA=$(LUA) LUAC=$(LUAC) | ||
46 | |||
47 | clean: | ||
48 | cd src && $(MAKE) clean | ||
49 | |||
50 | debug: | ||
51 | $(MAKE) clean | ||
52 | cd src && $(MAKE) LUA=$(LUA) LUAC=$(LUAC) OPT_FLAGS="-O0 -g" | ||
53 | @echo "" | ||
54 | @echo "** Now, try 'make repetitive' or something and if it crashes, 'gdb $(LUA) ...core file...'" | ||
55 | @echo " Then 'bt' for a backtrace." | ||
56 | @echo "" | ||
57 | @echo " You have enabled core, no? 'ulimit -c unlimited'" | ||
58 | @echo " On OS X, core files are under '/cores/'" | ||
59 | @echo "" | ||
60 | |||
61 | gdb: | ||
62 | @echo "echo *** To start debugging: 'run tests/basic.lua' ***\n\n" > .gdb.cmd | ||
63 | $(_PREFIX) gdb -x .gdb.cmd $(LUA) | ||
64 | |||
65 | #--- LuaRocks automated build --- | ||
66 | # | ||
67 | rock: | ||
68 | cd src && $(MAKE) LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA) LUAC=$(LUAC) | ||
69 | |||
70 | |||
71 | #--- Testing --- | ||
72 | # | ||
73 | test: | ||
74 | $(MAKE) irayo_recursive | ||
75 | # $(MAKE) irayo_closure | ||
76 | $(MAKE) basic | ||
77 | $(MAKE) fifo | ||
78 | $(MAKE) keeper | ||
79 | $(MAKE) timer | ||
80 | $(MAKE) atomic | ||
81 | $(MAKE) cyclic | ||
82 | $(MAKE) objects | ||
83 | $(MAKE) fibonacci | ||
84 | $(MAKE) recursive | ||
85 | |||
86 | basic: tests/basic.lua $(_TARGET_SO) | ||
87 | $(_PREFIX) $(LUA) $< | ||
88 | |||
89 | # | ||
90 | # This tries to show out a bug which happens in lane cleanup (multicore CPU's only) | ||
91 | # | ||
92 | REP_ARGS=-llanes -e "print'say aaa'; for i=1,10 do print(i) end" | ||
93 | repetitive: $(_TARGET_SO) | ||
94 | for i in 1 2 3 4 5 6 7 8 9 10 a b c d e f g h i j k l m n o p q r s t u v w x y z; \ | ||
95 | do $(_PREFIX) $(LUA) $(REP_ARGS); \ | ||
96 | done | ||
97 | |||
98 | repetitive1: $(_TARGET_SO) | ||
99 | $(_PREFIX) $(LUA) $(REP_ARGS) | ||
100 | |||
101 | fifo: tests/fifo.lua $(_TARGET_SO) | ||
102 | $(_PREFIX) $(LUA) $< | ||
103 | |||
104 | keeper: tests/keeper.lua $(_TARGET_SO) | ||
105 | $(_PREFIX) $(LUA) $< | ||
106 | |||
107 | fibonacci: tests/fibonacci.lua $(_TARGET_SO) | ||
108 | $(_PREFIX) $(LUA) $< | ||
109 | |||
110 | timer: tests/timer.lua $(_TARGET_SO) | ||
111 | $(_PREFIX) $(LUA) $< | ||
112 | |||
113 | atomic: tests/atomic.lua $(_TARGET_SO) | ||
114 | $(_PREFIX) $(LUA) $< | ||
115 | |||
116 | cyclic: tests/cyclic.lua $(_TARGET_SO) | ||
117 | $(_PREFIX) $(LUA) $< | ||
118 | |||
119 | recursive: tests/recursive.lua $(_TARGET_SO) | ||
120 | $(_PREFIX) $(LUA) $< | ||
121 | |||
122 | hangtest: tests/hangtest.lua $(_TARGET_SO) | ||
123 | $(_PREFIX) $(LUA) $< | ||
124 | |||
125 | ehynes: tests/ehynes.lua $(_TARGET_SO) | ||
126 | $(_PREFIX) $(LUA) $< | ||
127 | |||
128 | #require: tests/require.lua $(_TARGET_SO) | ||
129 | # $(_PREFIX) $(LUA) $< | ||
130 | |||
131 | objects: tests/objects.lua $(_TARGET_SO) | ||
132 | $(_PREFIX) $(LUA) $< | ||
133 | |||
134 | irayo_recursive: tests/irayo_recursive.lua $(_TARGET_SO) | ||
135 | $(_PREFIX) $(LUA) $< | ||
136 | |||
137 | irayo_closure: tests/irayo_closure.lua $(_TARGET_SO) | ||
138 | $(_PREFIX) $(LUA) $< | ||
139 | |||
140 | finalizer: tests/finalizer.lua $(_TARGET_SO) | ||
141 | $(_PREFIX) $(LUA) $< | ||
142 | |||
143 | error-test: tests/error.lua $(_TARGET_SO) | ||
144 | $(_PREFIX) $(LUA) $< | ||
145 | |||
146 | #--- | ||
147 | perftest-plain: tests/perftest.lua $(_TARGET_SO) | ||
148 | $(MAKE) _perftest ARGS="$< $(N) -plain" | ||
149 | |||
150 | perftest: tests/perftest.lua $(_TARGET_SO) | ||
151 | $(MAKE) _perftest ARGS="$< $(N)" | ||
152 | |||
153 | perftest-odd: tests/perftest.lua $(_TARGET_SO) | ||
154 | $(MAKE) _perftest ARGS="$< $(N) -prio=+2" | ||
155 | |||
156 | perftest-even: tests/perftest.lua $(_TARGET_SO) | ||
157 | $(MAKE) _perftest ARGS="$< $(N) -prio=-2" | ||
158 | |||
159 | #--- | ||
160 | launchtest: tests/launchtest.lua $(_TARGET_SO) | ||
161 | $(MAKE) _perftest ARGS="$< $(N)" | ||
162 | |||
163 | _perftest: | ||
164 | $(_PREFIX) $(TIME) $(LUA) $(ARGS) | ||
165 | |||
166 | |||
167 | #--- Installing --- | ||
168 | # | ||
169 | # This is for LuaRocks automatic install, mainly | ||
170 | # | ||
171 | # LUA_LIBDIR and LUA_SHAREDIR are used by the .rockspec (don't change the names!) | ||
172 | # | ||
173 | DESTDIR=/usr/local | ||
174 | LUA_LIBDIR=$(DESTDIR)/lib/lua/5.1 | ||
175 | LUA_SHAREDIR=$(DESTDIR)/share/lua/5.1 | ||
176 | |||
177 | # | ||
178 | # AKa 17-Oct: changed to use 'install -m 644' and 'cp -p' | ||
179 | # | ||
180 | install: $(_TARGET_SO) src/lanes.lua | ||
181 | mkdir -p $(LUA_LIBDIR) $(LUA_SHAREDIR) | ||
182 | install -m 644 $(_TARGET_SO) $(LUA_LIBDIR) | ||
183 | cp -p src/lanes.lua $(LUA_SHAREDIR) | ||
184 | |||
185 | |||
186 | #--- Packaging --- | ||
187 | # | ||
188 | # Make a folder of the same name as tgz, good manners (for the manual | ||
189 | # expander) | ||
190 | # | ||
191 | # "make tgz VERSION=yyyymmdd" | ||
192 | # | ||
193 | VERSION= | ||
194 | |||
195 | tar tgz: | ||
196 | ifeq "$(VERSION)" "" | ||
197 | echo "Usage: make tar VERSION=x.x"; false | ||
198 | else | ||
199 | $(MAKE) clean | ||
200 | -rm -rf $(MODULE)-$(VERSION) | ||
201 | mkdir $(MODULE)-$(VERSION) | ||
202 | tar c * --exclude=.svn --exclude=.DS_Store --exclude="_*" \ | ||
203 | --exclude="*.tgz" --exclude="*.rockspec" \ | ||
204 | --exclude=lanes.dev --exclude="$(MODULE)-*" --exclude=xcode \ | ||
205 | --exclude="*.obj" --exclude="*.dll" --exclude=timeit.dat \ | ||
206 | | (cd $(MODULE)-$(VERSION) && tar x) | ||
207 | tar czvf $(MODULE)-$(VERSION).tgz $(MODULE)-$(VERSION) | ||
208 | rm -rf $(MODULE)-$(VERSION) | ||
209 | md5sum $(MODULE)-$(VERSION).tgz | ||
210 | endif | ||
211 | |||
212 | |||
213 | #--- Undocumented --- | ||
214 | # | ||
215 | |||
216 | # 2.0.1: Running this (instant exit of the main Lua state) occasionally | ||
217 | # segfaults (1:15 or so on OS X PowerPC G4). | ||
218 | # | ||
219 | require: $(_TARGET_SO) | ||
220 | $(_PREFIX) $(LUA) -e "require '$(MODULE)'" | ||
221 | |||
222 | run: $(_TARGET_SO) | ||
223 | $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -i | ||
224 | |||
225 | echo: | ||
226 | @echo $(PROGRAMFILES:C=X) | ||
227 | |||
228 | .PROXY: all clean test require debug _nodemo _notest | ||
229 | |||