-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (54 loc) · 2 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
# Makefile - build script */
# Copyright (C) 2013 Goswin von Brederlow <[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, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# build environment
GCCPREFIX = arm-none-eabi-
BUILD = build/
# source files
SOURCES_ASM := $(wildcard *.S)
SOURCES_ASM += $(wildcard lib/*.S)
SOURCES_CC := $(wildcard *.cpp)
# object files
OBJS := $(patsubst %.S,%.o,$(SOURCES_ASM))
OBJS += $(patsubst %.cpp,%.o,$(SOURCES_CC))
OBJS := $(addprefix $(BUILD),$(OBJS))
# Build flags
DEPENDFLAGS := -MD -MP
BASEFLAGS := -O2 -fpic -pedantic -pedantic-errors -nostdlib
BASEFLAGS += -nostartfiles -ffreestanding -nodefaultlibs
BASEFLAGS += -fno-builtin -fno-omit-frame-pointer -mcpu=arm1176jzf-s -gstabs
WARNFLAGS := -Wall -Wextra
ASFLAGS := $(DEPENDFLAGS) -D__ASSEMBLY__ -gstabs
CXXFLAGS := $(DEPENDFLAGS) $(BASEFLAGS) $(WARNFLAGS)
CXXFLAGS += -fno-exceptions -std=c++0x
# build rules
all: kernel.img
include $(wildcard *.d)
kernel.elf: $(OBJS) kernel.ld
$(GCCPREFIX)ld $(OBJS) -Llib -l csud -T kernel.ld -o $@
kernel.img: kernel.elf
$(GCCPREFIX)objcopy kernel.elf -O binary kernel.img
clean:
$(RM) -f $(OBJS) kernel.elf kernel.img
dist-clean: clean
find -name "*~" -delete
find -name "*.d" -delete
# C++.
$(BUILD)%.o: %.cpp Makefile
$(GCCPREFIX)g++ $(CXXFLAGS) -c $< -o $@
# AS.
$(BUILD)%.o: %.S Makefile
$(GCCPREFIX)g++ $(ASFLAGS) -c $< -o $@