1 # $NetBSD: Makefile,v 1.6 2024/04/29 07:34:27 skrll Exp $ 2 3 NODEBUG= yes 4 PROG= xxboot 5 NOMAN= # defined 6 SRCS= start.S main.c readufs.c readufs_ffs.c readufs_lfs.c milli_tiny.S 7 8 .PATH: ${.CURDIR}/../common 9 10 CPPFLAGS+= -I${.CURDIR}/../../../.. -I. -D_STANDALONE 11 # configuration for readufs module 12 CPPFLAGS+= -DUSE_LFS -DUSE_FFS -DUSE_UFS1 -DUSE_UFS2 13 # IODC can handle only 2GB, so this is enough 14 CPPFLAGS+= -D__daddr_t=int32_t -D__ino_t=uint32_t 15 # ANSI C feature prevents from being relocatable 16 #CPPFLAGS+= -traditional # would be best 17 CPPFLAGS+= -Dconst= 18 COPTS+= -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 21 DBG= # empty 22 23 .include <bsd.own.mk> 24 25 LINKS= ${BINDIR}/${PROG} ${BINDIR}/sdboot 26 27 BINDIR= /usr/mdec 28 STRIPFLAG= 29 BINMODE= 444 30 31 # standalone program 32 LIBCRTBEGIN= 33 LIBCRT0= 34 LIBCRTI= 35 LIBCRTEND= 36 LIBC= 37 38 S= ${.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 53 iplsum: iplsum.c 54 ${_MKTARGET_LINK} 55 ${HOST_CC} -o $@ ${.CURDIR}/iplsum.c 56 57 CLEANFILES+= ${PROG}1 ${PROG}2 ${PROG}1.bin ${PROG}2.bin ${PROG}.bin iplsum 58 CLEANFILES+= ${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