1 # $NetBSD: Makefile,v 1.102 2011/01/16 02:36:05 matt Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
8 # This executable needs to be linked dynamically
11 # And the minix gcc currently references /libexec/ld-elf.so.1
12 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /libexec
/ld-elf.so
.1
14 # This needs to be before bsd.init.mk
15 .if defined
(BSD_MK_COMPAT_FILE
)
16 .
include <${BSD_MK_COMPAT_FILE}>
19 # We are not building this with PIE
22 .
include <bsd.init.mk
> # for MKPIC definition
23 .
include <bsd.shlib.mk
> # for SHLINKINSTALLDIR definition
25 .if defined
(LDELFSO_MACHINE_CPU
) && !empty
(LDELFSO_MACHINE_CPU
) && \
26 exists
(${.CURDIR
}/arch
/${LDELFSO_MACHINE_CPU})
27 ARCHSUBDIR
= ${LDELFSO_MACHINE_CPU}
29 ARCHSUBDIR
= ${MACHINE_CPU}
31 M
= ${.CURDIR
}/arch
/${ARCHSUBDIR}
33 .if
((${MACHINE_ARCH} == "alpha") || \
34 (${MACHINE_CPU} == "arm") || \
35 (${MACHINE_ARCH} == "hppa") || \
36 (${MACHINE_ARCH} == "i386") || \
37 (${MACHINE_ARCH} == "m68k") || \
38 (${MACHINE_CPU} == "mips") || \
39 (${MACHINE_ARCH} == "powerpc") || \
40 (${MACHINE_CPU} == "sh3") || \
41 (${MACHINE_ARCH} == "sparc") || \
42 (${MACHINE_ARCH} == "sparc64") || \
43 (${MACHINE_ARCH} == "x86_64") || \
44 (${MACHINE_ARCH} == "vax")) && \
48 LDFLAGS
+= -shared
-symbolic
-nostartfiles
50 LDFLAGS
+= -shared
-Wl
,-Bsymbolic
-nostartfiles
53 LDFLAGS
+= -Wl
,--warn-shared-textrel
55 CFLAGS
+= -fvisibility
=hidden
57 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
59 .if exists
($M/Makefile.inc
)
60 .
include "$M/Makefile.inc"
63 # Support compat ld.elf_so.
65 PROG
= ld.elf_so-
${MLIBDIR}
66 CPPFLAGS
+= -DRTLD_ARCH_SUBDIR
=\"${MLIBDIR}\"
71 CLIBOBJ
!= cd
${NETBSDSRCDIR}/lib
/libc
&& ${PRINTOBJDIR}
73 SRCS
+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
74 map_object.c load.c search.c headers.c paths.c expand.c
76 .if
${USE_FORT} == "yes"
77 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/misc
78 SRCS
+= stack_protector.c
81 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/stdlib
84 errlist_concat.h
: ${NETBSDSRCDIR}/lib
/libc
/gen
/errlist.awk
${NETBSDSRCDIR}/include/sys
/errno.h
85 ${TOOL_AWK} -v concat
=1 -f
${.ALLSRC
} > ${.TARGET
}.tmp
&& \
86 mv
-f
${.TARGET
}.tmp
${.TARGET
}
88 xprintf.c
: errlist_concat.h
90 CLEANFILES
+= errlist_concat.h
92 BINDIR
= ${SHLINKINSTALLDIR}
94 CPPFLAGS
+= -DLIBDIR
=\"${LIBDIR}\" -D_PATH_RTLD
=\"${BINDIR}/${PROG}\"
95 CPPFLAGS
+= -I
${.CURDIR
} -I.
96 CPPFLAGS
+= -DRTLD_LOADER
97 CPPFLAGS
+= -D_RTLD_SOURCE
98 CPPFLAGS
+= -DCOMBRELOC
100 #CPPFLAGS+= -DRTLD_DEBUG
101 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
103 #DBG= -O3 -fomit-frame-pointer
105 .if
${SHLIBDIR} != ${LIBDIR}
106 CPPFLAGS
+= -DRTLD_DEFAULT_LIBRARY_PATH
=\"${SHLIBDIR}:${LIBDIR}\"
109 # rtld.c and symbol.c use alloca, so disable SSP warnings.
110 COPTS.rtld.c
+= -Wno-stack-protector
111 COPTS.symbol.c
+=-Wno-stack-protector
113 LDADD
+= -L
${CLIBOBJ} -L
${DESTDIR}${LIBDIR}
114 .if
${MKPICLIB} != "no"
116 .if
${MKPICINSTALL} != "no"
119 DPADD
+= ${CLIBOBJ}/libc_pic.a
122 DPADD
+= ${CLIBOBJ}/libc.a
129 ${PROG}: ${OBJS} ${DPADD}
130 ${_MKMSG_LINK} ${PROG}
131 ${CC} ${LDFLAGS} -o
${PROG} ${OBJS} ${LDADD}
133 .if
${SHLINKINSTALLDIR} != "/usr/libexec"
134 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /usr
/libexec
/${PROG}
137 .
include <bsd.prog.mk
>
142 .
include <bsd.man.mk
>