]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rtld-elf/Makefile
Merge from head
[FreeBSD/FreeBSD.git] / libexec / rtld-elf / Makefile
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>
8 MK_SSP=         no
9
10 PROG?=          ld-elf.so.1
11 SRCS=           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
14 MAN=            rtld.1
15 CSTD?=          gnu99
16 TOPSRCDIR=      ${.CURDIR}/../..
17 CFLAGS+=        -Wall -DFREEBSD_ELF -DIN_RTLD
18 CFLAGS+=        -I${TOPSRCDIR}/lib/csu/common
19 .if exists(${.CURDIR}/${MACHINE_ARCH})
20 RTLD_ARCH=      ${MACHINE_ARCH}
21 .else
22 RTLD_ARCH=      ${MACHINE_CPUARCH}
23 .endif
24 CFLAGS+=        -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
25 .if ${MACHINE_ARCH} == "powerpc64"
26 CFLAGS+=        -mcall-aixdesc
27 LDFLAGS+=       -nostdlib -e _rtld_start
28 .else
29 LDFLAGS+=       -nostdlib -e .rtld_start
30 .endif
31 WARNS?=         2
32 INSTALLFLAGS=   -C -b
33 PRECIOUSPROG=
34 BINDIR=         /libexec
35 SYMLINKS=       ${BINDIR}/${PROG} /usr/libexec/${PROG}
36 MLINKS=         rtld.1 ld-elf.so.1.1 \
37                 rtld.1 ld.so.1
38
39 .if ${MACHINE_CPUARCH} == "sparc64"
40 CFLAGS+=        -fPIC
41 .else
42 CFLAGS+=        -fpic
43 .endif
44 CFLAGS+=        -DPIC $(DEBUG)
45 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
46 CFLAGS+=        -fvisibility=hidden
47 .endif
48 LDFLAGS+=       -shared -Wl,-Bsymbolic
49 LIBADD=         c_pic
50
51 .if ${MACHINE_CPUARCH} == "arm"
52 # Some of the required math functions (div & mod) are implemented in
53 # libcompiler_rt on ARM. The library also needs to be placed first to be
54 # correctly linked. As some of the functions are used before we have
55 # shared libraries.
56 LIBADD+=        compiler_rt
57 .endif
58
59
60
61 .if ${MK_SYMVER} == "yes"
62 LIBCDIR=        ${TOPSRCDIR}/lib/libc
63 VERSION_DEF=    ${LIBCDIR}/Versions.def
64 SYMBOL_MAPS=    ${.CURDIR}/Symbol.map
65 VERSION_MAP=    Version.map
66 LDFLAGS+=       -Wl,--version-script=${VERSION_MAP}
67
68 ${PROG}:        ${VERSION_MAP}
69
70 .if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
71 SYMBOL_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.
79 beforeinstall:
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"
87 SUBDIR+=        tests
88 .endif
89
90 .include <bsd.symver.mk>
91 .include <bsd.prog.mk>