1 # $NetBSD: Makefile,v 1.129 2014/09/19 17:43:33 matt Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
10 LDELFSO_MACHINE_ARCH?
= ${MACHINE_ARCH}
12 # This needs to be before bsd.init.mk
13 .if defined
(BSD_MK_COMPAT_FILE
)
14 .
include <${BSD_MK_COMPAT_FILE}>
17 # We are not building this with PIE
20 .
include <bsd.init.mk
> # for MKPIC definition
21 .
include <bsd.shlib.mk
> # for SHLINKINSTALLDIR definition
23 .if defined
(LDELFSO_MACHINE_CPU
) && !empty
(LDELFSO_MACHINE_CPU
) && \
24 exists
(${.CURDIR
}/arch
/${LDELFSO_MACHINE_CPU})
25 ARCHSUBDIR
= ${LDELFSO_MACHINE_CPU}
27 ARCHSUBDIR
= ${MACHINE_CPU}
29 M
= ${.CURDIR
}/arch
/${ARCHSUBDIR}
31 .if
((${MACHINE_CPU} == "aarch64") || \
32 (${LDELFSO_MACHINE_ARCH} == "alpha") || \
33 (${MACHINE_CPU} == "arm") || \
34 (${LDELFSO_MACHINE_ARCH} == "coldfire") || \
35 (${LDELFSO_MACHINE_ARCH} == "hppa") || \
36 (${LDELFSO_MACHINE_ARCH} == "i386") || \
37 (${LDELFSO_MACHINE_ARCH} == "m68k") || \
38 (${MACHINE_CPU} == "mips") || \
39 (${MACHINE_CPU} == "or1k") || \
40 (${MACHINE_CPU} == "powerpc") || \
41 (${MACHINE_CPU} == "riscv") || \
42 (${MACHINE_CPU} == "sh3") || \
43 (${LDELFSO_MACHINE_ARCH} == "sparc") || \
44 (${LDELFSO_MACHINE_ARCH} == "sparc64") || \
45 (${LDELFSO_MACHINE_ARCH} == "x86_64") || \
46 (${LDELFSO_MACHINE_ARCH} == "vax")) && \
49 LDFLAGS
+= ${${ACTIVE_CC} == "clang":?
-Wl
,-Bsymbolic
: -symbolic
} \
50 -shared
-nostartfiles
-nodefaultlibs
51 .if defined
(__MINIX
) && ${HAVE_GOLD
:Uno
} == "no"
54 LDFLAGS
+= -Wl
,--warn-shared-textrel
55 LDFLAGS
+= -Wl
,-Map
=${.TARGET
}.map
57 COPTS
+= -fvisibility
=hidden
59 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
61 .if exists
($M/Makefile.inc
)
62 .
include "$M/Makefile.inc"
65 # Support compat ld.elf_so.
67 PROG
= ld.elf_so-
${MLIBDIR}
68 CPPFLAGS
+= -DRTLD_ARCH_SUBDIR
=\"${MLIBDIR}\"
73 CLIBOBJ
!= cd
${NETBSDSRCDIR}/lib
/libc
&& ${PRINTOBJDIR}
75 SRCS
+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
76 map_object.c load.c search.c headers.c paths.c expand.c \
77 tls.c symver.c diagassert.c
79 .if
${USE_FORT} == "yes"
80 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/misc
81 SRCS
+= stack_protector.c
84 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/stdlib
87 errlist_concat.h
: ${NETBSDSRCDIR}/lib
/libc
/gen
/errlist.awk
${NETBSDSRCDIR}/sys
/sys
/errno.h
88 ${TOOL_AWK} -v concat
=1 -f
${.ALLSRC
} > ${.TARGET
}.tmp
&& \
89 mv
-f
${.TARGET
}.tmp
${.TARGET
}
91 xprintf.c
: errlist_concat.h
93 CLEANFILES
+= errlist_concat.h
${PROG}.map
95 BINDIR
= ${SHLINKINSTALLDIR}
97 CPPFLAGS
+= -DLIBDIR
=\"${LIBDIR}\" -D_PATH_RTLD
=\"${BINDIR}/${PROG}\"
98 CPPFLAGS
+= -I
${.CURDIR
} -I.
99 CPPFLAGS
+= -DRTLD_LOADER
100 CPPFLAGS
+= -D_RTLD_SOURCE
101 CPPFLAGS
+= -DCOMBRELOC
103 #CPPFLAGS+= -DRTLD_DEBUG
104 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
105 .if
!empty
(LDELFSO_MACHINE_ARCH
:Mearm
*)
106 CPPFLAGS
+= -I
${NETBSDSRCDIR}/lib
/libexecinfo
111 .if
${MACHINE_CPU} != "m68k" && ${MACHINE_CPU} != "sh3" && ${MACHINE_ARCH} != "vax"
112 COPTS
+= -fomit-frame-pointer
115 .if
${LDELFSO_MACHINE_ARCH} == "i386" ||
${LDELFSO_MACHINE_ARCH} == "x86_64"
116 COPTS
+= -mno-3dnow
-mno-mmx
-mno-sse
-mno-sse2
-mno-sse3
120 .if
${SHLIBDIR} != ${LIBDIR}
121 CPPFLAGS
+= -DRTLD_DEFAULT_LIBRARY_PATH
=\"${SHLIBDIR}:${LIBDIR}\"
124 # rtld.c and symbol.c use alloca, so disable SSP warnings.
125 COPTS.rtld.c
+= -Wno-stack-protector
126 COPTS.symbol.c
+=-Wno-stack-protector
128 LDADD
+= -L
${CLIBOBJ} -L
${DESTDIR}${LIBDIR}
129 .if
${MKPICLIB} != "no"
131 .if
${MKPICINSTALL} != "no"
134 DPADD
+= ${CLIBOBJ}/libc_pic.a
137 DPADD
+= ${CLIBOBJ}/libc.a
140 .if
${MACHINE_CPU} == "hppa" ||
${MACHINE_CPU} == "sh3"
141 # for $$divU, $$remU etc. (millicode)
151 ${PROG}: ${OBJS} ${DPADD}
152 ${_MKMSG_LINK} ${PROG}
153 ${CC} ${LDFLAGS} -o
${PROG} ${OBJS} ${LDADD}
154 .if
${MKDEBUG} != "no"
155 ( ${OBJCOPY} --only-keep-debug
${.TARGET
} ${.TARGET
}.debug \
156 && ${OBJCOPY} --strip-debug
-p
-R .gnu_debuglink \
157 --add-gnu-debuglink
=${.TARGET
}.debug
${.TARGET
} \
158 ) ||
(rm -f
${.TARGET
}.debug
; false
)
160 _PROGDEBUG.
${PROG} := ${PROG}.debug
164 .if
${SHLINKINSTALLDIR} != "/usr/libexec"
165 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /usr
/libexec
/${PROG}
166 .if
${MKDEBUG} != "no"
167 SYMLINKS
+= ${DEBUGDIR}${BINDIR}/${PROG}.debug \
168 ${DEBUGDIR}/usr
${BINDIR}/${PROG}.debug
172 .
include <bsd.prog.mk
>
177 .
include <bsd.man.mk
>