forked from tj/luna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (43 loc) · 967 Bytes
/
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
SRC = $(wildcard src/*.c)
OBJ = ${SRC:.c=.o}
CC = clang
PREFIX = /usr/local
CFLAGS = -std=c99 -g -O0 -Wno-parentheses -Wno-switch-enum -Wno-unused-value
CFLAGS += -Wno-switch
CFLAGS += -I deps
LDFLAGS += -lm
# MinGW gcc support
# TODO: improve
clang = $(shell which clang 2> /dev/null)
ifeq (, $(clang))
CC = gcc
endif
# deps
CFLAGS += -I deps/linenoise
OBJ += deps/linenoise/linenoise.o
OBJ += deps/linenoise/utf8.o
# test
TEST_SRC = $(shell find src/*.c test/*.c | sed '/luna/d')
TEST_OBJ = ${TEST_SRC:.c=.o}
CFLAGS += -I src
# output
OUT = luna
ifdef SystemRoot
OUT = luna.exe
endif
$(OUT): $(OBJ)
$(CC) $^ $(LDFLAGS) -o $@
%.o: %.c
@$(CC) -c $(CFLAGS) $< -o $@
@printf "\e[36mCC\e[90m %s\e[0m\n" $@
test: test_runner
@./$<
test_runner: $(TEST_OBJ)
$(CC) $^ $(LDFLAGS) -o $@
install: luna
install luna $(PREFIX)/bin
uninstall:
rm $(PREFIX)/bin/luna
clean:
rm -f luna test_runner $(OBJ) $(TEST_OBJ)
.PHONY: clean test install uninstall