-
Notifications
You must be signed in to change notification settings - Fork 149
/
Makefile
53 lines (43 loc) · 1.35 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
PROJ_NAME = Blinky
BUILD_DIR = Build
# All Source code files
SRC = project_main.c\
src/user_utils.c
# All header file paths
INC = -I inc
# Find out the OS and configure the variables accordingly
ifdef OS # All configurations for Windwos OS
# Correct the path based on OS
FixPath = $(subst /,\,$1)
# Name of the compiler used
CC = avr-gcc.exe
# Name of the elf to hex file converter used
AVR_OBJ_CPY = avr-objcopy.exe
else #All configurations for Linux OS
ifeq ($(shell uname), Linux)
# Correct the path based on OS
FixPath = $1
# Name of the compiler used
CC = avr-gcc
# Name of the elf to hex file converter used
AVR_OBJ_CPY = avr-objcopy
endif
endif
# Command to make to consider these names as targets and not as file names in folder
.PHONY:all analysis clean doc
all:$(BUILD_DIR)
# Compile the code and generate the ELF file
$(CC) -g -Wall -Os -mmcu=atmega328 $(INC) $(SRC) -o $(call FixPath,$(BUILD_DIR)/$(PROJ_NAME).elf)
$(BUILD_DIR):
# Create directory to store the built files
mkdir $(BUILD_DIR)
analysis: $(SRC)
# Analyse the code using Cppcheck command line utility
cppcheck --enable=all $^
doc:
# Build the code code documentation using Doxygen command line utility
make -C documentation
clean:
# Remove all the build files and generated document files
rm -rf $(call FixPath,$(BUILD_DIR)/*)
make -C documentation clean