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 needs to be before bsd.init.mk
9 .if defined
(BSD_MK_COMPAT_FILE
)
10 .
include <${BSD_MK_COMPAT_FILE}>
13 # We are not building this with PIE
16 .
include <bsd.init.mk
> # for MKPIC definition
17 .
include <bsd.shlib.mk
> # for SHLINKINSTALLDIR definition
19 .if defined
(LDELFSO_MACHINE_CPU
) && !empty
(LDELFSO_MACHINE_CPU
) && \
20 exists
(${.CURDIR
}/arch
/${LDELFSO_MACHINE_CPU})
21 ARCHSUBDIR
= ${LDELFSO_MACHINE_CPU}
23 ARCHSUBDIR
= ${MACHINE_CPU}
25 M
= ${.CURDIR
}/arch
/${ARCHSUBDIR}
27 .if
((${MACHINE_ARCH} == "alpha") || \
28 (${MACHINE_CPU} == "arm") || \
29 (${MACHINE_ARCH} == "hppa") || \
30 (${MACHINE_ARCH} == "i386") || \
31 (${MACHINE_ARCH} == "m68k") || \
32 (${MACHINE_CPU} == "mips") || \
33 (${MACHINE_ARCH} == "powerpc") || \
34 (${MACHINE_CPU} == "sh3") || \
35 (${MACHINE_ARCH} == "sparc") || \
36 (${MACHINE_ARCH} == "sparc64") || \
37 (${MACHINE_ARCH} == "x86_64") || \
38 (${MACHINE_ARCH} == "vax")) && \
42 LDFLAGS
+= -shared
-symbolic
-nostartfiles
44 LDFLAGS
+= -shared
-Wl
,-Bsymbolic
-nostartfiles
47 LDFLAGS
+= -Wl
,--warn-shared-textrel
49 CFLAGS
+= -fvisibility
=hidden
51 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
53 .if exists
($M/Makefile.inc
)
54 .
include "$M/Makefile.inc"
57 # Support compat ld.elf_so.
59 PROG
= ld.elf_so-
${MLIBDIR}
60 CPPFLAGS
+= -DRTLD_ARCH_SUBDIR
=\"${MLIBDIR}\"
65 CLIBOBJ
!= cd
${NETBSDSRCDIR}/lib
/libc
&& ${PRINTOBJDIR}
67 SRCS
+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
68 map_object.c load.c search.c headers.c paths.c expand.c
70 .if
${USE_FORT} == "yes"
71 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/misc
72 SRCS
+= stack_protector.c
75 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/stdlib
78 errlist_concat.h
: ${NETBSDSRCDIR}/lib
/libc
/gen
/errlist.awk
${NETBSDSRCDIR}/sys
/sys
/errno.h
79 ${TOOL_AWK} -v concat
=1 -f
${.ALLSRC
} > ${.TARGET
}.tmp
&& \
80 mv
-f
${.TARGET
}.tmp
${.TARGET
}
82 xprintf.c
: errlist_concat.h
84 CLEANFILES
+= errlist_concat.h
86 BINDIR
= ${SHLINKINSTALLDIR}
88 CPPFLAGS
+= -DLIBDIR
=\"${LIBDIR}\" -D_PATH_RTLD
=\"${BINDIR}/${PROG}\"
89 CPPFLAGS
+= -I
${.CURDIR
} -I.
90 CPPFLAGS
+= -DRTLD_LOADER
91 CPPFLAGS
+= -D_RTLD_SOURCE
92 CPPFLAGS
+= -DCOMBRELOC
94 #CPPFLAGS+= -DRTLD_DEBUG
95 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
97 DBG
= -O3
-fomit-frame-pointer
99 .if
${SHLIBDIR} != ${LIBDIR}
100 CPPFLAGS
+= -DRTLD_DEFAULT_LIBRARY_PATH
=\"${SHLIBDIR}:${LIBDIR}\"
103 # rtld.c and symbol.c use alloca, so disable SSP warnings.
104 COPTS.rtld.c
+= -Wno-stack-protector
105 COPTS.symbol.c
+=-Wno-stack-protector
107 LDADD
+= -L
${CLIBOBJ} -L
${DESTDIR}${LIBDIR}
108 .if
${MKPICLIB} != "no"
110 .if
${MKPICINSTALL} != "no"
113 DPADD
+= ${CLIBOBJ}/libc_pic.a
116 DPADD
+= ${CLIBOBJ}/libc.a
123 ${PROG}: ${OBJS} ${DPADD}
124 ${_MKMSG_LINK} ${PROG}
125 ${CC} ${LDFLAGS} -o
${PROG} ${OBJS} ${LDADD}
127 .if
${SHLINKINSTALLDIR} != "/usr/libexec"
128 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /usr
/libexec
/${PROG}
131 .
include <bsd.prog.mk
>
136 .
include <bsd.man.mk
>