Home | History | Annotate | Line # | Download | only in ld.elf_so
Makefile revision 1.116
      1  1.116      matt #	$NetBSD: Makefile,v 1.116 2013/04/24 22:37:20 matt Exp $
      2   1.90        ad #
      3   1.90        ad # NOTE: when changing ld.so, ensure that ldd still compiles.
      4   1.90        ad #
      5   1.88     lukem 
      6   1.89  christos WARNS?=4
      7    1.5       cjs 
      8   1.92       mrg # This needs to be before bsd.init.mk
      9   1.92       mrg .if defined(BSD_MK_COMPAT_FILE)
     10   1.92       mrg .include <${BSD_MK_COMPAT_FILE}>
     11   1.92       mrg .endif
     12   1.92       mrg 
     13   1.86  christos # We are not building this with PIE
     14   1.86  christos PIE_CFLAGS=
     15   1.86  christos PIE_LDFLAGS=
     16   1.97       mrg .include <bsd.init.mk>			# for MKPIC definition
     17  1.114     joerg .include <bsd.shlib.mk>			# for SHLINKINSTALLDIR definition
     18   1.11  jonathan 
     19   1.87       mrg .if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
     20   1.87       mrg     exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
     21   1.87       mrg ARCHSUBDIR=	${LDELFSO_MACHINE_CPU}
     22   1.87       mrg .else
     23   1.67     skrll ARCHSUBDIR=	${MACHINE_CPU}
     24   1.87       mrg .endif
     25   1.67     skrll M=		${.CURDIR}/arch/${ARCHSUBDIR}
     26   1.23  jonathan 
     27   1.29   thorpej .if ((${MACHINE_ARCH} == "alpha") ||					\
     28   1.75    simonb      (${MACHINE_CPU} == "arm") ||					\
     29   1.49  fredette      (${MACHINE_ARCH} == "hppa") ||					\
     30   1.29   thorpej      (${MACHINE_ARCH} == "i386") ||					\
     31   1.29   thorpej      (${MACHINE_ARCH} == "m68k") ||					\
     32   1.75    simonb      (${MACHINE_CPU} == "mips") ||					\
     33   1.29   thorpej      (${MACHINE_ARCH} == "powerpc") ||					\
     34   1.75    simonb      (${MACHINE_CPU} == "sh3") ||					\
     35   1.29   thorpej      (${MACHINE_ARCH} == "sparc") ||					\
     36   1.32      matt      (${MACHINE_ARCH} == "sparc64") ||					\
     37   1.37      fvdl      (${MACHINE_ARCH} == "x86_64") ||					\
     38   1.32      matt      (${MACHINE_ARCH} == "vax")) &&					\
     39   1.97       mrg     ${MKPIC} != "no"
     40   1.29   thorpej 
     41  1.106     joerg LDFLAGS+=	${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
     42  1.106     joerg 		-shared -nostartfiles -nodefaultlibs
     43   1.74     skrll LDFLAGS+=	-Wl,-static
     44  1.102      matt LDFLAGS+=	-Wl,--warn-shared-textrel
     45  1.102      matt 
     46  1.112      matt COPTS+=		-fvisibility=hidden
     47   1.66       uwe 
     48    1.8     lukem # Adds SRCS, CPPFLAGS, LDFLAGS, etc.  Must go first so MD startup source
     49    1.1       cgd # is first.
     50   1.23  jonathan .if exists($M/Makefile.inc)
     51   1.23  jonathan .include "$M/Makefile.inc"
     52    1.3       cgd .endif
     53    1.1       cgd 
     54   1.93       mrg # Support compat ld.elf_so.
     55   1.91       mrg .if defined(MLIBDIR)
     56   1.93       mrg PROG=		ld.elf_so-${MLIBDIR}
     57   1.93       mrg CPPFLAGS+=	-DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
     58   1.87       mrg .else
     59   1.93       mrg PROG=		ld.elf_so
     60   1.93       mrg .endif
     61   1.93       mrg 
     62   1.51     lukem CLIBOBJ!=	cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
     63   1.44        tv 
     64  1.100     joerg SRCS+=		rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
     65  1.103     joerg 		map_object.c load.c search.c headers.c paths.c expand.c \
     66  1.111  christos 		tls.c symver.c diagassert.c
     67   1.40   thorpej 
     68   1.85  christos .if ${USE_FORT} == "yes"
     69   1.84        ad .PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
     70   1.80  christos SRCS+=		stack_protector.c
     71   1.85  christos .endif
     72   1.83     skrll 
     73   1.83     skrll .PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
     74   1.83     skrll SRCS+=		exit.c
     75   1.80  christos 
     76  1.101     joerg errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h
     77  1.101     joerg 	${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
     78  1.101     joerg 	mv -f ${.TARGET}.tmp ${.TARGET}
     79  1.101     joerg 
     80  1.101     joerg xprintf.c: errlist_concat.h
     81  1.101     joerg 
     82  1.101     joerg CLEANFILES+=	errlist_concat.h
     83  1.101     joerg 
     84  1.114     joerg BINDIR=		${SHLINKINSTALLDIR}
     85  1.114     joerg 
     86   1.67     skrll CPPFLAGS+=	-DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
     87  1.101     joerg CPPFLAGS+=	-I${.CURDIR} -I.
     88   1.67     skrll CPPFLAGS+=	-DRTLD_LOADER
     89   1.67     skrll CPPFLAGS+=	-D_RTLD_SOURCE
     90   1.76      matt CPPFLAGS+=	-DCOMBRELOC
     91   1.71    martin #CPPFLAGS+=	-DDEBUG
     92   1.67     skrll #CPPFLAGS+=	-DRTLD_DEBUG
     93   1.67     skrll #CPPFLAGS+=	-DRTLD_DEBUG_RELOC
     94  1.116      matt .if !empty(MACHINE_ARCH:Mearm*)
     95  1.116      matt CPPFLAGS+=	-I${NETBSDSRCDIR}/lib/libexecinfo
     96  1.116      matt .endif
     97   1.67     skrll #DBG=		-g
     98  1.112      matt COPTS=		-O3 -fomit-frame-pointer
     99   1.43     lukem 
    100  1.105     joerg .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
    101  1.112      matt COPTS+=		-mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
    102  1.105     joerg .endif
    103  1.105     joerg 
    104  1.114     joerg 
    105  1.114     joerg .if ${SHLIBDIR} != ${LIBDIR}
    106  1.114     joerg CPPFLAGS+=	-DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
    107  1.114     joerg .endif
    108  1.114     joerg 
    109   1.96     skrll # rtld.c and symbol.c use alloca, so disable SSP warnings.
    110   1.96     skrll COPTS.rtld.c+=	-Wno-stack-protector
    111   1.96     skrll COPTS.symbol.c+=-Wno-stack-protector
    112   1.96     skrll 
    113   1.77      matt LDADD+=		-L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
    114   1.77      matt .if ${MKPICLIB} != "no"
    115   1.77      matt LDADD+=		-lc_pic
    116   1.68     enami .if ${MKPICINSTALL} != "no"
    117   1.67     skrll DPADD+=		${LIBC_PIC}
    118   1.60       uwe .endif
    119   1.67     skrll DPADD+=		${CLIBOBJ}/libc_pic.a
    120   1.77      matt .else
    121   1.77      matt LDADD+=		-lc
    122   1.77      matt DPADD+=		${CLIBOBJ}/libc.a
    123   1.77      matt .endif
    124    1.1       cgd 
    125  1.109       uwe .if ${MACHINE_CPU} == "hppa" || ${MACHINE_CPU} == "sh3"
    126  1.107  christos # for $$divU, $$remU etc. (millicode)
    127  1.110       mrg LDADD+=		-lgcc
    128  1.110       mrg DPADD+=		${LIBGCC}
    129  1.107  christos .endif
    130  1.107  christos 
    131    1.4   thorpej STRIPFLAG=
    132    1.1       cgd 
    133   1.23  jonathan .PATH: $M
    134    1.1       cgd 
    135  1.115  christos 
    136   1.36  christos ${PROG}: ${OBJS} ${DPADD}
    137   1.64     lukem 	${_MKMSG_LINK} ${PROG}
    138   1.72     lukem 	${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
    139  1.115  christos .if ${MKDEBUG} != "no"
    140  1.115  christos 	(  ${OBJCOPY} --only-keep-debug ${.TARGET} ${.TARGET}.debug \
    141  1.115  christos 	   && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
    142  1.115  christos 	   --add-gnu-debuglink=${.TARGET}.debug ${.TARGET} \
    143  1.115  christos 	) || (rm -f ${.TARGET}.debug; false)
    144  1.115  christos 
    145  1.115  christos _PROGDEBUG.${PROG} := ${PROG}.debug
    146  1.115  christos .endif
    147  1.115  christos 
    148   1.35  christos 
    149  1.114     joerg .if ${SHLINKINSTALLDIR} != "/usr/libexec"
    150  1.114     joerg SYMLINKS+=	${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
    151    1.7       mrg .endif
    152    1.1       cgd 
    153    1.1       cgd .include <bsd.prog.mk>
    154   1.45     skrll .else
    155   1.45     skrll 
    156   1.68     enami MAN=		ld.elf_so.1
    157   1.45     skrll 
    158   1.45     skrll .include <bsd.man.mk>
    159   1.45     skrll .endif
    160