Makefile revision 83368
1# $FreeBSD: head/sys/boot/i386/loader/Makefile 83368 2001-09-12 10:25:50Z ru $
2
3BASE=		loader
4PROG=		${BASE}
5#NOMAN=
6STRIP=
7NEWVERSWHAT=	"bootstrap loader" i386
8BINDIR?=	/boot
9INSTALLFLAGS=	-b
10
11# architecture-specific loader code
12SRCS=		main.c conf.c
13
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# Always add MI sources 
37.PATH:		${.CURDIR}/../../common
38.include	<${.CURDIR}/../../common/Makefile.inc>
39CFLAGS+=	-I${.CURDIR}/../../common
40CFLAGS+=	-I${.CURDIR}/../../.. -I.
41
42CLEANFILES+=	vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
43
44CFLAGS+=	-Wall
45LDFLAGS=	-nostdlib -static -Ttext 0x0
46
47# i386 standalone support library
48LIBI386=	${.OBJDIR}/../libi386/libi386.a
49CFLAGS+=	-I${.CURDIR}/..
50
51# where to get libstand from
52#XXX need a better way to do this
53LIBSTAND=	${.CURDIR}/../../../../lib/libstand/libstand.a
54.if !exists(${LIBSTAND})
55LIBSTAND=	${.OBJDIR}/../../../../lib/libstand/libstand.a
56.if !exists(${LIBSTAND})
57LIBSTAND=	-lstand
58.endif
59.endif
60CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
61
62# BTX components
63.if exists(${.OBJDIR}/../btx)
64BTXDIR=		${.OBJDIR}/../btx
65.else
66BTXDIR=		${.CURDIR}/../btx
67.endif
68BTXLDR=		${BTXDIR}/btxldr/btxldr
69BTXKERN=	${BTXDIR}/btx/btx
70BTXCRT=		${BTXDIR}/lib/crt0.o
71CFLAGS+=	-I${.CURDIR}/../btx/lib
72
73# BTX is expecting ELF components
74CFLAGS+=	-elf
75
76# Debug me!
77#CFLAGS+=	-g
78#LDFLAGS+=	-g
79
80vers.o:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
81	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
82	${CC} -c vers.c
83
84${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT} ${BASE}.help
85	btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
86		-b ${BTXKERN} ${BASE}.bin
87#	/usr/bin/kzip ${.TARGET}
88#	mv ${.TARGET}.kz ${.TARGET}
89
90${BASE}.bin: ${BASE}.sym
91	cp ${.ALLSRC} ${.TARGET}
92	strip -R .comment -R .note ${.TARGET}
93
94${BASE}.help: help.common help.i386
95	cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
96
97beforeinstall:
98.if exists(${.OBJDIR}/loader.help)
99	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
100		${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
101.else
102	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
103		${.CURDIR}/${BASE}.help ${DESTDIR}/boot
104.endif
105.if !exists(${DESTDIR}/boot/loader.rc)
106	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
107		${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
108.endif
109	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
110		${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
111	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
112		${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
113	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
114		${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
115
116.include <${.CURDIR}/../Makefile.inc>
117
118# Cannot use ${OBJS} above this line
119.include <bsd.prog.mk>
120
121${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
122	${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
123		${LIBFICL} ${LIBI386} ${LIBSTAND}
124
125# If it's not there, don't consider it a target
126.if exists(${.CURDIR}/../../../i386/include)
127beforedepend ${OBJS}: machine
128
129machine:
130	ln -sf ${.CURDIR}/../../../i386/include machine
131
132.endif
133
134CLEANFILES+=	machine
135