forked from LvNA-system/riscv-rootfs
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile.compile
More file actions
36 lines (27 loc) · 786 Bytes
/
Makefile.compile
File metadata and controls
36 lines (27 loc) · 786 Bytes
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
include $(RISCV_ROOTFS_HOME)/Makefile.app
# Compilation flags
CROSS_COMPILE ?= riscv64-unknown-linux-gnu-
AS = $(CROSS_COMPILE)gcc
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)gcc
INCLUDES = $(addprefix -I, $(INC_DIR))
CFLAGS += -O2 -MMD $(INCLUDES)
CXXFLAGS += -O2 -MMD $(INCLUDES)
# Files to be compiled
OBJS = $(addprefix $(DST_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
# Compilation patterns
$(DST_DIR)/%.o: %.cpp
@echo + CXX $<
@mkdir -p $(dir $@)
@$(CXX) $(CXXFLAGS) -c -o $@ $<
$(DST_DIR)/%.o: %.c
@echo + CC $<
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c -o $@ $<
$(APP): $(OBJS)
@echo + LD $@
@$(LD) $(LDFLAGS) -o $(APP) $(OBJS)
# Dependencies
DEPS = $(addprefix $(DST_DIR)/, $(addsuffix .d, $(basename $(SRCS))))
-include $(DEPS)