-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (41 loc) · 1.16 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
.POSIX:
.PHONY: compile_commands.json
INCLUDES = -Iinclude
XCFLAGS = $(CFLAGS) $(CPPFLAGS) $(INCLUDES) \
-std=c11 \
-Wall -Wextra -Wshadow -Wnull-dereference -Wformat=2 -Wcast-qual \
-Wconversion -Wpointer-arith -Wunused-macros -Wredundant-decls \
-Wwrite-strings \
-Werror=int-conversion -Werror=implicit-function-declaration \
-Werror=incompatible-pointer-types
XLDFLAGS = $(LDFLAGS)
BIN = landbox
LIB = liblandbox.a
BIN_OBJ = \
src/landbox.o
LIB_OBJ = \
lib/landbox.o \
lib/util.o
all: $(BIN) $(LIB)
format:
clang-format -i ./*/*.[hc]
tidy:
clang-tidy ./*/*.[hc] -- $(XCFLAGS)
DEP = $(BIN_OBJ:.o=.d) $(LIB_OBJ:.o=.d)
-include $(DEP)
.c.o:
$(CC) $(XCFLAGS) -MMD -c -o $@ $<
$(LIB): $(LIB_OBJ)
$(AR) -rc $@ $(LIB_OBJ)
$(BIN): $(BIN_OBJ) $(LIB)
$(CC) $(XCFLAGS) -o $@ $(BIN_OBJ) $(LIB)
compile_commands.json:
CC=cc compiledb -n make
install: all
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/lib \
$(DESTDIR)/$(PREFIX)/include
cp -f $(BIN) $(DESTDIR)/$(PREFIX)/bin
cp -f $(LIB) $(DESTDIR)/$(PREFIX)/lib
cp -f include/landbox.h $(DESTDIR)/$(PREFIX)/include
clean:
$(RM) -f $(BIN) $(LIB) $(BIN_OBJ) $(LIB_OBJ) $(DEP) compile_commands.json