-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (99 loc) · 2.43 KB
/
Makefile
File metadata and controls
129 lines (99 loc) · 2.43 KB
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
124
125
126
127
128
129
# ----------------------------------------------------------------------
# Global Makefile
# Maintainer: Buddy <buddy.zhang@aliyun.com>
#
# Copyright (C) 2017 BiscuitOS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
VERSION = 1
NAME = BiscuitOS
DEBUG := 1
export DEBUG
# Beautify output
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
ifeq ($(KBUILD_VERBOSE), 1)
Q =
else
Q = @
endif
export Q
# Set PATH
srctree := $(CURDIR)
objtree := $(CURDIR)
src := $(CURDIR)
obj := $(CURDIR)
export srctree objtree
# Machine and compiler
ARCH := i386
CROSS_COMPILE :=
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
OBJCOPY = $(CROSS_COMPILE)objcopy
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
AR = $(CROSS_COMPILE)ar
# Compile flags
ASFLAGS =
CFLAGS =
LDFLAGS =
ifeq ($(ARCH), i386)
ASFLAGS += --32
LDFLAGS += -m elf_i386 --traditional-format
CFLAGS += -m32 -fno-stack-protector -fgnu89-inline -g
endif
ifneq ($(DEBUG),)
ASFLAGS += -ggdb -am
endif
# Header
CFLAGS += -I$(srctree)/include
LDFLAGS += -Ttext 0
export VERSION NAME
export ARCH CROSS_COMPILE AS LD CC OBJCOPY NM AR
export STRIP
export ASFLAGS CFLAGS LDFLAGS
# Subdir
SUBDIR += boot init lib drivers kernel
ARCHIVES := $(srctree)/kernel/kernel.o
DRIVERS := $(srctree)/drivers/chr_drv/chr_drv.o
LIBS := $(srctree)/lib/lib.o
MATH :=
IMAGE_PACKAGE := $(ARCHIVES) $(DRIVERS) $(LIBS) $(MATH)
export SUBDIR IMAGE_PACKAGE
# General Rule
.c.o:
$(Q)$(CC) $(CFLAGS) -c -o $*.o $<
.s.o:
$(Q)$(AS) $(ASFLAGS) -o $*.o $<
# To do compile
all: CHECK_START $(SUBDIR) Image
$(Q)figlet "BiscuitOS"
CHECK_START:
$(SUBDIR): ECHO
$(Q)make -s -C $@
ECHO:
Image:
$(Q)make -s -C $(srctree)/tools/build
start:
$(Q)make -s -C $(srctree)/tools/build start
debug:
$(Q)make -s -C $(srctree)/tools/build debug
help:
@echo "<<< BiscuitOS Help >>>"
@echo ""
@echo "Usage:"
@echo " make -- Generate a kernel Image"
@echo " make start -- Start the kernel on qemu"
@echo " make debug -- Debug the kernel in qemu & gdb at port 1234"
@echo " make clean -- Clean the object files"
.PHONY: clean
clean: $(SUBDIR)
$(Q)for i in $(SUBDIR); do make clean -s -C $$i; done
$(Q)make clean -s -C $(srctree)/tools/build