aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPeter Drahoš <drahosp@gmail.com>2010-10-01 03:22:32 +0200
committerPeter Drahoš <drahosp@gmail.com>2010-10-01 03:22:32 +0200
commit89d9c98af1ac352ba4d49d660e61b0853d6e1a86 (patch)
tree15c56d2ce66b4ab147171c0f674cdb4a435ff13f /Makefile
downloadlanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.gz
lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.tar.bz2
lanes-89d9c98af1ac352ba4d49d660e61b0853d6e1a86.zip
Import to git
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile229
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
16MODULE = lanes
17
18N=1000
19
20_SO=.so
21_TARGET_SO=src/lua51-lanes.so
22TIME=time
23
24ifeq "$(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
32else
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)
37endif
38
39_PREFIX=LUA_CPATH=./src/?$(_SO) LUA_PATH="src/?.lua;./tests/?.lua"
40
41#---
42all: $(_TARGET_SO)
43
44$(_TARGET_SO): src/*.lua src/*.c src/*.h
45 cd src && $(MAKE) LUA=$(LUA) LUAC=$(LUAC)
46
47clean:
48 cd src && $(MAKE) clean
49
50debug:
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
61gdb:
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#
67rock:
68 cd src && $(MAKE) LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA) LUAC=$(LUAC)
69
70
71#--- Testing ---
72#
73test:
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
86basic: 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#
92REP_ARGS=-llanes -e "print'say aaa'; for i=1,10 do print(i) end"
93repetitive: $(_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
98repetitive1: $(_TARGET_SO)
99 $(_PREFIX) $(LUA) $(REP_ARGS)
100
101fifo: tests/fifo.lua $(_TARGET_SO)
102 $(_PREFIX) $(LUA) $<
103
104keeper: tests/keeper.lua $(_TARGET_SO)
105 $(_PREFIX) $(LUA) $<
106
107fibonacci: tests/fibonacci.lua $(_TARGET_SO)
108 $(_PREFIX) $(LUA) $<
109
110timer: tests/timer.lua $(_TARGET_SO)
111 $(_PREFIX) $(LUA) $<
112
113atomic: tests/atomic.lua $(_TARGET_SO)
114 $(_PREFIX) $(LUA) $<
115
116cyclic: tests/cyclic.lua $(_TARGET_SO)
117 $(_PREFIX) $(LUA) $<
118
119recursive: tests/recursive.lua $(_TARGET_SO)
120 $(_PREFIX) $(LUA) $<
121
122hangtest: tests/hangtest.lua $(_TARGET_SO)
123 $(_PREFIX) $(LUA) $<
124
125ehynes: tests/ehynes.lua $(_TARGET_SO)
126 $(_PREFIX) $(LUA) $<
127
128#require: tests/require.lua $(_TARGET_SO)
129# $(_PREFIX) $(LUA) $<
130
131objects: tests/objects.lua $(_TARGET_SO)
132 $(_PREFIX) $(LUA) $<
133
134irayo_recursive: tests/irayo_recursive.lua $(_TARGET_SO)
135 $(_PREFIX) $(LUA) $<
136
137irayo_closure: tests/irayo_closure.lua $(_TARGET_SO)
138 $(_PREFIX) $(LUA) $<
139
140finalizer: tests/finalizer.lua $(_TARGET_SO)
141 $(_PREFIX) $(LUA) $<
142
143error-test: tests/error.lua $(_TARGET_SO)
144 $(_PREFIX) $(LUA) $<
145
146#---
147perftest-plain: tests/perftest.lua $(_TARGET_SO)
148 $(MAKE) _perftest ARGS="$< $(N) -plain"
149
150perftest: tests/perftest.lua $(_TARGET_SO)
151 $(MAKE) _perftest ARGS="$< $(N)"
152
153perftest-odd: tests/perftest.lua $(_TARGET_SO)
154 $(MAKE) _perftest ARGS="$< $(N) -prio=+2"
155
156perftest-even: tests/perftest.lua $(_TARGET_SO)
157 $(MAKE) _perftest ARGS="$< $(N) -prio=-2"
158
159#---
160launchtest: 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#
173DESTDIR=/usr/local
174LUA_LIBDIR=$(DESTDIR)/lib/lua/5.1
175LUA_SHAREDIR=$(DESTDIR)/share/lua/5.1
176
177#
178# AKa 17-Oct: changed to use 'install -m 644' and 'cp -p'
179#
180install: $(_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#
193VERSION=
194
195tar tgz:
196ifeq "$(VERSION)" ""
197 echo "Usage: make tar VERSION=x.x"; false
198else
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
210endif
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#
219require: $(_TARGET_SO)
220 $(_PREFIX) $(LUA) -e "require '$(MODULE)'"
221
222run: $(_TARGET_SO)
223 $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -i
224
225echo:
226 @echo $(PROGRAMFILES:C=X)
227
228.PROXY: all clean test require debug _nodemo _notest
229