17f3dea24SPeter Wemm# $FreeBSD$ 29d085703SBruce Evans 3d3b06cf2SKonstantin Belousov# Use the following command to build local debug version of dynamic 4d3b06cf2SKonstantin Belousov# linker: 5d3b06cf2SKonstantin Belousov# make DEBUG_FLAGS=-g DEBUG=-DDEBUG MK_TESTS=no all 6d3b06cf2SKonstantin Belousov 7c6063d0dSWarner Losh.include <src.opts.mk> 8c389411cSGlen BarberPACKAGE= clibs 9d9ca85fcSRuslan ErmilovMK_SSP= no 1000fb440cSDaniel Eischen 11c905e45dSPeter WemmPROG?= ld-elf.so.1 12c389411cSGlen Barber.if (${PROG:M*ld-elf32*} != "") 13c389411cSGlen BarberTAGS+= lib32 14c389411cSGlen Barber.endif 1555a4ccf3SStefan EßerSRCS= rtld_start.S \ 160e9a2605SKonstantin Belousov reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \ 17e659267fSOlivier Houchard malloc.c xmalloc.c debug.c libmap.c 18e5b5c66bSRuslan ErmilovMAN= rtld.1 198f17707cSDavid E. O'BrienCSTD?= gnu99 204cce0e98SNathan WhitehornCFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding 213c89d6b0SBryan DreweryCFLAGS+= -I${SRCTOP}/lib/csu/common 22789e8545SNathan Whitehorn.if exists(${.CURDIR}/${MACHINE_ARCH}) 23789e8545SNathan WhitehornRTLD_ARCH= ${MACHINE_ARCH} 24789e8545SNathan Whitehorn.else 25789e8545SNathan WhitehornRTLD_ARCH= ${MACHINE_CPUARCH} 26789e8545SNathan Whitehorn.endif 27789e8545SNathan WhitehornCFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR} 2827bd4146SNathan Whitehorn.if ${MACHINE_ARCH} == "powerpc64" 2927bd4146SNathan WhitehornLDFLAGS+= -nostdlib -e _rtld_start 3027bd4146SNathan Whitehorn.else 31d5b537d0SJohn PolstraLDFLAGS+= -nostdlib -e .rtld_start 3227bd4146SNathan Whitehorn.endif 331100c001SEd SchoutenWARNS?= 2 34dee651ebSRuslan ErmilovINSTALLFLAGS= -C -b 35dee651ebSRuslan ErmilovPRECIOUSPROG= 36f31c1e3fSPawel Jakub DawidekBINDIR= /libexec 377fdd45b0SBryan DrewerySYMLINKS= ${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG} 38d9943f16SAlexey ZelkinMLINKS= rtld.1 ld-elf.so.1.1 \ 39d9943f16SAlexey Zelkin rtld.1 ld.so.1 4013575fc4SDoug Rabson 41b9c727d8SDimitry Andric.if ${MACHINE_CPUARCH} == "sparc64" 42b9c727d8SDimitry AndricCFLAGS+= -fPIC 43b9c727d8SDimitry Andric.else 44b9c727d8SDimitry AndricCFLAGS+= -fpic 45b9c727d8SDimitry Andric.endif 4606786ccfSKonstantin BelousovCFLAGS+= -DPIC $(DEBUG) 470c4f9ecdSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 480c4f9ecdSKonstantin BelousovCFLAGS+= -fvisibility=hidden 490c4f9ecdSKonstantin Belousov.endif 50d5b537d0SJohn PolstraLDFLAGS+= -shared -Wl,-Bsymbolic 51ee5a34ecSBaptiste DaroussinLIBADD= c_pic 52c0f5aeb0SBryan Drewery.if ${MK_TOOLCHAIN} == "no" 53c0f5aeb0SBryan DreweryLDFLAGS+= -L${LIBCDIR} 54c0f5aeb0SBryan Drewery.endif 557ca8e6a6SAlexander Kabaev 566d4766c1SAndrew Turner.if ${MACHINE_CPUARCH} == "arm" 5737656b87SEd Schouten# Some of the required math functions (div & mod) are implemented in 5837656b87SEd Schouten# libcompiler_rt on ARM. The library also needs to be placed first to be 5937656b87SEd Schouten# correctly linked. As some of the functions are used before we have 6037656b87SEd Schouten# shared libraries. 61ee5a34ecSBaptiste DaroussinLIBADD+= compiler_rt 62de2be60cSAndrew Turner.endif 63de2be60cSAndrew Turner 64de2be60cSAndrew Turner 65de2be60cSAndrew Turner 6600fb440cSDaniel Eischen.if ${MK_SYMVER} == "yes" 673c89d6b0SBryan DreweryVERSION_DEF= ${LIBCSRCDIR}/Versions.def 687ca8e6a6SAlexander KabaevSYMBOL_MAPS= ${.CURDIR}/Symbol.map 697ca8e6a6SAlexander KabaevVERSION_MAP= Version.map 707ca8e6a6SAlexander KabaevLDFLAGS+= -Wl,--version-script=${VERSION_MAP} 717ca8e6a6SAlexander Kabaev 72789e8545SNathan Whitehorn.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map) 73789e8545SNathan WhitehornSYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map 747ca8e6a6SAlexander Kabaev.endif 75d5b537d0SJohn Polstra.endif 76d5b537d0SJohn Polstra 77789e8545SNathan Whitehorn.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc" 783124c3e0SJohn Polstra 79a857d930SGordon Tetlow# Since moving rtld-elf to /libexec, we need to create a symlink. 80a857d930SGordon Tetlow# Fixup the existing binary that's there so we can symlink over it. 81a857d930SGordon Tetlowbeforeinstall: 821508ab98SBryan Drewery.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no" 83456b64c4SPawel Jakub Dawidek -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG} 841b1aa7e4SRuslan Ermilov.endif 85a857d930SGordon Tetlow 86789e8545SNathan Whitehorn.PATH: ${.CURDIR}/${RTLD_ARCH} 873124c3e0SJohn Polstra 886b22f423SJonathan Anderson.if ${MK_TESTS} != "no" 896b22f423SJonathan AndersonSUBDIR+= tests 906b22f423SJonathan Anderson.endif 916b22f423SJonathan Anderson 923124c3e0SJohn Polstra.include <bsd.prog.mk> 93*e7debdcbSBryan Drewery${PROG_FULL}: ${VERSION_MAP} 94056b7d85SBryan Drewery.include <bsd.symver.mk> 95