-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathenv.am
executable file
·111 lines (94 loc) · 3.47 KB
/
env.am
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
# Copyright (C) 2016 David Gao <[email protected]>
# Copyright (C) 2016 Gan Quan <[email protected]>
#
# This file is part of AIM.
#
# AIM 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.
#
# AIM 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/>.
# AM_*FLAGS are applied when no target_*FLAGS are given, or when directly
# included in target_*FLAGS. Final values of these flags are used in the AIM
# kernel. Here we construct the base of all flags.
AM_CPPFLAGS_BASE = \
-nostdinc \
-I$(top_srcdir)/include/arch/$(ARCH)/mach-$(MACH) \
-I$(top_srcdir)/include/arch/$(ARCH) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib \
-I$(top_srcdir)
AM_CFLAGS_BASE = -Wall -O2 -fno-stack-protector @AIM_CFLAGS@
AM_CCASFLAGS_BASE =
AM_LDFLAGS_BASE = -nostdlib
# Tweak flags according to ARCH and MACH.
if ARCH_ARMV7A
AM_CFLAGS_BASE += -march=armv7-a
AM_LDFLAGS_BASE += -lgcc
endif
if ARCH_MIPS
AM_CFLAGS_BASE += -mips32 -mabi=32 -EL
AM_CCASFLAGS_BASE += -mips32 -mabi=32 -EL
AM_LDFLAGS_BASE += -lgcc
endif
if ARCH_MIPS64
AM_CFLAGS_BASE += -mips64r2 -mabi=32 -EL
AM_CCASFLAGS_BASE += -mips64r2 -mabi=32 -EL
AM_LDFLAGS_BASE += -lgcc
endif
if ARCH_I386
AM_CFLAGS_BASE += -m32
AM_CCASFLAGS_BASE += -m32
endif
if MACH_ZYNQ
AM_CFLAGS_BASE += -mtune=cortex-a9
endif
# We don't want to introduce PIC in firmware and bootloader, but we have
# to make kernel code position independent. Flags differ quite a lot between
# these two scenarios, so we construct a seperate set of FLAGS for explicit
# use with RAW targets, namely firmware and bootloader.
# Here we copy flag variables and tweak them for RAW targets.
AM_CPPFLAGS_NOPIC = $(AM_CPPFLAGS_BASE) -fno-pic -DRAW
AM_CFLAGS_NOPIC = $(AM_CFLAGS_BASE) -fno-pic -DRAW
AM_CCASFLAGS_NOPIC = $(AM_CCASFLAGS_BASE) -DRAW
AM_LDFLAGS_NOPIC = $(AM_LDFLAGS_BASE)
# Then, we tweak flags for the kernel targets.
AM_CPPFLAGS = $(AM_CPPFLAGS_BASE) -fPIE
AM_CFLAGS = $(AM_CFLAGS_BASE) -fPIE
AM_CCASFLAGS = $(AM_CCASFLAGS_BASE)
AM_LDFLAGS = $(AM_LDFLAGS_BASE)
# Almost done, one last tweak according to ARCH and MACH.
if ARCH_MIPS
AM_CFLAGS += -G 0 -mabicalls
AM_CCASFLAGS += -G 0 -Wa,-KPIC -mabicalls
AM_CFLAGS_NOPIC += -mno-abicalls
AM_CCASFLAGS_NOPIC += -mno-abicalls
endif
if ARCH_MIPS64
AM_CFLAGS += -G 0 -mabicalls
AM_CCASFLAGS += -G 0 -Wa,-KPIC -mabicalls
# FIXME: there's a bug in either my MBR or Loongson 3A's (modified) BIOS that
# the kernel file cannot be loaded correctly without -N flag. Since I decided
# to use Loongson's vanilla BIOS, and I don't have the ROM programmer right
# now, this is still left to be checked thoroughly.
AM_LDFLAGS += -N
AM_CFLAGS_NOPIC += -mno-abicalls
AM_CCASFLAGS_NOPIC += -mno-abicalls
endif
# C runtime and user program linker script
CRT_LDS = $(top_srcdir)/lib/libc/arch/$(ARCH)/default.lds
CRT_LDADDS = $(top_builddir)/lib/csu/libcrt.la \
$(top_builddir)/lib/libc/arch/$(ARCH)/libc-$(ARCH).la \
$(top_builddir)/lib/libc/libc.la
SUFFIXES = .elf .bin .s
.elf.bin:
$(AM_V_GEN) $(OBJCOPY) -O binary -S $^ $@
.elf.s:
$(AM_V_GEN) $(OBJDUMP) -Ss $^ > $@