1# $NetBSD: Makefile,v 1.3 2018/11/13 21:22:38 skrll Exp $ 2 3NODEBUG=yes 4PROG= xxboot 5NOMAN= # defined 6SRCS= start.S main.c readufs.c readufs_ffs.c readufs_lfs.c milli_tiny.S 7 8.PATH: ${.CURDIR}/../common 9 10CPPFLAGS+= -I${.CURDIR}/../../../.. -I. -D_STANDALONE 11# configuration for readufs module 12CPPFLAGS+= -DUSE_LFS -DUSE_FFS -DUSE_UFS1 -DUSE_UFS2 13# IODC can handle only 2GB, so this is enough 14CPPFLAGS+= -D__daddr_t=int32_t 15# ANSI C feature prevents from being relocatable 16#CPPFLAGS+= -traditional # would be best 17CPPFLAGS+= -Dconst= 18COPTS+= -Os -fno-delete-null-pointer-checks -funsigned-char -mdisable-fpregs -mpa-risc-1-0 19 20.include <bsd.own.mk> 21 22LINKS= ${BINDIR}/${PROG} ${BINDIR}/sdboot 23 24BINDIR= /usr/mdec 25STRIPFLAG= 26BINMODE= 444 27 28# standalone program 29LIBCRTBEGIN= 30LIBCRT0= 31LIBCRTI= 32LIBCRTEND= 33LIBC= 34 35S= ${.CURDIR}/../../../.. 36 37${PROG}: iplsum ${OBJS} 38 ${_MKTARGET_LINK} 39 ${LD} -Ttext 0 -Tdata 0 -e '$$START$$' -N -o $@1 $(OBJS) 40 ${LD} -Ttext 0x100 -Tdata 0x23456780 -e '$$START$$' -N -o $@2 $(OBJS) 41 ${SIZE} $@1 42 ${OBJCOPY} -O binary -j .data $@1 $@1.bin 43 ${OBJCOPY} -O binary -j .data $@2 $@2.bin 44 cmp $@1.bin $@2.bin # should be same 45 ${OBJCOPY} -O binary -j .text $@1 $@2.bin 46 test ! -s $@2.bin # text section must be empty 47 ${_MKMSG} " iplsum " ${.TARGET} 48 ./iplsum $@1.bin $@ 49 50iplsum: iplsum.c 51 ${_MKTARGET_LINK} 52 ${HOST_CC} -o $@ ${.CURDIR}/iplsum.c 53 54CLEANFILES+= ${PROG}1 ${PROG}2 ${PROG}1.bin ${PROG}2.bin ${PROG}.bin iplsum 55CLEANFILES+= ${SRCS:M*.c:S/.c$/.o.S/} 56 57.include <bsd.prog.mk> 58.include <bsd.klinks.mk> 59 60# override default rules 61 62# Place code to data section. 63.S.o: 64 ${_MKTARGET_COMPILE} 65 ${TOOL_SED} -e 's/\.code/.data/' \ 66 -e 's/\.bss/.section .bss,"aw",@nobits/' \ 67 -e 's/\.allow$$/.level 1.0/' -e 's/\.allow/.level/' \ 68 ${.IMPSRC} | ${AS} -o ${.TARGET} 69 70# Place code to data section, and make sure all address calculations 71# are relative to $global$. 72.c.o: 73 ${_MKTARGET_COMPILE} 74 ${CC} ${CFLAGS} ${CPPFLAGS} -o $@.S -S ${.IMPSRC} 75 grep -i 'ldil' $@.S | egrep -v "ldil L'-?[0-9]*," > /dev/null 2>&1; \ 76 if [ $$? = 0 ]; then \ 77 echo 'found non-relocatable code' >&2 && exit 1; \ 78 fi 79 ${TOOL_SED} -e 's/\.text/.data/' $@.S | ${AS} -o ${.TARGET} 80