etc/protocols - sync with NetBSD-8
[minix.git] / sys / arch / i386 / stand / bootxx / Makefile.bootxx
blob8aa4317011c6363b1c287c75abc811f2d6cdc192
1 # $NetBSD: Makefile.bootxx,v 1.49 2015/08/20 11:38:27 uebayasi Exp $
3 S=      ${.CURDIR}/../../../../..
5 AFLAGS.bootxx.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
6 AFLAGS.label.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
7 AFLAGS.pbr.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
9 PIE_CFLAGS=
10 PIE_LDFLAGS=
11 PIE_AFLAGS=
12 NOMAN=
13 PROG?= bootxx_${FS}
14 BINDIR= /usr/mdec
15 BINMODE= 0444
17 PRIMARY_LOAD_ADDRESS=0x1000
18 SECONDARY_LOAD_ADDRESS=0x10000
20 # We ought (need?) to fit into track 0 of a 1.2M floppy.
21 # This restricts us to 15 sectors (including pbr and label)
22 BOOTXX_SECTORS?=15
23 BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
25 SRCS= pbr.S label.S bootxx.S boot1.c
27 .include <bsd.own.mk>
29 STRIPFLAG=      # nothing
31 LIBCRT0=        # nothing
32 LIBCRTI=        # nothing
33 LIBCRTBEGIN=    # nothing
34 LIBCRTEND=      # nothing
35 LIBC=           # nothing
37 BINDIR=/usr/mdec
38 BINMODE=444
40 .PATH:  ${.CURDIR}/.. ${.CURDIR}/../../lib
42 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
43 CPPFLAGS+= -DBOOTXX
44 # CPPFLAGS+= -D__daddr_t=int32_t
45 CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
46 CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
47 CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
48 CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
49 CPPFLAGS+= -DXXfs_open=${FS}_open
50 CPPFLAGS+= -DXXfs_close=${FS}_close
51 CPPFLAGS+= -DXXfs_read=${FS}_read
52 CPPFLAGS+= -DXXfs_stat=${FS}_stat
53 CPPFLAGS+= -DFS=${FS}
54 # CPPFLAGS+= -DBOOT_MSG_COM0
56 # Make sure we override any optimization options specified by the user
57 .include "${.PARSEDIR}/../Makefile.inc"
58 COPTS=  ${OPT_SIZE.${ACTIVE_CC}}
59 DBG=
61 CPPFLAGS+= -DNO_LBA_CHECK
63 .if ${MACHINE_ARCH} == "x86_64"
64 LDFLAGS+=  -Wl,-m,elf_i386
65 AFLAGS+=   -m32
66 CPUFLAGS=  -m32
67 LIBKERN_ARCH=i386
68 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
69 .else
70 CPPFLAGS+= -DEPIA_HACK
71 CPUFLAGS=  -march=i386 -mtune=i386
72 .endif
74 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
75 CPPFLAGS+= -nostdinc -D_STANDALONE
76 CPPFLAGS+= -I$S
78 CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
79                 -DLIBSA_NO_TWIDDLE \
80                 -DLIBSA_NO_FD_CHECKING \
81                 -DLIBSA_NO_RAW_ACCESS \
82                 -DLIBSA_NO_FS_WRITE \
83                 -DLIBSA_NO_FS_SEEK \
84                 -DLIBSA_SINGLE_DEVICE=blkdev \
85                 -DLIBKERN_OPTIMISE_SPACE \
86                 -D"blkdevioctl(x,y,z)=EINVAL" \
87                 -D"blkdevclose(f)=0" \
88                 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
89                 -DLIBSA_NO_DISKLABEL_MSGS
91 # -DLIBSA_FS_SINGLECOMPONENT 
93 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
95 I386_STAND_DIR?= $S/arch/i386/stand
97 ### find out what to use for libi386
98 I386DIR= ${I386_STAND_DIR}/lib
99 .include "${I386DIR}/Makefile.inc"
100 LIBI386= ${I386LIB}
102 ### find out what to use for libsa
103 SA_AS= library
104 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
105 .include "${S}/lib/libsa/Makefile.inc"
106 LIBSA= ${SALIB}
108 .if !defined(__MINIX)
109 ### find out what to use for libkern
110 KERN_AS=        library
111 .include "${S}/lib/libkern/Makefile.inc"
112 LIBKERN=        ${KERNLIB}
113 .else
115 SAMISCMAKEFLAGS+="SA_INCLUDE_NET=no"
117 USE_BITCODE=no
119 # use MINIX minc
120 LIBKERN= ${DESTDIR}/usr/lib/libminc.a
121 .endif # !defined(__MINIX)
123 LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript
125 cleandir distclean: .WAIT cleanlibdir
127 cleanlibdir:
128         -rm -rf lib
130 LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
132 CLEANFILES+= ${PROG}.sym ${PROG}.map
134 ${PROG}: ${OBJS} ${LIBLIST} ${LDSCRIPT}
135         ${_MKTARGET_LINK}
136 .if defined(__MINIX)
137         ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,--section-start=.text=${PRIMARY_LOAD_ADDRESS} \
138                 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
139 .else
140         ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
141                 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
142 .endif # defined(__MINIX)
143         ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
144         @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
145         if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
146                 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
147                 rm ${PROG}; \
148                 ! :; \
149         else \
150                 : pad to sector boundary; \
151                 pad=$$(( 512 - ( $$sz & 511 ) )); \
152                 [ $$pad = 512 ] || \
153                     dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
154                 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
155         fi
157 .include <bsd.prog.mk>
158 KLINK_MACHINE=  i386
159 .include <bsd.klinks.mk>