-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·97 lines (75 loc) · 1.59 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
################
# DEFINITIONS
################
# This will be the name of the executable
TARGET:=ytelse_usbhost
# Directories
OBJDIR:=build
SRCDIR:=src
ITRLVDIR:=interleave/src
# ANSI color codes
# Only used for fancy output
NO_COLOR=\x1b[0m
RED:=\x1b[31m
GREEN:=\x1b[32m
YELLOW:=\x1b[33m
################
# TOOLCHAIN
################
CC:=gcc
LD:=gcc
################
# FLAGS
################
LIBUSB_PATH:=/usr/local/Cellar/libusb/1.0.20
INCLUDES:=-I$(LIBUSB_PATH)/include/libusb-1.0 -I$(SRCDIR) -I$(ITRLVDIR)
LIBS:=-L$(LIBUSB_PATH)/lib
CFLAGS:=-std=c99 -Wall $(INCLUDES)
LDFLAGS:=$(LIBS) -lusb-1.0 -lpthread
################
# FILES
################
CSRC:= $(addprefix $(SRCDIR)/, \
callbacks.c \
cmd_parser.c \
debug.c \
main.c \
usb_helpers.c \
pacman_comm_setup.c \
mcu_comm.c \
fpga_comm.c \
pthread_helper.c \
)
CSRC += $(addprefix $(ITRLVDIR)/, \
interleave.c \
printimg.c \
)
C_FILES := $(notdir $(CSRC))
C_PATHS := $(dir $(CSRC))
C_OBJS := $(addprefix $(OBJDIR)/, $(C_FILES:.c=.o))
OBJS = $(C_OBJS)
vpath %.c $(C_PATHS)
################
# BUILD RULES
################
.PHONY : debug
debug : CFLAGS += -DDEBUG
debug : $(TARGET)
.PHONY : nodebug
nodebug : CFLAGS += -DNODEBUG
nodebug : $(TARGET)
.PHONY : run
run : $(TARGET)
./$(TARGET)
$(TARGET) : $(OBJS)
@echo "$(YELLOW)Linking target: $@$(NO_COLOR)"
$(LD) $(LDFLAGS) -o $@ $(OBJS)
@echo "$(GREEN)==========================================$(NO_COLOR)"
$(OBJDIR)/%.o : %.c | $(OBJDIR)
@echo "$(YELLOW)Compiling source: $@$(NO_COLOR)"
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR) :
mkdir $@
.PHONY : clean
clean :
-rm -rf $(OBJDIR) $(TARGET)