1#         $NetBSD: Makefile,v 1.31 2023/02/09 15:20:40 tsutsui Exp $
2
3NOMAN=    # defined
4
5S=        ${.CURDIR}/../../../..
6
7### find out what to use for libkern
8KERN_AS=        library
9.include "${S}/lib/libkern/Makefile.inc"
10#LIBKERN=        ${KERNLIB}
11
12### find out what to use for libz
13Z_AS=           library
14.include "${S}/lib/libz/Makefile.inc"
15#LIBZ=           ${ZLIB}
16
17### find out what to use for libsa
18SA_AS=          library
19SAMISCMAKEFLAGS= SA_USE_LOADFILE=yes # SA_USE_CREAD=yes
20.include "${S}/lib/libsa/Makefile.inc"
21#LIBSA=          ${SALIB}
22
23RELOC=    4380000
24
25# XXX make defs arch-indep.
26INCLUDES+=          -I${.OBJDIR} -I${S}/arch -I${S} -I${S}/lib/libsa
27DEFS+=              -D_STANDALONE -DMC68040 -DSUPPORT_BOOTP -DSUPPORT_DHCP
28#DEFS+=             -DDEBUG -DSD_DEBUG -DSCSI_DEBUG -DEN_DEBUG -DNETIF_DEBUG
29SAMISCCPPFLAGS=     -DSUPPORT_DHCP -DSUPPORT_BOOTP -DSA_EXEC_ANYOWNER
30#SAMISCCPPFLAGS+= -DBOOTP_DEBUG -DETHER_DEBUG -DNET_DEBUG-DNETIF_DEBUG
31#SAMISCCPPFLAGS+= -DNFS_DEBUG -DARP_DEBUG
32WARNS=1
33CFLAGS+=  -ffreestanding -nostdinc ${INCLUDES} ${DEFS}
34CFLAGS+=  -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
35AFLAGS+=  ${INCLUDES}
36# XXX SHOULD NOT NEED TO DEFINE THESE!
37LIBCRT0=
38LIBCRTI=
39LIBC=
40LIBCRTBEGIN=
41LIBCRTEND=
42
43PROG=     boot
44SRCS=   boot.c machdep.c conf.c devopen.c rtc.c sd.c scsi.c en.c build.c
45
46# @@@ dev_net.c should really be in libsa, but it doesn't
47# declare ip_convertaddr correctly, so I put it here _temporarily_.
48.PATH: ${S}/lib/libsa
49SRCS+=    dev_net.c
50
51CLEANFILES+= srt0.o boot.elf boot.raw limits.h
52CLEANFILES+= build.c build    # generated dynamically
53
54BINDIR=   /usr/mdec
55#LIBS=    ${SALIB} ${KERNLIB} ${ZLIB}
56LIBS=     ${SALIB} ${KERNLIB}
57
58# do not strip ${PROG} on install
59STRIPFLAG=          # defined
60
61AWKPROG='\
62function x(v) { printf "\\0\\%o\\%o\\%o", (v / 65536) % 256, (v / 256) % 256, v % 256 } \
63{ \
64          printf "\047\\0\\207\\01\\07"; \
65          x($$1); \
66          x($$2); \
67          x($$3); \
68          printf "\\0\\0\\0\\0\\04\\070\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\047" \
69}'
70
71${PROG}: srt0.o ${OBJS} ${LIBS}
72          ${_MKTARGET_LINK}
73          ${LD} -N -Ttext ${RELOC} -e start srt0.o ${OBJS} ${LIBS} -o $@.elf
74          ${SIZE} $@.elf
75          ${OBJCOPY} -O binary $@.elf $@.raw
76          (${SIZE} $@.elf | tail +2 | ${TOOL_AWK} ${AWKPROG} | \
77                    xargs printf ; cat $@.raw) > $@
78
79# startup
80
81srt0.o: ${.CURDIR}/srt0.s
82          ${CC} -m68040 -x assembler-with-cpp ${INCLUDES} ${DEFS} -c ${.CURDIR}/srt0.s
83
84.PHONY: build.c
85build.c:
86          ${HOST_SH} ${.CURDIR}/newvers.sh
87
88.include "${S}/conf/newvers_stand.mk"
89
90#installboot: ${.CURDIR}/installboot.sh
91#         @rm -f installboot
92#         cp -p ${.CURDIR}/installboot.sh installboot
93
94# utilities
95
96.include <bsd.prog.mk>
97.include <bsd.klinks.mk>
98