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