CROSS = 

LD = ld
AS = as
ASFLAGS_THUMB = -mthumb-interwork
LDFLAGS_THUMB = --thumb-entry=_start

CC = gcc
CFLAGS = -O2 -Wall -g
CFLAGS_NOTHUMB = -marm -march=armv7-a+fp
CFLAGS_THUMB = -mthumb -march=armv7-a+fp
CFLAGS_NOOPT = -Wall -g
LFLAGS =


all:	

####

integer_print_asm:	integer_print_asm.o
	$(CROSS)$(LD) $(LDFLAGS) -o integer_print_asm integer_print_asm.o

integer_print_asm.o:	integer_print_asm.s
	$(CROSS)$(AS) $(ASFLAGS) -o integer_print_asm.o integer_print_asm.s


#####

crash:	crash.o
	$(CC) $(LFLAGS) -o crash crash.o

crash.o:	crash.c
	$(CC) $(CFLAGS_NOOPT) -o crash.o -c crash.c

#####

integer_print:	integer_print.o
	$(CROSS)$(CC) $(LFLAGS) -o integer_print integer_print.o

integer_print.o:	integer_print.c
	$(CROSS)$(CC) $(CFLAGS) $(CFLAGS_NOTHUMB) -o integer_print.o -c integer_print.c

#####

integer_print_static:	integer_print.o
	$(CROSS)$(CC) $(LFLAGS) -static -o integer_print_static integer_print.o

#integer_print.o:	integer_print.c
#	$(CROSS)$(CC) $(CFLAGS) -o integer_print.o -c integer_print.c


#####

integer_print.extra:	integer_print.extra.o
	$(CROSS)$(CC) $(LFLAGS) -o integer_print.extra integer_print.extra.o

integer_print.extra.o:	integer_print.extra.c
	$(CROSS)$(CC) $(CFLAGS) -o integer_print.extra.o -c integer_print.extra.c


####

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

integer_print.thumb2.o:	integer_print.c
	$(CROSS)$(CC) $(CFLAGS) $(CFLAGS_THUMB) -o integer_print.thumb2.o -c integer_print.c

####


submit:	32bit/hello_world_arm32.s 64bit/hello_world_arm64.s \
		crash/crash.c \
		Makefile README
	tar -czvf hw3_submit.tar.gz \
		32bit/hello_world_arm32.s 32bit/Makefile \
		64bit/hello_world_arm64.s 64bit/Makefile \
		crash/crash.c crash/Makefile \
		Makefile README

clean:	
	rm -f *~ *.o
	cd integer_print && make clean
	cd 32bit && make clean
	cd 64bit && make clean
	cd crash && make clean
