-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
47 lines (34 loc) · 753 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
# Compiler settings
CC=cc
CFLAGS = -std=c99 -Iinclude -Wall -O3
# Required object files
OBJFILES = bin/lzkn.o
.PHONY : lzkn clean test install uninstall
# Main target
lzkn: bin/lzkn
# Target: test
test: bin/test
./bin/test
# Target: clean
clean :
-rm -f $(OBJFILES)
-rm -f bin/lzkn
-rm -f bin/test
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
# Target: install
install: bin/lzkn
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp bin/lzkn $(DESTDIR)$(PREFIX)/bin/
# Target: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/lzkn
# Binary files rules
bin/lzkn: main.c $(OBJFILES)
$(CC) $(CFLAGS) $^ -o bin/lzkn
bin/test: test.c $(OBJFILES)
$(CC) $(CFLAGS) $^ -o bin/test
# Object files rules
bin/%.o: include/%.c
$(CC) $(CFLAGS) $^ -o $@ -c