ls2: add support for the Nexys Video board
[ls2.git] / hello_world / Makefile
1 ARCH = $(shell uname -m)
2 ifneq ("$(ARCH)", "ppc64")
3 ifneq ("$(ARCH)", "ppc64le")
4 CROSS_COMPILE ?= powerpc64le-linux-gnu-
5 endif
6 endif
7
8 #BOOT_INIT_BASE ?= 0xf0000000 # at QSPI address
9 BOOT_INIT_BASE ?= 0x00600000 # inside DRAM address space
10 # BOOT_INIT_BASE ?= 0xff000000 # at ROM hi address (with coldboot firmware)
11 # BOOT_INIT_BASE ?= 0x0 # start at zero (usual)
12
13 CC = $(CROSS_COMPILE)gcc
14 LD = $(CROSS_COMPILE)ld
15 OBJCOPY = $(CROSS_COMPILE)objcopy
16
17 CFLAGS = -Os -g -Wall -std=c99 -mabi=elfv2 -msoft-float -mno-string \
18 -mno-multiple -mno-vsx -mno-altivec -mlittle-endian \
19 -fno-stack-protector -mstrict-align -ffreestanding \
20 -fdata-sections -ffunction-sections -I../include \
21 -DBOOT_INIT_BASE=$(BOOT_INIT_BASE)
22
23 ASFLAGS = $(CFLAGS)
24 LDFLAGS = -static -nostdlib -T powerpc.lds --gc-sections
25
26 all: hello_world.hex
27
28 powerpc.lds: powerpc.lds.S
29 $(CC) $(CFLAGS) -P -E powerpc.lds.S -o powerpc.lds
30
31 console.o: ../lib/console.c
32 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
33
34 hello_world.elf: hello_world.o head.o console.o powerpc.lds
35 $(LD) $(LDFLAGS) -o $@ hello_world.o head.o console.o
36 powerpc64le-linux-gnu-objdump -D hello_world.elf > hello_world.as
37
38 hello_world.bin: hello_world.elf
39 $(OBJCOPY) -O binary $^ $@
40
41 hello_world.hex: hello_world.bin
42 ../scripts/bin2hex.py $^ > $@
43
44 clean:
45 @rm -f *.o hello_world.elf hello_world.bin hello_world.hex powerpc.lds
46 distclean: clean
47 rm -f *~
48