1 # Makefile - Build the NanoNote payload 2 # 3 # Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> 4 # Copyright (C) Xiangfu Liu <xiangfu@sharism.cc> 5 # 6 # This program is free software; you can redistribute it and/or modify it under 7 # the terms of the GNU General Public License as published by the Free Software 8 # Foundation; either version 3 of the License, or (at your option) any later 9 # version. 10 # 11 # This program is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 # details. 15 # 16 # You should have received a copy of the GNU General Public License along with 17 # this program. If not, see <http://www.gnu.org/licenses/>. 18 19 ARCH = mipsel-linux-gnu 20 CC = $(ARCH)-gcc 21 LD = $(ARCH)-ld 22 NM = $(ARCH)-nm 23 OBJCOPY=$(ARCH)-objcopy 24 OBJDUMP=$(ARCH)-objdump 25 26 CFLAGS = -Wall -fno-unit-at-a-time -fno-zero-initialized-in-bss \ 27 -march=mips32 -mno-abi-calls \ 28 -Iinclude 29 LDFLAGS = -nostdlib -EL -T target.ld 30 31 PAYLOAD = stage1.bin 32 TARGET = $(PAYLOAD:.bin=.elf) 33 DUMP = $(PAYLOAD:.bin=.dump) 34 MAP = $(PAYLOAD:.bin=.map) 35 SRC = head.S stage1.c board-jz4740.c 36 OBJ = $(SRC:.c=.o) 37 38 .PHONY: all clean distclean 39 40 all: $(PAYLOAD) 41 42 clean: 43 rm -f $(OBJ) $(TARGET) $(PAYLOAD) 44 45 distclean: clean 46 echo "Nothing else to clean." 47 48 $(TARGET): $(OBJ) 49 $(LD) $(LDFLAGS) $(OBJ) -o $@ 50 51 .bin.elf: 52 $(OBJCOPY) -O binary $< $@+ 53 $(OBJDUMP) -D $< > $(DUMP) 54 $(OBJDUMP) -h $< > $(MAP) 55 $(NM) -n $< > System.map 56 chmod -x $@+ 57 mv -f $@+ $@ 58 59 .c.o: 60 $(CC) -c $(CFLAGS) $< -o $@ 61 62 .S.o: 63 $(CC) -c $(CFLAGS) $< -o $@