1 # 2 # 3 #all: 4 # arm-linux-gcc main.c -c -o main.o -I./include 5 # arm-linux-gcc hardware.c -c -o hardware.o -I./include 6 # arm-linux-as start.S -o start.o 7 # 8 # arm-linux-ld start.o main.o hardware.o -o arm -Ttext 0x50000000 9 # 10 # arm-linux-objcopy -O binary arm arm.bin 11 TARGET :=arm 12 BIN :=$(TARGET).bin 13 LD_ADDR :=0x50000000 14 START_OBJ :=start.o 15 OBJS :=main.o hardware.o 16 17 CROSS_COMPILE :=arm-linux- 18 CC :=$(CROSS_COMPILE)gcc 19 LD :=$(CROSS_COMPILE)ld 20 AS :=$(CROSS_COMPILE)as 21 OBJCOPY :=$(CROSS_COMPILE)objcopy -O binary 22 OBJDUMP :=$(CROSS_COMPILE)objdump -D 23 NM :=$(CROSS_COMPILE)nm 24 25 CFLAGS :=-I./include 26 LDFLAGS := 27 RM :=rm -rf 28 29 all:$(TARGET) 30 $(OBJCOPY) $< $(BIN) 31 $(OBJDUMP) $< > bin.s 32 $(NM) $< > System.map 33 $(RM) $< 34 $(TARGET):$(START_OBJ) $(OBJS) 35 $(LD) $^ -o $@ -Ttext $(LD_ADDR) 36 %.o:%.s 37 $(AS) $< -o $@ 38 clean: 39 $(RM) *.o $(TARGET) $(BIN) System.map bin.s