1 # $FreeBSD: src/sys/boot/i386/loader/Makefile,v 1.66 2003/06/26 03:51:57 peter Exp $
2 # $DragonFly: src/sys/boot/pc32/loader/Makefile,v 1.11 2005/09/03 23:52:49 dillon Exp $
7 NEWVERSWHAT= "bootstrap loader" i386
11 # Notes: the 'loader' client is brought in with a virtual base of (typically)
12 # 0xa000 and a code offset of 0x0. The btxldr is loaded at 0x200000 (?).
14 # MEM_BTX_USR_ARG is not used in the boot2->loader stage, only in the
15 # boot1->boot2 stage (XXX what about the use in cdboot and pxeboot?)
19 # architecture-specific loader code
22 CFLAGS+= -ffreestanding
23 # Enable PXE TFTP or NFS support, not both.
24 #CFLAGS+= -DLOADER_TFTP_SUPPORT
25 CFLAGS+= -DLOADER_NFS_SUPPORT
27 # Enable PnP and ISA-PnP code.
32 CFLAGS+= -I${.CURDIR}/../../dloader -I${.CURDIR}/../../dloader/i386
33 .if exists(${.OBJDIR}/../../dloader/libdloader.a)
34 LIBDLOADER= ${.OBJDIR}/../../dloader/libdloader.a
36 LIBDLOADER= ${.CURDIR}/../../dloader/libdloader.a
39 .if defined(LOADER_BZIP2_SUPPORT)
40 CFLAGS+= -DLOADER_BZIP2_SUPPORT
42 .if !defined(LOADER_NO_GZIP_SUPPORT)
43 CFLAGS+= -DLOADER_GZIP_SUPPORT
46 # Always add MI sources
47 .PATH: ${.CURDIR}/../../common
48 .include <${.CURDIR}/../../common/Makefile.inc>
49 CFLAGS+= -I${.CURDIR}/../../common
50 CFLAGS+= -I${.CURDIR}/../../.. -I.
52 CLEANFILES+= vers.c vers.o ${PROG}.list ${PROG}.bin ${PROG}.sym ${PROG}.help
55 LDFLAGS= -nostdlib -static -Ttext ${ORG}
57 # i386 standalone support library
58 LIBI386= ${.OBJDIR}/../libi386/libi386.a
59 CFLAGS+= -I${.CURDIR}/..
61 # where to get libstand from
62 #XXX need a better way to do this
63 LIBSTAND= ${.CURDIR}/../../../../lib/libstand/libstand.a
64 .if !exists(${LIBSTAND})
65 LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
66 .if !exists(${LIBSTAND})
70 CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
73 .if exists(${.OBJDIR}/../btx)
74 BTXDIR= ${.OBJDIR}/../btx
76 BTXDIR= ${.CURDIR}/../btx
78 BTXLDR= ${BTXDIR}/btxldr/btxldr
79 BTXKERN= ${BTXDIR}/btx/btx
80 BTXCRT= ${BTXDIR}/lib/crt0.o
81 CFLAGS+= -I${.CURDIR}/../btx/lib
83 # BTX is expecting ELF components
90 vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
91 sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
92 ${CC} ${CFLAGS} -c vers.c
94 ${PROG}: ${PROG}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
95 btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
96 -b ${BTXKERN} ${PROG}.bin
97 # /usr/bin/kzip ${.TARGET}
98 # mv ${.TARGET}.kz ${.TARGET}
100 ${PROG}.bin: ${PROG}.sym
101 cp ${.ALLSRC} ${.TARGET}
102 strip -R .comment -R .note ${.TARGET}
104 ${PROG}.help: help.common help.i386
105 cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
107 .PATH: ${.CURDIR}/../../dloader
108 FILES= ${PROG}.help loader.conf loader-bootp.conf dloader.menu
109 FILESDIR_loader.conf= /boot/defaults
110 FILESDIR_loader-bootp.conf= /boot/defaults
111 FILESDIR_dloader.menu= /boot/defaults
113 .if !exists(${DESTDIR}/boot/dloader.rc)
114 FILES+= ${.CURDIR}/dloader.rc
117 .include "../Makefile.inc"
119 # Cannot use ${OBJS} above this line
120 .include <bsd.prog.mk>
122 ${PROG}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBDLOADER} vers.o
123 ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
124 ${LIBDLOADER} ${LIBI386} ${LIBSTAND}
126 # If it's not there, don't consider it a target
127 .if exists(${.CURDIR}/../../../i386/include)
128 beforedepend ${OBJS}: machine
131 ${LN} -sf ${.CURDIR}/../../../i386/include machine