1 1.10.2.3 jdolecek # $NetBSD: Makefile,v 1.10.2.3 2002/06/23 17:43:19 jdolecek Exp $ 2 1.10.2.2 thorpej 3 1.10.2.2 thorpej NOMAN= # defined 4 1.10.2.2 thorpej 5 1.10.2.2 thorpej .include <bsd.own.mk> 6 1.10.2.2 thorpej 7 1.10.2.2 thorpej BOOT= boot_ufs 8 1.10.2.2 thorpej VERSIONFILE= ${.CURDIR}/version 9 1.10.2.2 thorpej VERSION!= awk -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } END { print it }' ${VERSIONFILE} 10 1.10.2.2 thorpej NEWVERSWHAT= "${BOOT}" 11 1.10.2.2 thorpej 12 1.10.2.2 thorpej # text and bss addresses in hex 13 1.10.2.2 thorpej TEXT= 0f0000 # Primary (me) 14 1.10.2.2 thorpej BOOT_TEXT= 006000 # Secondary (/boot) 15 1.10.2.2 thorpej 16 1.10.2.2 thorpej PROG= xx$(BOOT) 17 1.10.2.2 thorpej LINKS= ${BINDIR}/xx$(BOOT) ${BINDIR}/sd$(BOOT) 18 1.10.2.2 thorpej LINKS+= ${BINDIR}/xx$(BOOT) ${BINDIR}/fd$(BOOT) 19 1.10.2.2 thorpej BINDIR= /usr/mdec 20 1.10.2.2 thorpej STRIPFLAG= 21 1.10.2.2 thorpej BINMODE= 444 22 1.10.2.2 thorpej 23 1.10.2.2 thorpej S= ${.CURDIR}/../../../.. 24 1.10.2.2 thorpej M= $S/arch/${MACHINE} 25 1.10.2.2 thorpej LIBKERN= $S/lib/libkern/arch/${MACHINE_ARCH} 26 1.10.2.2 thorpej COMMONDIR= $M/stand/common 27 1.10.2.2 thorpej LIBIOCS= $M/stand/libiocs 28 1.10.2.2 thorpej .PATH: ${LIBKERN} ${COMMONDIR} 29 1.10.2.3 jdolecek SRCS= boot.S bootmain.c readufs.c readufs_ffs.c readufs_lfs.c 30 1.10.2.2 thorpej SRCS+= exec_image.S memset.S strcmp.S 31 1.10.2.2 thorpej 32 1.10.2.2 thorpej SRCS+= vers.c 33 1.10.2.2 thorpej CLEANFILES+= vers.c 34 1.10.2.2 thorpej vers.c: ${VERSIONFILE} 35 1.10.2.2 thorpej sh ${S}/conf/newvers_stand.sh -DM ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT} 36 1.10.2.2 thorpej 37 1.10.2.2 thorpej CFLAGS= -Os -fomit-frame-pointer 38 1.10.2.2 thorpej CFLAGS+= -W -Wall -Wconversion -Wstrict-prototypes -Wmissing-prototypes 39 1.10.2.2 thorpej CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)" 40 1.10.2.2 thorpej CPPFLAGS+= -DBOOT=\"$(BOOT)\" -DBOOT_VERS=\"$(VERSION)\" 41 1.10.2.2 thorpej CPPFLAGS+= -DSCSI_ADHOC_BOOTPART 42 1.10.2.2 thorpej #CPPFLAGS+= -DBOOT_DEBUG 43 1.10.2.3 jdolecek CPPFLAGS+= -DUSE_FFS -DUSE_LFS 44 1.10.2.2 thorpej CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} 45 1.10.2.2 thorpej AFLAGS= ${CFLAGS:M-[ID]*} 46 1.10.2.2 thorpej .if ${OBJECT_FMT} == "ELF" 47 1.10.2.2 thorpej LDFLAGS= -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M 48 1.10.2.2 thorpej LDFLAGS+= -noinhibit-exec # XXX 49 1.10.2.2 thorpej .else 50 1.10.2.2 thorpej LDFLAGS= -n -Bstatic -Ttext ${TEXT} -M 51 1.10.2.2 thorpej OBJCOPY?= objcopy 52 1.10.2.2 thorpej .endif 53 1.10.2.2 thorpej 54 1.10.2.2 thorpej CLEANFILES+= $(PROG).x $(PROG).map 55 1.10.2.2 thorpej 56 1.10.2.2 thorpej 57 1.10.2.2 thorpej $(PROG): $(OBJS) 58 1.10.2.2 thorpej $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) > $(PROG).map 59 1.10.2.2 thorpej @grep first_kbyte $(PROG).map 60 1.10.2.2 thorpej .if ${OBJECT_FMT} == "ELF" 61 1.10.2.2 thorpej @if [ `(echo ibase=16; \ 62 1.10.2.2 thorpej sed -n 's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p' \ 63 1.10.2.2 thorpej $(PROG).map | \ 64 1.10.2.2 thorpej tr a-f A-F) | bc` -gt 0 ]; \ 65 1.10.2.2 thorpej then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ 66 1.10.2.2 thorpej rm $(PROG) ; exit 1; \ 67 1.10.2.2 thorpej fi 68 1.10.2.2 thorpej .else 69 1.10.2.2 thorpej mv $(PROG) $(PROG).x 70 1.10.2.2 thorpej $(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG) 71 1.10.2.2 thorpej @rm -f $(PROG).x 72 1.10.2.2 thorpej @if [ `(echo ibase=16; \ 73 1.10.2.2 thorpej sed -n 's/ first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p' \ 74 1.10.2.2 thorpej $(PROG).map | \ 75 1.10.2.2 thorpej tr a-f A-F) | bc` -gt 0 ]; \ 76 1.10.2.2 thorpej then echo '$(BOOT): first_kbyte exceeds the first killobyte'; \ 77 1.10.2.2 thorpej rm $(PROG) ; exit 1; \ 78 1.10.2.2 thorpej fi 79 1.10.2.2 thorpej .endif 80 1.10.2.2 thorpej 81 1.10.2.2 thorpej .include <bsd.prog.mk> 82