1# $NetBSD: Makefile,v 1.12 2011/02/20 07:52:43 matt Exp $
2
3.include <bsd.own.mk>
4.include <bsd.sys.mk>	# for ${HOST_SH}
5
6S!= cd ${.CURDIR}/../../../..; pwd
7
8PROG= boot
9MKMAN= no		# defined
10STRIPFLAG=
11BINMODE= 444
12
13NETBSD_VERS!=	${HOST_SH} ${S}/conf/osrelease.sh
14
15.PATH:		${S}/dev/arcbios
16
17SRCS=	start.S arcbios_calls.S
18SRCS+=	boot.c bootinfo.c conf.c devopen.c disk.c getchar.c getopt.c putchar.c
19
20.include "${S}/dev/arcbios/Makefile.inc"
21
22# XXX SHOULD NOT NEED TO DEFINE THESE!
23LIBCRT0=
24LIBC=
25LIBCRTBEGIN=
26LIBCRTEND=
27
28AFLAGS=    -x assembler-with-cpp -mno-abicalls -mips2 -mabi=32
29AFLAGS+=   -D_LOCORE -D_KERNEL
30CFLAGS=    -Os -mmemcpy -G 1024
31CFLAGS+=   -ffreestanding -mno-abicalls -msoft-float -mips2 -mabi=32
32CFLAGS+=   -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
33CPPFLAGS+= -nostdinc -I. -I${S}
34CPPFLAGS+= -D_STANDALONE -DNO_ABICALLS -D${MACHINE}
35CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
36#CPPFLAGS+= -DBOOT_DEBUG
37LDSCRIPT=  ${S}/arch/mips/conf/stand.ldscript
38TEXTADDR=  0x80f00000
39LD+=		-m elf32ltsmip
40
41# if there is a 'version' file, add rule for vers.c and add it to SRCS
42# and CLEANFILES
43.if exists(version)
44.PHONY: vers.c
45vers.c: ${.CURDIR}/version
46	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
47	    ${.CURDIR}/version ${MACHINE}
48
49SRCS+=	vers.c
50CLEANFILES+= vers.c
51.endif
52
53### find out what to use for libsa
54SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes
55.include "${S}/lib/libsa/Makefile.inc"
56LIBSA=   ${SALIB}
57
58### find out what to use for libkern
59.include "${S}/lib/libkern/Makefile.inc"
60LIBKERN= ${KERNLIB}
61
62### find out what to use for libz
63.include "${S}/lib/libz/Makefile.inc"
64LIBZ=    ${ZLIB}
65
66LIBS=  ${LIBSA} ${LIBKERN} ${LIBZ}
67
68cleandir distclean: .WAIT cleanlibdir
69cleanlibdir:
70	-rm -rf lib
71
72${PROG}: ${OBJS} ${LIBS}
73	${LD} -Map ${PROG}.map -N -x -Ttext ${TEXTADDR} -T ${LDSCRIPT} \
74	    -e start -o ${PROG}.elf ${OBJS} ${LIBS}
75	@${SIZE} ${PROG}.elf
76	${OBJCOPY} --impure -O ecoff-littlemips \
77	    -R .pdr -R .mdebug.abi32 -R .comment -R .ident \
78	    ${PROG}.elf ${.TARGET}
79
80CLEANFILES+=	${PROG}.elf ${PROG}.map
81
82.include <bsd.klinks.mk>
83.include <bsd.prog.mk>
84