Update post installation article url
[minix3.git] / libexec / ld.elf_so / Makefile
blob0ba3173b61662a733a979865c89c5a13a13e934d
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.
5 #MINIX:
6 USE_BITCODE=no
8 WARNS?=4
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}>
15 .endif
17 # We are not building this with PIE
18 PIE_CFLAGS=
19 PIE_LDFLAGS=
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}
26 .else
27 ARCHSUBDIR= ${MACHINE_CPU}
28 .endif
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")) && \
47 ${MKPIC} != "no"
49 LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
50 -shared -nostartfiles -nodefaultlibs
51 .if defined(__MINIX) && ${HAVE_GOLD:Uno} == "no"
52 LDFLAGS+= -Wl,-static
53 .endif
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
60 # is first.
61 .if exists($M/Makefile.inc)
62 .include "$M/Makefile.inc"
63 .endif
65 # Support compat ld.elf_so.
66 .if defined(MLIBDIR)
67 PROG= ld.elf_so-${MLIBDIR}
68 CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
69 .else
70 PROG= ld.elf_so
71 .endif
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
82 .endif
84 .PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
85 SRCS+= exit.c
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
102 #CPPFLAGS+= -DDEBUG
103 #CPPFLAGS+= -DRTLD_DEBUG
104 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
105 .if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
106 CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
107 .endif
108 #DBG= -g
109 COPTS+= -O3
111 .if ${MACHINE_CPU} != "m68k" && ${MACHINE_CPU} != "sh3" && ${MACHINE_ARCH} != "vax"
112 COPTS+= -fomit-frame-pointer
113 .endif
115 .if ${LDELFSO_MACHINE_ARCH} == "i386" || ${LDELFSO_MACHINE_ARCH} == "x86_64"
116 COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
117 .endif
120 .if ${SHLIBDIR} != ${LIBDIR}
121 CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
122 .endif
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"
130 LDADD+= -lc_pic
131 .if ${MKPICINSTALL} != "no"
132 DPADD+= ${LIBC_PIC}
133 .endif
134 DPADD+= ${CLIBOBJ}/libc_pic.a
135 .else
136 LDADD+= -lc
137 DPADD+= ${CLIBOBJ}/libc.a
138 .endif
140 .if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
141 # for $$divU, $$remU etc. (millicode)
142 LDADD+= -lgcc
143 DPADD+= ${LIBGCC}
144 .endif
146 STRIPFLAG=
148 .PATH: $M
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
161 .endif
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
169 .endif
170 .endif
172 .include <bsd.prog.mk>
173 .else
175 MAN= ld.elf_so.1
177 .include <bsd.man.mk>
178 .endif