-
Notifications
You must be signed in to change notification settings - Fork 108
/
Makefile
85 lines (66 loc) · 2.2 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
#
# Makefile for application
#
CROSS_COMPILE ?=
AS := $(CROSS_COMPILE)gcc -x assembler-with-cpp
CC := $(CROSS_COMPILE)gcc
CXX := $(CROSS_COMPILE)g++
LD := $(CROSS_COMPILE)ld
AR := $(CROSS_COMPILE)ar
SZ := $(CROSS_COMPILE)size
OC := $(CROSS_COMPILE)objcopy
OD := $(CROSS_COMPILE)objdump
STRIP := $(CROSS_COMPILE)strip
MKDIR := mkdir -p
RM := rm -fr
ASFLAGS := -g -ggdb -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99
CFLAGS := -g -ggdb -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99
CXXFLAGS := -g -ggdb -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding
LDFLAGS :=
OCFLAGS := -v -O binary
ODFLAGS :=
MCFLAGS :=
LIBDIRS :=
LIBS :=
INCDIRS := .
SRCDIRS := .
CFLAGS +=
CXXFLAGS +=
LIBDIRS +=
LIBS += -lm
sinclude ../src/onnx.mk
OUTPUT := output
NAME := $(OUTPUT)/tests
INCDIRS := $(patsubst %, -I %, $(sort $(INCDIRS)))
LIBDIRS := $(patsubst %, -L %, $(sort $(LIBDIRS)))
SRCDIRS := $(sort $(SRCDIRS))
OBJDIRS := $(patsubst %, .obj/%, $(SRCDIRS))
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.cpp))
SDEPS := $(patsubst %, .obj/%, $(SFILES:.S=.o.d))
CDEPS := $(patsubst %, .obj/%, $(CFILES:.c=.o.d))
CPPDEPS := $(patsubst %, .obj/%, $(CPPFILES:.cpp=.o.d))
DEPS := $(SDEPS) $(CDEPS) $(CPPDEPS)
SOBJS := $(patsubst %, .obj/%, $(SFILES:.S=.o))
COBJS := $(patsubst %, .obj/%, $(CFILES:.c=.o))
CPPOBJS := $(patsubst %, .obj/%, $(CPPFILES:.cpp=.o))
OBJS := $(SOBJS) $(COBJS) $(CPPOBJS)
VPATH := $(OBJDIRS)
.PHONY: all clean
all : $(NAME)
$(NAME) : $(OBJS)
@echo [LD] Linking $@
@$(CC) $(LDFLAGS) $(LIBDIRS) $^ -o $@ $(LIBS)
$(SOBJS) : .obj/%.o : %.S
@echo [AS] $<
@$(AS) $(ASFLAGS) -MD -MP -MF [email protected] $(INCDIRS) -c $< -o $@
$(COBJS) : .obj/%.o : %.c
@echo [CC] $<
@$(CC) $(CFLAGS) -MD -MP -MF [email protected] $(INCDIRS) -c $< -o $@
$(CPPOBJS) : .obj/%.o : %.cpp
@echo [CXX] $<
@$(CXX) $(CXXFLAGS) -MD -MP -MF [email protected] $(INCDIRS) -c $< -o $@
clean:
@$(RM) .obj $(OUTPUT)
sinclude $(shell $(MKDIR) $(OBJDIRS) $(OUTPUT)) $(DEPS)