-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (71 loc) · 2.47 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
MAKEFLAGS += -j
# Debugging
# DEBUG=1
# Enable this to use the virtual LED sign
USE_VIRTUAL_CANVAS=1
ifeq ($(USE_VIRTUAL_CANVAS), 1)
DEFINES+=-D USE_VIRTUAL_CANVAS
endif
# NOTE! When compiling on Raspberry-pi, use the g++-4.7 compiler
# for compatibility with rpi library
CC := clang++
SRCDIR := src
BUILDDIR := build
RESOURCEDIR := resources
TARGET := bin/ledsign
TARGET_RESOURCES := bin/resources
RESOURCES_DIR := $(realpath $(TARGET_RESOURCES))
DEFINES+=-D RESOURCES_DIR=\"$(RESOURCES_DIR)/\"
# RPI RGB Library
RPI_RGB_DIR=lib/rpi-rgb-led-matrix
RPI_RGB_INCDIR=$(RPI_RGB_DIR)/include
RPI_RGB_LIBDIR=$(RPI_RGB_DIR)/lib
RPI_RGB_LIBRARY_NAME=rgbmatrix
RPI_RGB_LIBRARY=$(RPI_RGB_LIBDIR)/lib$(RPI_RGB_LIBRARY_NAME).a
LDFLAGS+=-L$(RPI_RGB_LIBDIR) -l$(RPI_RGB_LIBRARY_NAME) -lrt -lm -lpthread
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) $(BUILDDIR)/resources.o
CFLAGS := -std=c++11 -g $(DEFINES) -MMD # -Wall
LIB := -lm -lstdc++ -std=c++11 -lpthread
DEPS := $(OBJECTS:.o=.d)
-include $(DEPS)
OS := $(shell uname)
ifeq ($(OS),Linux)
LIB += -lrt
CC := g++
endif
ifeq ($(USE_VIRTUAL_CANVAS), 1)
LIB+= -lSDL2
endif
INC := -I include -I$(RPI_RGB_INCDIR) -I $(BUILDDIR)
# ImageMagick
CFLAGS+=`pkg-config --cflags Magick++ giomm-2.4`
LDFLAGS+=`pkg-config --libs Magick++ giomm-2.4`
$(TARGET): $(OBJECTS) $(RPI_RGB_LIBRARY) $(TARGET_RESOURCES)
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET) $(LDFLAGS) $(LIB)"; $(CC) $(OBJECTS) $(RPI_RGB_LIBRARY) $(LDFLAGS) -o $(TARGET) $(LIB)
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) $(BUILDDIR)/resources.c $(BUILDDIR)/resources.h
@mkdir -p $(BUILDDIR)
@echo "$(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
$(RPI_RGB_LIBRARY): FORCE
$(MAKE) -C $(RPI_RGB_LIBDIR)
$(TARGET_RESOURCES): FORCE
@echo " Copying resources..."
@mkdir -p $(TARGET_RESOURCES)
@cp -f $(RESOURCEDIR)/* $(TARGET_RESOURCES) 2> /dev/null || :
@echo " Copying fonts..."
@mkdir -p $(TARGET_RESOURCES)/fonts
@cp -f $(RPI_RGB_DIR)/fonts/* $(TARGET_RESOURCES)/fonts
$(BUILDDIR)/resources.c: resources/resources.xml
@mkdir -p $(BUILDDIR)
glib-compile-resources --target=$@ --generate-source $<
$(BUILDDIR)/resources.h: resources/resources.xml
@mkdir -p $(BUILDDIR)
glib-compile-resources --target=$@ --generate-header $<
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)
.PHONY: clean
FORCE:
.PHONY: FORCE