Makefile.inc revision 1.23
11.23Smartin#	$NetBSD: Makefile.inc,v 1.23 2013/11/17 11:16:09 martin 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.1SjoergCPPFLAGS+=	-I${NETBSDSRCDIR}/libexec/ld.elf_so -I${COMMON_DIR} -I.
121.1Sjoerg
131.1SjoergOBJS+=		crt0.o gcrt0.o crti.o crtn.o
141.13SjoergOBJS+=		crtbegin.o crtend.o
151.13Sjoerg
161.13Sjoerg.if ${MKPIC} == "yes"
171.13SjoergOBJS+=		crtbeginS.o
181.15SmattCFLAGS.crtbegin.c+= -fPIE
191.13Sjoerg.endif
201.16Smatt.if ${MACHINE_ARCH} == "alpha"
211.16SmattOBJS+=		crtfm.o
221.16Smatt.endif
231.1Sjoerg
241.23Smartin.if ${CSU_MACHINE_ARCH} == "sparc64"
251.21Smartin# create helper objects for the compiler to mark compiler memory models
261.21Smartin.for m in medlow medmid medany
271.21Smartinsparc_mc${m}.o:	compident.S sysident_assym.h
281.21Smartin	${CC} ${ASFLAGS} -I. -DCONTENT=\"${m}\\0\\0\" -DCONTENTLENGTH=8 -c \
291.21Smartin		-o $@ ${COMMON_DIR}/compident.S
301.21Smartin.endfor
311.21SmartinOBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o
321.21Smartin.endif
331.21Smartin
341.1Sjoergrealall: ${OBJS}
351.1Sjoerg
361.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
371.10Smattcrtbegin.o: crtbegin.S
381.8Smatt	${_MKTARGET_COMPILE}
391.10Smatt	${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
401.8Smatt.else
411.10Smattcrtbegin.o: crtbegin.c crtbegin.h
421.1Sjoerg	${_MKTARGET_COMPILE}
431.15Smatt	${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
441.8Smatt.endif
451.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
461.1Sjoerg	rm -f ${.TARGET}.o
471.1Sjoerg.if ${MKSTRIPIDENT} != "no"
481.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
491.1Sjoerg.endif
501.1Sjoerg
511.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
521.10SmattcrtbeginS.o: crtbegin.S
531.8Smatt	${_MKTARGET_COMPILE}
541.19Suwe	${COMPILE.S} ${PICFLAGS} -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
551.8Smatt.else
561.10SmattcrtbeginS.o: crtbegin.c crtbegin.h
571.1Sjoerg	${_MKTARGET_COMPILE}
581.19Suwe	${COMPILE.c} ${PICFLAGS} -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
591.8Smatt.endif
601.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
611.1Sjoerg	rm -f ${.TARGET}.o
621.1Sjoerg.if ${MKSTRIPIDENT} != "no"
631.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
641.1Sjoerg.endif
651.1Sjoerg
661.1Sjoergcrtend.o: crtend.S
671.1Sjoerg	${_MKTARGET_COMPILE}
681.2Sjoerg	${COMPILE.S} ${ARCHDIR}/crtend.S -o ${.TARGET}.o
691.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
701.1Sjoerg	rm -f ${.TARGET}.o
711.1Sjoerg.if ${MKSTRIPIDENT} != "no"
721.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
731.1Sjoerg.endif
741.1Sjoerg
751.1Sjoerg.if ${MKPIC} != "no"
761.18SjoergMY_PICFLAGS=	${PICFLAGS}
771.1Sjoerg.else
781.18SjoergMY_PICFLAGS=
791.1Sjoerg.endif
801.1Sjoerg
811.6Suwecrt0.o: crt0.S crt0-common.c
821.1Sjoerg	${_MKTARGET_COMPILE}
831.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
841.18Sjoerg	${COMPILE.c} ${MY_PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
851.6Suwe	${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
861.6Suwe	rm -f ${.TARGET}.S.o ${.TARGET}.c.o
871.1Sjoerg.if ${MKSTRIPIDENT} != "no"
881.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
891.1Sjoerg.endif
901.1Sjoerg
911.6Suwegcrt0.o: crt0.S crt0-common.c
921.1Sjoerg	${_MKTARGET_COMPILE}
931.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
941.18Sjoerg	${COMPILE.c} ${MY_PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
951.6Suwe	${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
961.6Suwe	rm -f ${.TARGET}.S.o ${.TARGET}.c.o
971.1Sjoerg.if ${MKSTRIPIDENT} != "no"
981.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
991.1Sjoerg.endif
1001.1Sjoerg
1011.16Smatt.if ${MACHINE_ARCH} == "alpha"
1021.16Smatt# can't do this in Makefile.inc otherwise it will before realall:
1031.16Smattcrtfm.o: crtfm.c
1041.16Smatt	${_MKTARGET_COMPILE}
1051.16Smatt	${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o
1061.16Smatt	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
1071.16Smatt	rm -f ${.TARGET}.o
1081.16Smatt.endif
1091.16Smatt
1101.17SmattGENASSYM_CONF=	${COMMON_DIR}/sysident_assym.cf 
1111.20Sjoergsysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} ${NETBSDSRCDIR}/sys/sys/param.h
1121.1Sjoerg	${_MKTARGET_CREATE}
1131.1Sjoerg	cat ${COMMON_DIR}/sysident_assym.cf | \
1141.7Sjoerg	    ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
1151.1Sjoerg	    > sysident_assym.h.tmp && \
1161.1Sjoerg	mv -f sysident_assym.h.tmp sysident_assym.h
1171.1Sjoerg
1181.1SjoergCLEANFILES+=	sysident_assym.h
1191.1Sjoerg
1201.17Smattcrti.o: crti.S sysident_assym.h sysident.S
1211.1Sjoergcrtn.o: crtn.S
1221.1Sjoerg
1231.1SjoergFILES=${OBJS}
1241.1SjoergFILESDIR=${LIBDIR}
1251.1SjoergCLEANFILES+=${OBJS}
1261.13Sjoerg
1271.13Sjoerg.if ${MKPIC} == "yes"
1281.1SjoergSYMLINKS+=	crtbegin.o ${LIBDIR}/crtbeginT.o
1291.1SjoergSYMLINKS+=	crtend.o ${LIBDIR}/crtendS.o
1301.13Sjoerg.endif
1311.1Sjoerg
1321.1Sjoerg.include <bsd.prog.mk>
133