custom message type for VM_INFO
[minix3.git] / libexec / ld.elf_so / Makefile
blobc05852641bc1b5f387b096b48a3456c3a8fe5fa5
1 # $NetBSD: Makefile,v 1.125 2013/11/16 17:14:06 skrll Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
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 ((${LDELFSO_MACHINE_ARCH} == "alpha") || \
32 (${MACHINE_CPU} == "arm") || \
33 (${LDELFSO_MACHINE_ARCH} == "coldfire") || \
34 (${LDELFSO_MACHINE_ARCH} == "hppa") || \
35 (${LDELFSO_MACHINE_ARCH} == "i386") || \
36 (${LDELFSO_MACHINE_ARCH} == "m68k") || \
37 (${MACHINE_CPU} == "mips") || \
38 (${LDELFSO_MACHINE_ARCH} == "powerpc") || \
39 (${MACHINE_CPU} == "sh3") || \
40 (${LDELFSO_MACHINE_ARCH} == "sparc") || \
41 (${LDELFSO_MACHINE_ARCH} == "sparc64") || \
42 (${LDELFSO_MACHINE_ARCH} == "x86_64") || \
43 (${LDELFSO_MACHINE_ARCH} == "vax")) && \
44 ${MKPIC} != "no"
46 LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
47 -shared -nostartfiles -nodefaultlibs
48 .if defined(__MINIX) && ${HAVE_GOLD:Uno} == "no"
49 LDFLAGS+= -Wl,-static
50 .endif
51 LDFLAGS+= -Wl,--warn-shared-textrel
53 COPTS+= -fvisibility=hidden
55 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
56 # is first.
57 .if exists($M/Makefile.inc)
58 .include "$M/Makefile.inc"
59 .endif
61 # Support compat ld.elf_so.
62 .if defined(MLIBDIR)
63 PROG= ld.elf_so-${MLIBDIR}
64 CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
65 .else
66 PROG= ld.elf_so
67 .endif
69 CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
71 SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
72 map_object.c load.c search.c headers.c paths.c expand.c \
73 tls.c symver.c diagassert.c
75 .if defined(__MINIX)
76 SRCS+= map_object_fallback.c
77 .endif # defined(__MINIX)
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
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