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