1# $NetBSD: Makefile,v 1.6 2024/04/29 07:34:27 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 -D__ino_t=uint32_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# Make sure we override any optimization options specified by the user 21DBG= # empty 22 23.include <bsd.own.mk> 24 25LINKS= ${BINDIR}/${PROG} ${BINDIR}/sdboot 26 27BINDIR= /usr/mdec 28STRIPFLAG= 29BINMODE= 444 30 31# standalone program 32LIBCRTBEGIN= 33LIBCRT0= 34LIBCRTI= 35LIBCRTEND= 36LIBC= 37 38S= ${.CURDIR}/../../../.. 39 40${PROG}: iplsum ${OBJS} 41 ${_MKTARGET_LINK} 42 ${LD} -Ttext 0 -Tdata 0 -e '$$START$$' -N -o $@1 $(OBJS) 43 ${LD} -Ttext 0x100 -Tdata 0x23456780 -e '$$START$$' -N -o $@2 $(OBJS) 44 ${SIZE} $@1 45 ${OBJCOPY} -O binary -j .data $@1 $@1.bin 46 ${OBJCOPY} -O binary -j .data $@2 $@2.bin 47 cmp $@1.bin $@2.bin # should be same 48 ${OBJCOPY} -O binary -j .text $@1 $@2.bin 49 test ! -s $@2.bin # text section must be empty 50 ${_MKMSG} " iplsum " ${.TARGET} 51 ./iplsum $@1.bin $@ 52 53iplsum: iplsum.c 54 ${_MKTARGET_LINK} 55 ${HOST_CC} -o $@ ${.CURDIR}/iplsum.c 56 57CLEANFILES+= ${PROG}1 ${PROG}2 ${PROG}1.bin ${PROG}2.bin ${PROG}.bin iplsum 58CLEANFILES+= ${SRCS:M*.c:S/.c$/.o.S/} 59 60.include <bsd.prog.mk> 61.include <bsd.klinks.mk> 62 63# override default rules 64 65# Place code to data section. 66.S.o: 67 ${_MKTARGET_COMPILE} 68 ${TOOL_SED} -e 's/\.code/.data/' \ 69 -e 's/\.bss/.section .bss,"aw",@nobits/' \ 70 -e 's/\.allow$$/.level 1.0/' -e 's/\.allow/.level/' \ 71 ${.IMPSRC} | ${AS} -o ${.TARGET} 72 73# Place code to data section, and make sure all address calculations 74# are relative to $global$. 75.c.o: 76 ${_MKTARGET_COMPILE} 77 ${CC} ${CFLAGS} ${CPPFLAGS} -o $@.S -S ${.IMPSRC} 78 grep -i 'ldil' $@.S | egrep -v "ldil L'-?[0-9]*," > /dev/null 2>&1; \ 79 if [ $$? = 0 ]; then \ 80 echo 'found non-relocatable code' >&2 && exit 1; \ 81 fi 82 ${TOOL_SED} -e 's/\.text/.data/' $@.S | ${AS} -o ${.TARGET} 83