######################################################################### # # # Makefile for Assembler Introductory Programs # # # ######################################################################### # Author: John Zaitseff # Date: 9th March, 2003 # Version: 1.8 # This Makefile creates the executable images for all of the programs that # illustrate aspects of the GNU Assembler and C Compiler. You should read # the source code for the programs to see what each program is meant to # show. # # Assuming that you have the GNU Assembler and C Compiler for the ARM # microcontroller installed, type "make" to create the executable images. # After you finish, type "make clean" to remove all created files. # The first target is the default: typing "make" is the same as typing # "make all". The target "all" lists a number of other targets as its # dependencies (ie, "all" depends on these other targets). Note that "\" # at the end of the line means "this line continues onto the next one". all: \ simple \ subr \ values \ pseudo \ jumptbl \ wordcopy \ blockcopy \ strcopy-a \ strcopy-c clean: -rm -f \ simple.elf simple.o \ subr.elf subr.o \ values.elf values.o \ pseudo.elf pseudo.o \ jumptbl.elf jumptbl.o \ wordcopy.elf wordcopy.o \ blockcopy.elf blockcopy.o \ strcopy-a.elf strcopy-a.o \ copy.o \ strcopy-c.elf strcopy-c.o # simple: A simple ARM assembly language program, with which to start simple: simple.elf simple.elf: simple.o simple.o: simple.s # subr: A simple subroutine (function call) subr: subr.elf subr.elf: subr.o subr.o: subr.s # values: Load constant values into registers, with "ldr =" values: values.elf values.elf: values.o values.o: values.s # pseudo: More information about pseudo-instructions for the ARM pseudo: pseudo.elf pseudo.elf: pseudo.o pseudo.o: pseudo.s # jumptbl: Multi-way branches and pointers to functions jumptbl: jumptbl.elf jumptbl.elf: jumptbl.o jumptbl.o: jumptbl.s # wordcopy: Copy an array of words, stored in the ".data" section wordcopy: wordcopy.elf wordcopy.elf: wordcopy.o wordcopy.o: wordcopy.s # blockcopy: Copy an array en-masse, with stack pointer initialisation blockcopy: blockcopy.elf blockcopy.elf: blockcopy.o blockcopy.o: blockcopy.s # strcopy-a: String copy with multiple source files strcopy-a: strcopy-a.elf strcopy-a.elf: strcopy-a.o copy.o strcopy-a.o: strcopy-a.s copy.o: copy.s # strcopy-c: Mixing C and assembler for string copy strcopy-c: strcopy-c.elf strcopy-c.o: strcopy-c.c strcopy-c.elf: strcopy-c.o copy.o $(CC) $^ -lc -o $@ # strcopy-c.elf depends on the two files listed (strcopy-c.o and copy.o), # and requires the GNU C compiler to link it, not the GNU Linker. This # is due to the fact that the C compiler includes certain libraries that # the linker does not, by default. # The following variables and implicit rules are required for the GNU # Assembler and the GNU Compiler for ARM. You probably do not need to # modify anything here. AS = arm-elf-as CC = arm-elf-gcc LD = arm-elf-ld ASFLAGS = --gdwarf2 CFLAGS = -O2 -g -Wall LDFLAGS = LDLIBS = # Assemble ARM assembly language source to an object file %.o: %.s $(AS) -marm7tdmi $(ASFLAGS) $< -o $@ # Compile C code to an object file %.o: %.c $(CC) -c -mcpu=arm7tdmi $(CFLAGS) $< -o $@ # Compile C code into ARM assembly language %.s: %.c $(CC) -S -fverbose-asm -mcpu=arm7tdmi $(CFLAGS) $< -o $@ # Link object files into an ARM executable, using the GNU Linker. %.elf: %.o $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@ # Miscellaneous rules .PHONY: all clean .DEFAULT: .SUFFIXES: