Makefile revision 96306
150477Speter# $FreeBSD: head/sys/boot/i386/loader/Makefile 96306 2002-05-10 00:53:45Z obrien $
238465Smsmith
339441SmsmithBASE=		loader
458713SjhbPROG=		${BASE}
539857SjkhSTRIP=
648351SpeterNEWVERSWHAT=	"bootstrap loader" i386
739851SpeterBINDIR?=	/boot
883368SruINSTALLFLAGS=	-b
993352Sobrien.if !defined(LOADER_NO_AOUT_SUPPORT)
1093352SobrienLOADER_AOUT_SUPPORT=	yes
1193352Sobrien.endif
1238465Smsmith
1339441Smsmith# architecture-specific loader code
1459473SpsSRCS=		main.c conf.c
1539441Smsmith
1696306SobrienCFLAGS+=	-ffreestanding
1759087Sps# Enable PXE TFTP or NFS support, not both.
1868310Sps.if defined(LOADER_TFTP_SUPPORT)
1968310SpsCFLAGS+=	-DLOADER_TFTP_SUPPORT
2068310Sps.else
2159087SpsCFLAGS+=	-DLOADER_NFS_SUPPORT
2268310Sps.endif
2359087Sps
2439178Smsmith# Enable PnP and ISA-PnP code.
2540555SmsmithHAVE_PNP=	yes
2640555SmsmithHAVE_ISABUS=	yes
2739178Smsmith
2856992Sluigi.if !defined(NOFORTH)
2940877Smsmith# Enable BootForth
3056903SjhbBOOT_FORTH=	yes
3156903SjhbCFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386
3241107Sjkh.if exists(${.OBJDIR}/../../ficl/libficl.a)
3341107SjkhLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
3441107Sjkh.else
3541107SjkhLIBFICL=	${.CURDIR}/../../ficl/libficl.a
3641107Sjkh.endif
3756992Sluigi.endif
3840877Smsmith
3983616Ssobomax.if defined(LOADER_BZIP2_SUPPORT)
4083616SsobomaxCFLAGS+=	-DLOADER_BZIP2_SUPPORT
4183616Ssobomax.endif
4283616Ssobomax.if !defined(LOADER_NO_GZIP_SUPPORT)
4383616SsobomaxCFLAGS+=	-DLOADER_GZIP_SUPPORT
4483616Ssobomax.endif
4583616Ssobomax
4638465Smsmith# Always add MI sources 
4738465Smsmith.PATH:		${.CURDIR}/../../common
4838465Smsmith.include	<${.CURDIR}/../../common/Makefile.inc>
4940338SpeterCFLAGS+=	-I${.CURDIR}/../../common
5040338SpeterCFLAGS+=	-I${.CURDIR}/../../.. -I.
5138465Smsmith
5241821SmsmithCLEANFILES+=	vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
5338465Smsmith
5438465SmsmithCFLAGS+=	-Wall
5544243SmsmithLDFLAGS=	-nostdlib -static -Ttext 0x0
5638465Smsmith
5738465Smsmith# i386 standalone support library
5838465SmsmithLIBI386=	${.OBJDIR}/../libi386/libi386.a
5938465SmsmithCFLAGS+=	-I${.CURDIR}/..
6038465Smsmith
6139474Smsmith# where to get libstand from
6265598Simp#XXX need a better way to do this
6365598SimpLIBSTAND=	${.CURDIR}/../../../../lib/libstand/libstand.a
6465598Simp.if !exists(${LIBSTAND})
6565598SimpLIBSTAND=	${.OBJDIR}/../../../../lib/libstand/libstand.a
6665598Simp.if !exists(${LIBSTAND})
6739474SmsmithLIBSTAND=	-lstand
6865598Simp.endif
6965598Simp.endif
7059087SpsCFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
7139474Smsmith
7239441Smsmith# BTX components
7339646Speter.if exists(${.OBJDIR}/../btx)
7439646SpeterBTXDIR=		${.OBJDIR}/../btx
7539646Speter.else
7639441SmsmithBTXDIR=		${.CURDIR}/../btx
7739646Speter.endif
7839441SmsmithBTXLDR=		${BTXDIR}/btxldr/btxldr
7939441SmsmithBTXKERN=	${BTXDIR}/btx/btx
8039441SmsmithBTXCRT=		${BTXDIR}/lib/crt0.o
8139646SpeterCFLAGS+=	-I${.CURDIR}/../btx/lib
8239441Smsmith
8339441Smsmith# BTX is expecting ELF components
8439441SmsmithCFLAGS+=	-elf
8539441Smsmith
8639664Smsmith# Debug me!
8740884Smsmith#CFLAGS+=	-g
8840884Smsmith#LDFLAGS+=	-g
8939664Smsmith
9048351Spetervers.o:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
9148351Speter	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
9238465Smsmith	${CC} -c vers.c
9338465Smsmith
9494956Sru${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
9582133Speter	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
9658713Sjhb		-b ${BTXKERN} ${BASE}.bin
9742493Smsmith#	/usr/bin/kzip ${.TARGET}
9842493Smsmith#	mv ${.TARGET}.kz ${.TARGET}
9938465Smsmith
10040555Smsmith${BASE}.bin: ${BASE}.sym
10140555Smsmith	cp ${.ALLSRC} ${.TARGET}
10269985Srnordier	strip -R .comment -R .note ${.TARGET}
10340555Smsmith
10441821Smsmith${BASE}.help: help.common help.i386
10542807Smsmith	cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
10641821Smsmith
10794956Sru.PATH: ${.CURDIR}/../../forth 
10894956SruFILES=	${BASE}.help loader.4th support.4th loader.conf
10994956SruFILESDIR_loader.conf=	/boot/defaults
11094956Sru
11145759Sdcs.if !exists(${DESTDIR}/boot/loader.rc)
11294956SruFILES+=	loader.rc
11345759Sdcs.endif
11441821Smsmith
11558713Sjhb.include <${.CURDIR}/../Makefile.inc>
11658713Sjhb
11740555Smsmith# Cannot use ${OBJS} above this line
11840555Smsmith.include <bsd.prog.mk>
11940555Smsmith
12040877Smsmith${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
12140555Smsmith	${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
12259473Sps		${LIBFICL} ${LIBI386} ${LIBSTAND}
12339441Smsmith
12440555Smsmith# If it's not there, don't consider it a target
12540555Smsmith.if exists(${.CURDIR}/../../../i386/include)
12640555Smsmithbeforedepend ${OBJS}: machine
12739441Smsmith
12840338Spetermachine:
12940338Speter	ln -sf ${.CURDIR}/../../../i386/include machine
13040338Speter
13140555Smsmith.endif
13240555Smsmith
13340338SpeterCLEANFILES+=	machine
134