Makefile.booters revision 1.78 1 # $NetBSD: Makefile.booters,v 1.78 2009/03/30 09:22:52 tsutsui Exp $
2
3 .include <bsd.own.mk>
4
5 STRIPFLAG=
6 BINMODE=444
7
8 LIBCRT0= # nothing
9 LIBCRTBEGIN= # nothing
10 LIBCRTEND= # nothing
11 LIBC= # nothing
12
13 # Make sure we override any optimization options specified by the
14 # user.
15 .if defined(HAVE_GCC)
16 .if ${MACHINE_ARCH} == "x86_64"
17 CPUFLAGS= -m32
18 .if ${HAVE_GCC} != 3
19 CPUFLAGS+= -Wno-attributes
20 .endif
21 .else
22 .if ${HAVE_GCC} == 3
23 CPUFLAGS= -mcpu=i386
24 .else
25 CPUFLAGS= -march=i386 -mtune=i386 -Wno-attributes
26 .endif
27 .endif
28 .endif
29 COPTS= -Os -ffreestanding
30
31 I386_STAND_DIR?= $S/arch/i386/stand
32
33 .PATH: ${I386_STAND_DIR}/lib
34
35 ROMSTART= start_rom.o
36 GENPROMDIR= ${I386_STAND_DIR}/genprom
37 GENPROMOBJDIR!= cd ${GENPROMDIR} && ${PRINTOBJDIR}
38 GENPROM= ${GENPROMOBJDIR}/genprom
39
40 .PATH: ${I386_STAND_DIR}/lib/crt/dos
41 DOSSTART= start_dos.o doscommain.o
42
43 .PATH: ${I386_STAND_DIR}/lib/crt/pxe
44 PXESTART= start_pxe.o
45
46 CPPFLAGS+= -nostdinc -I${.OBJDIR} -I$S -I${I386_STAND_DIR}/lib -I$S/lib/libsa
47 CPPFLAGS+= -D_STANDALONE
48 LDFLAGS+= -nostdlib
49
50 # XXX
51 .if ${MACHINE_ARCH} == "x86_64"
52 CPPFLAGS+=-m32
53 LDFLAGS+=-Wl,-m,elf_i386
54 LIBKERN_ARCH=i386
55 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
56 .endif
57
58 CLEANFILES+= ${STARTFILE} vers.c ${BASE}.list
59 SRCS+= vers.c
60
61 CLEANFILES+= machine x86
62
63 .if !make(obj) && !make(clean) && !make(cleandir)
64 .BEGIN:
65 -rm -f machine && ln -s $S/arch/i386/include machine
66 -rm -f x86 && ln -s $S/arch/x86/include x86
67 .ifdef LIBOBJ
68 -rm -f lib && ln -s ${LIBOBJ}/lib lib
69 mkdir -p ${LIBOBJ}/lib
70 .endif
71 .endif
72
73 ### find out what to use for libkern
74 KERN_AS= library
75 .include "${S}/lib/libkern/Makefile.inc"
76 LIBKERN= ${KERNLIB}
77
78 ### find out what to use for libz
79 Z_AS= library
80 .include "${S}/lib/libz/Makefile.inc"
81 LIBZ= ${ZLIB}
82
83 ### find out what to use for libsa
84 SA_AS= library
85 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
86 .include "${S}/lib/libsa/Makefile.inc"
87 LIBSA= ${SALIB}
88
89 ### find out what to use for libi386
90 I386DIR= ${I386_STAND_DIR}/lib
91 .include "${I386DIR}/Makefile.inc"
92 LIBI386= ${I386LIB}
93
94 cleandir distclean: cleanlibdir
95
96 cleanlibdir:
97 -rm -rf lib
98
99 .if ${OBJECT_FMT} == "ELF"
100 LDFLAGS+=-Wl,-M -Wl,-e,start # -N does not work properly.
101 .else
102 LDFLAGS+=-Wl,-N -Wl,-M -Wl,-e,_start
103 .endif
104
105 LIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
106
107 vers.c: ${VERSIONFILE} ${SOURCES} ${S}/conf/newvers_stand.sh
108 ${HOST_SH} ${S}/conf/newvers_stand.sh -DM ${VERSIONFILE} x86 ${NEWVERSWHAT}
109
110 CLEANFILES+= ${BASE}.sym
111 ${BASE}.sym: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
112 ${_MKTARGET_LINK}
113 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
114 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
115
116 CLEANFILES+= ${BASE}.rom ${BASE}.rom.tmp
117 ${BASE}.rom: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
118 ${_MKTARGET_LINK}
119 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
120 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
121 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.rom.tmp
122 ${GENPROM} ${ROM_SIZE} < ${BASE}.rom.tmp > ${BASE}.rom || \
123 rm -f ${BASE}.rom
124 rm -f ${BASE}.rom.tmp
125
126 CLEANFILES+= ${BASE}.com
127 ${BASE}.com: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
128 ${_MKTARGET_LINK}
129 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
130 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list
131 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.com
132
133 CLEANFILES+= ${BASE}.bin
134 ${BASE}.bin: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386}
135 ${_MKTARGET_LINK}
136 ${CC} -o ${BASE}.sym ${LDFLAGS} -Wl,-Ttext,${RELOC} \
137 ${STARTFILE} ${OBJS} ${LIBLIST} > ${BASE}.list
138 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin
139
140 .include <bsd.prog.mk>
141