1# $NetBSD: Makefile.inc,v 1.35 2018/12/28 18:17:11 christos Exp $ 2 3.include <bsd.own.mk> 4 5# XXX: FIXME: This is defined in bsd.lib.mk 6PICFLAGS ?= -fPIC 7 8COMMON_DIR:= ${.CURDIR}/common 9.PATH: ${COMMON_DIR} 10 11CPPFLAGS+= -I${COMMON_DIR} -I. 12 13OBJS+= crt0.o gcrt0.o crti.o crtn.o 14OBJS+= crtbegin.o crtend.o 15OBJS+= sysident.o 16 17.if ${MKPIC} == "yes" 18OBJS+= crtbeginS.o 19CFLAGS.crtbegin.c+= -fPIE 20.endif 21 22.if ${MACHINE_ARCH} == "alpha" 23OBJS+= crtfm.o 24.endif 25 26.if ${CSU_MACHINE_ARCH} == "sparc64" 27# create helper objects for the compiler to mark compiler memory models 28.for m in medlow medmid medany 29sparc_mc${m}.o: compident.S sysident_assym.h 30 ${CC} ${ASFLAGS} -I. -DCONTENT=\"${m}\\0\\0\" -DCONTENTLENGTH=8 -c \ 31 -o $@ ${COMMON_DIR}/compident.S 32.endfor 33OBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o 34.endif 35 36realall: ${OBJS} 37 38.if exists(${ARCHDIR}/crtbegin.S) 39crtbegin.o: crtbegin.S 40 ${_MKTARGET_COMPILE} 41 ${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o 42.else 43crtbegin.o: crtbegin.c crtbegin.h 44 ${_MKTARGET_COMPILE} 45 ${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o 46.endif 47 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 48 rm -f ${.TARGET}.o 49.if ${MKSTRIPIDENT} != "no" 50 ${OBJCOPY} -R .ident ${.TARGET} 51.endif 52 53.if exists(${ARCHDIR}/crtbegin.S) 54crtbeginS.o: crtbegin.S 55 ${_MKTARGET_COMPILE} 56 ${COMPILE.S} ${PICFLAGS} -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o 57.else 58crtbeginS.o: crtbegin.c crtbegin.h 59 ${_MKTARGET_COMPILE} 60 ${COMPILE.c} ${CFLAGS.crtbeginS.c} ${PICFLAGS} -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o 61.endif 62 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 63 rm -f ${.TARGET}.o 64.if ${MKSTRIPIDENT} != "no" 65 ${OBJCOPY} -R .ident ${.TARGET} 66.endif 67 68crtend.o: crtend.S 69 ${_MKTARGET_COMPILE} 70 ${COMPILE.S} ${ARCHDIR}/crtend.S -o ${.TARGET}.o 71 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 72 rm -f ${.TARGET}.o 73.if ${MKSTRIPIDENT} != "no" 74 ${OBJCOPY} -R .ident ${.TARGET} 75.endif 76 77.if ${MKPIC} != "no" 78MY_PICFLAGS= ${PICFLAGS} 79.else 80MY_PICFLAGS= 81.endif 82 83crt0.o: crt0.S crt0-common.c 84 ${_MKTARGET_COMPILE} 85 ${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o 86 ${COMPILE.c} ${CFLAGS.crt0-common.c} ${MY_PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o 87 ${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o 88 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 89 rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o 90.if ${MKSTRIPIDENT} != "no" 91 ${OBJCOPY} -R .ident ${.TARGET} 92.endif 93 94gcrt0.o: crt0.S crt0-common.c 95 ${_MKTARGET_COMPILE} 96 ${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o 97 ${COMPILE.c} ${MY_PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o 98 ${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o 99 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 100 rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o 101.if ${MKSTRIPIDENT} != "no" 102 ${OBJCOPY} -R .ident ${.TARGET} 103.endif 104 105.if ${MACHINE_ARCH} == "alpha" 106# can't do this in Makefile.inc otherwise it will before realall: 107crtfm.o: crtfm.c 108 ${_MKTARGET_COMPILE} 109 ${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o 110 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} 111 rm -f ${.TARGET}.o 112.endif 113 114GENASSYM_CONF= ${COMMON_DIR}/sysident_assym.cf 115sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} ${NETBSDSRCDIR}/sys/sys/param.h 116 ${_MKTARGET_CREATE} 117 cat ${COMMON_DIR}/sysident_assym.cf | \ 118 ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \ 119 ${GENASSYM_CPPFLAGS} > sysident_assym.h.tmp && \ 120 mv -f sysident_assym.h.tmp sysident_assym.h 121 122CLEANFILES+= sysident_assym.h 123 124crti.o: crti.S sysident_assym.h sysident.S 125crtn.o: crtn.S 126sysident.o: sysident.S sysident_assym.h 127 128FILES=${OBJS} 129FILESDIR=${LIBDIR} 130CLEANFILES+=${OBJS} 131 132.if ${MKPIC} == "yes" 133SYMLINKS+= crtbegin.o ${LIBDIR}/crtbeginT.o 134SYMLINKS+= crtend.o ${LIBDIR}/crtendS.o 135.endif 136 137.include <bsd.prog.mk> 138