Makefile.inc revision 1.16
11.16Smatt#	$NetBSD: Makefile.inc,v 1.16 2013/08/05 13:38:35 matt Exp $
21.1Sjoerg
31.1Sjoerg.include <bsd.own.mk>
41.1Sjoerg
51.3SdrochnerCOMMON_DIR:=	${.CURDIR}/common
61.1Sjoerg.PATH:		${COMMON_DIR}
71.1Sjoerg
81.1SjoergCPPFLAGS+=	-I${NETBSDSRCDIR}/libexec/ld.elf_so -I${COMMON_DIR} -I.
91.1Sjoerg
101.1SjoergOBJS+=		crt0.o gcrt0.o crti.o crtn.o
111.13SjoergOBJS+=		crtbegin.o crtend.o
121.13Sjoerg
131.13Sjoerg.if ${MKPIC} == "yes"
141.13SjoergOBJS+=		crtbeginS.o
151.15SmattCFLAGS.crtbegin.c+= -fPIE
161.13Sjoerg.endif
171.16Smatt.if ${MACHINE_ARCH} == "alpha"
181.16SmattOBJS+=		crtfm.o
191.16Smatt.endif
201.1Sjoerg
211.1Sjoergrealall: ${OBJS}
221.1Sjoerg
231.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
241.10Smattcrtbegin.o: crtbegin.S
251.8Smatt	${_MKTARGET_COMPILE}
261.10Smatt	${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
271.8Smatt.else
281.10Smattcrtbegin.o: crtbegin.c crtbegin.h
291.1Sjoerg	${_MKTARGET_COMPILE}
301.15Smatt	${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
311.8Smatt.endif
321.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
331.1Sjoerg	rm -f ${.TARGET}.o
341.1Sjoerg.if ${MKSTRIPIDENT} != "no"
351.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
361.1Sjoerg.endif
371.1Sjoerg
381.10Smatt.if exists(${ARCHDIR}/crtbegin.S)
391.10SmattcrtbeginS.o: crtbegin.S
401.8Smatt	${_MKTARGET_COMPILE}
411.10Smatt	${COMPILE.S} -DPIC -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
421.8Smatt.else
431.10SmattcrtbeginS.o: crtbegin.c crtbegin.h
441.1Sjoerg	${_MKTARGET_COMPILE}
451.11Smatt	${COMPILE.c} -fPIC -DPIC -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
461.8Smatt.endif
471.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
481.1Sjoerg	rm -f ${.TARGET}.o
491.1Sjoerg.if ${MKSTRIPIDENT} != "no"
501.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
511.1Sjoerg.endif
521.1Sjoerg
531.1Sjoergcrtend.o: crtend.S
541.1Sjoerg	${_MKTARGET_COMPILE}
551.2Sjoerg	${COMPILE.S} ${ARCHDIR}/crtend.S -o ${.TARGET}.o
561.1Sjoerg	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
571.1Sjoerg	rm -f ${.TARGET}.o
581.1Sjoerg.if ${MKSTRIPIDENT} != "no"
591.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
601.1Sjoerg.endif
611.1Sjoerg
621.1Sjoerg.if ${MKPIC} != "no"
631.1SjoergPICFLAGS=	-fPIC
641.1Sjoerg.else
651.1SjoergPICFLAGS=
661.1Sjoerg.endif
671.1Sjoerg
681.6Suwecrt0.o: crt0.S crt0-common.c
691.1Sjoerg	${_MKTARGET_COMPILE}
701.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
711.1Sjoerg	${COMPILE.c} ${PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
721.6Suwe	${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
731.6Suwe	rm -f ${.TARGET}.S.o ${.TARGET}.c.o
741.1Sjoerg.if ${MKSTRIPIDENT} != "no"
751.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
761.1Sjoerg.endif
771.1Sjoerg
781.6Suwegcrt0.o: crt0.S crt0-common.c
791.1Sjoerg	${_MKTARGET_COMPILE}
801.6Suwe	${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
811.1Sjoerg	${COMPILE.c} ${PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
821.6Suwe	${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
831.6Suwe	rm -f ${.TARGET}.S.o ${.TARGET}.c.o
841.1Sjoerg.if ${MKSTRIPIDENT} != "no"
851.1Sjoerg	${OBJCOPY} -R .ident ${.TARGET}
861.1Sjoerg.endif
871.1Sjoerg
881.16Smatt.if ${MACHINE_ARCH} == "alpha"
891.16Smatt# can't do this in Makefile.inc otherwise it will before realall:
901.16Smattcrtfm.o: crtfm.c
911.16Smatt	${_MKTARGET_COMPILE}
921.16Smatt	${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o
931.16Smatt	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
941.16Smatt	rm -f ${.TARGET}.o
951.16Smatt.endif
961.16Smatt
971.1Sjoergsysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
981.1Sjoerg	${_MKTARGET_CREATE}
991.1Sjoerg	cat ${COMMON_DIR}/sysident_assym.cf | \
1001.7Sjoerg	    ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
1011.1Sjoerg	    > sysident_assym.h.tmp && \
1021.1Sjoerg	mv -f sysident_assym.h.tmp sysident_assym.h
1031.1Sjoerg
1041.1SjoergCLEANFILES+=	sysident_assym.h
1051.1Sjoerg
1061.1Sjoergcrti.o: crti.S sysident_assym.h
1071.1Sjoergcrtn.o: crtn.S
1081.1Sjoerg
1091.1SjoergFILES=${OBJS}
1101.1SjoergFILESDIR=${LIBDIR}
1111.1SjoergCLEANFILES+=${OBJS}
1121.13Sjoerg
1131.13Sjoerg.if ${MKPIC} == "yes"
1141.1SjoergSYMLINKS+=	crtbegin.o ${LIBDIR}/crtbeginT.o
1151.1SjoergSYMLINKS+=	crtend.o ${LIBDIR}/crtendS.o
1161.13Sjoerg.endif
1171.1Sjoerg
1181.1Sjoerg.include <bsd.prog.mk>
119