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