xref: /netbsd-src/sys/arch/i386/stand/boot/Makefile.boot (revision 2c6fc41c810f5088457889d00eba558e8bc74d9e)
1# $NetBSD: Makefile.boot,v 1.66 2014/04/14 15:05:19 uebayasi Exp $
2
3S=	${.CURDIR}/../../../../..
4
5NOMAN=
6PROG?= boot
7NEWVERSWHAT?= "BIOS Boot"
8VERSIONFILE?= ${.CURDIR}/../version
9
10AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
11
12SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
13SRCS= ${SOURCES}
14.if !make(depend)
15SRCS+= vers.c
16.endif
17
18PIE_CFLAGS=
19PIE_AFLAGS=
20PIE_LDFLAGS=
21
22.include <bsd.own.mk>
23
24STRIPFLAG=	# nothing
25
26LIBCRT0=	# nothing
27LIBCRTI=	# nothing
28LIBCRTBEGIN=	# nothing
29LIBCRTEND=	# nothing
30LIBC=		# nothing
31
32BINDIR=/usr/mdec
33BINMODE=444
34
35.PATH:	${.CURDIR}/.. ${.CURDIR}/../../lib
36
37LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
38CPPFLAGS+= -I ${.CURDIR}/..  -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
39CPPFLAGS+= -I ${.OBJDIR}
40# Make sure we override any optimization options specified by the user
41COPTS=  -Os
42
43.if ${MACHINE_ARCH} == "x86_64"
44LDFLAGS+=  -Wl,-m,elf_i386
45AFLAGS+=   -m32
46CPUFLAGS=  -m32
47LIBKERN_ARCH=i386
48KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
49.else
50CPUFLAGS=  -march=i386 -mtune=i386
51.endif
52
53CFLAGS+=   -mno-sse -mno-sse2 -mno-sse3
54
55COPTS+=    -ffreestanding
56CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
57CPPFLAGS+= -nostdinc -D_STANDALONE
58CPPFLAGS+= -I$S
59
60CPPFLAGS+= -DSUPPORT_PS2
61CPPFLAGS+= -DDIRECT_SERIAL
62CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
63
64CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
65CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
66CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
67
68CPPFLAGS+= -DSUPPORT_CD9660
69CPPFLAGS+= -DSUPPORT_USTARFS
70CPPFLAGS+= -DSUPPORT_DOSFS
71CPPFLAGS+= -DSUPPORT_EXT2FS
72#CPPFLAGS+= -DSUPPORT_MINIXFS3
73CPPFLAGS+= -DPASS_BIOSGEOM
74CPPFLAGS+= -DPASS_MEMMAP
75#CPPFLAGS+= -DBOOTPASSWD
76CPPFLAGS+= -DEPIA_HACK
77#CPPFLAGS+= -DDEBUG_MEMSIZE
78#CPPFLAGS+= -DBOOT_MSG_COM0
79CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
80
81# The biosboot code is linked to 'virtual' address of zero and is
82# loaded at physical address 0x10000.
83# XXX The heap values should be determined from _end.
84SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000
85SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
86SAMISCMAKEFLAGS+= SA_USE_CREAD=yes	# Read compressed kernels
87SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no	# Netboot via TFTP, NFS
88
89CPPFLAGS+=	-Wno-pointer-sign
90
91# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
92
93I386_STAND_DIR?= $S/arch/i386/stand
94
95### find out what to use for libi386
96I386DIR= ${I386_STAND_DIR}/lib
97.include "${I386DIR}/Makefile.inc"
98LIBI386= ${I386LIB}
99
100### find out what to use for libsa
101SA_AS= library
102SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
103SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
104.include "${S}/lib/libsa/Makefile.inc"
105LIBSA= ${SALIB}
106
107### find out what to use for libkern
108KERN_AS= library
109.include "${S}/lib/libkern/Makefile.inc"
110LIBKERN= ${KERNLIB}
111
112### find out what to use for libz
113Z_AS= library
114.include "${S}/lib/libz/Makefile.inc"
115LIBZ= ${ZLIB}
116
117LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript
118
119cleandir distclean: .WAIT 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 ${PROG}.sym vers.c
128
129vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
130	${HOST_SH} ${S}/conf/newvers_stand.sh ${VERSIONFILE} x86 ${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# explicitly pull in the required objects before any other library code.
135${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
136	${_MKTARGET_LINK}
137	bb="$$( ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \
138	    ${OBJS} ${LIBLIST} | ( \
139		while read symbol file; do \
140			[ -z "$$file" ] && continue; \
141			[ "$$symbol" = real_to_prot ] && break; \
142		done; \
143		while \
144			oifs="$$IFS"; \
145			IFS='()'; \
146			set -- $$file; \
147			IFS="$$oifs"; \
148			[ -n "$$2" ] && echo "${I386DST}/$$2"; \
149			read file rest && [ -z "$$rest" ]; \
150		do :; \
151		done; \
152	) )"; \
153	${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,0 -T ${LDSCRIPT} \
154		-Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
155	${OBJCOPY} -O binary ${PROG}.sym ${PROG}
156
157.include <bsd.prog.mk>
158KLINK_MACHINE=	i386
159.include <bsd.klinks.mk>
160