diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 09:32:02 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 09:32:02 +0100 |
commit | fc160438406458a11921566a4644c7f15d49c244 (patch) | |
tree | ca484f902d836626a45d973235a78cc85bae6e80 /src | |
parent | dacdd54a805aac286e07582706d8a0e85d1f69a4 (diff) | |
download | lanes-fc160438406458a11921566a4644c7f15d49c244.tar.gz lanes-fc160438406458a11921566a4644c7f15d49c244.tar.bz2 lanes-fc160438406458a11921566a4644c7f15d49c244.zip |
Makefile and code fixes to build the unit tests
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 110 |
1 files changed, 3 insertions, 107 deletions
diff --git a/src/Makefile b/src/Makefile index f2e2eb5..262f970 100644 --- a/src/Makefile +++ b/src/Makefile | |||
@@ -5,120 +5,16 @@ | |||
5 | # make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build | 5 | # make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build |
6 | # | 6 | # |
7 | 7 | ||
8 | include ../Shared.mk | ||
9 | |||
8 | MODULE=lanes | 10 | MODULE=lanes |
9 | 11 | ||
10 | CC= g++ -std=c++20 | 12 | CC= g++ -std=c++20 |
11 | 13 | ||
12 | SRC=_pch.cpp allocator.cpp cancel.cpp compat.cpp deep.cpp intercopycontext.cpp keeper.cpp lane.cpp lanes.cpp linda.cpp lindafactory.cpp nameof.cpp state.cpp threading.cpp tools.cpp tracker.cpp universe.cpp | 14 | SRC=$(wildcard *.cpp) |
13 | 15 | ||
14 | OBJ=$(SRC:.cpp=.o) | 16 | OBJ=$(SRC:.cpp=.o) |
15 | 17 | ||
16 | # LuaRocks gives 'LIBFLAG' from the outside | ||
17 | # | ||
18 | LIBFLAG=-shared | ||
19 | |||
20 | OPT_FLAGS=-O2 | ||
21 | # -O0 -g | ||
22 | |||
23 | _SO=so | ||
24 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
25 | _SO=dll | ||
26 | endif | ||
27 | |||
28 | ifeq "$(LUAROCKS)" "" | ||
29 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
30 | # MinGW MSYS on Windows | ||
31 | # | ||
32 | # - 'lua' and 'luac' expected to be on the path | ||
33 | # - %LUA_DEV% must lead to include files and libraries (Lua for Windows >= 5.1.3.14) | ||
34 | # - %MSCVR80% must be the full pathname of 'msvcr80.dll' | ||
35 | # | ||
36 | ifeq "$(LUA_DEV)" "" | ||
37 | $(warning LUA_DEV not defined - try i.e. 'make LUA_DEV=/c/Program\ Files/Lua/5.1') | ||
38 | # this assumes Lua was built and installed from source and everything is located in default folders (/usr/local/include and /usr/local/bin) | ||
39 | LUA_FLAGS:=-I "/usr/local/include" | ||
40 | LUA_LIBS:=$(word 1,$(shell which lua54.$(_SO)) $(shell which lua53.$(_SO)) $(shell which lua52.$(_SO)) $(shell which lua51$(_SO))) | ||
41 | else | ||
42 | LUA_FLAGS:=-I "$(LUA_DEV)/include" | ||
43 | LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc | ||
44 | endif | ||
45 | LIBFLAG=-shared -Wl,-Map,lanes.map | ||
46 | else | ||
47 | # Autodetect LUA_FLAGS and/or LUA_LIBS | ||
48 | # | ||
49 | ifneq "$(shell which pkg-config)" "" | ||
50 | ifeq "$(shell pkg-config --exists luajit && echo 1)" "1" | ||
51 | LUA_FLAGS:=$(shell pkg-config --cflags luajit) | ||
52 | LUA_LIBS:=$(shell pkg-config --libs luajit) | ||
53 | # | ||
54 | # Debian: -I/usr/include/luajit-2.0 | ||
55 | # -lluajit-5.1 | ||
56 | else | ||
57 | ifeq "$(shell pkg-config --exists lua5.1 && echo 1)" "1" | ||
58 | LUA_FLAGS:=$(shell pkg-config --cflags lua5.1) | ||
59 | LUA_LIBS:=$(shell pkg-config --libs lua5.1) | ||
60 | # | ||
61 | # Ubuntu: -I/usr/include/lua5.1 | ||
62 | # -llua5.1 | ||
63 | else | ||
64 | ifeq "$(shell pkg-config --exists lua && echo 1)" "1" | ||
65 | LUA_FLAGS:=$(shell pkg-config --cflags lua) | ||
66 | LUA_LIBS:=$(shell pkg-config --libs lua) | ||
67 | # | ||
68 | # OS X fink with pkg-config: | ||
69 | # -I/sw/include | ||
70 | # -L/sw/lib -llua -lm | ||
71 | else | ||
72 | $(warning *** 'pkg-config' existed but did not know of 'lua[5.1]' - Good luck!) | ||
73 | LUA_FLAGS:= | ||
74 | LUA_LIBS:=-llua | ||
75 | endif | ||
76 | endif | ||
77 | endif | ||
78 | else | ||
79 | # No 'pkg-config'; try defaults | ||
80 | # | ||
81 | ifeq "$(shell uname -s)" "Darwin" | ||
82 | $(warning *** Assuming 'fink' at default path) | ||
83 | LUA_FLAGS:=-I/sw/include | ||
84 | LUA_LIBS:=-L/sw/lib -llua | ||
85 | else | ||
86 | $(warning *** Assuming an arbitrary Lua installation; try installing 'pkg-config') | ||
87 | LUA_FLAGS:= | ||
88 | LUA_LIBS:=-llua | ||
89 | endif | ||
90 | endif | ||
91 | endif | ||
92 | |||
93 | ifeq "$(shell uname -s)" "Darwin" | ||
94 | # Some machines need 'MACOSX_DEPLOYMENT_TARGET=10.3' for using '-undefined dynamic_lookup' | ||
95 | # (at least PowerPC running 10.4.11); does not harm the others | ||
96 | # | ||
97 | CC = MACOSX_DEPLOYMENT_TARGET=10.3 gcc | ||
98 | LIBFLAG = -bundle -undefined dynamic_lookup | ||
99 | endif | ||
100 | |||
101 | CFLAGS=-Wall -Werror $(OPT_FLAGS) $(LUA_FLAGS) | ||
102 | LIBS=$(LUA_LIBS) | ||
103 | endif | ||
104 | |||
105 | #--- | ||
106 | # PThread platform specifics | ||
107 | # | ||
108 | ifeq "$(shell uname -s)" "Linux" | ||
109 | # -D_GNU_SOURCE needed for 'pthread_mutexattr_settype' | ||
110 | CFLAGS += -D_GNU_SOURCE -fPIC | ||
111 | |||
112 | # Use of -DUSE_PTHREAD_TIMEDJOIN is possible, but not recommended (slower & keeps threads | ||
113 | # unreleased somewhat longer) | ||
114 | #CFLAGS += -DUSE_PTHREAD_TIMEDJOIN | ||
115 | |||
116 | LIBS += -lpthread | ||
117 | endif | ||
118 | |||
119 | ifeq "$(shell uname -s)" "BSD" | ||
120 | LIBS += -lpthread | ||
121 | endif | ||
122 | 18 | ||
123 | MODULE_DIR=$(MODULE) | 19 | MODULE_DIR=$(MODULE) |
124 | 20 | ||