forked from toroidal-code/PixelBone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·107 lines (87 loc) · 2.18 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#########
#
# The top level targets link in the two .o files for now.
#
TARGETS += examples/rgb-test
TARGETS += examples/matrix-test
TARGETS += examples/tile-test
TARGETS += examples/scroll
TARGETS += examples/clear
TARGETS += examples/game_of_life
TARGETS += examples/clock
TARGETS += examples/binary_clock
TARGETS += examples/test
TARGETS += examples/2048
# TARGETS += examples/fade-test
# TARGETS += examples/fire
# TARGETS += network/udp-rx
# TARGETS += network/opc-rx
PIXELBONE_OBJS = pixel.o gfx.o matrix.o pru.o util.o
PIXELBONE_LIB := libpixelbone.a
all: $(TARGETS) ws281x.bin
CFLAGS += \
-std=c99 \
-W \
-Wall \
-D_BSD_SOURCE \
-Wp,-MMD,$(dir $@).$(notdir $@).d \
-Wp,-MT,$@ \
-I. \
-O2 \
-mtune=cortex-a8 \
-march=armv7-a \
LDFLAGS += \
LDLIBS += \
-lpthread \
export CROSS_COMPILE:=
#####
#
# The TI "app_loader" is the userspace library for talking to
# the PRU and mapping memory between it and the ARM.
#
APP_LOADER_DIR ?= ./am335x/app_loader
APP_LOADER_LIB := $(APP_LOADER_DIR)/lib/libprussdrv.a
CFLAGS += -I$(APP_LOADER_DIR)/include
LDLIBS += $(APP_LOADER_LIB)
#####
#
# The TI PRU assembler looks like it has macros and includes,
# but it really doesn't. So instead we use cpp to pre-process the
# file and then strip out all of the directives that it adds.
# PASM also doesn't handle multiple statements per line, so we
# insert hard newline characters for every ; in the file.
#
PASM_DIR ?= ./am335x/pasm
PASM := $(PASM_DIR)/pasm
%.bin: %.p $(PASM)
$(CPP) - < $< | perl -p -e 's/^#.*//; s/;/\n/g; s/BYTE\((\d+)\)/t\1/g' > $<.i
$(PASM) -V3 -b $<.i $(basename $@)
$(RM) $<.i
%.o: %.cpp
$(CXX) $(CXXFLAGS) -std=c++11 -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
$(foreach O,$(TARGETS),$(eval $O: $O.o $(PIXELBONE_OBJS) $(APP_LOADER_LIB)))
$(TARGETS):
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
.PHONY: clean
clean:
rm -rf \
**/*.o \
*.o \
ws281x.hp.i \
.*.o.d \
*~ \
$(INCDIR_APP_LOADER)/*~ \
$(TARGETS) \
*.bin \
###########
#
# PRU Libraries and PRU assembler are build from their own trees.
#
$(APP_LOADER_LIB):
$(MAKE) -C $(APP_LOADER_DIR)/interface
$(PASM):
$(MAKE) -C $(PASM_DIR)
# Include all of the generated dependency files
-include .*.o.d