Makefile revision 102591
1# $FreeBSD: head/sys/boot/i386/loader/Makefile 102591 2002-08-29 23:37:44Z peter $
2
3BASE=		loader
4PROG=		${BASE}
5STRIP=
6NEWVERSWHAT=	"bootstrap loader" i386
7BINDIR?=	/boot
8INSTALLFLAGS=	-b
9
10# architecture-specific loader code
11SRCS=		main.c conf.c
12
13CFLAGS+=	-ffreestanding
14# Enable PXE TFTP or NFS support, not both.
15.if defined(LOADER_TFTP_SUPPORT)
16CFLAGS+=	-DLOADER_TFTP_SUPPORT
17.else
18CFLAGS+=	-DLOADER_NFS_SUPPORT
19.endif
20
21# Enable PnP and ISA-PnP code.
22HAVE_PNP=	yes
23HAVE_ISABUS=	yes
24
25.if !defined(NOFORTH)
26# Enable BootForth
27BOOT_FORTH=	yes
28CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386
29.if exists(${.OBJDIR}/../../ficl/libficl.a)
30LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
31.else
32LIBFICL=	${.CURDIR}/../../ficl/libficl.a
33.endif
34.endif
35
36.if defined(LOADER_BZIP2_SUPPORT)
37CFLAGS+=	-DLOADER_BZIP2_SUPPORT
38.endif
39.if !defined(LOADER_NO_GZIP_SUPPORT)
40CFLAGS+=	-DLOADER_GZIP_SUPPORT
41.endif
42
43# Always add MI sources 
44.PATH:		${.CURDIR}/../../common
45.include	<${.CURDIR}/../../common/Makefile.inc>
46CFLAGS+=	-I${.CURDIR}/../../common
47CFLAGS+=	-I${.CURDIR}/../../.. -I.
48
49CLEANFILES+=	vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
50
51CFLAGS+=	-Wall
52LDFLAGS=	-nostdlib -static -Ttext 0x0
53
54# i386 standalone support library
55LIBI386=	${.OBJDIR}/../libi386/libi386.a
56CFLAGS+=	-I${.CURDIR}/..
57
58# where to get libstand from
59#XXX need a better way to do this
60LIBSTAND=	${.CURDIR}/../../../../lib/libstand/libstand.a
61.if !exists(${LIBSTAND})
62LIBSTAND=	${.OBJDIR}/../../../../lib/libstand/libstand.a
63.if !exists(${LIBSTAND})
64LIBSTAND=	-lstand
65.endif
66.endif
67CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
68
69# BTX components
70.if exists(${.OBJDIR}/../btx)
71BTXDIR=		${.OBJDIR}/../btx
72.else
73BTXDIR=		${.CURDIR}/../btx
74.endif
75BTXLDR=		${BTXDIR}/btxldr/btxldr
76BTXKERN=	${BTXDIR}/btx/btx
77BTXCRT=		${BTXDIR}/lib/crt0.o
78CFLAGS+=	-I${.CURDIR}/../btx/lib
79
80# BTX is expecting ELF components
81CFLAGS+=	-elf
82
83# Debug me!
84#CFLAGS+=	-g
85#LDFLAGS+=	-g
86
87vers.o:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
88	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
89	${CC} -c vers.c
90
91${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
92	btxld -v -f elf -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
93		-b ${BTXKERN} ${BASE}.bin
94#	/usr/bin/kzip ${.TARGET}
95#	mv ${.TARGET}.kz ${.TARGET}
96
97${BASE}.bin: ${BASE}.sym
98	cp ${.ALLSRC} ${.TARGET}
99	strip -R .comment -R .note ${.TARGET}
100
101${BASE}.help: help.common help.i386
102	cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
103
104.PATH: ${.CURDIR}/../../forth 
105FILES=	${BASE}.help loader.4th support.4th loader.conf
106FILESDIR_loader.conf=	/boot/defaults
107
108.if !exists(${DESTDIR}/boot/loader.rc)
109FILES+=	loader.rc
110.endif
111
112.include <${.CURDIR}/../Makefile.inc>
113
114# Cannot use ${OBJS} above this line
115.include <bsd.prog.mk>
116
117${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
118	${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
119		${LIBFICL} ${LIBI386} ${LIBSTAND}
120
121# If it's not there, don't consider it a target
122.if exists(${.CURDIR}/../../../i386/include)
123beforedepend ${OBJS}: machine
124
125machine:
126	ln -sf ${.CURDIR}/../../../i386/include machine
127
128.endif
129
130CLEANFILES+=	machine
131