]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rtld-elf/Makefile
Revert r340843 - addressed independently in r340842!
[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 WITHOUT_TESTS=yes all
6
7 .include <src.opts.mk>
8 PACKAGE=        clibs
9 MK_SSP=         no
10
11 CONFS=          libmap.conf
12 PROG?=          ld-elf.so.1
13 .if (${PROG:M*ld-elf32*} != "")
14 TAGS+=          lib32
15 .endif
16 SRCS=           rtld_start.S \
17                 reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
18                 malloc.c xmalloc.c debug.c libmap.c
19 MAN=            rtld.1
20 CSTD?=          gnu99
21 CFLAGS+=        -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
22 CFLAGS+=        -I${SRCTOP}/lib/csu/common
23 .if exists(${.CURDIR}/${MACHINE_ARCH})
24 RTLD_ARCH=      ${MACHINE_ARCH}
25 .else
26 RTLD_ARCH=      ${MACHINE_CPUARCH}
27 .endif
28 CFLAGS+=        -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
29 .if ${MACHINE_ARCH} == "powerpc64"
30 LDFLAGS+=       -nostdlib -e _rtld_start
31 .else
32 LDFLAGS+=       -nostdlib -e .rtld_start
33 .endif
34
35 NO_WCAST_ALIGN= yes
36 WARNS?=         6
37 INSTALLFLAGS=   -C -b
38 PRECIOUSPROG=
39 BINDIR=         /libexec
40 SYMLINKS=       ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
41 MLINKS=         rtld.1 ld-elf.so.1.1 \
42                 rtld.1 ld.so.1
43
44 .if ${MACHINE_CPUARCH} == "sparc64"
45 CFLAGS+=        -fPIC
46 .else
47 CFLAGS+=        -fpic
48 .endif
49 CFLAGS+=        -DPIC $(DEBUG)
50 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
51 CFLAGS+=        -fvisibility=hidden
52 .endif
53 .if ${MACHINE_CPUARCH} == "mips"
54 CFLAGS.reloc.c+=-fno-jump-tables
55 .endif
56 LDFLAGS+=       -shared -Wl,-Bsymbolic -Wl,-z,defs
57 LIBADD=         c_nossp_pic
58 .if ${MK_TOOLCHAIN} == "no"
59 LDFLAGS+=       -L${LIBCDIR}
60 .endif
61
62 .if ${MACHINE_CPUARCH} == "arm"
63 # Some of the required math functions (div & mod) are implemented in
64 # libcompiler_rt on ARM. The library also needs to be placed first to be
65 # correctly linked. As some of the functions are used before we have
66 # shared libraries.
67 LIBADD+=        compiler_rt
68 .endif
69
70
71
72 .if ${MK_SYMVER} == "yes"
73 VERSION_DEF=    ${LIBCSRCDIR}/Versions.def
74 SYMBOL_MAPS=    ${.CURDIR}/Symbol.map
75 VERSION_MAP=    Version.map
76 LDFLAGS+=       -Wl,--version-script=${VERSION_MAP}
77
78 .if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
79 SYMBOL_MAPS+=   ${.CURDIR}/${RTLD_ARCH}/Symbol.map
80 .endif
81 .endif
82
83 .sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
84
85 # Since moving rtld-elf to /libexec, we need to create a symlink.
86 # Fixup the existing binary that's there so we can symlink over it.
87 beforeinstall:
88 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
89         -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
90 .endif
91
92 .PATH: ${.CURDIR}/${RTLD_ARCH}
93
94 HAS_TESTS=
95 SUBDIR.${MK_TESTS}+= tests
96
97 .include <bsd.prog.mk>
98 ${PROG_FULL}:   ${VERSION_MAP}
99 .include <bsd.symver.mk>
100
101 .if ${COMPILER_TYPE} == "gcc"
102 # GCC warns about redeclarations even though they have __exported
103 # and are therefore not identical to the ones from the system headers.
104 CFLAGS+=        -Wno-redundant-decls
105 .if ${COMPILER_VERSION} < 40300
106 # Silence -Wshadow false positives in ancient GCC
107 CFLAGS+=        -Wno-shadow
108 .endif
109 .endif