1 # $NetBSD: bsd.lib.mk,v 1.342 2013/10/18 16:06:52 christos Exp $
2 # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
5 .
include <bsd.shlib.mk
>
7 # Pull in <bsd.sys.mk> here so we can override its .c.o rule
14 .if
${LIBISMODULE} != "no"
25 .if
${LIBISPRIVATE} != "no"
29 . if defined
(NOSTATICLIB
) && ${MKPICLIB} != "no"
38 .PHONY
: checkver libinstall
39 realinstall
: checkver libinstall
41 ##### LIB specific flags.
42 # XXX: This is needed for programs that link with .a libraries
43 # Perhaps a more correct solution is to always generate _pic.a
44 # files or always have a shared library.
45 .if defined
(MKPIE
) && (${MKPIE} != "no")
46 CFLAGS
+= ${PIE_CFLAGS}
47 AFLAGS
+= ${PIE_AFLAGS}
50 ##### Libraries that this may depend upon.
51 .if defined
(LIBDPLIBS
) && ${MKPIC} != "no" # {
52 .for _lib _dir in
${LIBDPLIBS}
53 .if
!defined
(LIBDO.
${_lib})
54 LIBDO.
${_lib}!= cd
"${_dir}" && ${PRINTOBJDIR}
55 .MAKEOVERRIDES
+=LIBDO.
${_lib}
57 .if
${LIBDO.
${_lib}} == "_external"
60 LDADD
+= -L
${LIBDO.
${_lib}} -l
${_lib}
61 DPADD
+= ${LIBDO.
${_lib}}/lib
${_lib}.so
# Don't use _LIB_PREFIX
66 ##### Build and install rules
67 MKDEP_SUFFIXES?
= .o .po .pico .go .ln
69 .if
!defined
(SHLIB_MAJOR
) && exists
(${SHLIB_VERSION_FILE}) # {
70 SHLIB_MAJOR
!= .
${SHLIB_VERSION_FILE} ; echo
$$major
71 SHLIB_MINOR
!= .
${SHLIB_VERSION_FILE} ; echo
$$minor
72 SHLIB_TEENY
!= .
${SHLIB_VERSION_FILE} ; echo
$$teeny
74 DPADD
+= ${SHLIB_VERSION_FILE}
76 # Check for higher installed library versions.
77 .if
!defined
(NOCHECKVER
) && !defined
(NOCHECKVER_
${LIB}) && \
78 exists
(${NETBSDSRCDIR}/lib
/checkver
)
80 @
(cd
"${.CURDIR}" && \
81 HOST_SH
=${HOST_SH
:Q
} AWK
=${TOOL_AWK
:Q
} \
82 ${HOST_SH} ${NETBSDSRCDIR}/lib
/checkver
-v
${SHLIB_VERSION_FILE} \
83 -d
${_DEST.OBJ
} ${LIB})
92 .if defined
(SHLIB_MAJOR
) && ${MKPIC} != "no"
99 .if defined
(SHLIB_MINOR
) && ${MKPIC} != "no"
106 .if defined
(SHLIB_TEENY
) && ${MKPIC} != "no"
112 .if defined
(SHLIB_MAJOR
) && !empty
(SHLIB_MAJOR
) # {
113 .if defined
(SHLIB_MINOR
) && !empty
(SHLIB_MINOR
)
114 .if defined
(SHLIB_TEENY
) && !empty
(SHLIB_TEENY
)
115 SHLIB_FULLVERSION
=${SHLIB_MAJOR}.
${SHLIB_MINOR}.
${SHLIB_TEENY}
117 SHLIB_FULLVERSION
=${SHLIB_MAJOR}.
${SHLIB_MINOR}
120 SHLIB_FULLVERSION
=${SHLIB_MAJOR}
124 # add additional suffixes not exported.
125 # .po is used for profiling object files.
126 # .pico is used for PIC object files.
127 .SUFFIXES
: .out .a .ln .pico .po .go .o .s .S .c .
cc .
cpp .
cxx .C .m .F .f .r .y .l .cl .p .h
128 .SUFFIXES
: .sh .m4 .m
131 # Set PICFLAGS to cc flags for producing position-independent code,
132 # if not already set.
134 # Data-driven table using make variables to control how shared libraries
135 # are built for different platforms and object formats.
136 # SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version
137 # numbers of shared library
138 # SHLIB_SOVERSION: version number to be compiled into a shared library
139 # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
140 # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
142 # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
143 # with ELF, also set shared-lib version for ld.so.
144 # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
145 # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
149 .if
${MKPICLIB} != "no"
150 CSHLIBFLAGS
+= ${PICFLAGS}
153 .if defined
(CSHLIBFLAGS
) && !empty
(CSHLIBFLAGS
)
159 .if
(defined
(MKDEBUG
) && (${MKDEBUG} != "no")) || \
160 (defined
(CFLAGS
) && !empty
(CFLAGS
:M
*-g
*))
161 # We only add -g to the shared library objects
162 # because we don't currently split .a archives.
164 .if
${LIBISPRIVATE} == "yes"
169 # Platform-independent linker flags for ELF shared libraries
170 SHLIB_SOVERSION
= ${SHLIB_MAJOR}
171 SHLIB_SHFLAGS
= -Wl
,-soname
,${_LIB}.so.
${SHLIB_SOVERSION}
172 SHLIB_SHFLAGS
+= -Wl
,--warn-shared-textrel
173 .if
!defined
(SHLIB_MKMAP
) ||
${SHLIB_MKMAP} != "no"
174 SHLIB_SHFLAGS
+= -Wl
,-Map
=${_LIB}.so.
${SHLIB_SOVERSION}.map
176 CLEANFILES
+= ${_LIB}.so.
${SHLIB_SOVERSION}.map
177 SHLIB_LDSTARTFILE?
= ${_GCC_CRTI} ${_GCC_CRTBEGINS}
178 SHLIB_LDENDFILE?
= ${_GCC_CRTENDS} ${_GCC_CRTN}
181 OBJCFLAGS
+= ${OBJCOPTS}
185 .if defined
(CTFCONVERT
)
186 .if defined
(CFLAGS
) && !empty
(CFLAGS
:M
*-g
*)
192 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
195 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
196 LIBSTRIPOBJCOBJS
= yes
198 .if
!defined
(FFLAGS
) || empty
(FFLAGS
:M
*-g
*)
201 .if
!defined
(CSHLIBFLAGS
) || empty
(CSHLIBFLAGS
:M
*-g
*)
202 LIBSTRIPSHLIBOBJS
= yes
205 .if defined
(__MINIX
) && ${USE_BITCODE
:Uno
} == "yes"
206 SHLIB_SHFLAGS
+= -L
${DESTDIR}/usr
/lib
207 SHLIB_SHFLAGS
+= -Wl
,-plugin
=${GOLD_PLUGIN} \
208 -Wl
,-plugin-opt
=-disable-opt
210 .S.bc
: ${.TARGET
:.bc
=.o
}
212 ln
${.TARGET
:.bc
=.o
} ${.TARGET
}
215 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
} -flto
217 .
cc.bc .
cxx.bc .
cpp.bc
:
219 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
} -flto
220 .
endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
223 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
224 .if defined
(CTFCONVERT
)
225 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
227 .if defined
(LIBSTRIPCOBJS
)
228 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
233 ${COMPILE.c
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
234 .if defined
(CTFCONVERT
)
235 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
237 .if defined
(LIBSTRIPCOBJS
)
238 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
243 ${COMPILE.c
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
247 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
248 .if defined
(LIBSTRIPSHLIBOBJS
)
249 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
252 .
cc.o .
cpp.o .
cxx.o .C.o
:
254 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
255 .if defined
(LIBSTRIPCOBJS
)
256 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
259 .
cc.po .
cpp.po .
cxx.po .C.po
:
261 ${COMPILE.
cc} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
262 .if defined
(LIBSTRIPCOBJS
)
263 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
266 .
cc.go .
cpp.go .
cxx.go .C.go
:
268 ${COMPILE.
cc} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
270 .
cc.pico .
cpp.pico .
cxx.pico .C.pico
:
272 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
273 .if defined
(LIBSTRIPSHLIBOBJS
)
274 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
279 ${COMPILE.f
} ${.IMPSRC
} -o
${.TARGET
}
280 .if defined
(CTFCONVERT
)
281 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
283 .if defined
(LIBSTRIPFOBJS
)
284 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
289 ${COMPILE.f
} ${PROFFLAGS} -pg
${.IMPSRC
} -o
${.TARGET
}
290 .if defined
(CTFCONVERT
)
291 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
293 .if defined
(LIBSTRIPFOBJS
)
294 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
299 ${COMPILE.f
} ${DEBUGFLAGS} -g
${.IMPSRC
} -o
${.TARGET
}
303 ${COMPILE.f
} ${PICFLAGS} ${.IMPSRC
} -o
${.TARGET
}
304 .if defined
(LIBSTRIPFOBJS
)
305 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
310 @echo Skipping lint for Fortran libraries.
314 ${COMPILE.m
} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
315 .if defined
(CTFCONVERT
)
316 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
318 .if defined
(LIBSTRIPOBJCOBJS
)
319 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
324 ${COMPILE.m
} ${PROFFLAGS} -pg
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
325 .if defined
(CTFCONVERT
)
326 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
328 .if defined
(LIBSTRIPOBJCOBJS
)
329 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
334 ${COMPILE.m
} ${DEBUGFLAGS} -g
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
335 .if defined
(LIBSTRIPOBJCOBJS
)
336 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
341 ${COMPILE.m
} ${CSHLIBFLAGS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
342 .if defined
(LIBSTRIPOBJCOBJS
)
343 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
348 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
349 .if defined
(CTFCONVERT
)
350 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
352 .if defined
(LIBSTRIPAOBJS
)
353 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
358 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
359 .if defined
(CTFCONVERT
)
360 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
362 .if defined
(LIBSTRIPAOBJS
)
363 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
368 ${COMPILE.s
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
369 .if defined
(CTFCONVERT
)
370 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
372 .if defined
(LIBSTRIPAOBJS
)
373 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
378 ${COMPILE.S
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
379 .if defined
(CTFCONVERT
)
380 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
382 .if defined
(LIBSTRIPAOBJS
)
383 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
388 ${COMPILE.s
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
392 ${COMPILE.S
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
396 ${COMPILE.s
} ${PICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
397 .if defined
(LIBSTRIPAOBJS
)
398 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
403 ${COMPILE.S
} ${PICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
404 .if defined
(LIBSTRIPAOBJS
)
405 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
408 # Declare a few variables to make our life easier later.
409 _LIB
:=${_LIB_PREFIX}${LIB}
411 _LIB_p.a
:=${_LIB}_p.a
412 _LIB_g.a
:=${_LIB}_g.a
413 _LIB_pic.a
:=${_LIB}_pic.a
414 _LIB.ln
:=llib-l
${LIB}.ln
415 .if defined
(__MINIX
) && ${USE_BITCODE
:Uno
} == "yes"
416 _LIB_bc.a
:=${_LIB}_bc.a
417 .
endif # defined(__MINIX)
419 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
421 _LIB.so.major
:=${_LIB}.so.
${SHLIB_MAJOR}
422 _LIB.so.full
:=${_LIB}.so.
${SHLIB_FULLVERSION}
423 .if
${MKDEBUG} != "no"
424 _LIB.so.debug
:=${_LIB.so.full
}.debug
428 _DEST.LIB
:=${DESTDIR}${LIBDIR}
429 _DEST.OBJ
:=${DESTDIR}${_LIBSODIR}
430 _DEST.LINT
:=${DESTDIR}${LINTLIBDIR}
431 _DEST.DEBUG
:=${DESTDIR}${DEBUGDIR}${LIBDIR}
432 _DEST.ODEBUG
:=${DESTDIR}${DEBUGDIR}${_LIBSODIR}
435 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
436 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
442 .if
${LIBISPRIVATE} != "no" \
443 && (defined
(USE_COMBINE
) && ${USE_COMBINE} == "yes" \
444 && !defined
(NOCOMBINE
)) # {
445 .for f in
${SRCS
:N
*.h
:N
*.sh
:C
/\.
[yl
]$/.c
/g
}
446 COMBINEFLAGS.
${LIB}.
$f := ${CPPFLAGS.
$f:D1
} ${CPUFLAGS.
$f:D2
} ${COPTS.
$f:D3
} ${OBJCOPTS.
$f:D4
} ${CXXFLAGS.
$f:D5
}
447 .if empty
(COMBINEFLAGS.
${LIB}.
${f}) && !defined
(NOCOMBINE.
$f)
451 OBJS
+= ${f
:R
:S
/$/.o
/}
455 .if
!empty
(COMBINESRCS
)
456 OBJS
+= ${_LIB}_combine.o
457 ${_LIB}_combine.o
: ${COMBINESRCS}
459 ${COMPILE.c
} -MD
--combine
${.ALLSRC
} -o
${.TARGET
}
460 .if defined
(LIBSTRIPOBJS
)
461 ${OBJCOPY} -x
${.TARGET
}
464 CLEANFILES
+= ${_LIB}_combine.d
466 .if exists
("${_LIB}_combine.d")
467 .
include "${_LIB}_combine.d"
469 .
endif # empty(XSRCS.${LIB})
471 OBJS
+=${SRCS
:N
*.h
:N
*.sh
:R
:S
/$/.o
/g
}
476 LOBJS
+=${LSRCS
:.c
=.ln
} ${SRCS
:M
*.c
:.c
=.ln
}
478 .if
${LIBISPRIVATE} != "no"
479 # No installation is required
483 .if
${MKDEBUGLIB} != "no"
485 GOBJS
+=${OBJS
:.o
=.go
}
489 .if
${MKPROFILE} != "no"
491 POBJS
+=${OBJS
:.o
=.po
}
492 PROFFLAGS?
=-DGPROF
-DPROF
495 .if
${MKPIC} != "no" # {
496 .if
${MKPICLIB} == "no"
497 .if
${MKSHLIBOBJS} != "no"
498 # make _pic.a, which isn't really pic,
499 # since it's needed for making shared lib.
500 # but don't install it.
502 SOBJS
+=${OBJS
:.o
=.pico
}
509 SOBJS
+=${OBJS
:.o
=.pico
}
511 .if defined
(SHLIB_FULLVERSION
)
512 _LIBS
+=${_LIB.so.full
}
516 .if
${MKLINT} != "no" && !empty
(LOBJS
)
521 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
522 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
525 ALLOBJS
+=${POBJS} ${SOBJS}
526 .if
${MKLINT} != "no" && !empty
(LOBJS
)
529 .
else # !defined(LIB) # } {
532 .
endif # !defined(LIB) # }
534 _YLSRCS
= ${SRCS
:M
*.
[ly
]:C
/\..
$/.c
/} ${YHEADER
:D
${SRCS
:M
*.y
:.y
=.h
}}
536 .if
${USE_BITCODE
:Uno
} == "yes"
538 .
endif # ${USE_BITCODE:Uno} == "yes"
540 .NOPATH
: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
542 realall
: ${SRCS} ${ALLOBJS
:O
} ${_LIBS} ${_LIB.so.debug
}
546 .if
${MKARZERO} == "yes"
553 .if
${USE_BITCODE
:Uno
} == "yes"
554 _INSTRANLIB
=${empty
(PRESERVE
):?
-a
"${AR} --plugin ${GOLD_PLUGIN} -s":}
556 _INSTRANLIB
=${empty
(PRESERVE
):?
-a
"${RANLIB} -t":}
557 .
endif # ${USE_BITCODE:Uno} == "yes"
560 # If you change this, please consider reflecting the change in
561 # the override in sys/rump/Makefile.rump.
562 .if
!target
(__archivebuild
)
566 ${AR} ${_ARFL} ${.TARGET
} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
569 .if
!target
(__archiveinstall
)
570 __archiveinstall
: .USE
572 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
573 ${_INSTRANLIB} ${.ALLSRC
} ${.TARGET
}
576 __archivesymlinkpic
: .USE
578 ${INSTALL_SYMLINK} ${.ALLSRC
} ${.TARGET
}
581 CLEANFILES
+= ${_YLSRCS}
583 ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
585 .if
${USE_BITCODE
:Uno
} == "yes"
587 .if
!target
(__archivebuildbc
)
588 __archivebuildbc
: .USE
591 ${AR} ${_ARFL} --plugin
${GOLD_PLUGIN} ${.TARGET
} ${.ALLSRC
:M
*bc
}
594 # LSC: Ignore libunwind in the bitcode archive, otherwise final linking chokes
595 # on libunwind hidden assembly symbols.
596 BCOBJS
+=${OBJS
:Nlibunwind.
*:.o
=.bc
}
598 ${_LIB_bc.a
}:: ${BCOBJS} __archivebuildbc
600 .
endif # ${USE_BITCODE:Uno} == "yes"
602 ${_LIB.a
}:: ${STOBJS} __archivebuild
604 ${_LIB_p.a
}:: ${POBJS} __archivebuild
606 ${_LIB_pic.a
}:: ${SOBJS} __archivebuild
608 ${_LIB_g.a
}:: ${GOBJS} __archivebuild
612 .if
${SHLIBDIR} != "/usr/lib"
613 _LIBLDOPTS
+= -Wl
,-rpath
,${SHLIBDIR} \
615 .elif
${SHLIBINSTALLDIR} != "/usr/lib"
616 _LIBLDOPTS
+= -Wl
,-rpath-link
,${DESTDIR}${SHLIBINSTALLDIR} \
617 -L
=${SHLIBINSTALLDIR}
620 # gcc -shared now adds -lc automatically. For libraries other than libc and
621 # libgcc* we add as a dependency the installed shared libc. For libc and
622 # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
623 # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
624 # to add standard libraries, not the linker.
627 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
630 .if
${LIB} != "c" && ${LIB
:Mgcc
*} == "" \
631 && ${LIB} != "sys" && ${LIB} != "minc" && ${LIB} != "mthread" # Minix-specific libs
633 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
636 LDLIBC ?
= -nodefaultlibs
637 .if
${HAVE_LIBGCC} == "yes" && (${LIB} == "c" ||
${LIB} == "minc")
638 .if
!defined
(__MINIX
)
641 LDADD
+= ${${ACTIVE_CC} == "gcc":?
-lgcc
:}
642 .if
${MACHINE_ARCH} == "earm"
643 LDADD
+= ${${ACTIVE_CC} == "gcc":?
-lgcc_eh
:}
644 .
endif # ${MACHINE_ARCH} == "earm"
645 .
endif # !defined(__MINIX)
650 .if
${LIBISCXX} != "no"
652 . if
${MKLIBCXX} == "yes"
653 LIBDPLIBS
+= c
++ ${.CURDIR
}/..
/..
/..
/..
/..
/external
/bsd
/libc
++/lib
654 . elif defined
(HAVE_GCC
) && ${HAVE_GCC} == 4
655 LIBDPLIBS
+= stdc
++ ${.CURDIR
}/..
/..
/..
/..
/..
/gnu
/lib
/libstdc
++-v3_4
657 LIBDPLIBS
+= stdc
++ ${.CURDIR
}/..
/..
/..
/..
/..
/external
/gpl3
/gcc
/lib
/libstdc
++-v3
663 _LDADD.
${_LIB}= ${LDADD} ${LDADD.
${_LIB}}
664 _LDFLAGS.
${_LIB}= ${LDFLAGS} ${LDFLAGS.
${_LIB}}
666 ${_LIB.so.full
}: ${SOLIB} ${DPADD} ${DPLIBC} \
667 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
670 ${LIBCC} ${LDLIBC} -Wl
,-x
-shared
${SHLIB_SHFLAGS} \
671 ${_LDFLAGS.
${_LIB}} -o
${.TARGET
} ${_LIBLDOPTS} \
672 -Wl
,--whole-archive
${SOLIB} \
673 -Wl
,--no-whole-archive
${_LDADD.
${_LIB}}
674 # We don't use INSTALL_SYMLINK here because this is just
675 # happening inside the build directory/objdir. XXX Why does
676 # this spend so much effort on libraries that aren't live??? XXX
677 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
678 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
679 ${HOST_LN} -sf
${_LIB.so.full
} ${_LIB.so.major
}.tmp
680 mv
-f
${_LIB.so.major
}.tmp
${_LIB.so.major
}
682 ${HOST_LN} -sf
${_LIB.so.full
} ${_LIB.so
}.tmp
683 mv
-f
${_LIB.so
}.tmp
${_LIB.so
}
684 .if
${MKSTRIPIDENT} != "no"
685 ${OBJCOPY} -R .ident
${.TARGET
}
688 .if defined
(_LIB.so.debug
)
689 ${_LIB.so.debug
}: ${_LIB.so.full
}
691 ( ${OBJCOPY} --only-keep-debug
${_LIB.so.full
} ${_LIB.so.debug
} \
692 && ${OBJCOPY} --strip-debug
-p
-R .gnu_debuglink \
693 --add-gnu-debuglink
=${_LIB.so.debug
} ${_LIB.so.full
} \
694 ) ||
(rm -f
${.TARGET
}; false
)
697 .if
!empty
(LOBJS
) # {
703 ${LINT} -C
${LIB} ${.ALLSRC
} -L
${DESTDIR}/usr
/libdata
${LLIBS}
705 ${LINT} -C
${LIB} ${.ALLSRC
} ${LLIBS}
710 .if defined
(LOBJS
) && !empty
(LOBJS
)
711 ${LINT} ${LINTFLAGS} ${LOBJS}
715 # If the number of entries in CLEANFILES is too large, then the
716 # commands in bsd.clean.mk encounter errors like "exec(/bin/sh)
717 # failed (Argument list too long)". Avoid that by splitting the
718 # files to clean into several lists using different variable names.
719 # __cleanuse is an internal target in bsd.clean.mk; the way we
720 # use it here mimics the way it's used by the clean target in
723 clean: libclean1 libclean2 libclean3 libclean4 libclean5
724 libclean1
: .PHONY .MADE __cleanuse LIBCLEANFILES1
725 libclean2
: .PHONY .MADE __cleanuse LIBCLEANFILES2
726 libclean3
: .PHONY .MADE __cleanuse LIBCLEANFILES3
727 libclean4
: .PHONY .MADE __cleanuse LIBCLEANFILES4
728 libclean5
: .PHONY .MADE __cleanuse LIBCLEANFILES5
730 # MINIX: core conflicts with core/ in lib/liblwip
731 CLEANFILES
+= a.out
[Ee
]rrs mklog
*.core
733 CLEANFILES
+= a.out
[Ee
]rrs mklog core
*.core
734 .
endif # defined(__MINIX)
735 LIBCLEANFILES1
+= ${_LIB.a
} ${STOBJS} ${STOBJS
:=.tmp
}
736 LIBCLEANFILES2
+= ${_LIB_p.a
} ${POBJS} ${POBJS
:=.tmp
}
737 LIBCLEANFILES3
+= ${_LIB_g.a
} ${GOBJS} ${GOBJS
:=.tmp
}
738 LIBCLEANFILES4
+= ${_LIB_pic.a
}
739 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
740 LIBCLEANFILES4
+= ${_LIB.so
}.
* ${_LIB.so
} ${_LIB.so.debug
}
742 LIBCLEANFILES4
+= ${SOBJS} ${SOBJS
:=.tmp
}
743 LIBCLEANFILES5
+= ${_LIB.ln
} ${LOBJS}
747 libclean6
: .PHONY .MADE __cleanuse LIBCLEANFILES6
748 LIBCLEANFILES6
+= ${_LIB_bc.a
} ${BCOBJS} ${BCOBJS
:=.tmp
}
751 .if
!target
(libinstall
) # {
752 # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
755 .if
${USE_BITCODE
:Uno
} == "yes"
756 libinstall
:: ${_DEST.LIB
}/bc
/${_LIB.a
}
757 .PRECIOUS
: ${_DEST.LIB
}/bc
/${_LIB.a
}
759 .if
${MKUPDATE} == "no"
760 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_bc.a
})
761 ${_DEST.LIB
}/bc
/${_LIB.a
}! .MADE
763 ${_DEST.LIB
}/bc
/${_LIB.a
}! ${_LIB_bc.a
} __archiveinstall
765 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_bc.a
})
766 ${_DEST.LIB
}/bc
/${_LIB.a
}: .MADE
768 ${_DEST.LIB
}/bc
/${_LIB.a
}: ${_LIB_bc.a
} __archiveinstall
770 .
endif # ${USE_BITCODE:Uno} == "yes"
772 .if
${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
773 libinstall
:: ${_DEST.LIB
}/${_LIB.a
}
774 .PRECIOUS
: ${_DEST.LIB
}/${_LIB.a
}
776 .if
${MKUPDATE} == "no"
777 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.a
})
778 ${_DEST.LIB
}/${_LIB.a
}! .MADE
780 ${_DEST.LIB
}/${_LIB.a
}! ${_LIB.a
} __archiveinstall
782 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.a
})
783 ${_DEST.LIB
}/${_LIB.a
}: .MADE
785 ${_DEST.LIB
}/${_LIB.a
}: ${_LIB.a
} __archiveinstall
789 .if
${MKPROFILE} != "no"
790 libinstall
:: ${_DEST.LIB
}/${_LIB_p.a
}
791 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_p.a
}
793 .if
${MKUPDATE} == "no"
794 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_p.a
})
795 ${_DEST.LIB
}/${_LIB_p.a
}! .MADE
797 ${_DEST.LIB
}/${_LIB_p.a
}! ${_LIB_p.a
} __archiveinstall
799 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_p.a
})
800 ${_DEST.LIB
}/${_LIB_p.a
}: .MADE
802 ${_DEST.LIB
}/${_LIB_p.a
}: ${_LIB_p.a
} __archiveinstall
806 .if
${MKDEBUGLIB} != "no"
807 libinstall
:: ${_DEST.LIB
}/${_LIB_g.a
}
808 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_g.a
}
810 .if
${MKUPDATE} == "no"
811 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_g.a
})
812 ${_DEST.LIB
}/${_LIB_g.a
}! .MADE
814 ${_DEST.LIB
}/${_LIB_g.a
}! ${_LIB_g.a
} __archiveinstall
816 .if
!defined
(BUILD
) && !make
(all) && !make
(${LIB_g.a
})
817 ${_DEST.LIB
}/${_LIB_g.a
}: .MADE
819 ${_DEST.LIB
}/${_LIB_g.a
}: ${_LIB_g.a
} __archiveinstall
823 .if
${MKPIC} != "no" && ${MKPICINSTALL} != "no"
824 libinstall
:: ${_DEST.LIB
}/${_LIB_pic.a
}
825 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_pic.a
}
827 .if
${MKUPDATE} == "no"
828 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_pic.a
})
829 ${_DEST.LIB
}/${_LIB_pic.a
}! .MADE
831 .if
${MKPICLIB} == "no"
832 ${_DEST.LIB
}/${_LIB_pic.a
}! ${_LIB.a
} __archivesymlinkpic
834 ${_DEST.LIB
}/${_LIB_pic.a
}! ${_LIB_pic.a
} __archiveinstall
837 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_pic.a
})
838 ${_DEST.LIB
}/${_LIB_pic.a
}: .MADE
840 .if
${MKPICLIB} == "no"
841 ${_DEST.LIB
}/${_LIB_pic.a
}: ${_LIB.a
} __archivesymlinkpic
843 ${_DEST.LIB
}/${_LIB_pic.a
}: ${_LIB_pic.a
} __archiveinstall
848 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
850 libinstall
:: ${_DEST.OBJ
}/${_LIB.so.full
}
851 .PRECIOUS
: ${_DEST.OBJ
}/${_LIB.so.full
}
853 .if
${MKUPDATE} == "no"
854 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.so.full
})
855 ${_DEST.OBJ
}/${_LIB.so.full
}! .MADE
857 ${_DEST.OBJ
}/${_LIB.so.full
}! ${_LIB.so.full
}
859 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.so.full
})
860 ${_DEST.OBJ
}/${_LIB.so.full
}: .MADE
862 ${_DEST.OBJ
}/${_LIB.so.full
}: ${_LIB.so.full
}
865 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
866 ${.ALLSRC
} ${.TARGET
}
867 .if
${_LIBSODIR} != ${LIBDIR}
868 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
869 ${_DEST.LIB
}/${_LIB.so.full
}
871 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
872 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
873 ${INSTALL_SYMLINK} ${_LIB.so.full
} ${_DEST.OBJ
}/${_LIB.so.major
}
874 .if
${_LIBSODIR} != ${LIBDIR}
875 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
876 ${_DEST.LIB
}/${_LIB.so.major
}
879 .if
${MKLINKLIB} != "no"
880 ${INSTALL_SYMLINK} ${_LIB.so.full
} ${_DEST.OBJ
}/${_LIB.so
}
881 .if
${_LIBSODIR} != ${LIBDIR}
882 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
883 ${_DEST.LIB
}/${_LIB.so
}
888 .if defined
(_LIB.so.debug
)
889 libinstall
:: ${_DEST.DEBUG
}/${_LIB.so.debug
}
890 .PRECIOUS
: ${_DEST.DEBUG
}/${_LIB.so.debug
}
892 ${_DEST.DEBUG
}/${_LIB.so.debug
}: ${_LIB.so.debug
}
894 ${INSTALL_FILE} -o
${DEBUGOWN} -g
${DEBUGGRP} -m
${DEBUGMODE} \
895 ${.ALLSRC
} ${.TARGET
}
896 .if
${_LIBSODIR} != ${LIBDIR}
897 ${INSTALL_SYMLINK} -l r
${_DEST.DEBUG
}/${_LIB.so.debug
} \
898 ${_DEST.ODEBUG
}/${_LIB.so.debug
}
902 .if
${MKLINT} != "no" && !empty
(LOBJS
)
903 libinstall
:: ${_DEST.LINT
}/${_LIB.ln
}
904 .PRECIOUS
: ${_DEST.LINT
}/${_LIB.ln
}
906 .if
${MKUPDATE} == "no"
907 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.ln
})
908 ${_DEST.LINT
}/${_LIB.ln
}! .MADE
910 ${_DEST.LINT
}/${_LIB.ln
}! ${_LIB.ln
}
912 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.ln
})
913 ${_DEST.LINT
}/${_LIB.ln
}: .MADE
915 ${_DEST.LINT
}/${_LIB.ln
}: ${_LIB.ln
}
918 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
919 ${.ALLSRC
} ${_DEST.LINT
}
921 .
endif # !target(libinstall) # }
923 ##### Pull in related .mk logic
926 LINKSMODE?
= ${LIBMODE}
927 .
include <bsd.man.mk
>
928 .
include <bsd.nls.mk
>
929 .
include <bsd.files.mk
>
930 .
include <bsd.inc.mk
>
931 .
include <bsd.links.mk
>
932 .
include <bsd.dep.mk
>
933 .
include <bsd.clang-analyze.mk
>
934 .
include <bsd.
clean.mk
>
936 ${TARGETS}: # ensure existence