NetBSD/libexec/ld.elf_so/Makefile

178 lines
4.6 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile,v 1.137 2017/06/19 11:57:01 joerg Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
2009-05-20 00:44:52 +04:00
WARNS?=4
2013-05-03 19:52:31 +04:00
LDELFSO_MACHINE_ARCH?= ${MACHINE_ARCH}
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
.include <${BSD_MK_COMPAT_FILE}>
.endif
2008-10-16 18:36:20 +04:00
# We are not building this with PIE
PIE_CFLAGS=
PIE_LDFLAGS=
.include <bsd.init.mk> # for MKPIC definition
.include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
.if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
.else
2004-02-24 00:27:20 +03:00
ARCHSUBDIR= ${MACHINE_CPU}
.endif
2004-02-24 00:27:20 +03:00
M= ${.CURDIR}/arch/${ARCHSUBDIR}
.if ((${MACHINE_CPU} == "aarch64") || \
(${LDELFSO_MACHINE_ARCH} == "alpha") || \
(${MACHINE_CPU} == "arm") || \
2013-07-19 01:58:13 +04:00
(${LDELFSO_MACHINE_ARCH} == "coldfire") || \
2013-05-03 19:52:31 +04:00
(${LDELFSO_MACHINE_ARCH} == "hppa") || \
(${LDELFSO_MACHINE_ARCH} == "i386") || \
(${LDELFSO_MACHINE_ARCH} == "m68k") || \
(${MACHINE_CPU} == "mips") || \
2014-09-03 23:31:32 +04:00
(${MACHINE_CPU} == "or1k") || \
(${MACHINE_CPU} == "powerpc") || \
2014-09-19 21:43:33 +04:00
(${MACHINE_CPU} == "riscv") || \
(${MACHINE_CPU} == "sh3") || \
2013-05-03 19:52:31 +04:00
(${LDELFSO_MACHINE_ARCH} == "sparc") || \
(${LDELFSO_MACHINE_ARCH} == "sparc64") || \
(${LDELFSO_MACHINE_ARCH} == "x86_64") || \
(${LDELFSO_MACHINE_ARCH} == "vax")) && \
${MKPIC} != "no"
2011-05-30 20:30:01 +04:00
LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
-shared -nostartfiles -nodefaultlibs
2006-06-29 23:30:59 +04:00
LDFLAGS+= -Wl,-static
2011-01-16 05:36:05 +03:00
LDFLAGS+= -Wl,--warn-shared-textrel
LDFLAGS+= -Wl,-Map=${.TARGET}.map
2011-01-16 05:36:05 +03:00
2012-08-04 19:17:16 +04:00
COPTS+= -fvisibility=hidden
1997-10-22 09:45:08 +04:00
# Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
# is first.
.if exists($M/Makefile.inc)
.include "$M/Makefile.inc"
.endif
# Support compat ld.elf_so.
2009-12-13 11:25:20 +03:00
.if defined(MLIBDIR)
PROG= ld.elf_so-${MLIBDIR}
CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
. if ${MLIBDIR} == "o32"
. endif
.else
PROG= ld.elf_so
.endif
CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
map_object.c load.c search.c headers.c paths.c expand.c \
tls.c symver.c diagassert.c
.if ${USE_FORT} == "yes"
2007-11-13 18:34:51 +03:00
.PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
SRCS+= stack_protector.c
.endif
.PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
SRCS+= exit.c
errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
mv -f ${.TARGET}.tmp ${.TARGET}
xprintf.c: errlist_concat.h
CLEANFILES+= errlist_concat.h ${PROG}.map
BINDIR= ${SHLINKINSTALLDIR}
2004-02-24 00:27:20 +03:00
CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
CPPFLAGS+= -I${.CURDIR} -I. -D_KERNTYPES
2004-02-24 00:27:20 +03:00
CPPFLAGS+= -DRTLD_LOADER
CPPFLAGS+= -DGNU_RELRO
2004-02-24 00:27:20 +03:00
CPPFLAGS+= -D_RTLD_SOURCE
#CPPFLAGS+= -DDEBUG
2004-02-24 00:27:20 +03:00
#CPPFLAGS+= -DRTLD_DEBUG
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
2013-05-03 19:52:31 +04:00
.if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
.endif
2004-02-24 00:27:20 +03:00
#DBG= -g
COPTS+= -O3
.if ${MACHINE_CPU} != "m68k" && ${MACHINE_CPU} != "sh3" && ${MACHINE_ARCH} != "vax"
COPTS+= -fomit-frame-pointer
.endif
2013-05-03 19:52:31 +04:00
.if ${LDELFSO_MACHINE_ARCH} == "i386" || ${LDELFSO_MACHINE_ARCH} == "x86_64"
2012-08-04 19:17:16 +04:00
COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
.endif
.if ${SHLIBDIR} != ${LIBDIR}
CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
.endif
# rtld.c and symbol.c use alloca, so disable SSP warnings.
COPTS.rtld.c+= -Wno-stack-protector
COPTS.symbol.c+=-Wno-stack-protector
LDADD+= -Wl,--version-script=${.CURDIR}/symbols.map
2007-03-15 20:27:15 +03:00
LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
.if ${MKPICLIB} != "no"
LDADD+= -lc_pic
2004-02-27 00:45:59 +03:00
.if ${MKPICINSTALL} != "no"
2004-02-24 00:27:20 +03:00
DPADD+= ${LIBC_PIC}
.endif
2004-02-24 00:27:20 +03:00
DPADD+= ${CLIBOBJ}/libc_pic.a
2007-03-15 20:27:15 +03:00
.else
LDADD+= -lc
DPADD+= ${CLIBOBJ}/libc.a
.endif
2016-10-07 22:10:03 +03:00
.if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
2011-06-06 03:08:17 +04:00
# for $$divU, $$remU etc. (millicode)
LDADD+= -lgcc
DPADD+= ${LIBGCC}
2011-06-06 03:08:17 +04:00
.endif
STRIPFLAG=
.PATH: $M
2013-04-06 00:16:40 +04:00
${PROG}: ${OBJS} ${DPADD}
${_MKMSG_LINK} ${PROG}
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
2013-04-06 00:16:40 +04:00
.if ${MKDEBUG} != "no"
( ${OBJCOPY} --only-keep-debug ${.TARGET} ${.TARGET}.debug \
&& ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
--add-gnu-debuglink=${.TARGET}.debug ${.TARGET} \
) || (rm -f ${.TARGET}.debug; false)
_PROGDEBUG.${PROG} := ${PROG}.debug
.endif
.if ${SHLINKINSTALLDIR} != "/usr/libexec"
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
2013-05-08 19:33:45 +04:00
.if ${MKDEBUG} != "no"
2013-05-09 15:44:36 +04:00
SYMLINKS+= ${DEBUGDIR}${BINDIR}/${PROG}.debug \
${DEBUGDIR}/usr${BINDIR}/${PROG}.debug
2013-05-08 19:33:45 +04:00
.endif
.endif
.include <bsd.prog.mk>
.else
2004-02-27 00:45:59 +03:00
MAN= ld.elf_so.1
.include <bsd.man.mk>
.endif