1 # $NetBSD: Makefile,v 1.1.10.3 2017/12/03 11:36:17 jdolecek 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 15 # ANSI C feature prevents from being relocatable 16 #CPPFLAGS+= -traditional # would be best 17 CPPFLAGS+= -Dconst= 18 COPTS+= -Os -funsigned-char -mdisable-fpregs -mpa-risc-1-0 19 20 .include <bsd.own.mk> 21 22 LINKS= ${BINDIR}/${PROG} ${BINDIR}/sdboot 23 24 BINDIR= /usr/mdec 25 STRIPFLAG= 26 BINMODE= 444 27 28 # standalone program 29 LIBCRTBEGIN= 30 LIBCRT0= 31 LIBCRTI= 32 LIBCRTEND= 33 LIBC= 34 35 S= ${.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 50 iplsum: iplsum.c 51 ${_MKTARGET_LINK} 52 ${HOST_CC} -o $@ ${.CURDIR}/iplsum.c 53 54 CLEANFILES+= ${PROG}1 ${PROG}2 ${PROG}1.bin ${PROG}2.bin ${PROG}.bin iplsum 55 CLEANFILES+= ${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