Rename Makefile.in to Makefile.sub
[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.4 2004/01/26 19:49:32 joerg Exp $
3
4 PROG=           loader
5 STRIP=
6 NEWVERSWHAT=    "bootstrap loader" i386
7 BINDIR?=        /boot
8 INSTALLFLAGS=   -b
9
10 # architecture-specific loader code
11 SRCS=           main.c conf.c
12
13 CFLAGS+=        -ffreestanding
14 # Enable PXE TFTP or NFS support, not both.
15 .if defined(LOADER_TFTP_SUPPORT)
16 CFLAGS+=        -DLOADER_TFTP_SUPPORT
17 .else
18 CFLAGS+=        -DLOADER_NFS_SUPPORT
19 .endif
20
21 # Enable PnP and ISA-PnP code.
22 HAVE_PNP=       yes
23 HAVE_ISABUS=    yes
24
25 .if !defined(NOFORTH)
26 # Enable BootForth
27 BOOT_FORTH=     yes
28 CFLAGS+=        -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386
29 .if exists(${.OBJDIR}/../../ficl/libficl.a)
30 LIBFICL=        ${.OBJDIR}/../../ficl/libficl.a
31 .else
32 LIBFICL=        ${.CURDIR}/../../ficl/libficl.a
33 .endif
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 LDFLAGS=        -nostdlib -static -Ttext 0x0
53
54 # i386 standalone support library
55 LIBI386=        ${.OBJDIR}/../libi386/libi386.a
56 CFLAGS+=        -I${.CURDIR}/..
57
58 # where to get libstand from
59 #XXX need a better way to do this
60 LIBSTAND=       ${.CURDIR}/../../../../lib/libstand/libstand.a
61 .if !exists(${LIBSTAND})
62 LIBSTAND=       ${.OBJDIR}/../../../../lib/libstand/libstand.a
63 .if !exists(${LIBSTAND})
64 LIBSTAND=       -lstand
65 .endif
66 .endif
67 CFLAGS+=        -I${.CURDIR}/../../../../lib/libstand/
68
69 # BTX components
70 .if exists(${.OBJDIR}/../btx)
71 BTXDIR=         ${.OBJDIR}/../btx
72 .else
73 BTXDIR=         ${.CURDIR}/../btx
74 .endif
75 BTXLDR=         ${BTXDIR}/btxldr/btxldr
76 BTXKERN=        ${BTXDIR}/btx/btx
77 BTXCRT=         ${BTXDIR}/lib/crt0.o
78 CFLAGS+=        -I${.CURDIR}/../btx/lib
79
80 # BTX is expecting ELF components
81 CFLAGS+=        -elf
82
83 # Debug me!
84 #CFLAGS+=       -g
85 #LDFLAGS+=      -g
86
87 vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
88         sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
89         ${CC} ${CFLAGS} -c vers.c
90
91 ${PROG}: ${PROG}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT}
92         btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \
93                 -b ${BTXKERN} ${PROG}.bin
94 #       /usr/bin/kzip ${.TARGET}
95 #       mv ${.TARGET}.kz ${.TARGET}
96
97 ${PROG}.bin: ${PROG}.sym
98         cp ${.ALLSRC} ${.TARGET}
99         strip -R .comment -R .note ${.TARGET}
100
101 ${PROG}.help: help.common help.i386
102         cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
103
104 .PATH: ${.CURDIR}/../../forth 
105 FILES=  ${PROG}.help loader.4th support.4th loader.conf
106 FILES+= screen.4th frames.4th beastie.4th
107 FILESDIR_loader.conf=   /boot/defaults
108
109 .if !exists(${DESTDIR}/boot/loader.rc)
110 FILES+= ${.CURDIR}/loader.rc
111 .endif
112
113 .include "../Makefile.sub"
114
115 # Cannot use ${OBJS} above this line
116 .include <bsd.prog.mk>
117
118 ${PROG}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
119         ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
120                 ${LIBFICL} ${LIBI386} ${LIBSTAND}
121
122 # If it's not there, don't consider it a target
123 .if exists(${.CURDIR}/../../../i386/include)
124 beforedepend ${OBJS}: machine
125
126 machine:
127         ln -sf ${.CURDIR}/../../../i386/include machine
128
129 .endif
130
131 CLEANFILES+=    machine