CROSS =

LD = ld
AS = as
CC = gcc
CFLAGS = -Wall -O2 -g
LFLAGS =
ARM32CFLAGS = -mcpu=arm1176jzf-s -marm -mfpu=vfp -mfloat-abi=hard
THUMBCFLAGS = -march=armv5t -mthumb
THUMB2CFLAGS = -mthumb -march=armv7-a -mfpu=vfp -mfloat-abi=hard
THUMBLFLAGS = --thumb-entry=_start

all:	hello_world.arm32 hello_world.thumb2 hello_world.static

# doesn't work on Pis

thumb:	hello_world.thumb

hello_world.arm32:	hello_world.arm32.o
	$(CROSS)$(CC) $(LFLAGS) -o hello_world.arm32 hello_world.arm32.o

hello_world.arm32.o:	hello_world.c
	$(CROSS)$(CC) $(CFLAGS) $(ARM32CFLAGS) -o hello_world.arm32.o -c hello_world.c

###

hello_world.thumb:	hello_world.thumb.o
	$(CROSS)$(CC) $(LFLAGS) -o hello_world.thumb hello_world.thumb.o

hello_world.thumb.o:	hello_world.c
	$(CROSS)$(CC) $(CFLAGS) $(THUMBCFLAGS) -o hello_world.thumb.o -c hello_world.c


###

hello_world.thumb2:	hello_world.thumb2.o
	$(CROSS)$(CC) $(LFLAGS) -o hello_world.thumb2 hello_world.thumb2.o

hello_world.thumb2.o:	hello_world.c
	$(CROSS)$(CC) $(CFLAGS) $(THUMB2CFLAGS) -o hello_world.thumb2.o -c hello_world.c


###

hello_world.static:	hello_world.o
	$(CROSS)$(CC) $(LFLAGS) -static -o hello_world.static hello_world.o

hello_world.o:	hello_world.c
	$(CROSS)$(CC) $(CFLAGS) -c hello_world.c


###

clean:	
	rm -f *~ *.o \
	hello_world.arm32 hello_world.thumb hello_world.thumb2 \
	 hello_world.static
