indent(1): Untangle the connection between pr_comment.c and io.c.
[freebsd-src.git] / libexec / rtld-elf / Makefile
blobde98da2553aab067ac9f2b191e22a2ed419688d9
1 # $FreeBSD$
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
7 .include <src.opts.mk>
8 PACKAGE= clibs
9 MK_SSP= no
11 PROG?= ld-elf.so.1
12 .if (${PROG:M*ld-elf32*} != "")
13 TAGS+= lib32
14 .endif
15 SRCS= rtld_start.S \
16 reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
17 malloc.c xmalloc.c debug.c libmap.c
18 MAN= rtld.1
19 CSTD?= gnu99
20 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
21 CFLAGS+= -I${SRCTOP}/lib/csu/common
22 .if exists(${.CURDIR}/${MACHINE_ARCH})
23 RTLD_ARCH= ${MACHINE_ARCH}
24 .else
25 RTLD_ARCH= ${MACHINE_CPUARCH}
26 .endif
27 CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
28 .if ${MACHINE_ARCH} == "powerpc64"
29 LDFLAGS+= -nostdlib -e _rtld_start
30 .else
31 LDFLAGS+= -nostdlib -e .rtld_start
32 .endif
33 WARNS?= 2
34 INSTALLFLAGS= -C -b
35 PRECIOUSPROG=
36 BINDIR= /libexec
37 SYMLINKS= ${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
38 MLINKS= rtld.1 ld-elf.so.1.1 \
39 rtld.1 ld.so.1
41 .if ${MACHINE_CPUARCH} == "sparc64"
42 CFLAGS+= -fPIC
43 .else
44 CFLAGS+= -fpic
45 .endif
46 CFLAGS+= -DPIC $(DEBUG)
47 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
48 CFLAGS+= -fvisibility=hidden
49 .endif
50 LDFLAGS+= -shared -Wl,-Bsymbolic
51 LIBADD= c_pic
52 .if ${MK_TOOLCHAIN} == "no"
53 LDFLAGS+= -L${LIBCDIR}
54 .endif
56 .if ${MACHINE_CPUARCH} == "arm"
57 # Some of the required math functions (div & mod) are implemented in
58 # libcompiler_rt on ARM. The library also needs to be placed first to be
59 # correctly linked. As some of the functions are used before we have
60 # shared libraries.
61 LIBADD+= compiler_rt
62 .endif
66 .if ${MK_SYMVER} == "yes"
67 VERSION_DEF= ${LIBCSRCDIR}/Versions.def
68 SYMBOL_MAPS= ${.CURDIR}/Symbol.map
69 VERSION_MAP= Version.map
70 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
72 .if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
73 SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map
74 .endif
75 .endif
77 .sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
79 # Since moving rtld-elf to /libexec, we need to create a symlink.
80 # Fixup the existing binary that's there so we can symlink over it.
81 beforeinstall:
82 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
83 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
84 .endif
86 .PATH: ${.CURDIR}/${RTLD_ARCH}
88 .if ${MK_TESTS} != "no"
89 SUBDIR+= tests
90 .endif
92 .include <bsd.prog.mk>
93 ${PROG_FULL}: ${VERSION_MAP}
94 .include <bsd.symver.mk>