1 # Makefile - Build the IntCondTest payload 2 # 3 # Copyright (C) 2015, 2017, 2018 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 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation, either version 3 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with 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 # NOTE: -O2 is actually needed to prevent memcpy references, whereas probably 27 # NOTE: one of the -f{freestanding, no-hosted, no-builtin} options should work. 28 # NOTE: See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888 29 30 CFLAGS = -O2 -Wall \ 31 -fno-unit-at-a-time -fno-zero-initialized-in-bss \ 32 -ffreestanding -fno-hosted -fno-builtin \ 33 -march=mips32 34 LDFLAGS = -nostdlib -EL 35 36 TARGET = intcond.elf 37 DUMP = $(TARGET:.elf=.dump) 38 MAP = $(TARGET:.elf=.map) 39 SCRIPT = $(TARGET:.elf=.ld) 40 41 HEX = $(TARGET:.elf=.hex) 42 SREC = $(TARGET:.elf=.srec) 43 44 # Ordering of objects is important and cannot be left to replacement rules. 45 46 SRC = intcond.S main.c init.c cpu.S 47 OBJ = intcond.o main.o init.o cpu.o 48 49 .PHONY: all clean distclean 50 51 all: $(HEX) $(SREC) 52 53 clean: 54 rm -f $(OBJ) $(TARGET) $(HEX) $(SREC) $(DUMP) *.map 55 56 distclean: clean 57 echo "Nothing else to clean." 58 59 $(HEX): $(TARGET) 60 $(OBJCOPY) -O ihex $(TARGET) $(HEX) 61 62 $(SREC): $(TARGET) 63 $(OBJCOPY) -O srec $(TARGET) $(SREC) 64 65 $(TARGET): $(OBJ) 66 $(LD) $(LDFLAGS) -T $(SCRIPT) $(OBJ) -o $@ 67 $(OBJDUMP) -D $(TARGET) > $(DUMP) 68 $(OBJDUMP) -h $(TARGET) > $(MAP) 69 $(NM) -n $(TARGET) > System.map 70 71 .c.o: 72 $(CC) -c $(CFLAGS) $< -o $@ 73 74 .S.o: 75 $(CC) -c $(CFLAGS) $< -o $@