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