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