Merge branch 'vendor/CVS'
[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 BOOT_DLOADER=   yes
32 CFLAGS+=        -I${.CURDIR}/../../dloader -I${.CURDIR}/../../dloader/i386
33 .if exists(${.OBJDIR}/../../dloader/libdloader.a)
34 LIBDLOADER=     ${.OBJDIR}/../../dloader/libdloader.a
35 .else
36 LIBDLOADER=     ${.CURDIR}/../../dloader/libdloader.a
37 .endif
38
39 .if defined(LOADER_BZIP2_SUPPORT)
40 CFLAGS+=        -DLOADER_BZIP2_SUPPORT
41 .endif
42 .if !defined(LOADER_NO_GZIP_SUPPORT)
43 CFLAGS+=        -DLOADER_GZIP_SUPPORT
44 .endif
45
46 # Always add MI sources 
47 .PATH:          ${.CURDIR}/../../common
48 .include        <${.CURDIR}/../../common/Makefile.inc>
49 CFLAGS+=        -I${.CURDIR}/../../common
50 CFLAGS+=        -I${.CURDIR}/../../.. -I.
51
52 CLEANFILES+=    vers.c vers.o ${PROG}.list ${PROG}.bin ${PROG}.sym ${PROG}.help
53
54 CFLAGS+=        -Wall
55 LDFLAGS=        -nostdlib -static -Ttext ${ORG}
56
57 # i386 standalone support library
58 LIBI386=        ${.OBJDIR}/../libi386/libi386.a
59 CFLAGS+=        -I${.CURDIR}/..
60
61 # where to get libstand from
62 #XXX need a better way to do this
63 LIBSTAND=       ${.CURDIR}/../../../../lib/libstand/libstand.a
64 .if !exists(${LIBSTAND})
65 LIBSTAND=       ${.OBJDIR}/../../../../lib/libstand/libstand.a
66 .if !exists(${LIBSTAND})
67 LIBSTAND=       -lstand
68 .endif
69 .endif
70 CFLAGS+=        -I${.CURDIR}/../../../../lib/libstand/
71
72 # BTX components
73 .if exists(${.OBJDIR}/../btx)
74 BTXDIR=         ${.OBJDIR}/../btx
75 .else
76 BTXDIR=         ${.CURDIR}/../btx
77 .endif
78 BTXLDR=         ${BTXDIR}/btxldr/btxldr
79 BTXKERN=        ${BTXDIR}/btx/btx
80 BTXCRT=         ${BTXDIR}/lib/crt0.o
81 CFLAGS+=        -I${.CURDIR}/../btx/lib
82
83 # BTX is expecting ELF components
84 CFLAGS+=        -elf
85
86 # Debug me!
87 #CFLAGS+=       -g
88 #LDFLAGS+=      -g
89
90 vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
91         sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
92         ${CC} ${CFLAGS} -c vers.c
93
94 ${PROG}: ${PROG}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
95         btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
96                 -b ${BTXKERN} ${PROG}.bin
97 #       /usr/bin/kzip ${.TARGET}
98 #       mv ${.TARGET}.kz ${.TARGET}
99
100 ${PROG}.bin: ${PROG}.sym
101         cp ${.ALLSRC} ${.TARGET}
102         strip -R .comment -R .note ${.TARGET}
103
104 ${PROG}.help: help.common help.i386
105         cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
106
107 .PATH: ${.CURDIR}/../../dloader
108 FILES=  ${PROG}.help loader.conf loader-bootp.conf dloader.menu
109 FILESDIR_loader.conf=   /boot/defaults
110 FILESDIR_loader-bootp.conf=     /boot/defaults
111 FILESDIR_dloader.menu=  /boot/defaults
112
113 .if !exists(${DESTDIR}/boot/dloader.rc)
114 FILES+= ${.CURDIR}/dloader.rc
115 .endif
116
117 .include "../Makefile.inc"
118
119 # Cannot use ${OBJS} above this line
120 .include <bsd.prog.mk>
121
122 ${PROG}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBDLOADER} vers.o
123         ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
124                 ${LIBDLOADER} ${LIBI386} ${LIBSTAND}
125
126 # If it's not there, don't consider it a target
127 .if exists(${.CURDIR}/../../../i386/include)
128 beforedepend ${OBJS}: machine
129
130 machine:
131         ${LN} -sf ${.CURDIR}/../../../i386/include machine
132
133 .endif
134
135 CLEANFILES+=    machine