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