forked from OpenIoTAcademy/EmbeddedTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
68 lines (52 loc) · 972 Bytes
/
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
#
# The root makefile
#
OUTPUT_PATH=out
OUTPUT_NAME=test
# The cross compile if exists, otherwise uses the gcc
CROSS_COMPILE?=
#
# Source (.c) Files
#
SOURCE_FILES= \
Source/test.c
#
# Header (.h) File Directories
#
# Bear in mind, include directories must have -I prefix
#
INCLUDE_DIRECTORIES= \
-IInclude/
#
# Project Definitions
#
# Bear in mind, definitions must have -D prefix
#
DEFINES= \
-DTEST_CONFIG=255
#
# All Flags
#
CFLAGS=${INCLUDE_DIRECTORIES} ${DEFINES}
#############################################
# Rules
#############################################
.PHONY: all rebuild test clean out run
# Rebuild
rebuild: clean all
#
# The main rule
#
all: test
# The test rule
test: out
${CROSS_COMPILE}gcc -g ${SOURCE_FILES} ${CFLAGS} -o ${OUTPUT_PATH}/${OUTPUT_NAME}
# The clean rule
clean:
rm -f test
# The rule to create out path
out:
mkdir -p ${OUTPUT_PATH}
# The rule to run the output executable
run:
./${OUTPUT_PATH}/${OUTPUT_NAME}