1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-02-06 08:15:03 +00:00
Files
antonblanchard.microwatt/hello_world/Makefile
Paul Mackerras abefafd70b hello_world: Adjust header inclusions and Makefile
Currently hello_world fails to build with distro cross compiler
packages such as Debian gcc-powerpc64-linux-gnu, because it doesn't
provide string.h or unistd.h.  In fact we don't need them, we just
need stddef.h.  This adds #include <stddef.h> to console.h to get
size_t defined.  We also add #include "console.h" to console.c.

The hello_world Makefile currently hard-codes CROSS_COMPILE on
non-PPC machines.  This means that a command like:

	$ CROSS_COMPILE=powerpc64le-linux-gnu- make

doesn't do what you expect; it just tries to use powerpc64le-linux-gcc
regardless.  Adding a '?' makes it do what one expects.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2020-04-03 12:10:31 +11:00

29 lines
865 B
Makefile

ARCH = $(shell uname -m)
ifneq ("$(ARCH)", "ppc64")
ifneq ("$(ARCH)", "ppc64le")
CROSS_COMPILE ?= powerpc64le-linux-
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
ASFLAGS = $(CFLAGS)
LDFLAGS = -T powerpc.lds
all: hello_world.hex
hello_world.elf: hello_world.o head.o console.o
$(LD) $(LDFLAGS) -o hello_world.elf hello_world.o head.o console.o
hello_world.bin: hello_world.elf
$(OBJCOPY) -O binary hello_world.elf hello_world.bin
hello_world.hex: hello_world.bin
../scripts/bin2hex.py hello_world.bin > hello_world.hex
clean:
@rm -f *.o hello_world.elf hello_world.bin hello_world.hex