Makefile revision 1.1
11.1Sskrll#	$NetBSD: Makefile,v 1.1 2014/02/24 07:23:43 skrll Exp $
21.1Sskrll
31.1SskrllPROG=	xxboot
41.1SskrllNOMAN=	# defined
51.1SskrllSRCS=	start.S main.c readufs.c readufs_ffs.c readufs_lfs.c milli_tiny.S
61.1Sskrll
71.1Sskrll.PATH:	${.CURDIR}/../common
81.1Sskrll
91.1SskrllCPPFLAGS+=	-I${.CURDIR}/../../../.. -I. -D_STANDALONE
101.1Sskrll# configuration for readufs module
111.1SskrllCPPFLAGS+=	-DUSE_LFS -DUSE_FFS -DUSE_UFS1 -DUSE_UFS2
121.1Sskrll# IODC can handle only 2GB, so this is enough
131.1SskrllCPPFLAGS+=	-D__daddr_t=int32_t
141.1Sskrll# ANSI C feature prevents from being relocatable
151.1Sskrll#CPPFLAGS+=	-traditional	# would be best
161.1SskrllCPPFLAGS+=	-Dconst=
171.1SskrllCOPTS+=		-Os -funsigned-char -mdisable-fpregs -mpa-risc-1-0
181.1Sskrll
191.1Sskrll.include <bsd.own.mk>
201.1Sskrll
211.1SskrllLINKS=	${BINDIR}/${PROG} ${BINDIR}/sdboot
221.1Sskrll
231.1SskrllBINDIR=		/usr/mdec
241.1SskrllSTRIPFLAG=
251.1SskrllBINMODE=	444
261.1Sskrll
271.1Sskrll# standalone program
281.1SskrllLIBCRTBEGIN=
291.1SskrllLIBCRT0=
301.1SskrllLIBCRTI=
311.1SskrllLIBCRTEND=
321.1SskrllLIBC=
331.1Sskrll
341.1SskrllS=		${.CURDIR}/../../../..
351.1Sskrll
361.1Sskrll${PROG}: iplsum ${OBJS}
371.1Sskrll	${_MKTARGET_LINK}
381.1Sskrll	${LD} -Ttext 0 -Tdata 0 -e '$$START$$' -N -o $@1 $(OBJS)
391.1Sskrll	${LD} -Ttext 0x100 -Tdata 0x23456780 -e '$$START$$' -N -o $@2 $(OBJS)
401.1Sskrll	${SIZE} $@1
411.1Sskrll	${OBJCOPY} -O binary -j .data $@1 $@1.bin
421.1Sskrll	${OBJCOPY} -O binary -j .data $@2 $@2.bin
431.1Sskrll	cmp $@1.bin $@2.bin	# should be same
441.1Sskrll	${OBJCOPY} -O binary -j .text $@1 $@2.bin
451.1Sskrll	test ! -s $@2.bin	# text section must be empty
461.1Sskrll	${_MKMSG} " iplsum " ${.TARGET}
471.1Sskrll	./iplsum $@1.bin $@
481.1Sskrll
491.1Sskrlliplsum: iplsum.c
501.1Sskrll	${_MKTARGET_LINK}
511.1Sskrll	${HOST_CC} -o $@ ${.CURDIR}/iplsum.c
521.1Sskrll
531.1SskrllCLEANFILES+=	${PROG}1 ${PROG}2 ${PROG}1.bin ${PROG}2.bin ${PROG}.bin iplsum
541.1SskrllCLEANFILES+=	${SRCS:M*.c:S/.c$/.o.S/}
551.1Sskrll
561.1Sskrll.include <bsd.prog.mk>
571.1Sskrll.include <bsd.klinks.mk>
581.1Sskrll
591.1Sskrll# override default rules
601.1Sskrll
611.1Sskrll# Place code to data section.
621.1Sskrll.S.o:
631.1Sskrll	${_MKTARGET_COMPILE}
641.1Sskrll	${TOOL_SED} -e 's/\.code/.data/' \
651.1Sskrll	-e 's/\.bss/.section .bss,"aw",@nobits/' \
661.1Sskrll	-e 's/\.allow$$/.level	1.0/' -e 's/\.allow/.level/' \
671.1Sskrll	 ${.IMPSRC} | ${AS} -o ${.TARGET}
681.1Sskrll
691.1Sskrll# Place code to data section, and make sure all address calculations
701.1Sskrll# are relative to $global$.
711.1Sskrll.c.o:
721.1Sskrll	${_MKTARGET_COMPILE}
731.1Sskrll	${CC} ${CFLAGS} ${CPPFLAGS} -o $@.S -S ${.IMPSRC}
741.1Sskrll	grep -i 'ldil' $@.S | egrep -v "ldil L'-?[0-9]*," > /dev/null 2>&1; \
751.1Sskrll		if [ $$? = 0 ]; then \
761.1Sskrll			echo 'found non-relocatable code' >&2 && exit 1; \
771.1Sskrll		fi
781.1Sskrll	${TOOL_SED} -e 's/\.text/.data/' $@.S | ${AS} -o ${.TARGET}
79