NetBSD/libexec/ld.elf_so/Makefile

139 lines
3.3 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile,v 1.105 2011/05/20 22:22:44 joerg Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
2009-05-20 00:44:52 +04:00
WARNS?=4
# 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_ARCH} == "alpha") || \
(${MACHINE_CPU} == "arm") || \
(${MACHINE_ARCH} == "hppa") || \
(${MACHINE_ARCH} == "i386") || \
(${MACHINE_ARCH} == "m68k") || \
(${MACHINE_CPU} == "mips") || \
(${MACHINE_ARCH} == "powerpc") || \
(${MACHINE_CPU} == "sh3") || \
(${MACHINE_ARCH} == "sparc") || \
(${MACHINE_ARCH} == "sparc64") || \
(${MACHINE_ARCH} == "x86_64") || \
(${MACHINE_ARCH} == "vax")) && \
${MKPIC} != "no"
LDFLAGS+= -shared -symbolic -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
CFLAGS+= -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}\"
.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
.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
2004-02-24 00:27:20 +03:00
BINDIR= ${SHLINKINSTALLDIR}
* Add user-controlled mk.conf variables - SHLIBDIR Location to install shared libraries if ${USE_SHLIBDIR} is "yes". Defaults to "/usr/lib". - USE_SHLIBDIR If "yes", install shared libraries in ${SHLIBDIR} instead of ${LIBDIR}. Defaults to "no". Sets ${_LIBSODIR} to the appropriate value. This may be set by individual Makefiles as well. - SHLINKDIR Location of shared linker. Defaults to "/usr/libexec". If != "/usr/libexec", change the dynamic-linker encoded in shared programs * Set USE_SHLIBDIR for libraries used by /bin and /sbin: libc libcrypt libcrypto libedit libipsec libkvm libm libmi387 libtermcap libutil libz * If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so* to ${_LIBSODIR}/${LIB}.so* for compatibility. * Always install /sbin/init statically (for now) The net effect of these changes depends on how the variables are set: 1.) If nothing is set or changed, there is no change from the current behaviour: - Static /bin, /sbin, and bits of /usr/* - Dynamic rest - Shared linker is /usr/libexec/ld*so 2.) If the following make variables are set: LDSTATIC= SHLINKDIR=/lib SHLIBDIR=/lib Then the behaviour becomes: - Dynamic tools - .so libraries used by /bin and /sbin are installed to /lib, with symlinks from /usr/lib/lib*so to -> /lib/lib*so where appropriate - Shared linker is /lib/ld*so 3.) As per 2.), but add the following variable: USE_SHLIBDIR=yes This forces all .so's to be instaleld in /lib (with compat symlinks), not just those tagged by their Makefiles to be. Again, compat symlinks are installed
2001-12-28 04:32:37 +03:00
2004-02-24 00:27:20 +03:00
CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
CPPFLAGS+= -I${.CURDIR} -I.
2004-02-24 00:27:20 +03:00
CPPFLAGS+= -DRTLD_LOADER
CPPFLAGS+= -D_RTLD_SOURCE
CPPFLAGS+= -DCOMBRELOC
#CPPFLAGS+= -DDEBUG
2004-02-24 00:27:20 +03:00
#CPPFLAGS+= -DRTLD_DEBUG
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
#DBG= -g
DBG= -O3 -fomit-frame-pointer
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
DBG+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
.endif
.if ${SHLIBDIR} != ${LIBDIR}
2004-02-24 00:27:20 +03:00
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
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
STRIPFLAG=
.PATH: $M
${PROG}: ${OBJS} ${DPADD}
${_MKMSG_LINK} ${PROG}
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
.if ${SHLINKINSTALLDIR} != "/usr/libexec"
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
.endif
.include <bsd.prog.mk>
.else
2004-02-27 00:45:59 +03:00
MAN= ld.elf_so.1
.include <bsd.man.mk>
.endif