3 # Use the following command to build local debug version of dynamic
5 # make DEBUG_FLAGS=-g DEBUG=-DDEBUG WITHOUT_TESTS=yes all
10 MK_PIE= no # Always position independent using local rules
15 .if (${PROG:M*ld-elf32*} != "")
31 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
32 CFLAGS+= -I${SRCTOP}/lib/csu/common
33 .if exists(${.CURDIR}/${MACHINE_ARCH})
34 RTLD_ARCH= ${MACHINE_ARCH}
36 RTLD_ARCH= ${MACHINE_CPUARCH}
38 CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
39 .if ${MACHINE_ARCH} == "powerpc64"
40 LDFLAGS+= -nostdlib -e _rtld_start
42 LDFLAGS+= -nostdlib -e .rtld_start
50 SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
51 MLINKS= rtld.1 ld-elf.so.1.1 \
54 .if ${MACHINE_CPUARCH} == "sparc64"
59 CFLAGS+= -DPIC $(DEBUG)
60 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
61 CFLAGS+= -fvisibility=hidden
63 .if ${MACHINE_CPUARCH} == "mips"
64 CFLAGS.reloc.c+=-fno-jump-tables
66 LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs
68 .if ${MK_TOOLCHAIN} == "no"
69 LDFLAGS+= -L${LIBCDIR}
72 .if ${MACHINE_CPUARCH} == "arm"
73 # Some of the required math functions (div & mod) are implemented in
74 # libcompiler_rt on ARM. The library also needs to be placed first to be
75 # correctly linked. As some of the functions are used before we have
82 .if ${MK_SYMVER} == "yes"
83 VERSION_DEF= ${LIBCSRCDIR}/Versions.def
84 SYMBOL_MAPS= ${.CURDIR}/Symbol.map
85 VERSION_MAP= Version.map
86 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
88 .if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
89 SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map
93 .sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
95 # Since moving rtld-elf to /libexec, we need to create a symlink.
96 # Fixup the existing binary that's there so we can symlink over it.
98 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
99 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
102 .PATH: ${.CURDIR}/${RTLD_ARCH}
105 SUBDIR.${MK_TESTS}+= tests
107 .include <bsd.prog.mk>
108 ${PROG_FULL}: ${VERSION_MAP}
109 .include <bsd.symver.mk>
111 .if ${COMPILER_TYPE} == "gcc"
112 # GCC warns about redeclarations even though they have __exported
113 # and are therefore not identical to the ones from the system headers.
114 CFLAGS+= -Wno-redundant-decls
115 .if ${COMPILER_VERSION} < 40300
116 # Silence -Wshadow false positives in ancient GCC