Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / i386 / stand / bootxx / Makefile.bootxx
blob7f84d70aee171489960d148ea6128aa3fa63af1b
1 # $NetBSD: Makefile.bootxx,v 1.37 2009/11/20 17:28:19 dsl Exp $
3 S=      ${.CURDIR}/../../../../..
5 PIE_CFLAGS=
6 PIE_LDFLAGS=
7 PIE_AFLAGS=
8 NOMAN=
9 PROG?= bootxx_${FS}
10 BINDIR= /usr/mdec
11 BINMODE= 0444
13 PRIMARY_LOAD_ADDRESS=0x1000
14 SECONDARY_LOAD_ADDRESS=0x10000
16 # We ought (need?) to fit into track 0 of a 1.2M floppy.
17 # This restricts us to 15 sectors (including pbr and label)
18 BOOTXX_SECTORS?=15
19 BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
21 SRCS= pbr.S label.S bootxx.S boot1.c
23 .include <bsd.own.mk>
25 STRIPFLAG=      # nothing
27 LIBCRT0=        # nothing
28 LIBCRTBEGIN=    # nothing
29 LIBCRTEND=      # nothing
30 LIBC=           # nothing
32 BINDIR=/usr/mdec
33 BINMODE=444
35 .PATH:  ${.CURDIR}/.. ${.CURDIR}/../../lib
37 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
38 CPPFLAGS+= -DBOOTXX
39 # CPPFLAGS+= -D__daddr_t=int32_t
40 CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
41 CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
42 CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
43 CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
44 CPPFLAGS+= -DXXfs_open=${FS}_open
45 CPPFLAGS+= -DXXfs_close=${FS}_close
46 CPPFLAGS+= -DXXfs_read=${FS}_read
47 CPPFLAGS+= -DXXfs_stat=${FS}_stat
48 CPPFLAGS+= -DFS=${FS}
49 # CPPFLAGS+= -DBOOT_MSG_COM0
51 # Make sure we override any optimization options specified by the user
52 COPTS=  -Os -momit-leaf-frame-pointer
53 DBG=
55 CPPFLAGS+= -DNO_LBA_CHECK
57 .if defined(HAVE_GCC)
58 .if ${MACHINE_ARCH} == "x86_64"
59 LDFLAGS+=  -Wl,-m,elf_i386
60 AFLAGS+=   -m32
61 CPUFLAGS=  -m32
62 LIBKERN_ARCH=i386
63 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
64 .else
65 CPPFLAGS+= -DEPIA_HACK
66 .if ${HAVE_GCC} == 3
67 CPUFLAGS=  -mcpu=i386
68 .else
69 CPUFLAGS=  -march=i386 -mtune=i386
70 .endif
71 .endif
72 .endif
74 COPTS+=    -ffreestanding
75 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
76 CPPFLAGS+= -nostdinc -D_STANDALONE
77 CPPFLAGS+= -I$S
79 CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
80                 -DLIBSA_NO_TWIDDLE \
81                 -DLIBSA_NO_FD_CHECKING \
82                 -DLIBSA_NO_RAW_ACCESS \
83                 -DLIBSA_NO_FS_WRITE \
84                 -DLIBSA_NO_FS_SEEK \
85                 -DLIBSA_SINGLE_DEVICE=blkdev \
86                 -DLIBKERN_OPTIMISE_SPACE \
87                 -D"blkdevioctl(x,y,z)=EINVAL" \
88                 -D"blkdevclose(f)=0" \
89                 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
90                 -DLIBSA_NO_DISKLABEL_MSGS
92 # -DLIBSA_FS_SINGLECOMPONENT 
94 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
96 I386_STAND_DIR?= $S/arch/i386/stand
98 CLEANFILES+= machine x86
100 .if !make(obj) && !make(clean) && !make(cleandir)
101 .BEGIN:
102         -rm -f machine && ln -s $S/arch/i386/include machine
103         -rm -f x86 && ln -s $S/arch/x86/include x86
104 .ifdef LIBOBJ
105         -rm -f lib && ln -s ${LIBOBJ}/lib lib
106         mkdir -p ${LIBOBJ}/lib
107 .endif
108 .endif
110 ### find out what to use for libi386
111 I386DIR= ${I386_STAND_DIR}/lib
112 .include "${I386DIR}/Makefile.inc"
113 LIBI386= ${I386LIB}
115 ### find out what to use for libsa
116 SA_AS= library
117 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
118 .include "${S}/lib/libsa/Makefile.inc"
119 LIBSA= ${SALIB}
121 ### find out what to use for libkern
122 KERN_AS=        library
123 .include "${S}/lib/libkern/Makefile.inc"
124 LIBKERN=        ${KERNLIB}
127 cleandir distclean: cleanlibdir
129 cleanlibdir:
130         -rm -rf lib
132 LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
134 CLEANFILES+= ${PROG}.sym ${PROG}.map
136 ${PROG}: ${OBJS} ${LIBLIST}
137         ${_MKTARGET_LINK}
138         ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
139                 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
140         ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
141         @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
142         if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
143                 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
144                 rm ${PROG}; \
145                 ! :; \
146         else \
147                 : pad to sector boundary; \
148                 pad=$$(( 512 - ( $$sz & 511 ) )); \
149                 [ $$pad = 512 ] || \
150                     dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
151                 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
152         fi
154 .include <bsd.prog.mk>