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