ldivmod, uldivmod: fix qdivrem calls
[minix.git] / libexec / ld.elf_so / Makefile
blob0ca15ffcd15e1a6813e3986dd6937c350c25c9f4
1 # $NetBSD: Makefile,v 1.114 2012/08/23 21:21:15 joerg Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
6 WARNS?=4
8 # Minix Clang binaries references /libexec/ld.elf_so
9 SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld.elf_so
10 # And the minix gcc currently references /libexec/ld-elf.so.1
11 SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld-elf.so.1
13 # This needs to be before bsd.init.mk
14 .if defined(BSD_MK_COMPAT_FILE)
15 .include <${BSD_MK_COMPAT_FILE}>
16 .endif
18 # We are not building this with PIE
19 PIE_CFLAGS=
20 PIE_LDFLAGS=
21 .include <bsd.init.mk> # for MKPIC definition
22 .include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
24 .if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
25 exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
26 ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
27 .else
28 ARCHSUBDIR= ${MACHINE_CPU}
29 .endif
30 M= ${.CURDIR}/arch/${ARCHSUBDIR}
32 .if ((${MACHINE_ARCH} == "alpha") || \
33 (${MACHINE_CPU} == "arm") || \
34 (${MACHINE_ARCH} == "hppa") || \
35 (${MACHINE_ARCH} == "i386") || \
36 (${MACHINE_ARCH} == "m68k") || \
37 (${MACHINE_CPU} == "mips") || \
38 (${MACHINE_ARCH} == "powerpc") || \
39 (${MACHINE_CPU} == "sh3") || \
40 (${MACHINE_ARCH} == "sparc") || \
41 (${MACHINE_ARCH} == "sparc64") || \
42 (${MACHINE_ARCH} == "x86_64") || \
43 (${MACHINE_ARCH} == "vax")) && \
44 ${MKPIC} != "no"
46 LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
47 -shared -nostartfiles -nodefaultlibs
48 LDFLAGS+= -Wl,-static
49 LDFLAGS+= -Wl,--warn-shared-textrel
51 COPTS+= -fvisibility=hidden
53 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
54 # is first.
55 .if exists($M/Makefile.inc)
56 .include "$M/Makefile.inc"
57 .endif
59 # Support compat ld.elf_so.
60 .if defined(MLIBDIR)
61 PROG= ld.elf_so-${MLIBDIR}
62 CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
63 .else
64 PROG= ld.elf_so
65 .endif
67 CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
69 SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
70 map_object.c load.c search.c headers.c paths.c expand.c \
71 tls.c symver.c diagassert.c
73 .if ${USE_FORT} == "yes"
74 .PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
75 SRCS+= stack_protector.c
76 .endif
78 .PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
79 SRCS+= exit.c
81 errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
82 ${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
83 mv -f ${.TARGET}.tmp ${.TARGET}
85 xprintf.c: errlist_concat.h
87 CLEANFILES+= errlist_concat.h
89 BINDIR= ${SHLINKINSTALLDIR}
91 CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
92 CPPFLAGS+= -I${.CURDIR} -I.
93 CPPFLAGS+= -DRTLD_LOADER
94 CPPFLAGS+= -D_RTLD_SOURCE
95 CPPFLAGS+= -DCOMBRELOC
96 #CPPFLAGS+= -DDEBUG
97 #CPPFLAGS+= -DRTLD_DEBUG
98 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
99 #DBG= -g
100 COPTS= -O3 -fomit-frame-pointer
102 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
103 COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
104 .endif
107 .if ${SHLIBDIR} != ${LIBDIR}
108 CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
109 .endif
111 # rtld.c and symbol.c use alloca, so disable SSP warnings.
112 COPTS.rtld.c+= -Wno-stack-protector
113 COPTS.symbol.c+=-Wno-stack-protector
115 LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
116 .if ${MKPICLIB} != "no"
117 LDADD+= -lc_pic
118 .if ${MKPICINSTALL} != "no"
119 DPADD+= ${LIBC_PIC}
120 .endif
121 DPADD+= ${CLIBOBJ}/libc_pic.a
122 .else
123 LDADD+= -lc
124 DPADD+= ${CLIBOBJ}/libc.a
125 .endif
127 .if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
128 # for $$divU, $$remU etc. (millicode)
129 LDADD+= -lgcc
130 DPADD+= ${LIBGCC}
131 .endif
133 STRIPFLAG=
135 .PATH: $M
137 ${PROG}: ${OBJS} ${DPADD}
138 ${_MKMSG_LINK} ${PROG}
139 ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
141 .if ${SHLINKINSTALLDIR} != "/usr/libexec"
142 SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
143 .endif
145 .include <bsd.prog.mk>
146 .else
148 MAN= ld.elf_so.1
150 .include <bsd.man.mk>
151 .endif