-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
96 lines (74 loc) · 2.01 KB
/
Makefile
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
PLATFORM ?= gnu
APP_NAME = lu5
VERSION = 0.0.5
SRCDIR = src
BINDIR = bin
DOC_BUILD_SCRIPT = build_docs.lua
MACROS=-D'LU5_VERSION="$(VERSION)"'
ifeq ($(PLATFORM), win)
CC := x86_64-w64-mingw32-gcc
BIN = $(BINDIR)/win64/$(APP_NAME).exe
OBJDIR = $(BINDIR)/win64/obj
CFLAGS = -Wall -I/usr/x86_64-w64-mingw32/include -L/usr/x86_64-w64-mingw32/lib $(shell pkg-config --cflags freetype2)
LDFLAGS := -L/usr/x86_64-w64-mingw32\
$(shell pkg-config --static --libs freetype2)\
-lglfw3\
-lopengl32\
-lgdi32\
-llua\
-lm\
-lstdc++
else
CC := gcc
BIN = $(BINDIR)/linux/$(APP_NAME)
OBJDIR = $(BINDIR)/linux/obj
CFLAGS = -Wall\
$(shell pkg-config --cflags lua5.4)\
$(shell pkg-config --cflags glfw3)\
$(shell pkg-config --cflags glew)\
$(shell pkg-config --cflags gl)\
$(shell pkg-config --cflags freetype2)
LDFLAGS :=\
$(shell pkg-config --static --libs lua5.4)\
$(shell pkg-config --static --libs glfw3)\
$(shell pkg-config --static --libs glew)\
$(shell pkg-config --static --libs gl)\
$(shell pkg-config --libs freetype2)\
-lm
endif
SOURCES = $(wildcard $(SRCDIR)/*.c) $(wildcard $(SRCDIR)/bindings/*.c) $(wildcard $(SRCDIR)/shaders/*.c)
OBJECTS := $(patsubst src/%.c,$(OBJDIR)/%.o,$(SOURCES))
DEP = $(OBJECTS:.o=.d)
EXAMPLES = $(wildcard examples/*.lua)
all: $(BIN)
-include $(DEP)
$(OBJDIR)/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) -static -MMD $(MACROS) -c $< -o $@ $(CFLAGS)
$(BIN): $(OBJECTS)
@mkdir -p $(dir $@)
ifeq ($(PLATFORM), win)
$(CC) -static -o $@ $^ $(LDFLAGS)
else
$(CC) -o $@ $^ $(LDFLAGS)
endif
.PHONY: all clean install docs zip examples
run: $(BIN)
$(BIN) ./test.lua
examples: $(all) $(EXAMPLES:=.run)
examples/%.lua.run: examples/%.lua
$(BIN) $<
rm -f $@
docs: $(BIN)
$(BIN) ./tasks/$(DOC_BUILD_SCRIPT)
zip:
zip $(BINDIR)/linux/lu5-x86_64-linux-$(VERSION).zip $(BIN)
install:
cp $(BIN) /usr/bin/$(APP_NAME)
clean:
rm -fr bin/*
rm -fr docs/*.html
rm -fr docs/assets/*.svg
rm -fr docs/assets/*.css
rm -fr docs/assets/*.js
rm -fr examples/*.lua.run