libstand: Build libstand for x86_64, and libstand32 for the bios loader.
[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 #
3
4 PROG=           loader
5 STRIP=
6 NEWVERSWHAT=    "bootstrap loader" i386
7 BINDIR?=        /boot
8 INSTALLFLAGS=   -b
9
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 #
16
17 # architecture-specific loader code
18 SRCS=           main.c conf.c
19
20 # Enable PXE TFTP or NFS support, not both.
21 #CFLAGS+=       -DLOADER_TFTP_SUPPORT
22 CFLAGS+=        -DLOADER_NFS_SUPPORT
23
24 # Enable PnP and ISA-PnP code.
25 HAVE_PNP=       yes
26 HAVE_ISABUS=    yes
27
28 BOOT_DLOADER=   yes
29 CFLAGS+=        -I${.CURDIR}/../../dloader
30 .if exists(${.OBJDIR}/../../dloader/libdloader.a)
31 LIBDLOADER=     ${.OBJDIR}/../../dloader/libdloader.a
32 .else
33 LIBDLOADER=     ${.CURDIR}/../../dloader/libdloader.a
34 .endif
35
36 .if defined(LOADER_BZIP2_SUPPORT)
37 CFLAGS+=        -DLOADER_BZIP2_SUPPORT
38 .endif
39 .if !defined(LOADER_NO_GZIP_SUPPORT)
40 CFLAGS+=        -DLOADER_GZIP_SUPPORT
41 .endif
42
43 # Always add MI sources 
44 .PATH:          ${.CURDIR}/../../common
45 .include        <${.CURDIR}/../../common/Makefile.inc>
46 CFLAGS+=        -I${.CURDIR}/../../common
47 CFLAGS+=        -I${.CURDIR}/../../.. -I.
48
49 CLEANFILES+=    vers.c vers.o ${PROG}.list ${PROG}.bin ${PROG}.sym ${PROG}.help
50
51 CFLAGS+=                -Wall
52 COMPILER_LDFLAGS=       -nostdlib -static
53 COMPILER_LDFLAGS+=      -Wl,--script,${.CURDIR}/loader.ldscript
54
55 # i386 standalone support library
56 LIBI386=        ${.OBJDIR}/../libi386/libi386.a
57 CFLAGS+=        -I${.CURDIR}/..
58
59 # where to get libstand from
60 #XXX need a better way to do this
61 LIBSTAND=       ${.CURDIR}/../../libstand32/libstand32.a
62 .if !exists(${LIBSTAND})
63 LIBSTAND=       ${.OBJDIR}/../../libstand32/libstand32.a
64 .endif
65 CFLAGS+=        -I${.CURDIR}/../../../../lib/libstand/
66
67 # BTX components
68 .if exists(${.OBJDIR}/../btx)
69 BTXDIR=         ${.OBJDIR}/../btx
70 .else
71 BTXDIR=         ${.CURDIR}/../btx
72 .endif
73 BTXLDR=         ${BTXDIR}/btxldr/btxldr
74 BTXKERN=        ${BTXDIR}/btx/btx
75 BTXCRT=         ${BTXDIR}/lib/crt0.o
76 CFLAGS+=        -I${.CURDIR}/../btx/lib
77
78 # Debug me!
79 #CFLAGS+=       -g
80
81 vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
82         sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
83
84 vers.o: vers.c
85         ${CC} ${CFLAGS} -c vers.c
86
87 ${PROG}: ${PROG}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
88         btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
89                 -b ${BTXKERN} ${PROG}.bin
90
91 ${PROG}.bin: ${PROG}.sym
92         cp ${.ALLSRC} ${.TARGET}
93         strip -R .comment -R .note -R .note.gnu.gold-version ${.TARGET}
94
95 ${PROG}.help: help.common help.i386
96         cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
97
98 .PATH: ${.CURDIR}/../../dloader
99 FILES=  ${PROG}.help loader.conf loader-bootp.conf dloader.menu
100 FILESDIR_loader.conf=   /boot/defaults
101 FILESDIR_loader-bootp.conf=     /boot/defaults
102 FILESDIR_dloader.menu=  /boot/defaults
103
104 .if !exists(${DESTDIR}/boot/dloader.rc)
105 FILES+= ${.CURDIR}/dloader.rc
106 .endif
107
108 .include "../Makefile.inc"
109
110 # Cannot use ${OBJS} above this line
111 .include <bsd.prog.mk>
112
113 ${PROG}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBDLOADER} vers.o
114         ${CC} ${COMPILER_LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
115                 ${LIBDLOADER} ${LIBI386} ${LIBSTAND}