Makefile revision 1.117 1 1.117 matt # $NetBSD: Makefile,v 1.117 2013/05/03 15:52:31 matt Exp $
2 1.90 ad #
3 1.90 ad # NOTE: when changing ld.so, ensure that ldd still compiles.
4 1.90 ad #
5 1.88 lukem
6 1.89 christos WARNS?=4
7 1.5 cjs
8 1.117 matt LDELFSO_MACHINE_ARCH?= ${MACHINE_ARCH}
9 1.117 matt
10 1.92 mrg # This needs to be before bsd.init.mk
11 1.92 mrg .if defined(BSD_MK_COMPAT_FILE)
12 1.92 mrg .include <${BSD_MK_COMPAT_FILE}>
13 1.92 mrg .endif
14 1.92 mrg
15 1.86 christos # We are not building this with PIE
16 1.86 christos PIE_CFLAGS=
17 1.86 christos PIE_LDFLAGS=
18 1.97 mrg .include <bsd.init.mk> # for MKPIC definition
19 1.114 joerg .include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
20 1.11 jonathan
21 1.87 mrg .if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
22 1.87 mrg exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
23 1.87 mrg ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
24 1.87 mrg .else
25 1.67 skrll ARCHSUBDIR= ${MACHINE_CPU}
26 1.87 mrg .endif
27 1.67 skrll M= ${.CURDIR}/arch/${ARCHSUBDIR}
28 1.23 jonathan
29 1.117 matt .if ((${LDELFSO_MACHINE_ARCH} == "alpha") || \
30 1.75 simonb (${MACHINE_CPU} == "arm") || \
31 1.117 matt (${LDELFSO_MACHINE_ARCH} == "hppa") || \
32 1.117 matt (${LDELFSO_MACHINE_ARCH} == "i386") || \
33 1.117 matt (${LDELFSO_MACHINE_ARCH} == "m68k") || \
34 1.75 simonb (${MACHINE_CPU} == "mips") || \
35 1.117 matt (${LDELFSO_MACHINE_ARCH} == "powerpc") || \
36 1.75 simonb (${MACHINE_CPU} == "sh3") || \
37 1.117 matt (${LDELFSO_MACHINE_ARCH} == "sparc") || \
38 1.117 matt (${LDELFSO_MACHINE_ARCH} == "sparc64") || \
39 1.117 matt (${LDELFSO_MACHINE_ARCH} == "x86_64") || \
40 1.117 matt (${LDELFSO_MACHINE_ARCH} == "vax")) && \
41 1.97 mrg ${MKPIC} != "no"
42 1.29 thorpej
43 1.106 joerg LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
44 1.106 joerg -shared -nostartfiles -nodefaultlibs
45 1.74 skrll LDFLAGS+= -Wl,-static
46 1.102 matt LDFLAGS+= -Wl,--warn-shared-textrel
47 1.102 matt
48 1.112 matt COPTS+= -fvisibility=hidden
49 1.66 uwe
50 1.8 lukem # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
51 1.1 cgd # is first.
52 1.23 jonathan .if exists($M/Makefile.inc)
53 1.23 jonathan .include "$M/Makefile.inc"
54 1.3 cgd .endif
55 1.1 cgd
56 1.93 mrg # Support compat ld.elf_so.
57 1.91 mrg .if defined(MLIBDIR)
58 1.93 mrg PROG= ld.elf_so-${MLIBDIR}
59 1.93 mrg CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
60 1.87 mrg .else
61 1.93 mrg PROG= ld.elf_so
62 1.93 mrg .endif
63 1.93 mrg
64 1.51 lukem CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
65 1.44 tv
66 1.100 joerg SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
67 1.103 joerg map_object.c load.c search.c headers.c paths.c expand.c \
68 1.111 christos tls.c symver.c diagassert.c
69 1.40 thorpej
70 1.85 christos .if ${USE_FORT} == "yes"
71 1.84 ad .PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
72 1.80 christos SRCS+= stack_protector.c
73 1.85 christos .endif
74 1.83 skrll
75 1.83 skrll .PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
76 1.83 skrll SRCS+= exit.c
77 1.80 christos
78 1.101 joerg errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
79 1.101 joerg ${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
80 1.101 joerg mv -f ${.TARGET}.tmp ${.TARGET}
81 1.101 joerg
82 1.101 joerg xprintf.c: errlist_concat.h
83 1.101 joerg
84 1.101 joerg CLEANFILES+= errlist_concat.h
85 1.101 joerg
86 1.114 joerg BINDIR= ${SHLINKINSTALLDIR}
87 1.114 joerg
88 1.67 skrll CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
89 1.101 joerg CPPFLAGS+= -I${.CURDIR} -I.
90 1.67 skrll CPPFLAGS+= -DRTLD_LOADER
91 1.67 skrll CPPFLAGS+= -D_RTLD_SOURCE
92 1.76 matt CPPFLAGS+= -DCOMBRELOC
93 1.71 martin #CPPFLAGS+= -DDEBUG
94 1.67 skrll #CPPFLAGS+= -DRTLD_DEBUG
95 1.67 skrll #CPPFLAGS+= -DRTLD_DEBUG_RELOC
96 1.117 matt .if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
97 1.116 matt CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
98 1.116 matt .endif
99 1.67 skrll #DBG= -g
100 1.112 matt COPTS= -O3 -fomit-frame-pointer
101 1.43 lukem
102 1.117 matt .if ${LDELFSO_MACHINE_ARCH} == "i386" || ${LDELFSO_MACHINE_ARCH} == "x86_64"
103 1.112 matt COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
104 1.105 joerg .endif
105 1.105 joerg
106 1.114 joerg
107 1.114 joerg .if ${SHLIBDIR} != ${LIBDIR}
108 1.114 joerg CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
109 1.114 joerg .endif
110 1.114 joerg
111 1.96 skrll # rtld.c and symbol.c use alloca, so disable SSP warnings.
112 1.96 skrll COPTS.rtld.c+= -Wno-stack-protector
113 1.96 skrll COPTS.symbol.c+=-Wno-stack-protector
114 1.96 skrll
115 1.77 matt LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
116 1.77 matt .if ${MKPICLIB} != "no"
117 1.77 matt LDADD+= -lc_pic
118 1.68 enami .if ${MKPICINSTALL} != "no"
119 1.67 skrll DPADD+= ${LIBC_PIC}
120 1.60 uwe .endif
121 1.67 skrll DPADD+= ${CLIBOBJ}/libc_pic.a
122 1.77 matt .else
123 1.77 matt LDADD+= -lc
124 1.77 matt DPADD+= ${CLIBOBJ}/libc.a
125 1.77 matt .endif
126 1.1 cgd
127 1.109 uwe .if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
128 1.107 christos # for $$divU, $$remU etc. (millicode)
129 1.110 mrg LDADD+= -lgcc
130 1.110 mrg DPADD+= ${LIBGCC}
131 1.107 christos .endif
132 1.107 christos
133 1.4 thorpej STRIPFLAG=
134 1.1 cgd
135 1.23 jonathan .PATH: $M
136 1.1 cgd
137 1.115 christos
138 1.36 christos ${PROG}: ${OBJS} ${DPADD}
139 1.64 lukem ${_MKMSG_LINK} ${PROG}
140 1.72 lukem ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
141 1.115 christos .if ${MKDEBUG} != "no"
142 1.115 christos ( ${OBJCOPY} --only-keep-debug ${.TARGET} ${.TARGET}.debug \
143 1.115 christos && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
144 1.115 christos --add-gnu-debuglink=${.TARGET}.debug ${.TARGET} \
145 1.115 christos ) || (rm -f ${.TARGET}.debug; false)
146 1.115 christos
147 1.115 christos _PROGDEBUG.${PROG} := ${PROG}.debug
148 1.115 christos .endif
149 1.115 christos
150 1.35 christos
151 1.114 joerg .if ${SHLINKINSTALLDIR} != "/usr/libexec"
152 1.114 joerg SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
153 1.7 mrg .endif
154 1.1 cgd
155 1.1 cgd .include <bsd.prog.mk>
156 1.45 skrll .else
157 1.45 skrll
158 1.68 enami MAN= ld.elf_so.1
159 1.45 skrll
160 1.45 skrll .include <bsd.man.mk>
161 1.45 skrll .endif
162