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