xref: /netbsd-src/sys/arch/macppc/stand/ofwboot/Makefile (revision daf6c4152fcddc27c445489775ed1f66ab4ea9a9)
1#	$NetBSD: Makefile,v 1.51 2011/01/22 19:19:19 joerg Exp $
2
3S=	${.CURDIR}/../../../..
4
5PROG=		ofwboot
6FILES=		${PROG}.elf ${PROG}.xcf
7SRCS=		Locore.c boot.c ofdev.c hfs.c net.c netif_of.c alloc.c vers.c
8XCOFFXTRA=	Xcoffxtra.c
9XCOFFXTRAOBJ=	Xcoffxtra.o
10CFLAGS+=	-msoft-float -mmultiple -ffreestanding
11CFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
12#CPPFLAGS+=	-DDEBUG -DNETIF_DEBUG
13CPPFLAGS+=	-D_STANDALONE -DSUPPORT_DHCP
14CPPFLAGS+=	-DSUPPORT_USTARFS -DHAVE_CHANGEDISK_HOOK
15DBG=		-Os
16
17LIBCRT0=	# nothing
18LIBCRTBEGIN=	# nothing
19LIBCRTEND=	# nothing
20LIBC=		# nothing
21
22.PATH:		${S}/arch/powerpc/powerpc
23SRCS+=		ofwmagic.S
24
25.PATH:		${S}/lib/libsa
26SRCS+=		byteorder.c
27
28NOMAN=		# defined
29STRIPFLAG=
30BINMODE=	444
31
32.include <bsd.own.mk>
33
34.if !defined(FIXCOFF)
35.if !defined(TOOL_MACPPCFIXCOFF)
36TOOL_MACPPCFIXCOFFDIR!=	cd ${.CURDIR}/../fixcoff && ${PRINTOBJDIR}
37TOOL_MACPPCFIXCOFF=	${TOOL_MACPPCFIXCOFFDIR}/fixcoff
38.endif
39.endif
40
41NEWVERSWHAT=	"OpenFirmware Boot"
42
43# For now...
44#RELOC=		20000
45RELOC=		E00000
46
47ENTRY=		_start
48
49CLEANFILES+=	vers.c ${PROG}.elf ${PROG}.el1 ${PROG}.mrg ${PROG}.xcf
50
51CPPFLAGS+=	-I. -I${.CURDIR} -I${.CURDIR}/../../.. -I${.CURDIR}/../../../..
52CPPFLAGS+=	-DRELOC=0x${RELOC} -DRELOC_FLATFILE=0x${RELOC_FLATFILE}
53#CPPFLAGS+=	-DXCOFF_GLUE		# for booting PCI Powermacs
54
55CLEANFILES+= ${XCOFFXTRAOBJ}
56
57### find out what to use for libkern
58KERN_AS=	library
59.include "${S}/lib/libkern/Makefile.inc"
60LIBKERN=	${KERNLIB}
61
62### find out what to use for libz
63Z_AS=		library
64.include "${S}/lib/libz/Makefile.inc"
65LIBZ=		${ZLIB}
66
67### find out what to use for libsa
68SA_AS=		library
69SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes
70.include "${S}/lib/libsa/Makefile.inc"
71LIBSA=		${SALIB}
72
73cleandir distclean: .WAIT cleanlibdir
74
75cleanlibdir:
76	-rm -rf lib
77
78.PHONY: vers.c
79vers.c: version
80	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
81	    ${.CURDIR}/version "macppc" ${NEWVERSWHAT}
82
83all realall: ${PROG} ${PROG}.xcf ${PROG}.elf
84
85${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
86	${_MKTARGET_LINK}
87	${LD} -s -N -Ttext ${RELOC} -Bstatic -o ${PROG}.el1 \
88	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
89	${OBJCOPY} -O binary ${PROG}.el1 ${PROG}
90
91.include <bsd.klinks.mk>
92.include <bsd.prog.mk>
93
94${PROG}.elf: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
95	${_MKTARGET_LINK}
96	${LD} -s -N -Ttext ${RELOC} -Bstatic -o ${PROG}.elf \
97	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
98
99${PROG}.xcf: ${OBJS} ${XCOFFXTRAOBJ} ${LIBSA} ${LIBZ} ${LIBKERN}
100	${_MKTARGET_LINK}
101	${LD} -s -N -T ${.CURDIR}/../fixcoff/elf32_powerpc_merge.x -e _entry \
102	    -Ttext ${RELOC} -Bstatic -o ${PROG}.mrg  ${XCOFFXTRAOBJ} \
103	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
104	${OBJCOPY} -O aixcoff-rs6000 -R .comment -R .note \
105	    ${PROG}.mrg ${PROG}.xcf
106	${TOOL_MACPPCFIXCOFF} ${PROG}.xcf
107