3 # Use the following command to build local debug version of dynamic
5 # make DEBUG_FLAGS=-g DEBUG=-DDEBUG WITHOUT_TESTS=yes all
14 .if (${PROG:M*ld-elf32*} != "")
18 reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
19 malloc.c xmalloc.c debug.c libmap.c
22 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
23 CFLAGS+= -I${SRCTOP}/lib/csu/common
24 .if exists(${.CURDIR}/${MACHINE_ARCH})
25 RTLD_ARCH= ${MACHINE_ARCH}
27 RTLD_ARCH= ${MACHINE_CPUARCH}
29 CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
30 .if ${MACHINE_ARCH} == "powerpc64"
31 LDFLAGS+= -nostdlib -e _rtld_start
33 LDFLAGS+= -nostdlib -e .rtld_start
41 SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
42 MLINKS= rtld.1 ld-elf.so.1.1 \
45 .if ${MACHINE_CPUARCH} == "sparc64"
50 CFLAGS+= -DPIC $(DEBUG)
51 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
52 CFLAGS+= -fvisibility=hidden
54 .if ${MACHINE_CPUARCH} == "mips"
55 CFLAGS.reloc.c+=-fno-jump-tables
57 LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs
59 .if ${MK_TOOLCHAIN} == "no"
60 LDFLAGS+= -L${LIBCDIR}
63 .if ${MACHINE_CPUARCH} == "arm"
64 # Some of the required math functions (div & mod) are implemented in
65 # libcompiler_rt on ARM. The library also needs to be placed first to be
66 # correctly linked. As some of the functions are used before we have
73 .if ${MK_SYMVER} == "yes"
74 VERSION_DEF= ${LIBCSRCDIR}/Versions.def
75 SYMBOL_MAPS= ${.CURDIR}/Symbol.map
76 VERSION_MAP= Version.map
77 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
79 .if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
80 SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map
84 .sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
86 # Since moving rtld-elf to /libexec, we need to create a symlink.
87 # Fixup the existing binary that's there so we can symlink over it.
89 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
90 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
93 .PATH: ${.CURDIR}/${RTLD_ARCH}
96 SUBDIR.${MK_TESTS}+= tests
98 .include <bsd.prog.mk>
99 ${PROG_FULL}: ${VERSION_MAP}
100 .include <bsd.symver.mk>
102 .if ${COMPILER_TYPE} == "gcc"
103 # GCC warns about redeclarations even though they have __exported
104 # and are therefore not identical to the ones from the system headers.
105 CFLAGS+= -Wno-redundant-decls
106 .if ${COMPILER_VERSION} < 40300
107 # Silence -Wshadow false positives in ancient GCC