NanoPayload

stage1/Makefile

194:aac340efb570
2016-05-14 Paul Boddie Introduced memory layout headers and consolidated memory-related definitions. Made the linker scripts more consistent.
     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     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 	-I../include    35 LDFLAGS = -nostdlib -EL    36     37 PAYLOAD = stage1.bin    38 TARGET = $(PAYLOAD:.bin=.elf)    39 DUMP = $(PAYLOAD:.bin=.dump)    40 MAP = $(PAYLOAD:.bin=.map)    41     42 # Ordering of objects is important and cannot be left to replacement rules.    43     44 SRC = head1.S stage1.c board.c    45 OBJ = head1.o stage1.o board.o    46     47 .PHONY:	all clean distclean    48     49 all:	$(PAYLOAD)    50     51 clean:    52 	rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(DUMP) *.map    53     54 distclean: clean    55 	echo "Nothing else to clean."    56     57 $(PAYLOAD): $(TARGET)    58 	$(OBJCOPY) -O binary $(@:.bin=.elf) $@+    59 	$(OBJDUMP) -D $(@:.bin=.elf) > $(@:.bin=.dump)    60 	$(OBJDUMP) -h $(@:.bin=.elf) > $(@:.bin=.map)    61 	$(NM) -n $(@:.bin=.elf) > System.map    62 	chmod -x $@+    63 	mv -f $@+ $@    64     65 stage1.elf: $(OBJ)    66 	$(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) -o $@    67     68 .c.o:    69 	$(CC) -c $(CFLAGS) $< -o $@    70     71 .S.o:    72 	$(CC) -c $(CFLAGS) $< -o $@