NanoPayload

stage2/Makefile

216:95be7694d999
2017-06-28 Paul Boddie Employ structure member names to make initialisation clearer.
     1 # Makefile - Build the NanoNote payload     2 #     3 # Copyright (C) 2015, 2016 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 -fPIC \    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 = $(NANONOTE_SRC:.c=.o)    48 MINIPC_SRC = board-minipc.c minipc_claa070vc01.c    49 MINIPC_OBJ = $(MINIPC_SRC:.c=.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 # Configure generic objects.    62     63 CORE_SRC = stage2.c cpu.c lcd.c jzlcd.c board.c irq.c paging.c tasks.c task_gpio.c    64 CORE_OBJ = $(CORE_SRC:.c=.o)    65     66 # Add tasks.    67     68 TASKS_SRC = $(wildcard tasks/*.c)    69 TASKS_OBJ = $(TASKS_SRC:.c=.o)    70     71 # Resulting definitions.    72     73 DEFS = $(BOARD_DEFS)    74     75 # Ordering of objects is important and cannot be left to replacement rules.    76 # In particular the head2 file must appear first.    77     78 SRC = head2.S entry.S handlers.S cpu_op.S $(CORE_SRC) $(BOARD_SRC)    79 OBJ = head2.o entry.o handlers.o cpu_op.o $(CORE_OBJ) $(BOARD_OBJ)    80     81 .PHONY:	all clean distclean tasks    82     83 all:	$(PAYLOAD) $(UIMAGE) tasks    84     85 clean:    86 	rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(UIMAGE) $(DUMP) *.map    87 	make -C tasks clean    88     89 distclean: clean    90 	echo "Nothing else to clean."    91 	make -C tasks distclean    92     93 tasks:    94 	make -C tasks    95     96 $(UIMAGE): $(PAYLOAD)    97 	$(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x81c00000 -e 0x81c00000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE)    98     99 $(PAYLOAD): $(TARGET)   100 	$(OBJCOPY) -O binary $(@:.bin=.elf) $@+   101 	$(OBJDUMP) -D $(@:.bin=.elf) > $(@:.bin=.dump)   102 	$(OBJDUMP) -h $(@:.bin=.elf) > $(@:.bin=.map)   103 	$(NM) -n $(@:.bin=.elf) > System.map   104 	chmod -x $@+   105 	mv -f $@+ $@   106    107 $(TARGET): $(OBJ) tasks   108 	$(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) $(TASKS_OBJ) -o $@   109    110 .c.o:   111 	$(CC) -c $(CFLAGS) $(DEFS) $< -o $@   112    113 .S.o:   114 	$(CC) -c $(CFLAGS) $(DEFS) $< -o $@