Makefile.booters revision 1.81
11.81Sjakllsch#	$NetBSD: Makefile.booters,v 1.81 2010/12/22 20:46:42 jakllsch Exp $
21.32Sthorpej
31.32Sthorpej.include <bsd.own.mk>
41.1Sperry
51.2SthorpejSTRIPFLAG=
61.1SperryBINMODE=444
71.38Sthorpej
81.38SthorpejLIBCRT0=	# nothing
91.38SthorpejLIBCRTBEGIN=	# nothing
101.38SthorpejLIBCRTEND=	# nothing
111.38SthorpejLIBC=		# nothing
121.29Stls
131.33Sthorpej# Make sure we override any optimization options specified by the
141.33Sthorpej# user.
151.76Sgmcgarry.if defined(HAVE_GCC)
161.37Sfvdl.if ${MACHINE_ARCH} == "x86_64"
171.58SthorpejCPUFLAGS= -m32
181.37Sfvdl.else
191.63Smrg.if ${HAVE_GCC} == 3
201.63SmrgCPUFLAGS=  -mcpu=i386
211.63Smrg.else
221.81SjakllschCPUFLAGS=  -march=i386 -mtune=i386
231.63Smrg.endif
241.37Sfvdl.endif
251.76Sgmcgarry.endif
261.58SthorpejCOPTS=	-Os -ffreestanding
271.1Sperry
281.8SdrochnerI386_STAND_DIR?= $S/arch/i386/stand
291.8Sdrochner
301.52Sdsl.PATH: ${I386_STAND_DIR}/lib
311.32Sthorpej
321.16SchristosROMSTART= start_rom.o
331.8SdrochnerGENPROMDIR= ${I386_STAND_DIR}/genprom
341.32SthorpejGENPROMOBJDIR!= cd ${GENPROMDIR} && ${PRINTOBJDIR}
351.32SthorpejGENPROM= ${GENPROMOBJDIR}/genprom
361.32Sthorpej
371.8Sdrochner.PATH: ${I386_STAND_DIR}/lib/crt/dos
381.16SchristosDOSSTART= start_dos.o doscommain.o
391.32Sthorpej
401.31Sthorpej.PATH: ${I386_STAND_DIR}/lib/crt/pxe
411.31SthorpejPXESTART= start_pxe.o
421.1Sperry
431.70SyamtCPPFLAGS+= -nostdinc -I${.OBJDIR} -I$S -I${I386_STAND_DIR}/lib -I$S/lib/libsa
441.5SdrochnerCPPFLAGS+= -D_STANDALONE
451.68SlukemLDFLAGS+=  -nostdlib
461.37Sfvdl
471.37Sfvdl# XXX
481.37Sfvdl.if ${MACHINE_ARCH} == "x86_64"
491.37SfvdlCPPFLAGS+=-m32
501.68SlukemLDFLAGS+=-Wl,-m,elf_i386
511.37SfvdlLIBKERN_ARCH=i386
521.37SfvdlKERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
531.37Sfvdl.endif
541.1Sperry
551.41SdslCLEANFILES+= ${STARTFILE} vers.c ${BASE}.list
561.26SjdolecekSRCS+=	vers.c
571.7Sthorpej
581.44SdrochnerCLEANFILES+= machine x86
591.6Sdrochner
601.61Schs.if !make(obj) && !make(clean) && !make(cleandir)
611.61Schs.BEGIN:
621.61Schs	-rm -f machine && ln -s $S/arch/i386/include machine
631.61Schs	-rm -f x86 && ln -s $S/arch/x86/include x86
641.53Sdsl.ifdef LIBOBJ
651.61Schs	-rm -f lib && ln -s ${LIBOBJ}/lib lib
661.61Schs	mkdir -p ${LIBOBJ}/lib
671.61Schs.endif
681.53Sdsl.endif
691.6Sdrochner
701.1Sperry### find out what to use for libkern
711.1SperryKERN_AS=	library
721.1Sperry.include "${S}/lib/libkern/Makefile.inc"
731.1SperryLIBKERN=	${KERNLIB}
741.1Sperry
751.1Sperry### find out what to use for libz
761.1SperryZ_AS=		library
771.1Sperry.include "${S}/lib/libz/Makefile.inc"
781.1SperryLIBZ=		${ZLIB}
791.1Sperry
801.1Sperry### find out what to use for libsa
811.1SperrySA_AS=		library
821.22SchristosSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
831.1Sperry.include "${S}/lib/libsa/Makefile.inc"
841.1SperryLIBSA=		${SALIB}
851.1Sperry
861.1Sperry### find out what to use for libi386
871.8SdrochnerI386DIR= ${I386_STAND_DIR}/lib
881.1Sperry.include "${I386DIR}/Makefile.inc"
891.1SperryLIBI386=		${I386LIB}
901.17Stron
911.79Sdhollandcleandir distclean: .WAIT cleanlibdir
921.17Stron
931.17Stroncleanlibdir:
941.57Sjmc	-rm -rf lib
951.16Schristos
961.68SlukemLDFLAGS+=-Wl,-M -Wl,-e,start 	# -N does not work properly.
971.16Schristos
981.22SchristosLIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
991.22Schristos
1001.78Stsutsuivers.c: ${VERSIONFILE} ${SOURCES} ${S}/conf/newvers_stand.sh
1011.78Stsutsui	${HOST_SH} ${S}/conf/newvers_stand.sh -DM ${VERSIONFILE} x86 ${NEWVERSWHAT}
1021.7Sthorpej
1031.32SthorpejCLEANFILES+= ${BASE}.sym
1041.32Sthorpej${BASE}.sym: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
1051.64Slukem	${_MKTARGET_LINK}
1061.68Slukem	${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
1071.39Sdsl	    ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
1081.32Sthorpej
1091.65SlukemCLEANFILES+= ${BASE}.rom ${BASE}.rom.tmp
1101.32Sthorpej${BASE}.rom: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
1111.64Slukem	${_MKTARGET_LINK}
1121.68Slukem	${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
1131.68Slukem	    ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
1141.65Slukem	${OBJCOPY} -O binary ${BASE}.sym ${BASE}.rom.tmp
1151.65Slukem	${GENPROM} ${ROM_SIZE} < ${BASE}.rom.tmp > ${BASE}.rom || \
1161.32Sthorpej	    rm -f ${BASE}.rom
1171.65Slukem	rm -f ${BASE}.rom.tmp
1181.9Sdrochner
1191.32SthorpejCLEANFILES+= ${BASE}.com
1201.32Sthorpej${BASE}.com: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
1211.64Slukem	${_MKTARGET_LINK}
1221.68Slukem	${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
1231.68Slukem	    ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
1241.32Sthorpej	${OBJCOPY} -O binary ${BASE}.sym ${BASE}.com
1251.32Sthorpej
1261.32SthorpejCLEANFILES+= ${BASE}.bin
1271.32Sthorpej${BASE}.bin: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
1281.64Slukem	${_MKTARGET_LINK}
1291.68Slukem	${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
1301.68Slukem	    ${STARTFILE} ${OBJS} ${LIBLIST} > ${BASE}.list
1311.32Sthorpej	${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin
1321.9Sdrochner
1331.9Sdrochner.include <bsd.prog.mk>
134