-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
62 lines (47 loc) · 1.3 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
# ------------------------------------------------
# PianoTutor+ Makefile
# ------------------------------------------------
# Project name (also final executable name)
TARGET = pianotutor+
# Folder organization
INCDIR = inc
SRCDIR = src
OBJDIR = obj
BINDIR = bin
# External dependencies
LED_STRIP_LIB_FOLDER = /home/pi/rpi_ws281x
LED_STRIP_LIB_NAME = ws2811
# Toolchain and flags
CC = g++
CFLAGS = -Wall -pedantic -I./$(INCDIR) -I$(LED_STRIP_LIB_FOLDER)
LINKER = g++
LFLAGS = -Wall -I./$(INCDIR) -lm -L$(LED_STRIP_LIB_FOLDER) -l$(LED_STRIP_LIB_NAME) -lasound
# Files and macros
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(INCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
rm = rm -f
mkdir = mkdir -p
# Make rules
.PHONY: all
all: directories $(BINDIR)/$(TARGET)
.PHONY: debug
debug: CFLAGS += -DDEBUG -g -O0
debug: directories $(BINDIR)/$(TARGET)
$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
@echo "Linking complete"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
@$(CC) $(CFLAGS) -c $< -o $@
@echo $<" compiled successfully"
.PHONY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete"
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Executable removed"
.PHONY: directories
directories:
@$(mkdir) $(OBJDIR) $(BINDIR)