blob: 15094d27ff64875787d7a387dff046c8e50d7e26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
CC := clang
GIT_COMMIT := "$(shell git -c safe.directory='*' describe --tags)-$(shell git -c safe.directory='*' describe --always --match 'NOT A TAG')"
version ?= 5.4
install_version = $(version)
ifeq ($(version),jit)
install_version = 5.1
endif
CFLAGS := -Wall -Werror -fPIC -DGIT_COMMIT='$(GIT_COMMIT)' `pkg-config --cflags lua$(version)`
LFLAGS := -lm -shared -lcrypto -lssl
LINKER := $(CC)
TARGET := lullaby.so
INSTALL_DIR := /usr/lib64/lua/
SRCS := $(wildcard src/*.c) $(wildcard src/*/*.c)
OBJS := $(SRCS:.c=.o)
ifeq ($(OS),Windows_NT)
CFLAGS += -I/mingw64/include
LFLAGS += -L/mingw64/bin -llua54 -lws2_32
TARGET := $(TARGET:.so=.dll)
else
CFLAGS += -fPIC
endif
all: $(TARGET)
release: CFLAGS += -O3
release: all
install::
mkdir $(INSTALL_DIR)$(install_version) -p
cp $(TARGET) $(INSTALL_DIR)$(install_version)/$(TARGET)
# ok so im pretty sure asan should be linked too, however dlclose needs to be masked anyways
# and since libasan needs to be the first thing to load, you'll have to add it anyways
# run with something like 'LD_PRELOAD="/usr/lib/gcc/x86_64-pc-linux-gnu/14/libasan.so ./fakedlclose.so" lua5.4 ...'
# fakedlclose.so should be something as simple as the following:
#
# "
# #include <stdio.h>
# int dlclose(void *handle) {;}
# "
#
# code (& fix) courtesy of
# https://github.com/google/sanitizers/issues/89#issuecomment-406316683
#
# this also requires lua to be built with asan
debug: CFLAGS += -ggdb3 -fno-omit-frame-pointer -fno-optimize-sibling-calls
debug: all
san: CFLAGS += -ggdb3 -static-libasan -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls
san: all
reg:
rm src/reg.o
reg: all
%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
$(TARGET): $(OBJS)
$(LINKER) $(OBJS) -o $(TARGET) $(LFLAGS)
clean:
rm -f $(OBJS)
|