-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
46 lines (36 loc) · 1.58 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
arch=$(uname -m)
ifeq ($arch,"aarch64")
cc=gcc
else
cc=aarch64-linux-gnu-gcc
endif
cc=gcc
cur_dir = $(PWD)
asmarg = -I $(cur_dir)/include -c -D__ASSEMBLY__ -g
carg = -I$(cur_dir)/include -I$(cur_dir)/nolib/include -I$(cur_dir)/fdt/include -U __linux__ -nostdlib -nolibc -fno-builtin -fno-stack-protector -fno-omit-frame-pointer -Wall -Wextra -c -g
ldflag = -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none -nolibc -nodefaultlibs
c-device = device/pl011.c device/gic-v2.c device/fdt.c
obj-dev = device/pl011.o device/gic-v2.o device/fdt.o
c-fdt = fdt/fdt.c fdt/fdt_interrupts.c fdt/fdt_ro.c fdt/fdt_strerror.c fdt/fdt_wip.c fdt/fdt_addresses.c fdt/fdt_empty_tree.c fdt/fdt_overlay.c fdt/fdt_rw.c fdt/fdt_sw.c
obj-fdt = fdt/fdt.o fdt/fdt_ro.o fdt/fdt_strerror.o fdt/fdt_wip.o fdt/fdt_addresses.o fdt/fdt_empty_tree.o fdt/fdt_overlay.o fdt/fdt_rw.o fdt/fdt_sw.o
obj-core = core/main.o core/entry64.o core/cache64.o core/pagetable64.o core/exceptions.o core/trap.o core/lcpu.o
obj = $(obj-core) $(obj-dev) $(obj-fdt) $(obj-nolib)
obj-nolib = nolib/errno.o nolib/string.o nolib/stdio.o nolib/ctype.o
armos: $(obj) link64.lds
$(cc) $(obj) $(ldflag) -T link64.lds -static -o armos
%.o: %.S
$(cc) $(asmarg) $^ -o $@
%.o: %.c
$(cc) $(carg) $^ -o $@
devcie/%.o: device/%.c
$(cc) $(carg) $^ -o $@
fdt/%.o: fdt/%.c
$(cc) $(carg) $^ -o $@
nolib/%.o: nolib/%.c
$(cc) $(carg) $^ -o $@
core/%.o: core/%.c
$(cc) $(carg) $^ -o $@
link64.lds: link64.lds.S
$(cc) -E -P -x assembler-with-cpp -I $(cur_dir)/include -no-pie -nostdinc -nostdlib -D__ASSEMBLY__ link64.lds.S -o link64.lds
clean:
rm $(obj) armos