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