3 # Use the following command to build local debug version of dynamic
5 # make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
7 RTLD_ELF_DIR:= ${.PARSEDIR}
11 MK_PIE= no # Always position independent using local rules
16 .if (${PROG:M*ld-elf32*} != "")
33 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
34 CFLAGS+= -I${SRCTOP}/lib/csu/common
35 .if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
36 RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/}
38 RTLD_ARCH= ${MACHINE_CPUARCH}
40 CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
46 SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
47 MLINKS?= rtld.1 ld-elf.so.1.1 \
50 CFLAGS+= -fpic -DPIC $(DEBUG)
52 LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY}
53 # Pull in the dependencies that we use from libc
54 .include "rtld-libc/Makefile.inc"
55 .if ${MK_TOOLCHAIN} == "no"
56 LDFLAGS+= -L${LIBCDIR}
59 VERSION_DEF= ${LIBCSRCDIR}/Versions.def
60 SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map
61 VERSION_MAP= Version.map
62 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
64 .if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map)
65 SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
68 .sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
69 RTLD_ENTRY?= .rtld_start
71 # Since moving rtld-elf to /libexec, we need to create a symlink.
72 # Fixup the existing binary that's there so we can symlink over it.
74 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
75 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
78 .PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common
80 .if ${.CURDIR} == ${RTLD_ELF_DIR}
82 SUBDIR.${MK_TESTS}+= tests
85 .include <bsd.prog.mk>
86 ${PROG_FULL}: ${VERSION_MAP}
87 .include <bsd.symver.mk>
89 .if ${COMPILER_TYPE} == "gcc"
90 # GCC warns about redeclarations even though they have __exported
91 # and are therefore not identical to the ones from the system headers.
92 CFLAGS+= -Wno-redundant-decls