Merge pull request #273 from antonblanchard/wishbone-checking
[microwatt.git] / hello_world / Makefile
index 89f3e006e05aa9b4d268d312147bfe0c384a0354..dd51bd38f9ae428328cb8f0d2c3eea479068d997 100644 (file)
@@ -1,28 +1,34 @@
 ARCH = $(shell uname -m)
 ifneq ("$(ARCH)", "ppc64")
 ifneq ("$(ARCH)", "ppc64le")
-        CROSS_COMPILE = powerpc64le-linux-
-        endif
-        endif
+       CROSS_COMPILE ?= powerpc64le-linux-gnu-
+endif
+endif
 
 CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
-CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections 
+CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I../include
 ASFLAGS = $(CFLAGS)
 LDFLAGS = -T powerpc.lds
 
 all: hello_world.hex
 
-hello_world.elf: hello_world.o head.o
-       $(LD) $(LDFLAGS) -o hello_world.elf hello_world.o head.o
+console.o: ../lib/console.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+
+hello_world.elf: hello_world.o head.o console.o
+       $(LD) $(LDFLAGS) -o $@ $^
 
 hello_world.bin: hello_world.elf
-       $(OBJCOPY) -O binary hello_world.elf hello_world.bin
+       $(OBJCOPY) -O binary $^ $@
 
 hello_world.hex: hello_world.bin
-       ../scripts/bin2hex.py hello_world.bin > hello_world.hex
+       ../scripts/bin2hex.py $^ > $@
 
 clean:
        @rm -f *.o hello_world.elf hello_world.bin hello_world.hex
+distclean: clean
+       rm -f *~
+