-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
93 lines (76 loc) · 2.03 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
91
92
93
# Makefile for building the port binary
#
# Makefile targets:
#
# all/install build and install
# clean clean build products and intermediates
#
# Variables to override:
#
# MIX_APP_PATH path to the build directory
#
# CC C compiler
# CROSSCOMPILE crosscompiler prefix, if any
# CFLAGS compiler flags for compiling all C files
# LDFLAGS linker flags for linking all binaries
PREFIX = $(MIX_APP_PATH)/priv
BUILD = $(MIX_APP_PATH)/obj
TARGET_CFLAGS = $(shell src/detect_target.sh)
LDFLAGS += -lm
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic
CFLAGS += $(TARGET_CFLAGS)
# Enable for debug messages
# CFLAGS += -DDEBUG
# Check that we're on a supported build platform
ifeq ($(CROSSCOMPILE),)
# Not crosscompiling.
ifeq ($(shell uname -s),Darwin)
$(warning rpi_fb_capture only works on Nerves and Raspbian.)
$(warning Compiling the simulator.)
SRC = src/capture_sim.c
else
ifeq ($(TARGET_CFLAGS),)
$(warning rpi_fb_capture only works on Nerves and Raspbian.)
$(warning Compiling the simulator.)
SRC = src/capture_sim.c
else
SRC = src/capture_dispmanx.c
LDFLAGS += -lbcm_host -lvchostif
endif
endif
else
# Crosscompiled build
SRC = src/capture_dispmanx.c
LDFLAGS += -lbcm_host -lvchostif
endif
SRC += src/main.c src/dithering.c
HEADERS = $(wildcard src/*.h)
OBJ = $(SRC:src/%.c=$(BUILD)/%.o)
BIN = $(PREFIX)/rpi_fb_capture
calling_from_make:
mix compile
all: install
install: $(PREFIX) $(BUILD) $(BIN)
$(OBJ): $(HEADERS) Makefile
$(BUILD)/%.o: src/%.c
$(CC) -c $(CFLAGS) -o $@ $<
$(BIN): $(OBJ)
$(CC) -o $@ $^ $(ERL_LDFLAGS) $(LDFLAGS)
$(PREFIX) $(BUILD):
mkdir -p $@
clean:
$(RM) $(BIN) $(OBJ)
format:
astyle \
--style=kr \
--indent=spaces=4 \
--align-pointer=name \
--align-reference=name \
--convert-tabs \
--attach-namespaces \
--max-code-length=100 \
--max-instatement-indent=120 \
--pad-header \
--pad-oper \
$(SRC)
.PHONY: all clean calling_from_make install format