xref: /netbsd-src/sys/arch/i386/stand/boot/Makefile.boot (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1# $NetBSD: Makefile.boot,v 1.25 2005/12/11 12:17:47 christos Exp $
2
3S=	${.CURDIR}/../../../../../
4
5NOMAN=
6BINDIR= /usr/mdec
7BINMODE= 0444
8PROG?= boot
9NEWVERSWHAT?= "BIOS Boot"
10VERSIONFILE?= ${.CURDIR}/../version
11
12SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
13SRCS= ${SOURCES}
14.if !make(depend)
15SRCS+= vers.c
16.endif
17
18.include <bsd.own.mk>
19
20STRIPFLAG=	# nothing
21
22LIBCRT0=	# nothing
23LIBCRTBEGIN=	# nothing
24LIBCRTEND=	# nothing
25LIBC=		# nothing
26
27BINDIR=/usr/mdec
28BINMODE=444
29
30.PATH:	${.CURDIR}/.. ${.CURDIR}/../../lib
31
32LDFLAGS+= -N -e boot_start
33# CPPFLAGS+= -D__daddr_t=int32_t
34CPPFLAGS+= -I ${.CURDIR}/..  -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
35CPPFLAGS+= -I ${.OBJDIR}
36#CPPFLAGS+= -DDEBUG_MEMSIZE
37
38# Make sure we override any optimization options specified by the user
39COPTS=  -Os
40
41.if ${MACHINE} == "amd64"
42LD+=  -m elf_i386
43AFLAGS+=   -m32
44CPUFLAGS=  -m32
45LIBKERN_ARCH=i386
46KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
47CPPFLAGS+= -DBOOT_ELF64
48.else
49CPUFLAGS=  -mcpu=i386
50.endif
51
52COPTS+=    -ffreestanding
53CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
54CPPFLAGS+= -nostdinc -D_STANDALONE
55CPPFLAGS+= -I$S
56
57CPPFLAGS+= -DSUPPORT_PS2
58CPPFLAGS+= -DDIRECT_SERIAL
59CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
60
61CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
62CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
63CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
64
65CPPFLAGS+= -DSUPPORT_CD9660
66CPPFLAGS+= -DSUPPORT_USTARFS
67CPPFLAGS+= -DSUPPORT_DOSFS
68CPPFLAGS+= -DPASS_BIOSGEOM
69CPPFLAGS+= -DPASS_MEMMAP
70#CPPFLAGS+= -DBOOTPASSWD
71CPPFLAGS+= -DEPIA_HACK
72
73# The biosboot code is linked to 'virtual' address of zero and is
74# loaded at physical address 0x10000.
75# XXX The heap values should be determined from _end.
76SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000
77SAMISCMAKEFLAGS+= SA_USE_CREAD=yes	# Read compressed kernels
78SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no	# Netboot via TFTP, NFS
79
80
81# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
82
83I386_STAND_DIR?= $S/arch/i386/stand
84
85CLEANFILES+= machine x86
86
87.if !make(obj) && !make(clean) && !make(cleandir)
88.BEGIN:
89	-rm -f machine && ln -s $S/arch/i386/include machine
90	-rm -f x86 && ln -s $S/arch/x86/include x86
91.ifdef LIBOBJ
92	-rm -f lib && ln -s ${LIBOBJ}/lib lib
93	mkdir -p ${LIBOBJ}/lib
94.endif
95.endif
96
97### find out what to use for libi386
98I386DIR= ${I386_STAND_DIR}/lib
99.include "${I386DIR}/Makefile.inc"
100LIBI386= ${I386LIB}
101
102### find out what to use for libsa
103SA_AS= library
104SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
105.include "${S}/lib/libsa/Makefile.inc"
106LIBSA= ${SALIB}
107
108### find out what to use for libkern
109KERN_AS= library
110.include "${S}/lib/libkern/Makefile.inc"
111LIBKERN= ${KERNLIB}
112
113### find out what to use for libz
114Z_AS= library
115.include "${S}/lib/libz/Makefile.inc"
116LIBZ= ${ZLIB}
117
118
119cleandir distclean: cleanlibdir
120
121cleanlibdir:
122	-rm -rf lib
123
124LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA}
125# LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN}
126
127CLEANFILES+= ${PROG}.tmp ${PROG}.map vers.c
128
129vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
130	${HOST_SH} ${S}conf/newvers_stand.sh ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT}
131
132# Anything that calls 'real_to_prot' must have a %pc < 0x10000.
133# We link the program, find the callers (all in libi386), then
134# explicitely pull in the required objects before any other library code.
135${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
136	bb="$$( ${LD} -o ${PROG}.tmp ${LDFLAGS} -Ttext 0 -cref \
137	    ${OBJS} ${LIBLIST} | ( \
138		while read symbol file; do \
139			[ -z "$$file" ] && continue; \
140			[ "$$symbol" = real_to_prot ] && break; \
141		done; \
142		while \
143			oifs="$$IFS"; \
144			IFS='()'; \
145			set -- $$file; \
146			IFS="$$oifs"; \
147			[ -n "$$2" ] && echo "${I386DST}/$$2"; \
148			read file rest && [ -z "$$rest" ]; \
149		do :; \
150		done; \
151	) )"; \
152	${LD} -o ${PROG}.tmp ${LDFLAGS} -Ttext 0 \
153		-Map ${PROG}.map -cref ${OBJS} $$bb ${LIBLIST}
154	${OBJCOPY} -O binary ${PROG}.tmp ${PROG}
155	rm -f ${PROG}.tmp
156
157.include <bsd.prog.mk>
158