aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-03-13 16:09:03 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-03-13 16:09:03 +0100
commit24c8215fa05142cc2461efacc1187ef443450af9 (patch)
treecf03c78028abc7f0c0973328f9580e5acc7b4cc9
parent3ad53d3db2215aa50517a646296b9c25cb3155e3 (diff)
downloadlanes-24c8215fa05142cc2461efacc1187ef443450af9.tar.gz
lanes-24c8215fa05142cc2461efacc1187ef443450af9.tar.bz2
lanes-24c8215fa05142cc2461efacc1187ef443450af9.zip
More work on Makefiles
* renamed makefiles: - Shared.mk → Shared.makefile - src/Makefile → src/Lanes.makefile - unit_tests/Makefile → unit_tests/UnitTests.makefile - deep_userdata_example/Makefile → deep_userdata_example/DUE.makefile * Add a makefile for deep_userdata_example * added a target 'unit_tests' to build them (not running them yet) * plus some minor internal improvements
-rw-r--r--Lanes.vcxproj4
-rw-r--r--Lanes.vcxproj.filters4
-rw-r--r--Makefile157
-rw-r--r--Shared.makefile (renamed from Shared.mk)59
-rw-r--r--deep_userdata_example/DUE.makefile36
-rw-r--r--deep_userdata_example/deep_userdata_example.vcxproj2
-rw-r--r--deep_userdata_example/deep_userdata_example.vcxproj.filters17
-rw-r--r--src/Lanes.makefile (renamed from src/Makefile)29
-rw-r--r--unit_tests/UnitTests.makefile (renamed from unit_tests/Makefile)18
-rw-r--r--unit_tests/UnitTests.vcxproj2
-rw-r--r--unit_tests/UnitTests.vcxproj.filters2
11 files changed, 196 insertions, 134 deletions
diff --git a/Lanes.vcxproj b/Lanes.vcxproj
index 1b3d224..740af04 100644
--- a/Lanes.vcxproj
+++ b/Lanes.vcxproj
@@ -1595,8 +1595,8 @@ xcopy /F /R /Y "$(OutputPath)core.pdb" $(SolutionDir)..\..\..\Lua52\bin\$(Platfo
1595 <None Include="lanes-4.0.0-0.rockspec" /> 1595 <None Include="lanes-4.0.0-0.rockspec" />
1596 <None Include="Lanes.slnenv" /> 1596 <None Include="Lanes.slnenv" />
1597 <None Include="make-vc.cmd" /> 1597 <None Include="make-vc.cmd" />
1598 <None Include="Shared.mk" /> 1598 <None Include="Shared.makefile" />
1599 <None Include="src\Makefile" /> 1599 <None Include="src\Lanes.makefile" />
1600 <None Include="Makefile" /> 1600 <None Include="Makefile" />
1601 <None Include="tests\appendud.lua" /> 1601 <None Include="tests\appendud.lua" />
1602 <None Include="tests\argtable.lua" /> 1602 <None Include="tests\argtable.lua" />
diff --git a/Lanes.vcxproj.filters b/Lanes.vcxproj.filters
index 2479f1c..3014132 100644
--- a/Lanes.vcxproj.filters
+++ b/Lanes.vcxproj.filters
@@ -153,7 +153,7 @@
153 </ClInclude> 153 </ClInclude>
154 </ItemGroup> 154 </ItemGroup>
155 <ItemGroup> 155 <ItemGroup>
156 <None Include="src\Makefile"> 156 <None Include="src\Lanes.makefile">
157 <Filter>Resource Files\Make\src</Filter> 157 <Filter>Resource Files\Make\src</Filter>
158 </None> 158 </None>
159 <None Include="tests\appendud.lua"> 159 <None Include="tests\appendud.lua">
@@ -267,7 +267,7 @@
267 <None Include="Makefile"> 267 <None Include="Makefile">
268 <Filter>Resource Files\Make</Filter> 268 <Filter>Resource Files\Make</Filter>
269 </None> 269 </None>
270 <None Include="Shared.mk"> 270 <None Include="Shared.makefile">
271 <Filter>Resource Files\Make</Filter> 271 <Filter>Resource Files\Make</Filter>
272 </None> 272 </None>
273 <None Include="make-vc.cmd"> 273 <None Include="make-vc.cmd">
diff --git a/Makefile b/Makefile
index df56dcd..7d6b2ce 100644
--- a/Makefile
+++ b/Makefile
@@ -15,56 +15,77 @@
15 15
16MODULE = lanes 16MODULE = lanes
17 17
18N=1000 18N = 1000
19 19
20_TARGET_DIR=src/lanes 20TIME = time
21TIME=time
22 21
23ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" 22ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW"
24 # MinGW MSYS on Windows 23 # MinGW MSYS on Windows
25 # 24 #
26 _SO=dll 25 _SO := dll
27 _LUAEXT=.exe 26 _LUAEXT := .exe
28 TIME=timeit.exe 27 TIME := timeit.exe
29else 28else
30 _SO=so 29 _SO := so
31 _LUAEXT= 30 _LUAEXT :=
32endif 31endif
33 32
34# Autodetect LUA 33# Autodetect LUA
35# 34#
36LUA:=$(word 1,$(shell which lua5.1$(_LUAEXT) 2>/dev/null) $(shell which lua51$(_LUAEXT) 2>/dev/null) $(shell which lua$(_LUAEXT) 2>/dev/null) $(shell which luajit$(_LUAEXT) 2>/dev/null)) 35LUA := $(word 1,$(shell which lua5.1$(_LUAEXT) 2>/dev/null) $(shell which lua51$(_LUAEXT) 2>/dev/null) $(shell which lua$(_LUAEXT) 2>/dev/null) $(shell which luajit$(_LUAEXT) 2>/dev/null))
37LUA_VERSION:=$(shell $(LUA) -e "print(string.sub(_VERSION,5,7))") 36LUA_VERSION := $(shell $(LUA) -e "print(string.sub(_VERSION,5,7))")
38 37
39$(info LUA is $(LUA)) 38$(info LUA: $(LUA))
40$(info LUA_VERSION is $(LUA_VERSION)) 39$(info LUA_VERSION: $(LUA_VERSION))
41 40
42_TARGET_SO:=$(_TARGET_DIR)/core.$(_SO) 41_LANES_TARGET := src/lanes/core.$(_SO)
42$(info _LANES_TARGET: $(_LANES_TARGET))
43 43
44_UNITTEST_TARGET:=$(_TARGET_DIR)/UnitTests$(_LUAEXT) 44_UNITTEST_TARGET := unit_tests/UnitTests$(_LUAEXT)
45$(info _UNITTEST_TARGET: $(_UNITTEST_TARGET))
45 46
46_PREFIX:=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" 47_DUE_TARGET := deep_userdata_example/deep_userdata_example.$(_SO)
48$(info _DUE_TARGET: $(_DUE_TARGET))
49
50_PREFIX := LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua"
51
52.PHONY: all unit_tests
53
54# only build lanes itself by default
55all: $(_LANES_TARGET)
56
57# build the unit_tests and the side deep_userdata_example module
58unit_tests: $(_UNITTEST_TARGET) $(_DUE_TARGET)
59 cd deep_userdata_example && $(MAKE) -f DUE.makefile LUA_LIBDIR=$(LUA_LIBDIR) install
47 60
48#--- 61#---
49all: $(_TARGET_SO) $(_UNITTEST_TARGET)
50 62
51$(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp 63$(_LANES_TARGET): src/*.lua src/*.cpp src/*.h src/*.hpp
52 @echo ========================================================================================= 64 @echo =========================================================================================
53 cd src && $(MAKE) LUA=$(LUA) 65 cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA)
54 @echo ========== $(_TARGET_SO): DONE! 66 @echo ==================== $(_LANES_TARGET): DONE!
67 @echo
55 68
56$(_UNITTEST_TARGET): $(_TARGET_SO) 69$(_UNITTEST_TARGET): $(_LANES_TARGET)
57 @echo ========================================================================================= 70 @echo =========================================================================================
58 cd unit_tests && $(MAKE) 71 cd unit_tests && $(MAKE) -f UnitTests.makefile
59 @echo ========== $(_UNITTEST_TARGET): DONE! 72 @echo ==================== $(_UNITTEST_TARGET): DONE!
73 @echo
74
75$(_DUE_TARGET):
76 @echo =========================================================================================
77 cd deep_userdata_example && $(MAKE) -f DUE.makefile
78 @echo ==================== $(_DUE_TARGET): DONE!
79 @echo
60 80
61clean: 81clean:
62 cd src && $(MAKE) clean 82 cd src && $(MAKE) -f Lanes.makefile clean
63 cd unit_tests && $(MAKE) clean 83 cd unit_tests && $(MAKE) -f UnitTests.makefile clean
84 cd deep_userdata_example && $(MAKE) -f DUE.makefile clean
64 85
65debug: 86debug:
66 $(MAKE) clean 87 $(MAKE) clean
67 cd src && $(MAKE) LUA=$(LUA) OPT_FLAGS="-O0 -g" 88 cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA) OPT_FLAGS="-O0 -g"
68 @echo "" 89 @echo ""
69 @echo "** Now, try 'make repetitive' or something and if it crashes, 'gdb $(LUA) ...core file...'" 90 @echo "** Now, try 'make repetitive' or something and if it crashes, 'gdb $(LUA) ...core file...'"
70 @echo " Then 'bt' for a backtrace." 91 @echo " Then 'bt' for a backtrace."
@@ -80,7 +101,7 @@ gdb:
80#--- LuaRocks automated build --- 101#--- LuaRocks automated build ---
81# 102#
82rock: 103rock:
83 cd src && $(MAKE) LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA) 104 cd src && $(MAKE) -f Lanes.makefile LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA)
84 105
85 106
86#--- Testing --- 107#--- Testing ---
@@ -114,117 +135,117 @@ test:
114 $(MAKE) timer 135 $(MAKE) timer
115 $(MAKE) track_lanes 136 $(MAKE) track_lanes
116 137
117appendud: tests/appendud.lua $(_TARGET_SO) 138appendud: tests/appendud.lua $(_LANES_TARGET)
118 $(_PREFIX) $(LUA) $< 139 $(_PREFIX) $(LUA) $<
119 140
120atexit: tests/atexit.lua $(_TARGET_SO) 141atexit: tests/atexit.lua $(_LANES_TARGET)
121 $(_PREFIX) $(LUA) $< 142 $(_PREFIX) $(LUA) $<
122 143
123atomic: tests/atomic.lua $(_TARGET_SO) 144atomic: tests/atomic.lua $(_LANES_TARGET)
124 $(_PREFIX) $(LUA) $< 145 $(_PREFIX) $(LUA) $<
125 146
126basic: tests/basic.lua $(_TARGET_SO) 147basic: tests/basic.lua $(_LANES_TARGET)
127 $(_PREFIX) $(LUA) $< 148 $(_PREFIX) $(LUA) $<
128 149
129cancel: tests/cancel.lua $(_TARGET_SO) 150cancel: tests/cancel.lua $(_LANES_TARGET)
130 $(_PREFIX) $(LUA) $< 151 $(_PREFIX) $(LUA) $<
131 152
132cyclic: tests/cyclic.lua $(_TARGET_SO) 153cyclic: tests/cyclic.lua $(_LANES_TARGET)
133 $(_PREFIX) $(LUA) $< 154 $(_PREFIX) $(LUA) $<
134 155
135deadlock: tests/deadlock.lua $(_TARGET_SO) 156deadlock: tests/deadlock.lua $(_LANES_TARGET)
136 $(_PREFIX) $(LUA) $< 157 $(_PREFIX) $(LUA) $<
137 158
138ehynes: tests/ehynes.lua $(_TARGET_SO) 159ehynes: tests/ehynes.lua $(_LANES_TARGET)
139 $(_PREFIX) $(LUA) $< 160 $(_PREFIX) $(LUA) $<
140 161
141errhangtest: tests/errhangtest.lua $(_TARGET_SO) 162errhangtest: tests/errhangtest.lua $(_LANES_TARGET)
142 $(_PREFIX) $(LUA) $< 163 $(_PREFIX) $(LUA) $<
143 164
144error: tests/error.lua $(_TARGET_SO) 165error: tests/error.lua $(_LANES_TARGET)
145 $(_PREFIX) $(LUA) $< 166 $(_PREFIX) $(LUA) $<
146 167
147fibonacci: tests/fibonacci.lua $(_TARGET_SO) 168fibonacci: tests/fibonacci.lua $(_LANES_TARGET)
148 $(_PREFIX) $(LUA) $< 169 $(_PREFIX) $(LUA) $<
149 170
150fifo: tests/fifo.lua $(_TARGET_SO) 171fifo: tests/fifo.lua $(_LANES_TARGET)
151 $(_PREFIX) $(LUA) $< 172 $(_PREFIX) $(LUA) $<
152 173
153finalizer: tests/finalizer.lua $(_TARGET_SO) 174finalizer: tests/finalizer.lua $(_LANES_TARGET)
154 $(_PREFIX) $(LUA) $< 175 $(_PREFIX) $(LUA) $<
155 176
156func_is_string: tests/func_is_string.lua $(_TARGET_SO) 177func_is_string: tests/func_is_string.lua $(_LANES_TARGET)
157 $(_PREFIX) $(LUA) $< 178 $(_PREFIX) $(LUA) $<
158 179
159hangtest: tests/hangtest.lua $(_TARGET_SO) 180hangtest: tests/hangtest.lua $(_LANES_TARGET)
160 $(_PREFIX) $(LUA) $< 181 $(_PREFIX) $(LUA) $<
161 182
162irayo_closure: tests/irayo_closure.lua $(_TARGET_SO) 183irayo_closure: tests/irayo_closure.lua $(_LANES_TARGET)
163 $(_PREFIX) $(LUA) $< 184 $(_PREFIX) $(LUA) $<
164 185
165irayo_recursive: tests/irayo_recursive.lua $(_TARGET_SO) 186irayo_recursive: tests/irayo_recursive.lua $(_LANES_TARGET)
166 $(_PREFIX) $(LUA) $< 187 $(_PREFIX) $(LUA) $<
167 188
168keeper: tests/keeper.lua $(_TARGET_SO) 189keeper: tests/keeper.lua $(_LANES_TARGET)
169 $(_PREFIX) $(LUA) $< 190 $(_PREFIX) $(LUA) $<
170 191
171launchtest: tests/launchtest.lua $(_TARGET_SO) 192launchtest: tests/launchtest.lua $(_LANES_TARGET)
172 $(MAKE) _perftest ARGS="$< $(N)" 193 $(MAKE) _perftest ARGS="$< $(N)"
173 194
174linda_perf: tests/linda_perf.lua $(_TARGET_SO) 195linda_perf: tests/linda_perf.lua $(_LANES_TARGET)
175 $(_PREFIX) $(LUA) $< 196 $(_PREFIX) $(LUA) $<
176 197
177manual_register: tests/manual_register.lua $(_TARGET_SO) 198manual_register: tests/manual_register.lua $(_LANES_TARGET)
178 $(_PREFIX) $(LUA) $< 199 $(_PREFIX) $(LUA) $<
179 200
180nameof: tests/nameof.lua $(_TARGET_SO) 201nameof: tests/nameof.lua $(_LANES_TARGET)
181 $(_PREFIX) $(LUA) $< 202 $(_PREFIX) $(LUA) $<
182 203
183objects: tests/objects.lua $(_TARGET_SO) 204objects: tests/objects.lua $(_LANES_TARGET)
184 $(_PREFIX) $(LUA) $< 205 $(_PREFIX) $(LUA) $<
185 206
186package: tests/package.lua $(_TARGET_SO) 207package: tests/package.lua $(_LANES_TARGET)
187 $(_PREFIX) $(LUA) $< 208 $(_PREFIX) $(LUA) $<
188 209
189perftest: tests/perftest.lua $(_TARGET_SO) 210perftest: tests/perftest.lua $(_LANES_TARGET)
190 $(MAKE) _perftest ARGS="$< $(N)" 211 $(MAKE) _perftest ARGS="$< $(N)"
191 212
192perftest-even: tests/perftest.lua $(_TARGET_SO) 213perftest-even: tests/perftest.lua $(_LANES_TARGET)
193 $(MAKE) _perftest ARGS="$< $(N) -prio=-2" 214 $(MAKE) _perftest ARGS="$< $(N) -prio=-2"
194 215
195perftest-odd: tests/perftest.lua $(_TARGET_SO) 216perftest-odd: tests/perftest.lua $(_LANES_TARGET)
196 $(MAKE) _perftest ARGS="$< $(N) -prio=+2" 217 $(MAKE) _perftest ARGS="$< $(N) -prio=+2"
197 218
198perftest-plain: tests/perftest.lua $(_TARGET_SO) 219perftest-plain: tests/perftest.lua $(_LANES_TARGET)
199 $(MAKE) _perftest ARGS="$< $(N) -plain" 220 $(MAKE) _perftest ARGS="$< $(N) -plain"
200 221
201pingpong: tests/pingpong.lua $(_TARGET_SO) 222pingpong: tests/pingpong.lua $(_LANES_TARGET)
202 $(_PREFIX) $(LUA) $< 223 $(_PREFIX) $(LUA) $<
203 224
204recursive: tests/recursive.lua $(_TARGET_SO) 225recursive: tests/recursive.lua $(_LANES_TARGET)
205 $(_PREFIX) $(LUA) $< 226 $(_PREFIX) $(LUA) $<
206 227
207require: tests/require.lua $(_TARGET_SO) 228require: tests/require.lua $(_LANES_TARGET)
208 $(_PREFIX) $(LUA) $< 229 $(_PREFIX) $(LUA) $<
209 230
210rupval: tests/rupval.lua $(_TARGET_SO) 231rupval: tests/rupval.lua $(_LANES_TARGET)
211 $(_PREFIX) $(LUA) $< 232 $(_PREFIX) $(LUA) $<
212 233
213timer: tests/timer.lua $(_TARGET_SO) 234timer: tests/timer.lua $(_LANES_TARGET)
214 $(_PREFIX) $(LUA) $< 235 $(_PREFIX) $(LUA) $<
215 236
216track_lanes: tests/track_lanes.lua $(_TARGET_SO) 237track_lanes: tests/track_lanes.lua $(_LANES_TARGET)
217 $(_PREFIX) $(LUA) $< 238 $(_PREFIX) $(LUA) $<
218# 239#
219# This tries to show out a bug which happens in lane cleanup (multicore CPU's only) 240# This tries to show out a bug which happens in lane cleanup (multicore CPU's only)
220# 241#
221REP_ARGS=-llanes -e "print'say aaa'; for i=1,10 do print(i) end" 242REP_ARGS=-llanes -e "print'say aaa'; for i=1,10 do print(i) end"
222repetitive: $(_TARGET_SO) 243repetitive: $(_LANES_TARGET)
223 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; \ 244 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; \
224 do $(_PREFIX) $(LUA) $(REP_ARGS); \ 245 do $(_PREFIX) $(LUA) $(REP_ARGS); \
225 done 246 done
226 247
227repetitive1: $(_TARGET_SO) 248repetitive1: $(_LANES_TARGET)
228 $(_PREFIX) $(LUA) $(REP_ARGS) 249 $(_PREFIX) $(LUA) $(REP_ARGS)
229 250
230#--- 251#---
@@ -246,15 +267,15 @@ LUA_SHAREDIR:=$(DESTDIR)/share/lua/$(LUA_VERSION)
246# 267#
247# AKa 17-Oct: changed to use 'install -m 644' and 'cp -p' 268# AKa 17-Oct: changed to use 'install -m 644' and 'cp -p'
248# 269#
249install: $(_TARGET_SO) src/lanes.lua 270install: $(_LANES_TARGET) src/lanes.lua
250 mkdir -p $(LUA_LIBDIR) $(LUA_LIBDIR)/lanes $(LUA_SHAREDIR) 271 mkdir -p $(LUA_LIBDIR) $(LUA_LIBDIR)/lanes $(LUA_SHAREDIR)
251 install -m 644 $(_TARGET_SO) $(LUA_LIBDIR)/lanes 272 install -m 644 $(_LANES_TARGET) $(LUA_LIBDIR)/lanes
252 cp -p src/lanes.lua $(LUA_SHAREDIR) 273 cp -p src/lanes.lua $(LUA_SHAREDIR)
253 274
254uninstall: 275uninstall:
255 rm $(LUA_LIBDIR)/lanes/core.$(_SO) 276 rm $(LUA_LIBDIR)/lanes/core.$(_SO)
256 rm $(LUA_SHAREDIR)/lanes.lua 277 rm $(LUA_SHAREDIR)/lanes.lua
257 278 rm $(LUA_LIBDIR)/deep_userdata_example.$(_SO)
258 279
259#--- Packaging --- 280#--- Packaging ---
260# 281#
@@ -289,14 +310,14 @@ endif
289# 2.0.1: Running this (instant exit of the main Lua state) occasionally 310# 2.0.1: Running this (instant exit of the main Lua state) occasionally
290# segfaults (1:15 or so on OS X PowerPC G4). 311# segfaults (1:15 or so on OS X PowerPC G4).
291# 312#
292require_module: $(_TARGET_SO) 313require_module: $(_LANES_TARGET)
293 $(_PREFIX) $(LUA) -e "require '$(MODULE)'" 314 $(_PREFIX) $(LUA) -e "require '$(MODULE)'"
294 315
295run: $(_TARGET_SO) 316run: $(_LANES_TARGET)
296 $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -i 317 $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -i
297 318
298echo: 319echo:
299 @echo $(PROGRAMFILES:C=X) 320 @echo $(PROGRAMFILES:C=X)
300 321
301.PHONY: all clean debug gdb rock test require install uninstall _nodemo _notest 322.PHONY: clean debug gdb rock test require install uninstall _nodemo _notest
302 323
diff --git a/Shared.mk b/Shared.makefile
index f6941e1..492c05d 100644
--- a/Shared.mk
+++ b/Shared.makefile
@@ -1,21 +1,21 @@
1CC= g++ -std=c++20 1CC := g++ -std=c++20
2 2
3# LuaRocks gives 'LIBFLAG' from the outside 3# LuaRocks gives 'LIBFLAG' from the outside
4# 4#
5LIBFLAG=-shared 5LIBFLAG := -shared
6 6
7OPT_FLAGS=-O2 7OPT_FLAGS := -O2
8# -O0 -g 8# -O0 -g
9 9
10ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" 10ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW"
11 # MinGW MSYS on Windows 11 # MinGW MSYS on Windows
12 # 12 #
13 _SO:=dll 13 _SO := dll
14 _LUAEXT:=.exe 14 _LUAEXT := .exe
15 TIME:=timeit.exe 15 TIME := timeit.exe
16else 16else
17 _SO:=so 17 _SO := so
18 _LUAEXT:= 18 _LUAEXT :=
19endif 19endif
20 20
21ifeq "$(LUAROCKS)" "" 21ifeq "$(LUAROCKS)" ""
@@ -29,42 +29,43 @@ ifeq "$(LUAROCKS)" ""
29 ifeq "$(LUA_DEV)" "" 29 ifeq "$(LUA_DEV)" ""
30 $(warning LUA_DEV not defined - try i.e. 'make LUA_DEV=/c/Program\ Files/Lua/5.1') 30 $(warning LUA_DEV not defined - try i.e. 'make LUA_DEV=/c/Program\ Files/Lua/5.1')
31 # this assumes Lua was built and installed from source and everything is located in default folders (/usr/local/include and /usr/local/bin) 31 # this assumes Lua was built and installed from source and everything is located in default folders (/usr/local/include and /usr/local/bin)
32 LUA_FLAGS:=-I "/usr/local/include" 32 LUA_FLAGS := -I "/usr/local/include"
33 LUA_LIBS:=$(word 1,$(shell which lua54.$(_SO) 2>/dev/null) $(shell which lua53.$(_SO) 2>/dev/null) $(shell which lua52.$(_SO) 2>/dev/null) $(shell which lua51$(_SO) 2>/dev/null)) 33 LUA_LIBS := $(word 1,$(shell which lua54.$(_SO) 2>/dev/null) $(shell which lua53.$(_SO) 2>/dev/null) $(shell which lua52.$(_SO) 2>/dev/null) $(shell which lua51$(_SO) 2>/dev/null))
34 $(info detected LUA_LIBS as $(LUA_LIBS))
34 else 35 else
35 LUA_FLAGS:=-I "$(LUA_DEV)/include" 36 LUA_FLAGS := -I "$(LUA_DEV)/include"
36 LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc 37 LUA_LIBS := "$(LUA_DEV)/lua5.1.dll" -lgcc
37 endif 38 endif
38 LIBFLAG=-shared -Wl,-Map,lanes.map 39 LIBFLAG := -shared -Wl,-Map,lanes.map
39 else 40 else
40 # Autodetect LUA_FLAGS and/or LUA_LIBS 41 # Autodetect LUA_FLAGS and/or LUA_LIBS
41 # 42 #
42 ifneq "$(shell which pkg-config)" "" 43 ifneq "$(shell which pkg-config)" ""
43 ifeq "$(shell pkg-config --exists luajit && echo 1)" "1" 44 ifeq "$(shell pkg-config --exists luajit && echo 1)" "1"
44 LUA_FLAGS:=$(shell pkg-config --cflags luajit) 45 LUA_FLAGS := $(shell pkg-config --cflags luajit)
45 LUA_LIBS:=$(shell pkg-config --libs luajit) 46 LUA_LIBS := $(shell pkg-config --libs luajit)
46 # 47 #
47 # Debian: -I/usr/include/luajit-2.0 48 # Debian: -I/usr/include/luajit-2.0
48 # -lluajit-5.1 49 # -lluajit-5.1
49 else 50 else
50 ifeq "$(shell pkg-config --exists lua5.1 && echo 1)" "1" 51 ifeq "$(shell pkg-config --exists lua5.1 && echo 1)" "1"
51 LUA_FLAGS:=$(shell pkg-config --cflags lua5.1) 52 LUA_FLAGS := $(shell pkg-config --cflags lua5.1)
52 LUA_LIBS:=$(shell pkg-config --libs lua5.1) 53 LUA_LIBS := $(shell pkg-config --libs lua5.1)
53 # 54 #
54 # Ubuntu: -I/usr/include/lua5.1 55 # Ubuntu: -I/usr/include/lua5.1
55 # -llua5.1 56 # -llua5.1
56 else 57 else
57 ifeq "$(shell pkg-config --exists lua && echo 1)" "1" 58 ifeq "$(shell pkg-config --exists lua && echo 1)" "1"
58 LUA_FLAGS:=$(shell pkg-config --cflags lua) 59 LUA_FLAGS := $(shell pkg-config --cflags lua)
59 LUA_LIBS:=$(shell pkg-config --libs lua) 60 LUA_LIBS := $(shell pkg-config --libs lua)
60 # 61 #
61 # OS X fink with pkg-config: 62 # OS X fink with pkg-config:
62 # -I/sw/include 63 # -I/sw/include
63 # -L/sw/lib -llua -lm 64 # -L/sw/lib -llua -lm
64 else 65 else
65 $(warning *** 'pkg-config' existed but did not know of 'lua[5.1]' - Good luck!) 66 $(warning *** 'pkg-config' existed but did not know of 'lua[5.1]' - Good luck!)
66 LUA_FLAGS:= 67 LUA_FLAGS :=
67 LUA_LIBS:=-llua 68 LUA_LIBS := -llua
68 endif 69 endif
69 endif 70 endif
70 endif 71 endif
@@ -73,12 +74,12 @@ ifeq "$(LUAROCKS)" ""
73 # 74 #
74 ifeq "$(shell uname -s)" "Darwin" 75 ifeq "$(shell uname -s)" "Darwin"
75 $(warning *** Assuming 'fink' at default path) 76 $(warning *** Assuming 'fink' at default path)
76 LUA_FLAGS:=-I/sw/include 77 LUA_FLAGS := -I/sw/include
77 LUA_LIBS:=-L/sw/lib -llua 78 LUA_LIBS := -L/sw/lib -llua
78 else 79 else
79 $(warning *** Assuming an arbitrary Lua installation; try installing 'pkg-config') 80 $(warning *** Assuming an arbitrary Lua installation; try installing 'pkg-config')
80 LUA_FLAGS:= 81 LUA_FLAGS :=
81 LUA_LIBS:=-llua 82 LUA_LIBS := -llua
82 endif 83 endif
83 endif 84 endif
84 endif 85 endif
@@ -87,12 +88,12 @@ ifeq "$(LUAROCKS)" ""
87 # Some machines need 'MACOSX_DEPLOYMENT_TARGET=10.3' for using '-undefined dynamic_lookup' 88 # Some machines need 'MACOSX_DEPLOYMENT_TARGET=10.3' for using '-undefined dynamic_lookup'
88 # (at least PowerPC running 10.4.11); does not harm the others 89 # (at least PowerPC running 10.4.11); does not harm the others
89 # 90 #
90 CC = MACOSX_DEPLOYMENT_TARGET=10.3 gcc 91 CC := MACOSX_DEPLOYMENT_TARGET=10.3 gcc
91 LIBFLAG = -bundle -undefined dynamic_lookup 92 LIBFLAG := -bundle -undefined dynamic_lookup
92 endif 93 endif
93 94
94 CFLAGS=-Wall -Werror $(OPT_FLAGS) $(LUA_FLAGS) 95 CFLAGS := -Wall -Werror $(OPT_FLAGS) $(LUA_FLAGS)
95 LIBS=$(LUA_LIBS) 96 LIBS :=
96endif 97endif
97 98
98#--- 99#---
diff --git a/deep_userdata_example/DUE.makefile b/deep_userdata_example/DUE.makefile
new file mode 100644
index 0000000..8fcc89e
--- /dev/null
+++ b/deep_userdata_example/DUE.makefile
@@ -0,0 +1,36 @@
1#
2# Lanes/deep_userdata_example/DUE.makefile
3#
4
5include ../Shared.makefile
6
7_MODULE=deep_userdata_example.$(_SO)
8
9_SRC:=$(wildcard *.cpp) ../src/compat.cpp ../src/deep.cpp
10
11_OBJ:=$(_SRC:.cpp=.o)
12
13#---
14all: $(_MODULE)
15 $(info CC: $(CC))
16 $(info _MODULE: $(_MODULE))
17 $(info _SRC: $(_SRC))
18
19_pch.hpp.gch: ../src/_pch.hpp
20 $(CC) -I "../.." $(CFLAGS) -x c++-header $< -o _pch.hpp.gch
21
22%.o: %.cpp _pch.hpp.gch DUE.makefile
23 $(CC) -I "../.." $(CFLAGS) -c $<
24
25# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think)
26#
27$(_MODULE): $(_OBJ)
28 $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@
29
30install:
31 install -m 644 $(_MODULE) $(LUA_LIBDIR)/
32
33clean:
34 -rm -rf $(_MODULE) *.o *.map *.gch
35
36.PHONY: all clean
diff --git a/deep_userdata_example/deep_userdata_example.vcxproj b/deep_userdata_example/deep_userdata_example.vcxproj
index 74d8e76..ec40f30 100644
--- a/deep_userdata_example/deep_userdata_example.vcxproj
+++ b/deep_userdata_example/deep_userdata_example.vcxproj
@@ -855,7 +855,7 @@
855 </ItemGroup> 855 </ItemGroup>
856 <ItemGroup> 856 <ItemGroup>
857 <None Include="deeptest.lua" /> 857 <None Include="deeptest.lua" />
858 <None Include="Makefile" /> 858 <None Include="DUE.makefile" />
859 </ItemGroup> 859 </ItemGroup>
860 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 860 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
861 <ImportGroup Label="ExtensionTargets"> 861 <ImportGroup Label="ExtensionTargets">
diff --git a/deep_userdata_example/deep_userdata_example.vcxproj.filters b/deep_userdata_example/deep_userdata_example.vcxproj.filters
index e3fd9bf..ecb3c60 100644
--- a/deep_userdata_example/deep_userdata_example.vcxproj.filters
+++ b/deep_userdata_example/deep_userdata_example.vcxproj.filters
@@ -5,14 +5,17 @@
5 <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> 5 <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6 <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> 6 <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7 </Filter> 7 </Filter>
8 <Filter Include="Resource Files">
9 <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
10 <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
11 </Filter>
12 <Filter Include="Lanes"> 8 <Filter Include="Lanes">
13 <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> 9 <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
14 <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions> 10 <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
15 </Filter> 11 </Filter>
12 <Filter Include="Make">
13 <UniqueIdentifier>{e3eeb49e-1b60-4885-b634-80e39d11acc7}</UniqueIdentifier>
14 </Filter>
15 <Filter Include="test">
16 <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
17 <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
18 </Filter>
16 </ItemGroup> 19 </ItemGroup>
17 <ItemGroup> 20 <ItemGroup>
18 <ClCompile Include="..\src\compat.cpp"> 21 <ClCompile Include="..\src\compat.cpp">
@@ -47,10 +50,10 @@
47 </ItemGroup> 50 </ItemGroup>
48 <ItemGroup> 51 <ItemGroup>
49 <None Include="deeptest.lua"> 52 <None Include="deeptest.lua">
50 <Filter>Resource Files</Filter> 53 <Filter>test</Filter>
51 </None> 54 </None>
52 <None Include="Makefile"> 55 <None Include="DUE.makefile">
53 <Filter>Resource Files</Filter> 56 <Filter>Make</Filter>
54 </None> 57 </None>
55 </ItemGroup> 58 </ItemGroup>
56</Project> \ No newline at end of file 59</Project> \ No newline at end of file
diff --git a/src/Makefile b/src/Lanes.makefile
index 39b98e6..d9127f7 100644
--- a/src/Makefile
+++ b/src/Lanes.makefile
@@ -1,40 +1,39 @@
1# 1#
2# Lanes/src/Makefile 2# Lanes/src/Lanes.makefile
3# 3#
4# make Manual build 4# make Manual build
5# make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build 5# make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build
6# 6#
7 7
8include ../Shared.mk 8include ../Shared.makefile
9 9
10MODULE=lanes 10_MODULE=lanes
11 11
12CC:= g++ -std=c++20 12_SRC := $(wildcard *.cpp)
13 13
14SRC:=$(wildcard *.cpp) 14_OBJ := $(_SRC:.cpp=.o)
15 15
16OBJ:=$(SRC:.cpp=.o) 16_MODULE_DIR = $(_MODULE)
17
18
19MODULE_DIR=$(MODULE)
20 17
21#--- 18#---
22all: $(MODULE)/core.$(_SO) 19all: $(_MODULE)/core.$(_SO)
20 $(info CC: $(CC))
21 $(info _SRC: $(_SRC))
23 22
24_pch.hpp.gch: _pch.hpp 23_pch.hpp.gch: _pch.hpp
25 $(CC) $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch 24 $(CC) $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch
26 25
27%.o: %.cpp _pch.hpp.gch *.h *.hpp Makefile 26%.o: %.cpp _pch.hpp.gch *.h *.hpp Lanes.makefile
28 $(CC) $(CFLAGS) -c $< 27 $(CC) $(CFLAGS) -c $<
29 28
30# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) 29# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think)
31# 30#
32$(MODULE_DIR)/core.$(_SO): $(OBJ) 31$(_MODULE_DIR)/core.$(_SO): $(_OBJ)
33 mkdir -p $(MODULE_DIR) 32 mkdir -p $(_MODULE_DIR)
34 $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ 33 $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@
35 34
36clean: 35clean:
37 -rm -rf $(MODULE)/core.$(_SO) *.o *.map *.gch 36 -rm -rf $(_MODULE)/core.$(_SO) *.o *.map *.gch
38 37
39#--- 38#---
40# NSLU2 "slug" Linux ARM 39# NSLU2 "slug" Linux ARM
@@ -52,7 +51,7 @@ nslu2:
52# 51#
53# EXPERIMENTAL; NOT TESTED OF LATE. 52# EXPERIMENTAL; NOT TESTED OF LATE.
54# 53#
55MINGW_GCC=mingw32-gcc 54MINGW_GCC = mingw32-gcc
56# i686-pc-mingw32-gcc 55# i686-pc-mingw32-gcc
57 56
58win32: $(WIN32_LUA51)/include/lua.h 57win32: $(WIN32_LUA51)/include/lua.h
diff --git a/unit_tests/Makefile b/unit_tests/UnitTests.makefile
index 89106b9..b3d1c58 100644
--- a/unit_tests/Makefile
+++ b/unit_tests/UnitTests.makefile
@@ -1,31 +1,33 @@
1# 1#
2# Lanes/unit_tests/Makefile 2# Lanes/unit_tests/UnitTests.makefile
3# 3#
4 4
5include ../Shared.mk 5include ../Shared.makefile
6 6
7SRC=$(wildcard *.cpp) ../src/deep.cpp ../src/compat.cpp 7_SRC := $(wildcard *.cpp) ../src/deep.cpp ../src/compat.cpp
8 8
9OBJ=$(SRC:.cpp=.o) 9_OBJ := $(_SRC:.cpp=.o)
10 10
11 11
12_UNITTEST_TARGET=UnitTests$(_LUAEXT) 12_UNITTEST_TARGET := UnitTests$(_LUAEXT)
13 13
14#--- 14#---
15all: $(_UNITTEST_TARGET) 15all: $(_UNITTEST_TARGET)
16 $(info CC: $(CC))
17 $(info _SRC: $(_SRC))
16 18
17_pch.hpp.gch: _pch.hpp 19_pch.hpp.gch: _pch.hpp
18 $(CC) -I "../.." $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch 20 $(CC) -I "../.." $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch
19 21
20%.o: %.cpp _pch.hpp.gch *.h *.hpp Makefile 22%.o: %.cpp _pch.hpp.gch *.h *.hpp UnitTests.makefile
21 $(CC) -I "../.." $(CFLAGS) -c $< 23 $(CC) -I "../.." $(CFLAGS) -c $<
22 24
23# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) 25# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think)
24# 26#
25$(_UNITTEST_TARGET): $(OBJ) 27$(_UNITTEST_TARGET): $(_OBJ)
26 $(CC) $^ $(LIBS) $(LUA_LIBS) -o $@ 28 $(CC) $^ $(LIBS) $(LUA_LIBS) -o $@
27 29
28clean: 30clean:
29 -rm -rf $(_UNITTEST_TARGET) *.o *.map *.gch 31 -rm -rf $(_UNITTEST_TARGET) *.o *.map *.gch
30 32
31.PROXY: all clean 33.PHONY: all clean
diff --git a/unit_tests/UnitTests.vcxproj b/unit_tests/UnitTests.vcxproj
index 9645a30..013a84f 100644
--- a/unit_tests/UnitTests.vcxproj
+++ b/unit_tests/UnitTests.vcxproj
@@ -939,7 +939,7 @@
939 </ItemGroup> 939 </ItemGroup>
940 <ItemGroup> 940 <ItemGroup>
941 <None Include="Catch2.runsettings" /> 941 <None Include="Catch2.runsettings" />
942 <None Include="Makefile" /> 942 <None Include="UnitTests.makefile" />
943 <None Include="scripts\coro\basics.lua" /> 943 <None Include="scripts\coro\basics.lua" />
944 <None Include="scripts\coro\error_handling.lua" /> 944 <None Include="scripts\coro\error_handling.lua" />
945 <None Include="scripts\lane\cooperative_shutdown.lua" /> 945 <None Include="scripts\lane\cooperative_shutdown.lua" />
diff --git a/unit_tests/UnitTests.vcxproj.filters b/unit_tests/UnitTests.vcxproj.filters
index c4e85c5..eb02d19 100644
--- a/unit_tests/UnitTests.vcxproj.filters
+++ b/unit_tests/UnitTests.vcxproj.filters
@@ -110,7 +110,7 @@
110 <None Include="Catch2.runsettings"> 110 <None Include="Catch2.runsettings">
111 <Filter>Catch2</Filter> 111 <Filter>Catch2</Filter>
112 </None> 112 </None>
113 <None Include="Makefile"> 113 <None Include="UnitTests.makefile">
114 <Filter>Make</Filter> 114 <Filter>Make</Filter>
115 </None> 115 </None>
116 </ItemGroup> 116 </ItemGroup>