1 ARCH
= $(shell uname
-m
)
2 ifneq ("$(ARCH)", "ppc64")
3 ifneq ("$(ARCH)", "ppc64le")
4 CROSS_COMPILE ?
= powerpc64le-linux-gnu-
8 #BOOT_INIT_BASE ?= 0xf0000000 # at QSPI address
9 BOOT_INIT_BASE ?
= 0xff000000 # at ROM hi address (with coldboot firmware)
10 # BOOT_INIT_BASE ?= 0x0 # start at zero (usual)
12 CC
= $(CROSS_COMPILE
)gcc
13 LD
= $(CROSS_COMPILE
)ld
14 OBJCOPY
= $(CROSS_COMPILE
)objcopy
16 CFLAGS
= -Os
-g
-Wall
-std
=c99
-mabi
=elfv2
-msoft-float
-mno-string \
17 -mno-multiple
-mno-vsx
-mno-altivec
-mlittle-endian \
18 -fno-stack-protector
-mstrict-align
-ffreestanding \
19 -fdata-sections
-ffunction-sections
-I..
/include \
20 -DBOOT_INIT_BASE
=$(BOOT_INIT_BASE
)
23 LDFLAGS
= -static
-nostdlib
-T powerpc.lds
--gc-sections
27 powerpc.lds
: powerpc.lds.S
28 $(CC
) $(CFLAGS
) -P
-E powerpc.lds.S
-o powerpc.lds
30 console.o
: ..
/lib
/console.c
31 $(CC
) $(CPPFLAGS
) $(CFLAGS
) -c
$< -o
$@
33 hello_world.elf
: hello_world.o head.o console.o powerpc.lds
34 $(LD
) $(LDFLAGS
) -o
$@ hello_world.o head.o console.o
35 powerpc64le-linux-gnu-objdump
-D hello_world.elf
> hello_world.
as
37 hello_world.bin
: hello_world.elf
38 $(OBJCOPY
) -O binary
$^
$@
40 hello_world.hex
: hello_world.bin
41 ..
/scripts
/bin2hex.py
$^
> $@
44 @
rm -f
*.o hello_world.elf hello_world.bin hello_world.hex powerpc.lds