-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (59 loc) · 1.64 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
80
81
82
83
84
85
86
87
88
89
90
# Tools
CC = gcc
# Project
NAME ?= v4l2-bayer-client
# Directories
BUILD = build
OUTPUT = .
# Sources
SOURCES = v4l2.c v4l2-camera.c v4l2-params.c v4l2-bayer-protocol.c $(NAME).c
OBJECTS = $(SOURCES:.c=.o)
DEPS = $(SOURCES:.c=.d)
# Compiler
CFLAGS = -I. $(shell pkg-config --cflags libudev cairo)
LDFLAGS = $(shell pkg-config --libs libudev cairo)
# 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: client server standalone params
server:
@make -s NAME=v4l2-bayer-server build
.PHONY: server
client:
@make -s NAME=v4l2-bayer-client build
.PHONY: client
standalone:
@make -s NAME=v4l2-bayer-standalone build
.PHONY: standalone
params:
@make -s NAME=v4l2-isp-params build
.PHONY: params
build: $(OUTPUT_BINARY)
.PHONY: build
$(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 v4l2-bayer-standalone v4l2-bayer-client v4l2-bayer-server v4l2-isp-params
.PHONY: distclean
distclean: clean
@echo " DISTCLEAN"
@rm -rf $(BUILD)
-include $(BUILD_DEPS)