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