-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
100 lines (74 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
94
95
96
97
98
99
100
#
# Makefile
#
makefile_name := $(abspath $(lastword $(MAKEFILE_LIST)))
makefile_path := $(strip $(patsubst %/,% , $(dir $(makefile_name))))
# CC ?= gcc
CROSS := arm-none-linux-gnueabihf-
CC := $(CROSS)gcc
SZ := $(CROSS)size
PRJ_DIR := $(makefile_path)
LVGL_DIR := $(PRJ_DIR)
LVGL_DIR_NAME ?= lvgl
CFLAGS += -I$(LVGL_DIR)/ -I$(makefile_path)/ -c -fmessage-length=0
LDFLAGS := -lSDL2 -lm
BUILD_DIR := build/
OBJ_DIR := $(BUILD_DIR)object/
GEN_OBJ_DIR := $(OBJ_DIR)generated/
BIN_DIR := $(BUILD_DIR)bin/
RM := rm -f
RMDIR := rm -rf
EXEC = lvgl_app
MKDIR_P = mkdir -p
LDFLAGS += -LSDL2/lib
-include $(LVGL_DIR)/lvgl/lvgl.mk
-include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
-include $(LVGL_DIR)/lv_examples/lv_examples.mk
-include $(PRJ_DIR)/gui_guider/generated/generated.mk
-include $(PRJ_DIR)/gui_guider/custom/custom.mk
#Collect the files to compile
CSRCS += main.c
DEPPATH += --dep-path $(makefile_path)/
VPATH += :$(makefile_path)/
CFLAGS += "-I$(makefile_path)/"
CFLAGS += "-ISDL2/include" -MMD -MP
OBJEXT := .o
AOBJS = $(addprefix $(OBJ_DIR),$(ASRCS:.S=$(OBJEXT)))
COBJS = $(addprefix $(OBJ_DIR),$(CSRCS:.c=$(OBJEXT)))
DEPS = $(addprefix $(OBJ_DIR),$(CSRCS:.c=.d))
GEN_AOBJS = $(addprefix $(GEN_OBJ_DIR),$(GEN_ASRCS:.S=$(OBJEXT)))
GEN_COBJS = $(addprefix $(GEN_OBJ_DIR),$(GEN_CSRCS:.c=$(OBJEXT)))
DEPS += $(addprefix $(GEN_OBJ_DIR),$(GEN_CSRCS:.c=.d))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
GEN_SRCS = $(GEN_ASRCS) $(GEN_CSRCS)
GEN_OBJS = $(GEN_AOBJS) $(GEN_COBJS)
.PHONY: all env clean default clean_gen
all: env default
# monitor header files
-include $(DEPS)
env:
@if [ ! -d "build/bin" ]; then $(MKDIR_P) build/bin; fi
@if [ ! -d "build/object/generated" ]; then $(MKDIR_P) build/object/generated; fi
$(OBJ_DIR)main.o: main.c
@echo "Compiling $(makefile_path)/$<"
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)%.o: %.c
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
$(GEN_OBJ_DIR)%.o: %.c
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
default: $(OBJS) $(GEN_OBJS)
@echo "Linking $(EXEC)"
@$(CC) -o $(BIN_DIR)$(EXEC) $(OBJS) $(GEN_OBJS) $(LDFLAGS)
$(SZ) $(BUILD_DIR)bin/$(EXEC)
clean:
-@$(RMDIR) build
gen_images := $(wildcard $(PRJ_DIR)/gui_guider/generated/images/*.c)
gen_srcs := $(gen_images) $(wildcard $(PRJ_DIR)/gui_guider/generated/*.c) $(wildcard $(PRJ_DIR)/gui_guider/generated/*.h)
clean_gen_img:
$(RM) $(LVGL_DIR)/gui_guider/generated/images/*.c
clean_gen: clean_gen_img
$(RM) $(LVGL_DIR)/gui_guider/generated/*.c
$(RM) $(LVGL_DIR)/gui_guider/generated/*.h