From 24c8215fa05142cc2461efacc1187ef443450af9 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 13 Mar 2025 16:09:03 +0100 Subject: More work on Makefiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- Makefile | 157 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 89 insertions(+), 68 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index df56dcd..7d6b2ce 100644 --- a/Makefile +++ b/Makefile @@ -15,56 +15,77 @@ MODULE = lanes -N=1000 +N = 1000 -_TARGET_DIR=src/lanes -TIME=time +TIME = time ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" # MinGW MSYS on Windows # - _SO=dll - _LUAEXT=.exe - TIME=timeit.exe + _SO := dll + _LUAEXT := .exe + TIME := timeit.exe else - _SO=so - _LUAEXT= + _SO := so + _LUAEXT := endif # Autodetect LUA # -LUA:=$(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)) -LUA_VERSION:=$(shell $(LUA) -e "print(string.sub(_VERSION,5,7))") +LUA := $(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)) +LUA_VERSION := $(shell $(LUA) -e "print(string.sub(_VERSION,5,7))") -$(info LUA is $(LUA)) -$(info LUA_VERSION is $(LUA_VERSION)) +$(info LUA: $(LUA)) +$(info LUA_VERSION: $(LUA_VERSION)) -_TARGET_SO:=$(_TARGET_DIR)/core.$(_SO) +_LANES_TARGET := src/lanes/core.$(_SO) +$(info _LANES_TARGET: $(_LANES_TARGET)) -_UNITTEST_TARGET:=$(_TARGET_DIR)/UnitTests$(_LUAEXT) +_UNITTEST_TARGET := unit_tests/UnitTests$(_LUAEXT) +$(info _UNITTEST_TARGET: $(_UNITTEST_TARGET)) -_PREFIX:=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" +_DUE_TARGET := deep_userdata_example/deep_userdata_example.$(_SO) +$(info _DUE_TARGET: $(_DUE_TARGET)) + +_PREFIX := LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" + +.PHONY: all unit_tests + +# only build lanes itself by default +all: $(_LANES_TARGET) + +# build the unit_tests and the side deep_userdata_example module +unit_tests: $(_UNITTEST_TARGET) $(_DUE_TARGET) + cd deep_userdata_example && $(MAKE) -f DUE.makefile LUA_LIBDIR=$(LUA_LIBDIR) install #--- -all: $(_TARGET_SO) $(_UNITTEST_TARGET) -$(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp +$(_LANES_TARGET): src/*.lua src/*.cpp src/*.h src/*.hpp @echo ========================================================================================= - cd src && $(MAKE) LUA=$(LUA) - @echo ========== $(_TARGET_SO): DONE! + cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA) + @echo ==================== $(_LANES_TARGET): DONE! + @echo -$(_UNITTEST_TARGET): $(_TARGET_SO) +$(_UNITTEST_TARGET): $(_LANES_TARGET) @echo ========================================================================================= - cd unit_tests && $(MAKE) - @echo ========== $(_UNITTEST_TARGET): DONE! + cd unit_tests && $(MAKE) -f UnitTests.makefile + @echo ==================== $(_UNITTEST_TARGET): DONE! + @echo + +$(_DUE_TARGET): + @echo ========================================================================================= + cd deep_userdata_example && $(MAKE) -f DUE.makefile + @echo ==================== $(_DUE_TARGET): DONE! + @echo clean: - cd src && $(MAKE) clean - cd unit_tests && $(MAKE) clean + cd src && $(MAKE) -f Lanes.makefile clean + cd unit_tests && $(MAKE) -f UnitTests.makefile clean + cd deep_userdata_example && $(MAKE) -f DUE.makefile clean debug: $(MAKE) clean - cd src && $(MAKE) LUA=$(LUA) OPT_FLAGS="-O0 -g" + cd src && $(MAKE) -f Lanes.makefile LUA=$(LUA) OPT_FLAGS="-O0 -g" @echo "" @echo "** Now, try 'make repetitive' or something and if it crashes, 'gdb $(LUA) ...core file...'" @echo " Then 'bt' for a backtrace." @@ -80,7 +101,7 @@ gdb: #--- LuaRocks automated build --- # rock: - cd src && $(MAKE) LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA) + cd src && $(MAKE) -f Lanes.makefile LUAROCKS=1 CFLAGS="$(CFLAGS)" LIBFLAG="$(LIBFLAG)" LUA=$(LUA) #--- Testing --- @@ -114,117 +135,117 @@ test: $(MAKE) timer $(MAKE) track_lanes -appendud: tests/appendud.lua $(_TARGET_SO) +appendud: tests/appendud.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -atexit: tests/atexit.lua $(_TARGET_SO) +atexit: tests/atexit.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -atomic: tests/atomic.lua $(_TARGET_SO) +atomic: tests/atomic.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -basic: tests/basic.lua $(_TARGET_SO) +basic: tests/basic.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -cancel: tests/cancel.lua $(_TARGET_SO) +cancel: tests/cancel.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -cyclic: tests/cyclic.lua $(_TARGET_SO) +cyclic: tests/cyclic.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -deadlock: tests/deadlock.lua $(_TARGET_SO) +deadlock: tests/deadlock.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -ehynes: tests/ehynes.lua $(_TARGET_SO) +ehynes: tests/ehynes.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -errhangtest: tests/errhangtest.lua $(_TARGET_SO) +errhangtest: tests/errhangtest.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -error: tests/error.lua $(_TARGET_SO) +error: tests/error.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -fibonacci: tests/fibonacci.lua $(_TARGET_SO) +fibonacci: tests/fibonacci.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -fifo: tests/fifo.lua $(_TARGET_SO) +fifo: tests/fifo.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -finalizer: tests/finalizer.lua $(_TARGET_SO) +finalizer: tests/finalizer.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -func_is_string: tests/func_is_string.lua $(_TARGET_SO) +func_is_string: tests/func_is_string.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -hangtest: tests/hangtest.lua $(_TARGET_SO) +hangtest: tests/hangtest.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -irayo_closure: tests/irayo_closure.lua $(_TARGET_SO) +irayo_closure: tests/irayo_closure.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -irayo_recursive: tests/irayo_recursive.lua $(_TARGET_SO) +irayo_recursive: tests/irayo_recursive.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -keeper: tests/keeper.lua $(_TARGET_SO) +keeper: tests/keeper.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -launchtest: tests/launchtest.lua $(_TARGET_SO) +launchtest: tests/launchtest.lua $(_LANES_TARGET) $(MAKE) _perftest ARGS="$< $(N)" -linda_perf: tests/linda_perf.lua $(_TARGET_SO) +linda_perf: tests/linda_perf.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -manual_register: tests/manual_register.lua $(_TARGET_SO) +manual_register: tests/manual_register.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -nameof: tests/nameof.lua $(_TARGET_SO) +nameof: tests/nameof.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -objects: tests/objects.lua $(_TARGET_SO) +objects: tests/objects.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -package: tests/package.lua $(_TARGET_SO) +package: tests/package.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -perftest: tests/perftest.lua $(_TARGET_SO) +perftest: tests/perftest.lua $(_LANES_TARGET) $(MAKE) _perftest ARGS="$< $(N)" -perftest-even: tests/perftest.lua $(_TARGET_SO) +perftest-even: tests/perftest.lua $(_LANES_TARGET) $(MAKE) _perftest ARGS="$< $(N) -prio=-2" -perftest-odd: tests/perftest.lua $(_TARGET_SO) +perftest-odd: tests/perftest.lua $(_LANES_TARGET) $(MAKE) _perftest ARGS="$< $(N) -prio=+2" -perftest-plain: tests/perftest.lua $(_TARGET_SO) +perftest-plain: tests/perftest.lua $(_LANES_TARGET) $(MAKE) _perftest ARGS="$< $(N) -plain" -pingpong: tests/pingpong.lua $(_TARGET_SO) +pingpong: tests/pingpong.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -recursive: tests/recursive.lua $(_TARGET_SO) +recursive: tests/recursive.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -require: tests/require.lua $(_TARGET_SO) +require: tests/require.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -rupval: tests/rupval.lua $(_TARGET_SO) +rupval: tests/rupval.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -timer: tests/timer.lua $(_TARGET_SO) +timer: tests/timer.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< -track_lanes: tests/track_lanes.lua $(_TARGET_SO) +track_lanes: tests/track_lanes.lua $(_LANES_TARGET) $(_PREFIX) $(LUA) $< # # This tries to show out a bug which happens in lane cleanup (multicore CPU's only) # REP_ARGS=-llanes -e "print'say aaa'; for i=1,10 do print(i) end" -repetitive: $(_TARGET_SO) +repetitive: $(_LANES_TARGET) 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; \ do $(_PREFIX) $(LUA) $(REP_ARGS); \ done -repetitive1: $(_TARGET_SO) +repetitive1: $(_LANES_TARGET) $(_PREFIX) $(LUA) $(REP_ARGS) #--- @@ -246,15 +267,15 @@ LUA_SHAREDIR:=$(DESTDIR)/share/lua/$(LUA_VERSION) # # AKa 17-Oct: changed to use 'install -m 644' and 'cp -p' # -install: $(_TARGET_SO) src/lanes.lua +install: $(_LANES_TARGET) src/lanes.lua mkdir -p $(LUA_LIBDIR) $(LUA_LIBDIR)/lanes $(LUA_SHAREDIR) - install -m 644 $(_TARGET_SO) $(LUA_LIBDIR)/lanes + install -m 644 $(_LANES_TARGET) $(LUA_LIBDIR)/lanes cp -p src/lanes.lua $(LUA_SHAREDIR) uninstall: rm $(LUA_LIBDIR)/lanes/core.$(_SO) rm $(LUA_SHAREDIR)/lanes.lua - + rm $(LUA_LIBDIR)/deep_userdata_example.$(_SO) #--- Packaging --- # @@ -289,14 +310,14 @@ endif # 2.0.1: Running this (instant exit of the main Lua state) occasionally # segfaults (1:15 or so on OS X PowerPC G4). # -require_module: $(_TARGET_SO) +require_module: $(_LANES_TARGET) $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -run: $(_TARGET_SO) +run: $(_LANES_TARGET) $(_PREFIX) $(LUA) -e "require '$(MODULE)'" -i echo: @echo $(PROGRAMFILES:C=X) -.PHONY: all clean debug gdb rock test require install uninstall _nodemo _notest +.PHONY: clean debug gdb rock test require install uninstall _nodemo _notest -- cgit v1.2.3-55-g6feb