aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-03-14 09:23:23 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-03-14 09:23:23 +0100
commit536a64557c82c350fd73ea64c6d4dd1737896579 (patch)
treed90e1f2ba846090be20242925182ee5208828e15
parentc39cb92325ba7280dae175ec5a32a97d0668981e (diff)
downloadlanes-536a64557c82c350fd73ea64c6d4dd1737896579.tar.gz
lanes-536a64557c82c350fd73ea64c6d4dd1737896579.tar.bz2
lanes-536a64557c82c350fd73ea64c6d4dd1737896579.zip
More makefile tweaks
-rw-r--r--Makefile25
-rw-r--r--deep_userdata_example/DUE.makefile22
-rw-r--r--src/Lanes.makefile8
-rw-r--r--unit_tests/UnitTests.makefile14
4 files changed, 36 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 0eb485f..c620f0f 100644
--- a/Makefile
+++ b/Makefile
@@ -47,39 +47,40 @@ $(info _UNITTEST_TARGET: $(_UNITTEST_TARGET))
47_DUE_TARGET := deep_userdata_example/deep_userdata_example.$(_SO) 47_DUE_TARGET := deep_userdata_example/deep_userdata_example.$(_SO)
48$(info _DUE_TARGET: $(_DUE_TARGET)) 48$(info _DUE_TARGET: $(_DUE_TARGET))
49 49
50_PREFIX := LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" 50# setup LUA_PATH and LUA_CPATH so that requiring lanes and deep_userdata_example work without having to install them
51_PREFIX := LUA_CPATH="./src/?.$(_SO);./deep_userdata_example/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua"
51 52
52.PHONY: all unit_tests 53.PHONY: all build_lanes build_unit_tests build_DUE
53 54
54# only build lanes itself by default 55# only build lanes itself by default
55all: $(_LANES_TARGET) 56all: build_lanes
56
57# build the unit_tests and the side deep_userdata_example module
58# also run the test that shows whether lanes is successfully loaded or not
59unit_tests: $(_UNITTEST_TARGET) $(_DUE_TARGET)
60 cd deep_userdata_example && $(MAKE) -f DUE.makefile LUA_LIBDIR=$(LUA_LIBDIR) install
61 $(_UNITTEST_TARGET) "lanes.require 'lanes'"
62 57
63#--- 58#---
64 59
65$(_LANES_TARGET): src/*.lua src/*.cpp src/*.h src/*.hpp 60build_lanes:
66 @echo ========================================================================================= 61 @echo =========================================================================================
67 cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA) 62 cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA)
68 @echo ==================== $(_LANES_TARGET): DONE! 63 @echo ==================== $(_LANES_TARGET): DONE!
69 @echo 64 @echo
70 65
71$(_UNITTEST_TARGET): $(_LANES_TARGET) 66build_unit_tests:
72 @echo ========================================================================================= 67 @echo =========================================================================================
73 cd unit_tests && $(MAKE) -f UnitTests.makefile 68 cd unit_tests && $(MAKE) -f UnitTests.makefile
74 @echo ==================== $(_UNITTEST_TARGET): DONE! 69 @echo ==================== $(_UNITTEST_TARGET): DONE!
75 @echo 70 @echo
76 71
77$(_DUE_TARGET): 72build_DUE:
78 @echo ========================================================================================= 73 @echo =========================================================================================
79 cd deep_userdata_example && $(MAKE) -f DUE.makefile 74 cd deep_userdata_example && $(MAKE) -f DUE.makefile
80 @echo ==================== $(_DUE_TARGET): DONE! 75 @echo ==================== $(_DUE_TARGET): DONE!
81 @echo 76 @echo
82 77
78# build the unit_tests and the side deep_userdata_example module
79# also run a test that shows whether lanes is successfully loaded or not
80run_unit_tests: build_lanes build_unit_tests build_DUE
81 @echo =========================================================================================
82 $(_PREFIX) $(_UNITTEST_TARGET) "lanes.require 'lanes'"
83
83clean: 84clean:
84 cd src && $(MAKE) -f Lanes.makefile clean 85 cd src && $(MAKE) -f Lanes.makefile clean
85 cd unit_tests && $(MAKE) -f UnitTests.makefile clean 86 cd unit_tests && $(MAKE) -f UnitTests.makefile clean
diff --git a/deep_userdata_example/DUE.makefile b/deep_userdata_example/DUE.makefile
index 8fcc89e..b5c3a23 100644
--- a/deep_userdata_example/DUE.makefile
+++ b/deep_userdata_example/DUE.makefile
@@ -4,33 +4,33 @@
4 4
5include ../Shared.makefile 5include ../Shared.makefile
6 6
7_MODULE=deep_userdata_example.$(_SO) 7_TARGET := deep_userdata_example.$(_SO)
8 8
9_SRC:=$(wildcard *.cpp) ../src/compat.cpp ../src/deep.cpp 9_SRC := $(wildcard *.cpp) ../src/compat.cpp ../src/deep.cpp
10 10
11_OBJ:=$(_SRC:.cpp=.o) 11_OBJ := $(_SRC:.cpp=.o)
12 12
13#--- 13#---
14all: $(_MODULE) 14all: $(_TARGET)
15 $(info CC: $(CC)) 15 $(info CC: $(CC))
16 $(info _MODULE: $(_MODULE)) 16 $(info _TARGET: $(_TARGET))
17 $(info _SRC: $(_SRC)) 17 $(info _SRC: $(_SRC))
18 18
19_pch.hpp.gch: ../src/_pch.hpp 19_pch.hpp.gch: ../src/_pch.hpp
20 $(CC) -I "../.." $(CFLAGS) -x c++-header $< -o _pch.hpp.gch 20 $(CC) -I "../.." $(CFLAGS) -x c++-header $< -o _pch.hpp.gch
21 21
22%.o: %.cpp _pch.hpp.gch DUE.makefile 22%.o: %.cpp _pch.hpp.gch DUE.makefile
23 $(CC) -I "../.." $(CFLAGS) -c $< 23 $(CC) -I "../.." $(CFLAGS) -c $< -o $@
24 24
25# 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)
26# 26#
27$(_MODULE): $(_OBJ) 27$(_TARGET): $(_OBJ)
28 $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ 28 $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@
29 29
30install: 30install:
31 install -m 644 $(_MODULE) $(LUA_LIBDIR)/ 31 install -m 644 $(_TARGET) $(LUA_LIBDIR)/
32 32
33clean: 33clean:
34 -rm -rf $(_MODULE) *.o *.map *.gch 34 -rm -rf $(_TARGET) *.o *.map *.gch
35 35
36.PHONY: all clean 36.PHONY: all clean
diff --git a/src/Lanes.makefile b/src/Lanes.makefile
index d9127f7..9798848 100644
--- a/src/Lanes.makefile
+++ b/src/Lanes.makefile
@@ -16,7 +16,9 @@ _OBJ := $(_SRC:.cpp=.o)
16_MODULE_DIR = $(_MODULE) 16_MODULE_DIR = $(_MODULE)
17 17
18#--- 18#---
19all: $(_MODULE)/core.$(_SO) 19all: info $(_MODULE)/core.$(_SO)
20
21info:
20 $(info CC: $(CC)) 22 $(info CC: $(CC))
21 $(info _SRC: $(_SRC)) 23 $(info _SRC: $(_SRC))
22 24
@@ -24,7 +26,7 @@ _pch.hpp.gch: _pch.hpp
24 $(CC) $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch 26 $(CC) $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch
25 27
26%.o: %.cpp _pch.hpp.gch *.h *.hpp Lanes.makefile 28%.o: %.cpp _pch.hpp.gch *.h *.hpp Lanes.makefile
27 $(CC) $(CFLAGS) -c $< 29 $(CC) $(CFLAGS) -c $< -o $@
28 30
29# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) 31# Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think)
30# 32#
@@ -66,4 +68,4 @@ $(WIN32_LUA51)/include/lua.h:
66 @echo " [MINGW_GCC=...mingw32-gcc]" 68 @echo " [MINGW_GCC=...mingw32-gcc]"
67 @false 69 @false
68 70
69.PHONY: all clean nslu2 win32 71.PHONY: all info clean nslu2 win32
diff --git a/unit_tests/UnitTests.makefile b/unit_tests/UnitTests.makefile
index b3d1c58..a383516 100644
--- a/unit_tests/UnitTests.makefile
+++ b/unit_tests/UnitTests.makefile
@@ -4,30 +4,30 @@
4 4
5include ../Shared.makefile 5include ../Shared.makefile
6 6
7_TARGET := UnitTests$(_LUAEXT)
8
7_SRC := $(wildcard *.cpp) ../src/deep.cpp ../src/compat.cpp 9_SRC := $(wildcard *.cpp) ../src/deep.cpp ../src/compat.cpp
8 10
9_OBJ := $(_SRC:.cpp=.o) 11_OBJ := $(_SRC:.cpp=.o)
10 12
11
12_UNITTEST_TARGET := UnitTests$(_LUAEXT)
13
14#--- 13#---
15all: $(_UNITTEST_TARGET) 14all: $(_TARGET)
16 $(info CC: $(CC)) 15 $(info CC: $(CC))
16 $(info _TARGET: $(_TARGET))
17 $(info _SRC: $(_SRC)) 17 $(info _SRC: $(_SRC))
18 18
19_pch.hpp.gch: _pch.hpp 19_pch.hpp.gch: _pch.hpp
20 $(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
21 21
22%.o: %.cpp _pch.hpp.gch *.h *.hpp UnitTests.makefile 22%.o: %.cpp _pch.hpp.gch *.h *.hpp UnitTests.makefile
23 $(CC) -I "../.." $(CFLAGS) -c $< 23 $(CC) -I "../.." $(CFLAGS) -c $< -o $@
24 24
25# 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)
26# 26#
27$(_UNITTEST_TARGET): $(_OBJ) 27$(_TARGET): $(_OBJ)
28 $(CC) $^ $(LIBS) $(LUA_LIBS) -o $@ 28 $(CC) $^ $(LIBS) $(LUA_LIBS) -o $@
29 29
30clean: 30clean:
31 -rm -rf $(_UNITTEST_TARGET) *.o *.map *.gch 31 -rm -rf $(_TARGET) *.o *.map *.gch
32 32
33.PHONY: all clean 33.PHONY: all clean