-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (57 loc) · 1.99 KB
/
Copy pathMakefile
File metadata and controls
71 lines (57 loc) · 1.99 KB
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
# =========================================================
# Toolchain
# =========================================================
TOOLCHAIN = /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
CC = arm-poky-linux-gnueabi-gcc
CFLAGS = -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 \
--sysroot=/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi
LDFLAGS = -Lthird_party/mosquitto \
-lmosquitto \
-lpthread \
-Wl,-rpath,/usr/lib
# Tự động source toolchain
export PATH := /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi:$(PATH)
# =========================================================
# Project
# =========================================================
TARGET = mqtt_led_app
BINDIR = build
SRCS = src/main.c \
hardware/led/led.c \
hardware/button/button.c \
middle/mqtt/mqtt.c \
middle/ota/ota.c \
third_party/jsmn/jsmn.c
OBJS = $(patsubst %.c, $(BINDIR)/%.o, $(SRCS))
CFLAGS += -Ihardware \
-Iconfig \
-Imiddle/mqtt \
-Imiddle/ota \
-Ithird_party/jsmn \
-Ithird_party/mosquitto \
-Wall -Wextra
# =========================================================
# Rules
# =========================================================
all: $(BINDIR) $(BINDIR)/$(TARGET)
$(BINDIR):
mkdir -p $(BINDIR) \
$(BINDIR)/src \
$(BINDIR)/config \
$(BINDIR)/hardware/led \
$(BINDIR)/hardware/button \
$(BINDIR)/middle/mqtt \
$(BINDIR)/middle/ota \
$(BINDIR)/third_party/jsmn
$(BINDIR)/$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@echo "[OK] Built: $@"
$(BINDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(BINDIR)
@echo "[OK] Cleaned"
install: $(BINDIR)/$(TARGET)
cp $(BINDIR)/$(TARGET) $(ROOTFS)/usr/bin/
@echo "[OK] Installed to rootfs"
.PHONY: all clean install