Makefile revision 1.25
11.25Schristos#	$NetBSD: Makefile,v 1.25 2017/04/09 14:51:52 christos Exp $
21.25Schristos
31.25Schristos.include <bsd.init.mk>
41.25Schristos.include <bsd.sys.mk>
51.1Smhitch
61.1Smhitch### what we need:
71.1Smhitch
81.25SchristosDIR_TOP=	${.CURDIR}/../../../../..
91.25SchristosDIR_SA = 	${DIR_TOP}/lib/libsa
101.25SchristosDIR_KERN=	${DIR_TOP}/lib/libkern
111.25SchristosDIR_KERN_MD=	${DIR_TOP}/lib/libkern/arch/$(MACHINE_ARCH)
121.25SchristosDIR_LIBC=	${DIR_TOP}/../common/lib/libc
131.10Sis
141.10Sis.PATH:  ${.CURDIR}/../boot $(DIR_SA) $(DIR_KERN) $(DIR_KERN_MD) \
151.10Sis	${DIR_LIBC}/gen ${DIR_LIBC}/arch/m68k/gen \
161.10Sis	${DIR_LIBC}/inet ${DIR_LIBC}/arch/m68k/inet \
171.10Sis	${DIR_LIBC}/quad ${DIR_LIBC}/arch/m68k/quad \
181.10Sis	${DIR_LIBC}/string ${DIR_LIBC}/arch/m68k/string
191.1Smhitch
201.25SchristosS=		${DIR_TOP}
211.1Smhitch
221.1Smhitch# prefer our assembler versions over assembler, and assembler over C:
231.1Smhitch
241.1Smhitch.SUFFIXES:
251.13Smrg.SUFFIXES: .out .o .po .pico .so .s .S .c .cc .C .f .y .l .ln .m4 .sh
261.1Smhitch
271.1SmhitchFILES= bootxx_ffs bootxx_fd
281.1SmhitchBINDIR=/usr/mdec
291.1Smhitch
301.1SmhitchCOBJS = main.o console.o xd.o twiddle.o bzero.o gets.o
311.25SchristosCOBJS+=  lseek.o open.o vers.o read.o close.o dev.o errno.o
321.24SchristosCOBJS+=  ufs.o ustarfs.o panic.o files.o
331.1Smhitch
341.1SmhitchSOBJS = alloc.o ashrdi3.o ashldi3.o bcopy.o muldi3.o printf.o startit.o
351.1SmhitchSOBJS += strlen.o strcmp.o fstat.o
361.6SheSOBJS += libstubs.o memcmp.o memmove.o memset.o strncmp.o
371.1Smhitch
381.24SchristosOBJS+=	$(SOBJS) $(COBJS)
391.1Smhitch
401.23SmlelstvDEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -D_PRIMARY_BOOT -DSERCONSOLE
411.1Smhitch
421.1Smhitch.NOPATH: ${OBJS} x.out f.out libboot.a xxstart.o
431.1Smhitch
441.1Smhitch### main target: ###
451.1Smhitch
461.20Smattrealall: ${FILES}
471.1Smhitch
481.24SchristosCLEANFILES += bootxx_ffs bootxx_fd x.out f.out xxstart.o fdstart.o libboot.a
491.1Smhitch
501.25SchristosVERSIONFILE=${.CURDIR}/../boot/version
511.25SchristosVERSIONFLAGS+=-n
521.25Schristos.include "${S}/conf/newvers_stand.mk"
531.25Schristos
541.1Smhitch.include <bsd.prog.mk>
551.20Smatt.include <bsd.klinks.mk>
561.1Smhitch
571.1Smhitch### special  rules for bootblocks ###
581.1Smhitch
591.24SchristosINCPATH = -nostdinc -I${S} -I${S}/lib/libsa -I${.CURDIR}
601.1SmhitchINCPATH += -I${.CURDIR}/../boot -I${.CURDIR}/../../..
611.14SmrgINCPATH += -I${.CURDIR}/../elf2bb -I${.OBJDIR}
621.1Smhitch
631.1SmhitchAFLAGS += -m68030 -l
641.22SmartinCAFLAGS += -Wa,-l -Wa,-march=68030 -Wa,-mcpu=68030 ${INCPATH} -D_PRIMARY_BOOT
651.1Smhitch
661.19SjoergCOPTIM= -Os -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks
671.21SmlelstvCOPTIM+= -Wa,-l -m68060 -Wa,-mcpu=68030 -fno-unwind-tables
681.4SthorpejCFLAGS= -ffreestanding ${COPTIM} ${INCPATH} ${DEFS} -Wall #-Wstrict-prototypes
691.1Smhitch
701.8SlukemNETBSD_VERS!=	${HOST_SH} ${.CURDIR}/../../../../../conf/osrelease.sh
711.1SmhitchDEFS+=	-DNETBSD_VERS='"${NETBSD_VERS}"'
721.5Smhitch
731.5Smhitch# Use small daddr_t to avoid code bloat
741.5SmhitchDEFS+=	-D__daddr_t=int32_t
751.1Smhitch
761.1Smhitch.c.o:
771.20Smatt	${_MKTARGET_COMPILE}
781.1Smhitch	${CC} ${CFLAGS} -S $< -o $*.s
791.1Smhitch	${TXLT} < $*.s | ${AS} ${AFLAGS} -o $*.o
801.1Smhitch	rm $*.s
811.1Smhitch
821.20Smatt.s.o:
831.20Smatt	${_MKTARGET_COMPILE}
841.20Smatt	${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp -o $@ -c $<
851.20Smatt
861.20Smatt.S.o:
871.20Smatt	${_MKTARGET_COMPILE}
881.20Smatt	${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp -o $@ -c $<
891.1Smhitch
901.1Smhitchbootxx_ffs: x.out
911.20Smatt	${_MKTARGET_CREATE}
921.17Smrg	${RELOC2BB} x.out $@ || (${NM} -u x.out && false)
931.1Smhitch
941.1Smhitchbootxx_fd: f.out
951.20Smatt	${_MKTARGET_CREATE}
961.17Smrg	${RELOC2BB} -F f.out $@ || (${NM} -u f.out && false)
971.1Smhitch
981.1Smhitchx.out: xxstart.o libboot.a
991.20Smatt	${_MKTARGET_LINK}
1001.20Smatt	${LD} ${LDFLAGS} -r -dc -e start -o $@ $>
1011.1Smhitch	${SIZE} $@
1021.1Smhitch	${NM} -u $@
1031.1Smhitch
1041.1Smhitchf.out: fdstart.o libboot.a
1051.20Smatt	${_MKTARGET_LINK}
1061.20Smatt	${LD} ${LDFLAGS} -r -dc -e start -o $@ $>
1071.1Smhitch	${SIZE} $@
1081.1Smhitch	${NM} -u $@
1091.1Smhitch
1101.1Smhitchxxstart.o: ${.CURDIR}/../boot/bbstart.s
1111.20Smatt	${_MKTARGET_COMPILE}
1121.1Smhitch	${CC} ${CAFLAGS} ${COPTS} -x assembler-with-cpp \
1131.1Smhitch		-o $@ -c $>
1141.1Smhitch
1151.1Smhitchfdstart.o: ${.CURDIR}/../boot//bbstart.s
1161.20Smatt	${_MKTARGET_COMPILE}
1171.1Smhitch	${CC} -DAUTOLOAD=8192 ${CAFLAGS} ${COPTS} -x assembler-with-cpp \
1181.1Smhitch		-o $@ -c $>
1191.1Smhitch
1201.1Smhitchlibboot.a: ${OBJS}
1211.20Smatt	${_MKTARGET_BUILD}
1221.20Smatt	${AR} crs $@ $> && ${RANLIB} $@
1231.1Smhitch
1241.1Smhitch# make sure these are built:
1251.1Smhitch
1261.1Smhitch${COBJS}: ${TXLT}
1271.1Smhitch${FILES}: ${RELOC2BB}
1281.2Saymeric
1291.2Saymeric.include "${.CURDIR}/../Makefile.booters"
130