-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (52 loc) · 1.55 KB
/
Makefile
File metadata and controls
68 lines (52 loc) · 1.55 KB
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
CC = gcc
LUA_INCDIR ?= /usr/include
CFLAGS ?= -I$(LUA_INCDIR)
CFLAGS += $(shell python3-config --includes)
LUA_LIBDIR ?= /usr/lib
LUA_VERSION ?= 5.4
LDFLAGS = -L$(LUA_LIBDIR) $(shell python3-config --ldflags)
PREFIX ?= /usr
CC ?= gcc
# It appears that -O0 is necessary to avoid segmentation faults when running the tests. We should investigate this further but for now we will keep it as is.
CFLAGS += -O0 -fPIC -g -I./luapython/
LUA_VERSION ?= 5.4
LDFLAGS += -lm -ldl -shared
TARGET = luapython.so
INSTALL_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL_LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)
SOURCES = \
luapython/luapython.c \
luapython/number.c \
luapython/string.c \
luapython/set.c \
luapython/dict.c \
luapython/list.c \
luapython/tuple.c \
luapython/module.c \
luapython/function.c \
luapython/class.c \
luapython/iter.c \
luapython/tools.c
# SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
all: $(TARGET) loader.so
@echo CFLAGS: $(CFLAGS)
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) -shared -o $@ $^
loader.so: luapython/loader.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o loader.so luapython/loader.c
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf luapython/*.o
rm -f *.so
rm -f *.o
install:
mkdir -p $(INSTALL_LIBDIR)/luapython
mkdir -p $(INSTALL_LUADIR)/luapython
cp $(TARGET) $(INSTALL_LIBDIR)/luapython/core.so
cp loader.so $(INSTALL_LIBDIR)/luapython/loader.so
cp luapython/*.lua $(INSTALL_LUADIR)/luapython
uninstall:
rm -rf $(INSTALL_LUADIR)/luapython
rm -rf $(INSTALL_LIBDIR)/luapython