xref: /freebsd/libexec/rtld-elf/Makefile (revision c6db8143eda5c775467145ac73e8ebec47afdd8f)
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
16TOPSRCDIR=	${.CURDIR}/../..
17CFLAGS+=	-Wall -DFREEBSD_ELF -DIN_RTLD
18CFLAGS+=	-I${TOPSRCDIR}/lib/csu/common
19.if exists(${.CURDIR}/${MACHINE_ARCH})
20RTLD_ARCH=	${MACHINE_ARCH}
21.else
22RTLD_ARCH=	${MACHINE_CPUARCH}
23.endif
24CFLAGS+=	-I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
25.if ${MACHINE_ARCH} == "powerpc64"
26CFLAGS+=	-mcall-aixdesc
27LDFLAGS+=	-nostdlib -e _rtld_start
28.else
29LDFLAGS+=	-nostdlib -e .rtld_start
30.endif
31WARNS?=		2
32INSTALLFLAGS=	-C -b
33PRECIOUSPROG=
34BINDIR=		/libexec
35SYMLINKS=	${BINDIR}/${PROG} /usr/libexec/${PROG}
36MLINKS=		rtld.1 ld-elf.so.1.1 \
37		rtld.1 ld.so.1
38
39.if ${MACHINE_CPUARCH} == "sparc64"
40CFLAGS+=	-fPIC
41.else
42CFLAGS+=	-fpic
43.endif
44CFLAGS+=	-DPIC $(DEBUG)
45LDFLAGS+=	-shared -Wl,-Bsymbolic
46DPADD=		${LIBC_PIC}
47LDADD=		-lc_pic
48
49.if ${MACHINE_CPUARCH} == "arm"
50# Some of the required math functions (div & mod) are implemented in
51# libcompiler_rt on ARM. The library also needs to be placed first to be
52# correctly linked. As some of the functions are used before we have
53# shared libraries.
54DPADD+=		${LIBCOMPILER_RT}
55LDADD+=		-lcompiler_rt
56.endif
57
58
59
60.if ${MK_SYMVER} == "yes"
61LIBCDIR=	${TOPSRCDIR}/lib/libc
62VERSION_DEF=	${LIBCDIR}/Versions.def
63SYMBOL_MAPS=	${.CURDIR}/Symbol.map
64VERSION_MAP=	Version.map
65LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
66
67${PROG}:	${VERSION_MAP}
68
69.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
70SYMBOL_MAPS+=	${.CURDIR}/${RTLD_ARCH}/Symbol.map
71.endif
72.endif
73
74.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
75
76# Since moving rtld-elf to /libexec, we need to create a symlink.
77# Fixup the existing binary that's there so we can symlink over it.
78beforeinstall:
79.if exists(${DESTDIR}/usr/libexec/${PROG})
80	-chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
81.endif
82
83.PATH: ${.CURDIR}/${RTLD_ARCH}
84
85.if ${MK_TESTS} != "no"
86SUBDIR+=	tests
87.endif
88
89.include <bsd.symver.mk>
90.include <bsd.prog.mk>
91