Makefile revision 98542
11590Srgrimes# $FreeBSD: head/sys/boot/i386/loader/Makefile 98542 2002-06-21 06:18:05Z mckusick $
21590Srgrimes
31590SrgrimesBASE=		loader
41590SrgrimesPROG=		${BASE}
51590SrgrimesSTRIP=
61590SrgrimesNEWVERSWHAT=	"bootstrap loader" i386
71590SrgrimesBINDIR?=	/boot
81590SrgrimesINSTALLFLAGS=	-b
91590Srgrimes.if !defined(LOADER_NO_AOUT_SUPPORT)
101590SrgrimesLOADER_AOUT_SUPPORT=	yes
111590Srgrimes.endif
121590Srgrimes
131590Srgrimes# architecture-specific loader code
141590SrgrimesSRCS=		main.c conf.c
151590Srgrimes
161590SrgrimesCFLAGS+=	-ffreestanding
171590Srgrimes# Enable PXE TFTP or NFS support, not both.
181590Srgrimes.if defined(LOADER_TFTP_SUPPORT)
191590SrgrimesCFLAGS+=	-DLOADER_TFTP_SUPPORT
201590Srgrimes.else
211590SrgrimesCFLAGS+=	-DLOADER_NFS_SUPPORT
221590Srgrimes.endif
231590Srgrimes
241590Srgrimes# Enable PnP and ISA-PnP code.
251590SrgrimesHAVE_PNP=	yes
261590SrgrimesHAVE_ISABUS=	yes
271590Srgrimes
281590Srgrimes.if !defined(NOFORTH)
291590Srgrimes# Enable BootForth
301590SrgrimesBOOT_FORTH=	yes
311590SrgrimesCFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386
321590Srgrimes.if exists(${.OBJDIR}/../../ficl/libficl.a)
331590SrgrimesLIBFICL=	${.OBJDIR}/../../ficl/libficl.a
341590Srgrimes.else
351590SrgrimesLIBFICL=	${.CURDIR}/../../ficl/libficl.a
361590Srgrimes.endif
371590Srgrimes.endif
381590Srgrimes
391590Srgrimes.if defined(LOADER_BZIP2_SUPPORT)
401590SrgrimesCFLAGS+=	-DLOADER_BZIP2_SUPPORT
411590Srgrimes.endif
421590Srgrimes.if !defined(LOADER_NO_GZIP_SUPPORT)
431590SrgrimesCFLAGS+=	-DLOADER_GZIP_SUPPORT
441590Srgrimes.endif
451590Srgrimes
461590Srgrimes# Always add MI sources 
471590Srgrimes.PATH:		${.CURDIR}/../../common
481590Srgrimes.include	<${.CURDIR}/../../common/Makefile.inc>
491590SrgrimesCFLAGS+=	-I${.CURDIR}/../../common
501590SrgrimesCFLAGS+=	-I${.CURDIR}/../../.. -I.
511590Srgrimes
521590SrgrimesCLEANFILES+=	vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
531590Srgrimes
541590SrgrimesCFLAGS+=	-Wall
551590SrgrimesLDFLAGS=	-nostdlib -static -Ttext 0x0
561590Srgrimes
571590Srgrimes# i386 standalone support library
581590SrgrimesLIBI386=	${.OBJDIR}/../libi386/libi386.a
591590SrgrimesCFLAGS+=	-I${.CURDIR}/..
601590Srgrimes
611590Srgrimes# where to get libstand from
621590Srgrimes#XXX need a better way to do this
631590SrgrimesLIBSTAND=	${.CURDIR}/../../../../lib/libstand/libstand.a
641590Srgrimes.if !exists(${LIBSTAND})
651590SrgrimesLIBSTAND=	${.OBJDIR}/../../../../lib/libstand/libstand.a
661590Srgrimes.if !exists(${LIBSTAND})
671590SrgrimesLIBSTAND=	-lstand
681590Srgrimes.endif
691590Srgrimes.endif
701590SrgrimesCFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
711590Srgrimes
721590Srgrimes# BTX components
731590Srgrimes.if exists(${.OBJDIR}/../btx)
741590SrgrimesBTXDIR=		${.OBJDIR}/../btx
751590Srgrimes.else
761590SrgrimesBTXDIR=		${.CURDIR}/../btx
771590Srgrimes.endif
781590SrgrimesBTXLDR=		${BTXDIR}/btxldr/btxldr
791590SrgrimesBTXKERN=	${BTXDIR}/btx/btx
801590SrgrimesBTXCRT=		${BTXDIR}/lib/crt0.o
811590SrgrimesCFLAGS+=	-I${.CURDIR}/../btx/lib
821590Srgrimes
831590Srgrimes# BTX is expecting ELF components
841590SrgrimesCFLAGS+=	-elf
851590Srgrimes
861590Srgrimes# Debug me!
871590Srgrimes#CFLAGS+=	-g
881590Srgrimes#LDFLAGS+=	-g
891590Srgrimes
901590Srgrimesvers.o:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
911590Srgrimes	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
921590Srgrimes	${CC} -c vers.c
931590Srgrimes
941590Srgrimes${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
951590Srgrimes	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
961590Srgrimes		-b ${BTXKERN} ${BASE}.bin
971590Srgrimes#	/usr/bin/kzip ${.TARGET}
981590Srgrimes#	mv ${.TARGET}.kz ${.TARGET}
991590Srgrimes
1001590Srgrimes${BASE}.bin: ${BASE}.sym
1011590Srgrimes	cp ${.ALLSRC} ${.TARGET}
1026776Sguido	strip -R .comment -R .note ${.TARGET}
1036776Sguido
1046776Sguido${BASE}.help: help.common help.i386
1056776Sguido	cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
1061590Srgrimes
1071590Srgrimes.PATH: ${.CURDIR}/../../forth 
1086776SguidoFILES=	${BASE}.help loader.4th support.4th loader.conf
1096776SguidoFILESDIR_loader.conf=	/boot/defaults
1106776Sguido
1111590Srgrimes.if !exists(${DESTDIR}/boot/loader.rc)
1121590SrgrimesFILES+=	loader.rc
1131590Srgrimes.endif
1141590Srgrimes
1151590Srgrimes.include <${.CURDIR}/../Makefile.inc>
1161590Srgrimes
1171590Srgrimes# Cannot use ${OBJS} above this line
1181590Srgrimes.include <bsd.prog.mk>
1191590Srgrimes
1201590Srgrimes${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
1211590Srgrimes	${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
1221590Srgrimes		${LIBFICL} ${LIBI386} ${LIBSTAND} ${LIBI386}
1231590Srgrimes
1241590Srgrimes# If it's not there, don't consider it a target
1251590Srgrimes.if exists(${.CURDIR}/../../../i386/include)
1261590Srgrimesbeforedepend ${OBJS}: machine
1271590Srgrimes
1281590Srgrimesmachine:
1291590Srgrimes	ln -sf ${.CURDIR}/../../../i386/include machine
1301590Srgrimes
1311590Srgrimes.endif
1321590Srgrimes
1331590SrgrimesCLEANFILES+=	machine
1341590Srgrimes