Move primary cache code to libminixfs.
[minix.git] / libexec / ld.elf_so / Makefile
blob6cdfa0c585199d296b7df50722e3670ebc5f8d7f
1 # $NetBSD: Makefile,v 1.102 2011/01/16 02:36:05 matt Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
6 WARNS?=4
8 # This executable needs to be linked dynamically
9 MINIXDYNAMIC=yes
11 # And the minix gcc currently references /libexec/ld-elf.so.1
12 SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /libexec/ld-elf.so.1
14 # This needs to be before bsd.init.mk
15 .if defined(BSD_MK_COMPAT_FILE)
16 .include <${BSD_MK_COMPAT_FILE}>
17 .endif
19 # We are not building this with PIE
20 PIE_CFLAGS=
21 PIE_LDFLAGS=
22 .include <bsd.init.mk> # for MKPIC definition
23 .include <bsd.shlib.mk> # for SHLINKINSTALLDIR definition
25 .if defined(LDELFSO_MACHINE_CPU) && !empty(LDELFSO_MACHINE_CPU) && \
26 exists(${.CURDIR}/arch/${LDELFSO_MACHINE_CPU})
27 ARCHSUBDIR= ${LDELFSO_MACHINE_CPU}
28 .else
29 ARCHSUBDIR= ${MACHINE_CPU}
30 .endif
31 M= ${.CURDIR}/arch/${ARCHSUBDIR}
33 .if ((${MACHINE_ARCH} == "alpha") || \
34 (${MACHINE_CPU} == "arm") || \
35 (${MACHINE_ARCH} == "hppa") || \
36 (${MACHINE_ARCH} == "i386") || \
37 (${MACHINE_ARCH} == "m68k") || \
38 (${MACHINE_CPU} == "mips") || \
39 (${MACHINE_ARCH} == "powerpc") || \
40 (${MACHINE_CPU} == "sh3") || \
41 (${MACHINE_ARCH} == "sparc") || \
42 (${MACHINE_ARCH} == "sparc64") || \
43 (${MACHINE_ARCH} == "x86_64") || \
44 (${MACHINE_ARCH} == "vax")) && \
45 ${MKPIC} != "no"
47 .if ${CC} == "gcc"
48 LDFLAGS+= -shared -symbolic -nostartfiles
49 .else
50 LDFLAGS+= -shared -Wl,-Bsymbolic -nostartfiles
51 .endif
52 LDFLAGS+= -Wl,-static
53 LDFLAGS+= -Wl,--warn-shared-textrel
55 CFLAGS+= -fvisibility=hidden
57 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
58 # is first.
59 .if exists($M/Makefile.inc)
60 .include "$M/Makefile.inc"
61 .endif
63 # Support compat ld.elf_so.
64 .if defined(MLIBDIR)
65 PROG= ld.elf_so-${MLIBDIR}
66 CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
67 .else
68 PROG= ld.elf_so
69 .endif
71 CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
73 SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
74 map_object.c load.c search.c headers.c paths.c expand.c
76 .if ${USE_FORT} == "yes"
77 .PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
78 SRCS+= stack_protector.c
79 .endif
81 .PATH.c: ${NETBSDSRCDIR}/lib/libc/stdlib
82 SRCS+= exit.c
84 errlist_concat.h: ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk ${NETBSDSRCDIR}/include/sys/errno.h
85 ${TOOL_AWK} -v concat=1 -f ${.ALLSRC} > ${.TARGET}.tmp && \
86 mv -f ${.TARGET}.tmp ${.TARGET}
88 xprintf.c: errlist_concat.h
90 CLEANFILES+= errlist_concat.h
92 BINDIR= ${SHLINKINSTALLDIR}
94 CPPFLAGS+= -DLIBDIR=\"${LIBDIR}\" -D_PATH_RTLD=\"${BINDIR}/${PROG}\"
95 CPPFLAGS+= -I${.CURDIR} -I.
96 CPPFLAGS+= -DRTLD_LOADER
97 CPPFLAGS+= -D_RTLD_SOURCE
98 CPPFLAGS+= -DCOMBRELOC
99 #CPPFLAGS+= -DDEBUG
100 #CPPFLAGS+= -DRTLD_DEBUG
101 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
102 DBG= -g
103 #DBG= -O3 -fomit-frame-pointer
105 .if ${SHLIBDIR} != ${LIBDIR}
106 CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
107 .endif
109 # rtld.c and symbol.c use alloca, so disable SSP warnings.
110 COPTS.rtld.c+= -Wno-stack-protector
111 COPTS.symbol.c+=-Wno-stack-protector
113 LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
114 .if ${MKPICLIB} != "no"
115 LDADD+= -lc_pic
116 .if ${MKPICINSTALL} != "no"
117 DPADD+= ${LIBC_PIC}
118 .endif
119 DPADD+= ${CLIBOBJ}/libc_pic.a
120 .else
121 LDADD+= -lc
122 DPADD+= ${CLIBOBJ}/libc.a
123 .endif
125 STRIPFLAG=
127 .PATH: $M
129 ${PROG}: ${OBJS} ${DPADD}
130 ${_MKMSG_LINK} ${PROG}
131 ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
133 .if ${SHLINKINSTALLDIR} != "/usr/libexec"
134 SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
135 .endif
137 .include <bsd.prog.mk>
138 .else
140 MAN= ld.elf_so.1
142 .include <bsd.man.mk>
143 .endif