1# $OpenBSD: Makefile,v 1.36 2021/11/14 00:45:38 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.ifdef NOPIC 19PICFLAG= 20.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64" 21# The objects for shared libraries need to work for all possible 22# libraries, so force big PIC where it matters. 23# Arguably m88k should do this too, but maybe there aren't any 24# libraries big enough to need it there? 25PICFLAG= -fPIC 26.endif 27 28.if exists(${.CURDIR}/${MACHINE_CPU}/boot_md.h) 29CFLAGS+= -DBOOT_H=\"boot_md.h\" 30.else 31CFLAGS+= -DBOOT_H=\"boot.h\" 32.endif 33 34RCFLAGS=-DRCRT0 35# amd64 can access the stack protector before relocation has occurred. 36# Other archs aren't so lucky 37.if ${MACHINE_ARCH} != "amd64" 38RCFLAGS+=-fno-stack-protector 39.endif 40 41# Prevent use of builtins in _dl_boot_bind(). 42.if ${MACHINE_CPU} == "mips64" || ${MACHINE_CPU} == "powerpc" 43RCFLAGS+=-fno-builtin 44.endif 45 46.if ${MACHINE_CPU} == "powerpc64" 47RCFLAGS+= -mno-vsx -mno-altivec 48.endif 49 50# Prevent use of jump tables in _dl_boot_bind(). 51.if ${MACHINE_CPU} == "mips64" || ${MACHINE_CPU} == "powerpc" || \ 52 ${MACHINE_CPU} == "powerpc64" 53RCFLAGS+=-fno-jump-tables 54.endif 55 56DEPS = ${OBJS:.o=.d} 57DFLAGS += -MF ${.TARGET:R}.d 58 59all: ${OBJS} 60 61crt0.o: crt0.c 62 @echo ${COMPILE.c} ${.CURDIR}/crt0.c -o ${.TARGET} 63 @${COMPILE.c} ${DFLAGS} ${.CURDIR}/crt0.c -o ${.TARGET}.o 64 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 65 @rm -f ${.TARGET}.o 66 67gcrt0.o: crt0.c 68 @echo ${COMPILE.c} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET} 69 @${COMPILE.c} ${DFLAGS} -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET}.o 70 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 71 @rm -f ${.TARGET}.o 72 73rcrt0.o: crt0.c 74 @echo ${COMPILE.c} ${RCFLAGS} ${.CURDIR}/crt0.c -o ${.TARGET} 75 @${COMPILE.c} ${DFLAGS} ${RCFLAGS} ${.CURDIR}/crt0.c -o ${.TARGET}.o 76 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 77 @rm -f ${.TARGET}.o 78 79crtbegin.o: crtbegin.c 80 @echo ${COMPILE.c} ${.CURDIR}/crtbegin.c -o ${.TARGET} 81 @${COMPILE.c} ${DFLAGS} ${.CURDIR}/crtbegin.c -o ${.TARGET}.o 82 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 83 @rm -f ${.TARGET}.o 84 85crtbeginS.o: crtbeginS.c 86 @echo ${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtbeginS.c -o ${.TARGET} 87 @${COMPILE.c} ${DFLAGS} ${PICFLAG} ${.CURDIR}/crtbeginS.c -o ${.TARGET}.o 88 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 89 @rm -f ${.TARGET}.o 90 91crtend.o: crtend.c 92 @echo ${COMPILE.c} ${.CURDIR}/crtend.c -o ${.TARGET} 93 @${COMPILE.c} ${DFLAGS} ${.CURDIR}/crtend.c -o ${.TARGET}.o 94 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 95 @rm -f ${.TARGET}.o 96 97crtendS.o: crtendS.c 98 @echo ${COMPILE.c} ${PICFLAG} ${.CURDIR}/crtendS.c -o ${.TARGET} 99 @${COMPILE.c} ${DFLAGS} ${PICFLAG} ${.CURDIR}/crtendS.c -o ${.TARGET}.o 100 @${LD} -x -r -o ${.TARGET} ${.TARGET}.o 101 @rm -f ${.TARGET}.o 102 103realinstall: 104 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${OBJS} \ 105 ${DESTDIR}/usr/lib 106 107.include <bsd.prog.mk> 108