forked from iBreaker/OS-One
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (80 loc) · 2.75 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
86
87
88
89
90
91
92
93
94
##############################
# 2014年12月25日21:00:09
# V1.0 By Breaker
#
# 文件名:Makefile
# 项目的 Makefile
#
##############################
# 2015年01月05日11:58:29
# V2.0 By Breaker
# 增加include文件夹和source 等文件夹,libcsud.a
# 整理项目结构
# OS One - A simple OS for Raspberry Pi
# Copyright (C) 2014 - 2015 Breaker <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#默认参数
DIR_SRC ?= ./source
DIR_INC ?= ./include
DIR_OBJ ?= ./object
DIR_LIB ?= ./lib
TARGET ?= kernel
#
#(1)Makefile中的 符号 $@, $^, $< 的意思:
# $@ 表示目标文件
# $^ 表示所有的依赖文件
# $< 表示第一个依赖文件
# $? 表示比目标还要新的依赖文件列表
#
#(2)wildcard、notdir、patsubst的意思:
#
# wildcard : 扩展通配符
# notdir : 去除路径
# patsubst :替换通配符
GNU = arm-none-eabi-
CFLAGS += -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s \
-nostartfiles -g -Wl,--verbose -c -I ${DIR_INC}
LFLAGS += -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s \
-nostartfiles -g -Wl,-T,${DIR_SRC}/pi.x -Wl,-Map,${TARGET}.map
SRC = $(wildcard ${DIR_SRC}/*.c)
ASB = $(wildcard ${DIR_SRC}/*.s)
OBJ = $(patsubst %.c,${DIR_OBJ}/%.o,$(notdir ${SRC}))
#暂时不链接USB驱动
INC = $(wildcard ${DIR_INC}/*.h)
all:
make kernel.img
${DIR_OBJ}/%.o: ${DIR_SRC}/%.c Makefile
${GNU}gcc ${CFLAGS} -c $< -o $@
${TARGET}.img: Makefile ${TARGET}.elf
${GNU}objcopy ${TARGET}.elf -O binary $@
${TARGET}.elf:${OBJ} ${ASB} ${DIR_SRC}/pi.x
#${TARGET}.elf: Makefile ${OBJ} ${ASB} ${DIR_SRC}/pi.x
@echo ${OBJ} ${LIB} ${ASB} ${SRC} ${GNU}
${GNU}gcc ${LFLAGS} ${OBJ} ${ASB} -L ${DIR_LIB} -o ${TARGET}.elf
#${GNU}gcc ${LFLAGS} ${OBJ} ${ASB} -o ${TARGET}.elf
disasm:${TARGET}.elf
${GNU}objdump -S $< > ${TARGET}.disasm
clean:
rm -rf ./object/*.o
rm -rf *.img *.elf *.disasm *.map
install:kernel.img
sudo mkdir /media/breaker/boot
sudo mount /dev/sdc1 /media/breaker/boot
sudo cp kernel.img /media/breaker/boot
sudo umount /dev/sdc1
sudo rm -r /media/breaker/boot
rm:
sudo rm -rf /media/breaker/boot