forked from nanvix/nanvix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
90 lines (78 loc) · 2.4 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
#
# Copyright(C) 2011-2014 Pedro H. Penna <[email protected]>
#
# This file is part of Nanvix.
#
# Nanvix 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.
#
# Nanvix 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 Nanvix. If not, see <http://www.gnu.org/licenses/>.
#
#
# Change this to zero if you wanna a
# non-educational version of the system.
#
export EDUCATIONAL_KERNEL=1
# Directories.
export BINDIR = $(CURDIR)/bin
export SBINDIR = $(BINDIR)/sbin
export UBINDIR = $(BINDIR)/ubin
export DOCDIR = $(CURDIR)/doc
export INCDIR = $(CURDIR)/include
export LIBDIR = $(CURDIR)/lib
export DOXYDIR = $(CURDIR)/doxygen
export SRCDIR = $(CURDIR)/src
export TOOLSDIR = $(CURDIR)/tools
# Toolchain
export CC = $(TARGET)-gcc
export LD = $(TARGET)-ld
export AR = $(TARGET)-ar
# Random number for chaos.
export KEY = 13
# Toolchain configuration.
export CFLAGS = -I $(INCDIR)
export CFLAGS += -DKERNEL_HASH=$(KEY) -DEDUCATIONAL_KERNEL=$(EDUCATIONAL_KERNEL)
export CFLAGS += -std=c99 -pedantic-errors -fextended-identifiers
export CFLAGS += -nostdlib -nostdinc -fno-builtin -fno-stack-protector
export CFLAGS += -Wall -Wextra -Werror
export CFLAGS += -Wstack-usage=3192 -Wlogical-op
export CFLAGS += -Wredundant-decls -Wvla
export ASMFLAGS = -Wa,--divide,--warn
export ARFLAGS = -vq
export LDFLAGS = -Wl,-T $(LIBDIR)/link.ld
# Resolves conflicts.
.PHONY: tools
# Builds everything.
all: nanvix documentation
# Builds Nanvix.
nanvix:
mkdir -p $(BINDIR)
mkdir -p $(SBINDIR)
mkdir -p $(UBINDIR)
cd $(SRCDIR) && $(MAKE) all
# Builds system's image.
image: $(BINDIR)/kernel tools
mkdir -p $(BINDIR)
bash $(TOOLSDIR)/build/build-img.sh $(EDUCATIONAL_KERNEL)
# Builds documentation.
documentation:
doxygen $(DOXYDIR)/kernel.config
# Builds tools.
tools:
mkdir -p $(BINDIR)
cd $(TOOLSDIR) && $(MAKE) all
# Cleans compilation files.
clean:
@rm -f *.img
@rm -rf $(BINDIR)
@rm -rf $(DOCDIR)/*-kernel
cd $(SRCDIR) && $(MAKE) clean
cd $(TOOLSDIR) && $(MAKE) clean