NanoPayload

stage2/Makefile

77:7e61adf1e166
2015-07-03 Paul Boddie Experiment with loading the program at 0x80001000. stage2-non-pic
     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 MKIMAGE = mkimage    23 NM = $(ARCH)-nm    24 OBJCOPY=$(ARCH)-objcopy    25 OBJDUMP=$(ARCH)-objdump    26     27 # NOTE: -O2 is actually needed to prevent memcpy references, whereas probably    28 # NOTE: one of the -f{freestanding, no-hosted, no-builtin} options should work.    29 # NOTE: See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888    30     31 CFLAGS = -O2 -Wall \    32 	-fno-unit-at-a-time -fno-zero-initialized-in-bss \    33 	-ffreestanding -fno-hosted -fno-builtin \    34 	-march=mips32 \    35 	-I../include    36 LDFLAGS = -nostdlib -EL    37     38 UIMAGE = uImage    39 PAYLOAD = stage2.bin    40 TARGET = $(PAYLOAD:.bin=.elf)    41 DUMP = $(PAYLOAD:.bin=.dump)    42 MAP = $(PAYLOAD:.bin=.map)    43     44 # Configure target-specific objects.    45     46 NANONOTE_SRC = board-nanonote.c nanonote_gpm940b0.c    47 NANONOTE_OBJ = board-nanonote.o nanonote_gpm940b0.o    48 MINIPC_SRC = board-minipc.c minipc_claa070vc01.c    49 MINIPC_OBJ = board-minipc.o minipc_claa070vc01.o    50     51 ifdef MINIPC    52 BOARD_SRC = $(MINIPC_SRC)    53 BOARD_OBJ = $(MINIPC_OBJ)    54 BOARD_DEFS = -DCONFIG_CPU_JZ4730_MINIPC -DCONFIG_CPU_JZ4730    55 else    56 BOARD_SRC = $(NANONOTE_SRC)    57 BOARD_OBJ = $(NANONOTE_OBJ)    58 BOARD_DEFS =    59 endif    60     61 DEFS = $(BOARD_DEFS)    62     63 # Ordering of objects is important and cannot be left to replacement rules.    64     65 SRC = head2.S entry.S handlers.S stage2.c cpu.c lcd.c jzlcd.c board.c irq.c $(BOARD_SRC)    66 OBJ = head2.o entry.o handlers.o stage2.o cpu.o lcd.o jzlcd.o board.o irq.o $(BOARD_OBJ)    67     68 .PHONY:	all clean distclean    69     70 all:	$(PAYLOAD) $(UIMAGE)    71     72 clean:    73 	rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(UIMAGE) $(DUMP) *.map    74     75 distclean: clean    76 	echo "Nothing else to clean."    77     78 $(UIMAGE): $(PAYLOAD)    79 	$(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x80001000 -e 0x80001000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE)    80     81 $(PAYLOAD): $(TARGET)    82 	$(OBJCOPY) -O binary $(@:.bin=.elf) $@+    83 	$(OBJDUMP) -D $(@:.bin=.elf) > $(@:.bin=.dump)    84 	$(OBJDUMP) -h $(@:.bin=.elf) > $(@:.bin=.map)    85 	$(NM) -n $(@:.bin=.elf) > System.map    86 	chmod -x $@+    87 	mv -f $@+ $@    88     89 stage2.elf: $(OBJ)    90 	$(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) -o $@    91     92 .c.o:    93 	$(CC) -c $(CFLAGS) $(DEFS) $< -o $@    94     95 .S.o:    96 	$(CC) -c $(CFLAGS) $(DEFS) $< -o $@