forked from elixir-vision/picam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (54 loc) · 2.11 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
# Variables to override
#
# CC C compiler
# CROSSCOMPILE crosscompiler prefix, if any
# CFLAGS compiler flags for compiling all C files
# LDFLAGS linker flags for linking all binaries
# VIDEOCORE_DIR path to VideoCore libraries. This defaults to "/opt/vc"
# Initialize some variables if not set
LDFLAGS ?=
CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter
CC ?= $(CROSSCOMPILE)-gcc
# Check that we're on a supported build platform
ifeq ($(CROSSCOMPILE),)
# Not crosscompiling, so check that we're on Linux.
ifneq ($(shell uname -s),Linux)
$(warning raspijpgs only works on Linux on a Raspberry Pi. Crosscompilation)
$(warning is supported by defining at least $$CROSSCOMPILE. See Makefile for)
$(warning details. If using Nerves, this should be done automatically.)
$(warning .)
$(warning Skipping C compilation unless targets explicitly passed to make.)
DEFAULT_TARGETS = priv
else
# On the Raspberry Pi, the VideoCore libraries aren't in the standard
# locations in /usr/include and /usr/lib.
VIDEOCORE_DIR ?= /opt/vc
ifneq ($(wildcard $(VIDEOCORE_DIR)),)
CFLAGS += -I$(VIDEOCORE_DIR)/include
CFLAGS += -I$(VIDEOCORE_DIR)/include/interface/vcos/pthreads
CFLAGS += -I$(VIDEOCORE_DIR)/include/interface/vmcs_host/linux
LDFLAGS += -L$(VIDEOCORE_DIR)/lib
else
$(warning raspijpgs only works on Linux on a Raspberry Pi. The VideoCore)
$(warning libraries were not found, so assuming this is a non-Raspberry)
$(warning build and skipping C compilation. If this is wrong, check the)
$(warning Makefile and define VIDEOCORE_DIR.)
DEFAULT_TARGETS = priv
endif
endif
endif
DEFAULT_TARGETS ?= priv priv/raspijpgs
# Link in all of the VideoCore libraries
LDFLAGS +=-lmmal_core -lmmal_util -lmmal_vc_client -Lvcos -lbcm_host -lm
SRC=$(wildcard src/*.c)
OBJ=$(SRC:.c=.o)
.PHONY: all clean
all: $(DEFAULT_TARGETS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
priv:
mkdir -p priv
priv/raspijpgs: $(OBJ)
$(CC) $^ $(LDFLAGS) -o $@
clean:
rm -f priv/raspijpgs $(OBJ)