1# $OpenBSD: Makefile,v 1.26 2017/01/21 00:46:32 guenther Exp $ 2 3OBJS= crt0.o gcrt0.o 4OBJS+= crtbegin.o crtend.o 5OBJS+= crtbeginS.o crtendS.o 6OBJS+= rcrt0.o 7SRCS= crt0.c crtbegin.c crtbeginS.c crtend.c crtendS.c 8 9CFLAGS+= -I${.CURDIR}/${MACHINE_CPU} 10CFLAGS+= -I${.CURDIR}/../../libexec/ld.so 11CFLAGS+= -I${.CURDIR}/../../libexec/ld.so/${MACHINE_CPU} 12 13# XXX "use -fno-omit-frame-pointer; the reason is almost crazy; pr#287" 14.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" 15CFLAGS+= -fno-omit-frame-pointer 16.endif 17 18# Override powerpc default of -fPIE 19# XXX if this is safe, why not override CFLAGS for alpha and sparc64 too? 20# Does it work because the csu bits come first and get the first few GOT 21# entries? 22.if ${MACHINE_ARCH} == "powerpc" 23CFLAGS+= -fpie 24.endif 25 26.ifdef NOPIC 27PICFLAG= 28.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64" 29# The objects for shared libraries need to work for all possible 30# libraries, so force big PIC where it matters. 31# Arguably m88k should do this too, but maybe there aren't any 32# libraries big enough to need it there? 33PICFLAG= -fPIC 34.endif 35 36RCFLAGS=-DRCRT0 37# amd64 can access the stack protector before relocation has occurred. 38# Other archs aren't so lucky 39.if ${MACHINE_ARCH} != "amd64" 40RCFLAGS+=-fno-stack-protector 41.endif 42 43all: ${OBJS} 44 45crt0.o: crt0.c 46 @echo ${COMPILE.c} ${.CURDIR}/crt0.c -o ${.TARGET} 47 @${COMPILE.c} ${.CURDIR}/crt0.c -o ${.TARGET}.o 48 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 49 @rm -f ${.TARGET}.o 50 51gcrt0.o: crt0.c 52 @echo ${COMPILE.c} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET} 53 @${COMPILE.c} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET}.o 54 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 55 @rm -f ${.TARGET}.o 56 57rcrt0.o: crt0.c 58 @echo ${COMPILE.c} ${RCFLAGS} ${.CURDIR}/crt0.c -o ${.TARGET} 59 @${COMPILE.c} ${RCFLAGS} ${.CURDIR}/crt0.c -o ${.TARGET}.o 60 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 61 @rm -f ${.TARGET}.o 62 63crtbegin.o: crtbegin.c 64 @echo ${COMPILE.c} ${.CURDIR}/crtbegin.c -o ${.TARGET} 65 @${COMPILE.c} ${.CURDIR}/crtbegin.c -o ${.TARGET}.o 66 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 67 @rm -f ${.TARGET}.o 68 69crtbeginS.o: crtbeginS.c 70 @echo ${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtbeginS.c -o ${.TARGET} 71 @${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtbeginS.c -o ${.TARGET}.o 72 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 73 @rm -f ${.TARGET}.o 74 75crtend.o: crtend.c 76 @echo ${COMPILE.c} ${.CURDIR}/crtend.c -o ${.TARGET} 77 @${COMPILE.c} ${.CURDIR}/crtend.c -o ${.TARGET}.o 78 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 79 @rm -f ${.TARGET}.o 80 81crtendS.o: crtendS.c 82 @echo ${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtendS.c -o ${.TARGET} 83 @${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtendS.c -o ${.TARGET}.o 84 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 85 @rm -f ${.TARGET}.o 86 87realinstall: 88 ${INSTALL} ${INSTALL_COPY} -S -o ${BINOWN} -g ${BINGRP} -m 444 ${OBJS} \ 89 ${DESTDIR}/usr/lib 90 91afterdepend: .depend 92 @sed -i 's/^\([^\.]*\).o[ ]*:/\1.o g\1.o r\1.o:/' .depend 93 94.include <bsd.prog.mk> 95