xref: /freebsd-12.1/libexec/rtld-elf/Makefile (revision 056b7d85)
1# $FreeBSD$
2
3# Use the following command to build local debug version of dynamic
4# linker:
5# make DEBUG_FLAGS=-g DEBUG=-DDEBUG MK_TESTS=no all
6
7.include <src.opts.mk>
8MK_SSP=		no
9
10PROG?=		ld-elf.so.1
11SRCS=		rtld_start.S \
12		reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
13		malloc.c xmalloc.c debug.c libmap.c
14MAN=		rtld.1
15CSTD?=		gnu99
16CFLAGS+=	-Wall -DFREEBSD_ELF -DIN_RTLD
17CFLAGS+=	-I${SRCTOP}/lib/csu/common
18.if exists(${.CURDIR}/${MACHINE_ARCH})
19RTLD_ARCH=	${MACHINE_ARCH}
20.else
21RTLD_ARCH=	${MACHINE_CPUARCH}
22.endif
23CFLAGS+=	-I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
24.if ${MACHINE_ARCH} == "powerpc64"
25CFLAGS+=	-mcall-aixdesc
26LDFLAGS+=	-nostdlib -e _rtld_start
27.else
28LDFLAGS+=	-nostdlib -e .rtld_start
29.endif
30WARNS?=		2
31INSTALLFLAGS=	-C -b
32PRECIOUSPROG=
33BINDIR=		/libexec
34SYMLINKS=	${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
35MLINKS=		rtld.1 ld-elf.so.1.1 \
36		rtld.1 ld.so.1
37
38.if ${MACHINE_CPUARCH} == "sparc64"
39CFLAGS+=	-fPIC
40.else
41CFLAGS+=	-fpic
42.endif
43CFLAGS+=	-DPIC $(DEBUG)
44.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
45CFLAGS+=	-fvisibility=hidden
46.endif
47LDFLAGS+=	-shared -Wl,-Bsymbolic
48LIBADD=		c_pic
49
50.if ${MACHINE_CPUARCH} == "arm"
51# Some of the required math functions (div & mod) are implemented in
52# libcompiler_rt on ARM. The library also needs to be placed first to be
53# correctly linked. As some of the functions are used before we have
54# shared libraries.
55LIBADD+=	compiler_rt
56.endif
57
58
59
60.if ${MK_SYMVER} == "yes"
61VERSION_DEF=	${LIBCSRCDIR}/Versions.def
62SYMBOL_MAPS=	${.CURDIR}/Symbol.map
63VERSION_MAP=	Version.map
64LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
65
66${PROG}:	${VERSION_MAP}
67
68.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
69SYMBOL_MAPS+=	${.CURDIR}/${RTLD_ARCH}/Symbol.map
70.endif
71.endif
72
73.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
74
75# Since moving rtld-elf to /libexec, we need to create a symlink.
76# Fixup the existing binary that's there so we can symlink over it.
77beforeinstall:
78.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
79	-chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
80.endif
81
82.PATH: ${.CURDIR}/${RTLD_ARCH}
83
84.if ${MK_TESTS} != "no"
85SUBDIR+=	tests
86.endif
87
88.include <bsd.prog.mk>
89.include <bsd.symver.mk>
90