This repository has been archived by the owner on Jul 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (55 loc) · 2.09 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
prefix?=/usr/local
mle_cflags:=-std=c99 -Wall -Wextra -pedantic -Wno-pointer-arith -Wno-unused-result -Wno-unused-parameter -g -O3 -D_GNU_SOURCE -I. $(CFLAGS)
mle_ldflags:=$(LDFLAGS)
mle_dynamic_libs:=-lpcre -ltermbox -llua5.3
mle_static_libs:=vendor/pcre/.libs/libpcre.a vendor/termbox/src/libtermbox.a vendor/lua/liblua5.3.a
mle_forced_vendor_deps:=vendor/tvision/libtvision.a
mle_ldlibs:=-lm $(LDLIBS) -lstdc++ -lgpm -lncursesw $(mle_forced_vendor_deps)
mle_objects:=$(patsubst %.c,%.o,$(wildcard *.c))
mle_tuiobjects:=$(patsubst %.cc,%.o,$(wildcard tui/*.cc))
mle_objects_no_main:=$(filter-out main.o,$(mle_objects))
mle_func_tests:=$(wildcard tests/func/test_*.sh))
mle_unit_tests:=$(patsubst %.c,%,$(wildcard tests/unit/*.c))
mle_vendor_deps:=
mle_static_var:=
ifdef mle_static
mle_static_var:=-static
endif
ifdef mle_vendor
mle_ldlibs:=$(mle_static_libs) $(mle_ldlibs)
mle_cflags:=-Ivendor/pcre -Ivendor/termbox/src -Ivendor -Ivendor/uthash/src $(mle_cflags)
mle_vendor_deps:=$(mle_static_libs)
else
mle_ldlibs:=$(mle_dynamic_libs) $(mle_ldlibs)
endif
all: mle
mle: $(mle_vendor_deps) $(mle_objects) $(mle_tuiobjects)
$(CC) $(mle_static_var) $(mle_cflags) $(mle_objects) $(mle_tuiobjects) $(mle_ldflags) $(mle_ldlibs) -o mle
$(mle_objects): %.o: %.c
$(CC) -c $(mle_cflags) $< -o $@
$(mle_tuiobjects): tui/%.o: tui/%.cc vendor/tvision/libtvision.a
$(MAKE) -C tui
$(mle_vendor_deps):
$(MAKE) -C vendor
$(mle_forced_vendor_deps):
$(MAKE) -C vendor forced
$(mle_unit_tests): %: %.c
$(CC) $(mle_cflags) $(mle_objects_no_main) $(mle_ldflags) $(mle_ldlibs) $< -o $@
test: mle $(mle_unit_tests)
./mle -v && export MLE=$$(pwd)/mle && $(MAKE) -C tests
sloc:
find . -name '*.c' -or -name '*.h' | \
grep -Pv '(termbox|test|ut|lua)' | \
xargs -rn1 cat | \
wc -l
install: mle
install -v -d $(DESTDIR)$(prefix)/bin
install -v -m 755 mle $(DESTDIR)$(prefix)/bin/mle
uscript:
php uscript.inc.php >uscript.inc
clean_quick:
rm -f mle $(mle_objects)
clean:
rm -f mle $(mle_objects) $(mle_vendor_deps) $(mle_unit_tests) $(mle_tuiobjects)
$(MAKE) -C vendor clean
.PHONY: all test sloc install uscript clean