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