Makefile.booters revision 1.71
1# $NetBSD: Makefile.booters,v 1.71 2007/09/27 00:13:17 ad Exp $ 2 3.include <bsd.own.mk> 4 5STRIPFLAG= 6BINMODE=444 7 8LIBCRT0= # nothing 9LIBCRTBEGIN= # nothing 10LIBCRTEND= # nothing 11LIBC= # nothing 12 13# Make sure we override any optimization options specified by the 14# user. 15.if ${MACHINE_ARCH} == "x86_64" 16CPUFLAGS= -m32 17.if ${HAVE_GCC} != 3 18CPUFLAGS+= -Wno-attributes 19.endif 20.else 21.if ${HAVE_GCC} == 3 22CPUFLAGS= -mcpu=i386 23.else 24CPUFLAGS= -march=i386 -mtune=i386 -Wno-attributes 25.endif 26.endif 27# CPPFLAGS+= -DBOOT_ELF64 28COPTS= -Os -ffreestanding 29 30I386_STAND_DIR?= $S/arch/i386/stand 31 32.PATH: ${I386_STAND_DIR}/lib 33 34ROMSTART= start_rom.o 35GENPROMDIR= ${I386_STAND_DIR}/genprom 36GENPROMOBJDIR!= cd ${GENPROMDIR} && ${PRINTOBJDIR} 37GENPROM= ${GENPROMOBJDIR}/genprom 38 39.PATH: ${I386_STAND_DIR}/lib/crt/dos 40DOSSTART= start_dos.o doscommain.o 41 42.PATH: ${I386_STAND_DIR}/lib/crt/pxe 43PXESTART= start_pxe.o 44 45CPPFLAGS+= -nostdinc -I${.OBJDIR} -I$S -I${I386_STAND_DIR}/lib -I$S/lib/libsa 46CPPFLAGS+= -D_STANDALONE 47LDFLAGS+= -nostdlib 48 49# XXX 50.if ${MACHINE_ARCH} == "x86_64" 51CPPFLAGS+=-m32 52LDFLAGS+=-Wl,-m,elf_i386 53LIBKERN_ARCH=i386 54KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 55.endif 56 57CLEANFILES+= ${STARTFILE} vers.c ${BASE}.list 58SRCS+= vers.c 59 60CLEANFILES+= machine x86 61 62.if !make(obj) && !make(clean) && !make(cleandir) 63.BEGIN: 64 -rm -f machine && ln -s $S/arch/i386/include machine 65 -rm -f x86 && ln -s $S/arch/x86/include x86 66.ifdef LIBOBJ 67 -rm -f lib && ln -s ${LIBOBJ}/lib lib 68 mkdir -p ${LIBOBJ}/lib 69.endif 70.endif 71 72### find out what to use for libkern 73KERN_AS= library 74.include "${S}/lib/libkern/Makefile.inc" 75LIBKERN= ${KERNLIB} 76 77### find out what to use for libz 78Z_AS= library 79.include "${S}/lib/libz/Makefile.inc" 80LIBZ= ${ZLIB} 81 82### find out what to use for libsa 83SA_AS= library 84SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 85.include "${S}/lib/libsa/Makefile.inc" 86LIBSA= ${SALIB} 87 88### find out what to use for libi386 89I386DIR= ${I386_STAND_DIR}/lib 90.include "${I386DIR}/Makefile.inc" 91LIBI386= ${I386LIB} 92 93cleandir distclean: cleanlibdir 94 95cleanlibdir: 96 -rm -rf lib 97 98.if ${OBJECT_FMT} == "ELF" 99LDFLAGS+=-Wl,-M -Wl,-e,start # -N does not work properly. 100.else 101LDFLAGS+=-Wl,-N -Wl,-M -Wl,-e,_start 102.endif 103 104LIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} 105 106vers.c: ${VERSIONFILE} ${SOURCES} 107 ${HOST_SH} ${S}conf/newvers_stand.sh ${.ALLSRC} x86 ${NEWVERSWHAT} 108 109CLEANFILES+= ${BASE}.sym 110${BASE}.sym: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 111 ${_MKTARGET_LINK} 112 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \ 113 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list 114 115CLEANFILES+= ${BASE}.rom ${BASE}.rom.tmp 116${BASE}.rom: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 117 ${_MKTARGET_LINK} 118 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \ 119 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list 120 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.rom.tmp 121 ${GENPROM} ${ROM_SIZE} < ${BASE}.rom.tmp > ${BASE}.rom || \ 122 rm -f ${BASE}.rom 123 rm -f ${BASE}.rom.tmp 124 125CLEANFILES+= ${BASE}.com 126${BASE}.com: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 127 ${_MKTARGET_LINK} 128 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \ 129 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list 130 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.com 131 132CLEANFILES+= ${BASE}.bin 133${BASE}.bin: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 134 ${_MKTARGET_LINK} 135 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \ 136 ${STARTFILE} ${OBJS} ${LIBLIST} > ${BASE}.list 137 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin 138 139.include <bsd.prog.mk> 140