Makefile.inc revision 1.33
11.33Sjoerg#	$NetBSD: Makefile.inc,v 1.33 2018/11/26 17:37:46 joerg Exp $
21.1Sjoerg
31.1Sjoerg.include <bsd.own.mk>
41.1Sjoerg
51.19Suwe# XXX: FIXME: This is defined in bsd.lib.mk
61.19SuwePICFLAGS ?= -fPIC
71.19Suwe
81.3SdrochnerCOMMON_DIR:=	${.CURDIR}/common
91.1Sjoerg.PATH:		${COMMON_DIR}
101.1Sjoerg
111.33SjoergCPPFLAGS+=	-I${COMMON_DIR} -I.
121.1Sjoerg
131.1SjoergOBJS+=		crt0.o gcrt0.o crti.o crtn.o
141.13SjoergOBJS+=		crtbegin.o crtend.o
151.28SmartinOBJS+=		sysident.o
161.13Sjoerg
171.13Sjoerg.if ${MKPIC} == "yes"
181.13SjoergOBJS+=		crtbeginS.o
191.15SmattCFLAGS.crtbegin.c+= -fPIE
201.13Sjoerg.endif
211.26Smrg
221.16Smatt.if ${MACHINE_ARCH} == "alpha"
231.16SmattOBJS+=		crtfm.o
241.16Smatt.endif
251.1Sjoerg
261.23Smartin.if ${CSU_MACHINE_ARCH} == "sparc64"
271.21Smartin# create helper objects for the compiler to mark compiler memory models
281.21Smartin.for m in medlow medmid medany
291.21Smartinsparc_mc${m}.o:	compident.S sysident_assym.h
301.21Smartin	${CC} ${ASFLAGS} -I. -DCONTENT=\"${m}\\0\\0\" -DCONTENTLENGTH=8 -c \
311.21Smartin		-o $@ ${COMMON_DIR}/compident.S
321.21Smartin.endfor
331.21SmartinOBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o
341.21Smartin.endif
351.21Smartin
361.1Sjoergrealall: ${OBJS}
371.1Sjoerg
381.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
391.10Smattcrtbegin.o: crtbegin.S
401.8Smatt	${_MKTARGET_COMPILE}
411.10Smatt	${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
421.8Smatt.else
431.10Smattcrtbegin.o: crtbegin.c crtbegin.h
441.1Sjoerg	${_MKTARGET_COMPILE}
451.15Smatt	${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
461.8Smatt.endif
471.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
481.1Sjoerg	rm -f ${.TARGET}.o
491.1Sjoerg.if ${MKSTRIPIDENT} != "no"
501.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
511.1Sjoerg.endif
521.1Sjoerg
531.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
541.10SmattcrtbeginS.o: crtbegin.S
551.8Smatt	${_MKTARGET_COMPILE}
561.19Suwe	${COMPILE.S} ${PICFLAGS} -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
571.8Smatt.else
581.10SmattcrtbeginS.o: crtbegin.c crtbegin.h
591.1Sjoerg	${_MKTARGET_COMPILE}
601.26Smrg	${COMPILE.c} ${CFLAGS.crtbeginS.c} ${PICFLAGS} -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
611.8Smatt.endif
621.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
631.1Sjoerg	rm -f ${.TARGET}.o
641.1Sjoerg.if ${MKSTRIPIDENT} != "no"
651.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
661.1Sjoerg.endif
671.1Sjoerg
681.1Sjoergcrtend.o: crtend.S
691.1Sjoerg	${_MKTARGET_COMPILE}
701.2Sjoerg	${COMPILE.S} ${ARCHDIR}/crtend.S -o ${.TARGET}.o
711.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
721.1Sjoerg	rm -f ${.TARGET}.o
731.1Sjoerg.if ${MKSTRIPIDENT} != "no"
741.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
751.1Sjoerg.endif
761.1Sjoerg
771.1Sjoerg.if ${MKPIC} != "no"
781.18SjoergMY_PICFLAGS=	${PICFLAGS}
791.1Sjoerg.else
801.18SjoergMY_PICFLAGS=
811.1Sjoerg.endif
821.1Sjoerg
831.6Suwecrt0.o: crt0.S crt0-common.c
841.1Sjoerg	${_MKTARGET_COMPILE}
851.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
861.27Sskrll	${COMPILE.c} ${CFLAGS.crt0-common.c} ${MY_PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
871.24Smatt	${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o
881.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
891.24Smatt	rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o
901.1Sjoerg.if ${MKSTRIPIDENT} != "no"
911.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
921.1Sjoerg.endif
931.1Sjoerg
941.6Suwegcrt0.o: crt0.S crt0-common.c
951.1Sjoerg	${_MKTARGET_COMPILE}
961.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
971.18Sjoerg	${COMPILE.c} ${MY_PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
981.24Smatt	${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o
991.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
1001.24Smatt	rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o
1011.1Sjoerg.if ${MKSTRIPIDENT} != "no"
1021.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
1031.1Sjoerg.endif
1041.1Sjoerg
1051.16Smatt.if ${MACHINE_ARCH} == "alpha"
1061.16Smatt# can't do this in Makefile.inc otherwise it will before realall:
1071.16Smattcrtfm.o: crtfm.c
1081.16Smatt	${_MKTARGET_COMPILE}
1091.16Smatt	${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o
1101.24Smatt	${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 
1111.16Smatt	rm -f ${.TARGET}.o
1121.16Smatt.endif
1131.16Smatt
1141.17SmattGENASSYM_CONF=	${COMMON_DIR}/sysident_assym.cf 
1151.20Sjoergsysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} ${NETBSDSRCDIR}/sys/sys/param.h
1161.1Sjoerg	${_MKTARGET_CREATE}
1171.1Sjoerg	cat ${COMMON_DIR}/sysident_assym.cf | \
1181.7Sjoerg	    ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
1191.25Sjoerg	    ${GENASSYM_CPPFLAGS} > sysident_assym.h.tmp && \
1201.1Sjoerg	mv -f sysident_assym.h.tmp sysident_assym.h
1211.1Sjoerg
1221.1SjoergCLEANFILES+=	sysident_assym.h
1231.1Sjoerg
1241.17Smattcrti.o: crti.S sysident_assym.h sysident.S
1251.1Sjoergcrtn.o: crtn.S
1261.28Smartinsysident.o:	sysident.S sysident_assym.h
1271.1Sjoerg
1281.1SjoergFILES=${OBJS}
1291.1SjoergFILESDIR=${LIBDIR}
1301.1SjoergCLEANFILES+=${OBJS}
1311.13Sjoerg
1321.13Sjoerg.if ${MKPIC} == "yes"
1331.1SjoergSYMLINKS+=	crtbegin.o ${LIBDIR}/crtbeginT.o
1341.1SjoergSYMLINKS+=	crtend.o ${LIBDIR}/crtendS.o
1351.13Sjoerg.endif
1361.1Sjoerg
1371.1Sjoerg.include <bsd.prog.mk>
138