1#         $NetBSD: Makefile,v 1.6 2022/09/25 21:19:20 ryo Exp $
2
3S         = ${.CURDIR}/../../../..
4
5TOOLDIR   ?= /usr/pkg/cross-arm-none-eabi
6
7CC        = ${TOOLDIR}/bin/arm-none-eabi-gcc
8OBJCOPY   = ${TOOLDIR}/bin/arm-none-eabi-objcopy
9
10CFLAGS    = -W -Wall -mlittle-endian
11CFLAGS    += -O3 -mcpu=arm7
12CFLAGS    += -fomit-frame-pointer -funroll-loops -finline-functions
13CFLAGS    += -I${S}
14
15all: aica_armcode.h
16
17aica_armcode.h: aica_armcode.elf
18          ${OBJCOPY} -O binary aica_armcode.elf aica_armcode.bin
19          echo '/* $$'NetBSD'$$ */' > ${.TARGET}.tmp
20          echo 'static uint32_t aica_armcode[] = {' >> ${.TARGET}.tmp
21          hexdump -v -e '" /* %04.4_ax */\t" 1/4 "0x%08x, " "\n"' \
22                    aica_armcode.bin >> ${.TARGET}.tmp
23          echo '              0 };' >> ${.TARGET}.tmp
24          mv ${.TARGET}.tmp ${.TARGET}
25
26aica_armcode.elf: aica_arm_locore.o aica_arm.o
27          ${CC} ${CFLAGS} -Wl,-Ttext,0 -Wl,-T ldscript -nostdlib -e 0 \
28                    -o aica_armcode.elf aica_arm_locore.o aica_arm.o
29
30clean: clean-tmp
31#         rm -f aica_armcode.h
32
33clean-tmp:
34          rm -f *.o aica_armcode.elf aica_armcode.bin aica_armcode.h.tmp
35
36