aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-03-12 16:22:12 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-03-12 16:22:12 +0100
commitfb03f0e208801406400334014ebcf453ff6f1db0 (patch)
treeb64fdd4b75b1fc2c859b44d72361bb15370dd284
parent79c7eb627052183c142cd782e743b79869993d82 (diff)
downloadlanes-fb03f0e208801406400334014ebcf453ff6f1db0.tar.gz
lanes-fb03f0e208801406400334014ebcf453ff6f1db0.tar.bz2
lanes-fb03f0e208801406400334014ebcf453ff6f1db0.zip
More makefile improvements
-rw-r--r--Makefile28
-rw-r--r--Shared.mk12
-rw-r--r--src/Makefile8
3 files changed, 30 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index f5ac12e..df56dcd 100644
--- a/Makefile
+++ b/Makefile
@@ -33,22 +33,30 @@ endif
33 33
34# Autodetect LUA 34# Autodetect LUA
35# 35#
36LUA=$(word 1,$(shell which lua5.1$(_LUAEXT)) $(shell which lua51$(_LUAEXT)) $(shell which lua$(_LUAEXT)) $(shell which luajit$(_LUAEXT))) 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))
37LUA_VERSION:=$(shell $(LUA) -e "print(string.sub(_VERSION,5,7))")
37 38
38_TARGET_SO=$(_TARGET_DIR)/core.$(_SO) 39$(info LUA is $(LUA))
40$(info LUA_VERSION is $(LUA_VERSION))
39 41
40_UNITTEST_TARGET=$(_TARGET_DIR)/UnitTests$(_LUAEXT) 42_TARGET_SO:=$(_TARGET_DIR)/core.$(_SO)
41 43
42_PREFIX=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" 44_UNITTEST_TARGET:=$(_TARGET_DIR)/UnitTests$(_LUAEXT)
45
46_PREFIX:=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua"
43 47
44#--- 48#---
45all: $(_TARGET_SO) $(_UNITTEST_TARGET) 49all: $(_TARGET_SO) $(_UNITTEST_TARGET)
46 50
47$(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp 51$(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp
52 @echo =========================================================================================
48 cd src && $(MAKE) LUA=$(LUA) 53 cd src && $(MAKE) LUA=$(LUA)
54 @echo ========== $(_TARGET_SO): DONE!
49 55
50$(_UNITTEST_TARGET): $(_TARGET_SO) 56$(_UNITTEST_TARGET): $(_TARGET_SO)
57 @echo =========================================================================================
51 cd unit_tests && $(MAKE) 58 cd unit_tests && $(MAKE)
59 @echo ========== $(_UNITTEST_TARGET): DONE!
52 60
53clean: 61clean:
54 cd src && $(MAKE) clean 62 cd src && $(MAKE) clean
@@ -231,9 +239,9 @@ _perftest:
231# 239#
232# LUA_LIBDIR and LUA_SHAREDIR are used by the .rockspec (don't change the names!) 240# LUA_LIBDIR and LUA_SHAREDIR are used by the .rockspec (don't change the names!)
233# 241#
234DESTDIR=/usr/local 242DESTDIR:=/usr/local
235LUA_LIBDIR=$(DESTDIR)/lib/lua/5.1 243LUA_LIBDIR:=$(DESTDIR)/lib/lua/$(LUA_VERSION)
236LUA_SHAREDIR=$(DESTDIR)/share/lua/5.1 244LUA_SHAREDIR:=$(DESTDIR)/share/lua/$(LUA_VERSION)
237 245
238# 246#
239# AKa 17-Oct: changed to use 'install -m 644' and 'cp -p' 247# AKa 17-Oct: changed to use 'install -m 644' and 'cp -p'
@@ -243,6 +251,10 @@ install: $(_TARGET_SO) src/lanes.lua
243 install -m 644 $(_TARGET_SO) $(LUA_LIBDIR)/lanes 251 install -m 644 $(_TARGET_SO) $(LUA_LIBDIR)/lanes
244 cp -p src/lanes.lua $(LUA_SHAREDIR) 252 cp -p src/lanes.lua $(LUA_SHAREDIR)
245 253
254uninstall:
255 rm $(LUA_LIBDIR)/lanes/core.$(_SO)
256 rm $(LUA_SHAREDIR)/lanes.lua
257
246 258
247#--- Packaging --- 259#--- Packaging ---
248# 260#
@@ -286,5 +298,5 @@ run: $(_TARGET_SO)
286echo: 298echo:
287 @echo $(PROGRAMFILES:C=X) 299 @echo $(PROGRAMFILES:C=X)
288 300
289.PROXY: all clean test require debug _nodemo _notest 301.PHONY: all clean debug gdb rock test require install uninstall _nodemo _notest
290 302
diff --git a/Shared.mk b/Shared.mk
index 56c951c..f6941e1 100644
--- a/Shared.mk
+++ b/Shared.mk
@@ -10,12 +10,12 @@ OPT_FLAGS=-O2
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)" ""
@@ -30,7 +30,7 @@ ifeq "$(LUAROCKS)" ""
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)) $(shell which lua53.$(_SO)) $(shell which lua52.$(_SO)) $(shell which lua51$(_SO))) 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 else 34 else
35 LUA_FLAGS:=-I "$(LUA_DEV)/include" 35 LUA_FLAGS:=-I "$(LUA_DEV)/include"
36 LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc 36 LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc
diff --git a/src/Makefile b/src/Makefile
index 028ef3a..39b98e6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -9,11 +9,11 @@ include ../Shared.mk
9 9
10MODULE=lanes 10MODULE=lanes
11 11
12CC= g++ -std=c++20 12CC:= g++ -std=c++20
13 13
14SRC=$(wildcard *.cpp) 14SRC:=$(wildcard *.cpp)
15 15
16OBJ=$(SRC:.cpp=.o) 16OBJ:=$(SRC:.cpp=.o)
17 17
18 18
19MODULE_DIR=$(MODULE) 19MODULE_DIR=$(MODULE)
@@ -67,4 +67,4 @@ $(WIN32_LUA51)/include/lua.h:
67 @echo " [MINGW_GCC=...mingw32-gcc]" 67 @echo " [MINGW_GCC=...mingw32-gcc]"
68 @false 68 @false
69 69
70.PROXY: all clean nslu2 win32 70.PHONY: all clean nslu2 win32