forked from boundarydevices/ft5x06-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (66 loc) · 1.29 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
# O (Output) is the build directory
ifeq '$O' ''
O = .
endif
# V (Verbosity) is 0 (quiet) or 1 (verbose)
ifeq '$V' ''
V = 0
endif
# D (Debug) is 0 (optimize) or 1 (build debug version)
ifeq '$D' ''
D = 0
endif
# files
SRC_BIN = $(wildcard *.c)
OBJS = $(OBJ_BIN)
OBJ_BIN = $(SRC_BIN:%.c=$O/%.o)
TARGET_BIN = $O/ft5x06-tool
BINS = $(TARGET_BIN)
DESTDIR ?= /usr
# options
override CFLAGS += -fPIC -Wall
override LDFLAGS +=
# first rule (default)
all:
# rules verbosity
ifneq '$V' '0'
P = @ true
E =
else
P = @ echo
E = @
endif
# rules
directories :
$P ' MKDIR'
$E mkdir -p $O
$O/%.o : %.c directories
$P ' CC $(@F)'
$E $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(TARGET_BIN): $(OBJ_BIN)
$P ' LD $(@F)'
$E $(CC) $(LDFLAGS) $^ -o $@
.PHONY : all
all : $(TARGET_BIN)
.PHONY: clean
clean:
$P ' RM objs bins'
$E rm -f $(OBJS) $(BINS)
.PHONY: install
install: all
$P ' INSTALL DIRS'
$E mkdir -p $(DESTDIR)/bin
$P ' INSTALL FILES'
$E install $(TARGET_BIN) $(DESTDIR)/bin
.PHONY: uninstall
uninstall:
$P ' UNINSTALL'
$E rm -f $(DESTDIR)/bin/$(notdir $(TARGET_BIN))
.PHONY: help
help:
@echo
@echo make [D=1] [V=1] [O=path]
@echo " D=1: build debug version (default: D=0)"
@echo " V=1: verbose output (default: V=0)"
@echo " O=path: build binary in path (default: O=.)"
@echo