hmm getting flags sorted out on coldboot link
[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 CC = $(CROSS_COMPILE)gcc
9 LD = $(CROSS_COMPILE)ld
10 OBJCOPY = $(CROSS_COMPILE)objcopy
11
12 CFLAGS = -Os -g -Wall -std=c99 -mabi=elfv2 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I../include
13 ASFLAGS = $(CFLAGS)
14 LDFLAGS = -T powerpc.lds
15
16 all: hello_world.hex
17
18 console.o: ../lib/console.c
19 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
20
21 hello_world.elf: hello_world.o head.o console.o
22 $(LD) $(LDFLAGS) -o $@ $^
23
24 hello_world.bin: hello_world.elf
25 $(OBJCOPY) -O binary $^ $@
26
27 hello_world.hex: hello_world.bin
28 ../scripts/bin2hex.py $^ > $@
29
30 clean:
31 @rm -f *.o hello_world.elf hello_world.bin hello_world.hex
32 distclean: clean
33 rm -f *~
34