-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
73 lines (51 loc) · 1.3 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
# Tools
CC = gcc
# Project
NAME = v4l2-cedrus-enc-test
# Directories
BUILD = build
OUTPUT = .
# Sources
SOURCES = \
v4l2-cedrus-enc-test.c \
v4l2-encoder.c \
media.c \
v4l2.c \
draw.c \
csc.c
OBJECTS = $(SOURCES:.c=.o)
DEPS = $(SOURCES:.c=.d)
# Compiler
CFLAGS = -I. $(shell pkg-config --cflags cairo libudev) -Ofast
LDFLAGS = -lcairo -lm $(shell pkg-config --libs libudev)
# Produced files
BUILD_OBJECTS = $(addprefix $(BUILD)/,$(OBJECTS))
BUILD_DEPS = $(addprefix $(BUILD)/,$(DEPS))
BUILD_BINARY = $(BUILD)/$(NAME)
BUILD_DIRS = $(sort $(dir $(BUILD_BINARY) $(BUILD_OBJECTS)))
OUTPUT_BINARY = $(OUTPUT)/$(NAME)
OUTPUT_DIRS = $(sort $(dir $(OUTPUT_BINARY)))
all: $(OUTPUT_BINARY)
$(BUILD_DIRS):
@mkdir -p $@
$(BUILD_OBJECTS): $(BUILD)/%.o: %.c | $(BUILD_DIRS)
@echo " CC $<"
@$(CC) $(CFLAGS) -MMD -MF $(BUILD)/$*.d -c $< -o $@
$(BUILD_BINARY): $(BUILD_OBJECTS)
@echo " LINK $@"
@$(CC) $(CFLAGS) -o $@ $(BUILD_OBJECTS) $(LDFLAGS)
$(OUTPUT_DIRS):
@mkdir -p $@
$(OUTPUT_BINARY): $(BUILD_BINARY) | $(OUTPUT_DIRS)
@echo " BINARY $@"
@cp $< $@
.PHONY: clean
clean:
@echo " CLEAN"
@rm -rf $(foreach object,$(basename $(BUILD_OBJECTS)),$(object)*) $(basename $(BUILD_BINARY))*
@rm -rf $(OUTPUT_BINARY)
.PHONY: distclean
distclean: clean
@echo " DISTCLEAN"
@rm -rf $(BUILD)
-include $(BUILD_DEPS)