-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (34 loc) · 1.42 KB
/
Makefile
File metadata and controls
46 lines (34 loc) · 1.42 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
# VMSL — Makefile for C modules
# Build vectors.so and matrix.so for use with Lua >= 5.4
LUA_VERSION ?= 5.4
# Try pkg-config first, fall back to common paths
LUA_INC ?= $(shell pkg-config --cflags lua$(LUA_VERSION) 2>/dev/null || \
pkg-config --cflags lua-$(LUA_VERSION) 2>/dev/null || \
pkg-config --cflags lua 2>/dev/null || \
echo "-I/usr/include/lua$(LUA_VERSION)")
LUA_CMOD ?= $(shell pkg-config --variable=INSTALL_CMOD lua$(LUA_VERSION) 2>/dev/null || \
pkg-config --variable=INSTALL_CMOD lua-$(LUA_VERSION) 2>/dev/null || \
echo "/usr/local/lib/lua/$(LUA_VERSION)")
CC ?= gcc
CFLAGS += -O2 -Wall -Wextra -fPIC $(LUA_INC)
LDFLAGS += -shared -lm
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LDFLAGS += -undefined dynamic_lookup
EXT = .so
else
EXT = .so
endif
# ── targets ──────────────────────────────────────────────────────
all: vectors$(EXT) matrix$(EXT)
vectors$(EXT): src/vector.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
matrix$(EXT): src/matrix.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
install: all
install -d $(DESTDIR)$(LUA_CMOD)
install -m 755 vectors$(EXT) $(DESTDIR)$(LUA_CMOD)/vectors$(EXT)
install -m 755 matrix$(EXT) $(DESTDIR)$(LUA_CMOD)/matrix$(EXT)
clean:
rm -f vectors$(EXT) matrix$(EXT)
.PHONY: all install clean