Tweak some makefiles to prepare for bmake
[dragonfly.git] / sys / boot / pc32 / loader / Makefile
CommitLineData
5ee58eed 1# $FreeBSD: src/sys/boot/i386/loader/Makefile,v 1.66 2003/06/26 03:51:57 peter Exp $
cacaceec 2#
984263bc 3
a8440c4d 4PROG= loader
984263bc
MD
5STRIP=
6NEWVERSWHAT= "bootstrap loader" i386
7BINDIR?= /boot
8INSTALLFLAGS= -b
9
cacaceec
MD
10# Notes: the 'loader' client is brought in with a virtual base of (typically)
11# 0xa000 and a code offset of 0x0. The btxldr is loaded at 0x200000 (?).
12#
13# MEM_BTX_USR_ARG is not used in the boot2->loader stage, only in the
14# boot1->boot2 stage (XXX what about the use in cdboot and pxeboot?)
15#
cacaceec 16
984263bc
MD
17# architecture-specific loader code
18SRCS= main.c conf.c
19
20# Enable PXE TFTP or NFS support, not both.
423d6aa0 21#CFLAGS+= -DLOADER_TFTP_SUPPORT
984263bc 22CFLAGS+= -DLOADER_NFS_SUPPORT
984263bc
MD
23
24# Enable PnP and ISA-PnP code.
25HAVE_PNP= yes
26HAVE_ISABUS= yes
27
116b7e3c
MD
28BOOT_DLOADER= yes
29CFLAGS+= -I${.CURDIR}/../../dloader -I${.CURDIR}/../../dloader/i386
30.if exists(${.OBJDIR}/../../dloader/libdloader.a)
31LIBDLOADER= ${.OBJDIR}/../../dloader/libdloader.a
984263bc 32.else
116b7e3c 33LIBDLOADER= ${.CURDIR}/../../dloader/libdloader.a
984263bc 34.endif
984263bc
MD
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
a8440c4d 49CLEANFILES+= vers.c vers.o ${PROG}.list ${PROG}.bin ${PROG}.sym ${PROG}.help
984263bc 50
4849597a 51CFLAGS+= -Wall
208fbaaf
JM
52COMPILER_LDFLAGS= -nostdlib -static
53COMPILER_LDFLAGS+= -Wl,--script,${.CURDIR}/loader.ldscript
984263bc
MD
54
55# i386 standalone support library
56LIBI386= ${.OBJDIR}/../libi386/libi386.a
57CFLAGS+= -I${.CURDIR}/..
58
59# where to get libstand from
60#XXX need a better way to do this
61LIBSTAND= ${.CURDIR}/../../../../lib/libstand/libstand.a
62.if !exists(${LIBSTAND})
63LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
64.if !exists(${LIBSTAND})
65LIBSTAND= -lstand
66.endif
67.endif
68CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
69
70# BTX components
71.if exists(${.OBJDIR}/../btx)
72BTXDIR= ${.OBJDIR}/../btx
73.else
74BTXDIR= ${.CURDIR}/../btx
75.endif
76BTXLDR= ${BTXDIR}/btxldr/btxldr
77BTXKERN= ${BTXDIR}/btx/btx
78BTXCRT= ${BTXDIR}/lib/crt0.o
79CFLAGS+= -I${.CURDIR}/../btx/lib
80
984263bc
MD
81# Debug me!
82#CFLAGS+= -g
984263bc 83
a8a5ffd4 84vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
984263bc 85 sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
a8a5ffd4
JM
86
87vers.o: vers.c
5ee58eed 88 ${CC} ${CFLAGS} -c vers.c
984263bc 89
a8440c4d 90${PROG}: ${PROG}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
984263bc 91 btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
a8440c4d 92 -b ${BTXKERN} ${PROG}.bin
984263bc 93
a8440c4d 94${PROG}.bin: ${PROG}.sym
984263bc 95 cp ${.ALLSRC} ${.TARGET}
208fbaaf 96 strip -R .comment -R .note -R .note.gnu.gold-version ${.TARGET}
984263bc 97
a8440c4d 98${PROG}.help: help.common help.i386
984263bc
MD
99 cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
100
116b7e3c
MD
101.PATH: ${.CURDIR}/../../dloader
102FILES= ${PROG}.help loader.conf loader-bootp.conf dloader.menu
5ee58eed 103FILESDIR_loader.conf= /boot/defaults
8a6873dc 104FILESDIR_loader-bootp.conf= /boot/defaults
116b7e3c 105FILESDIR_dloader.menu= /boot/defaults
5ee58eed 106
116b7e3c
MD
107.if !exists(${DESTDIR}/boot/dloader.rc)
108FILES+= ${.CURDIR}/dloader.rc
984263bc 109.endif
984263bc 110
cd97d47d 111.include "../Makefile.inc"
984263bc
MD
112
113# Cannot use ${OBJS} above this line
114.include <bsd.prog.mk>
115
116b7e3c 116${PROG}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBDLOADER} vers.o
4849597a 117 ${CC} ${COMPILER_LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
116b7e3c 118 ${LIBDLOADER} ${LIBI386} ${LIBSTAND}
984263bc
MD
119
120# If it's not there, don't consider it a target
121.if exists(${.CURDIR}/../../../i386/include)
122beforedepend ${OBJS}: machine
123
124machine:
062db326 125 ${LN} -sf ${.CURDIR}/../../../i386/include machine
984263bc
MD
126
127.endif
128
129CLEANFILES+= machine