NanoPayload

stage2/Makefile

54:82e00671c53d
2015-06-12 Paul Boddie Made the stage 2 payload work as a uImage file with U-Boot (2012.10-rc2).
     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 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 -fPIC \    35 	-I../include    36 LDFLAGS = -nostdlib -EL -pie    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 stage2.c lcd.c jzlcd.c board.c $(BOARD_SRC)    66 OBJ = head2.o stage2.o lcd.o jzlcd.o board.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 u-boot -T standalone -C none -a 0x80000000 -e 0x80000000 -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 $@