forked from nqd/freertos_linux_devl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.common
123 lines (96 loc) · 2.7 KB
/
Makefile.common
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
######## Build options ########
verbose = 0
######## Build setup ########
# SRCROOT should always be the current directory
SRCROOT = $(TREEROOT)/FreeRTOS
POSIXPORT_ROOT = $(TREEROOT)/posix_port
# .o directory
ODIR = .obj
# the result
PROJECT ?= main
PROJECT_BIN = $(PROJECT).out
# Source paths
FREERTOS_DIR += $(SRCROOT)/Source
FREERTOS_DIR += $(SRCROOT)/Source/portable/MemMang
FREERTOS_DIR += $(SRCROOT)/Source/portable/GCC/POSIX
INCLUDES += -I$(SRCROOT)/Source/include
INCLUDES += -I$(SRCROOT)/Source/portable/GCC/POSIX/
# Porting paths
POSIX_PORT_DIR += $(POSIXPORT_ROOT)/Source/portable/GCC/POSIX
POSIX_PORT_DIR += $(POSIXPORT_ROOT)/POSIX/FileIO
POSIX_PORT_DIR += $(POSIXPORT_ROOT)/POSIX/ParTest
POSIX_PORT_DIR += $(POSIXPORT_ROOT)/POSIX
INCLUDES += -I$(POSIXPORT_ROOT)/Source/portable/GCC/POSIX
INCLUDES += -I$(POSIXPORT_ROOT)/POSIX
# All paths
VPATH += $(FREERTOS_DIR) $(POSIX_PORT_DIR)
# project object
C_FILES += $(PROJECT_SRC)
# IO objects
C_FILES += fileIO.c ParTest.c
# FreeRTOS Objects
C_FILES += croutine.c event_groups.c list.c queue.c tasks.c timers.c
# portable Objects
C_FILES += heap_3.c port.c
# minimal/full demo
include $(TREEROOT)/Makefile.demo
# Generate OBJS names
OBJS = $(patsubst %.c,%.o,$(C_FILES))
######## C Flags ########
# Warnings
CWARNS += -W
CWARNS += -Wall
CWARNS += -Werror
CWARNS += -Wextra
CWARNS += -Wformat
CWARNS += -Wmissing-braces
CWARNS += -Wno-cast-align
CWARNS += -Wparentheses
CWARNS += -Wshadow
CWARNS += -Wno-sign-compare
CWARNS += -Wswitch
CWARNS += -Wuninitialized
CWARNS += -Wunknown-pragmas
CWARNS += -Wunused-function
CWARNS += -Wunused-label
CWARNS += -Wunused-parameter
CWARNS += -Wunused-value
CWARNS += -Wunused-variable
CWARNS += -Wmissing-prototypes
CFLAGS += -m32
CFLAGS += -DDEBUG=1
CFLAGS += -ggdb -pthread -DUSE_STDIO=1 -D__GCC_POSIX__=1
# MAX_NUMBER_OF_TASKS = max pthreads used in the POSIX port.
# Default value is 64 (_POSIX_THREAD_THREADS_MAX), the minimum number required by POSIX.
CFLAGS += -DMAX_NUMBER_OF_TASKS=300
CFLAGS += $(INCLUDES) $(CWARNS) -O0
######## Makefile targets ########
# Rules
.PHONY : all setup clean
all: setup $(PROJECT_BIN)
setup:
# Make obj directory
@mkdir -p $(ODIR)
# Fix to place .o files in ODIR
_OBJS = $(patsubst %,$(ODIR)/%,$(OBJS))
# If verbose, print gcc execution
ifeq ($(verbose),1)
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif
$(ODIR)/%.o: %.c
$(vecho) "CC -c -o $@ $<"
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
$(PROJECT_BIN): $(_OBJS)
$(Q)$(CC) $(CFLAGS) $^ $(LINKFLAGS) $(LIBS) -o $@
@echo "-------------------------"
@echo "BUILD COMPLETE: $@"
@echo "-------------------------"
clean:
@-rm -rf $(ODIR) $(PROJECT_BIN)
@echo "--------------"
@echo "CLEAN COMPLETE"
@echo "--------------"