1 # $NetBSD: bsd.lib.mk,v 1.362 2015/09/08 16:06:42 uebayasi 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 .d
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 .if
!defined
(SHLIB_WARNTEXTREL
) ||
${SHLIB_WARNTEXTREL} != "no"
173 SHLIB_SHFLAGS
+= -Wl
,--warn-shared-textrel
175 .if
!defined
(SHLIB_MKMAP
) ||
${SHLIB_MKMAP} != "no"
176 SHLIB_SHFLAGS
+= -Wl
,-Map
=${_LIB}.so.
${SHLIB_SOVERSION}.map
178 CLEANFILES
+= ${_LIB}.so.
${SHLIB_SOVERSION}.map
179 SHLIB_LDSTARTFILE?
= ${_GCC_CRTI} ${_GCC_CRTBEGINS}
180 SHLIB_LDENDFILE?
= ${_GCC_CRTENDS} ${_GCC_CRTN}
183 OBJCFLAGS
+= ${OBJCOPTS}
187 .if defined
(CTFCONVERT
)
188 .if defined
(CFLAGS
) && !empty
(CFLAGS
:M
*-g
*)
190 .if defined
(HAVE_GCC
) && ${HAVE_GCC} >= 48
197 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
200 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
201 LIBSTRIPOBJCOBJS
= yes
203 .if
!defined
(FFLAGS
) || empty
(FFLAGS
:M
*-g
*)
206 .if
!defined
(CSHLIBFLAGS
) || empty
(CSHLIBFLAGS
:M
*-g
*)
207 LIBSTRIPSHLIBOBJS
= yes
210 .if defined
(__MINIX
) && ${USE_BITCODE
:Uno
} == "yes"
211 SHLIB_SHFLAGS
+= -L
${DESTDIR}/usr
/lib
212 SHLIB_SHFLAGS
+= -Wl
,-plugin
=${GOLD_PLUGIN} \
213 -Wl
,-plugin-opt
=-disable-opt
215 SECTIONIFYPASS?
=${NETBSDSRCDIR}/minix
/llvm
/bin
/sectionify.so
216 # dcvmoole: the following construction is a hack for libmagicrt. For reasons
217 # not entirely under our control, clang refuses to take .bc objects even when
218 # using the gold linker, saying that LLVM IR code cannot be linked. In order
219 # to sidestep this, libmagicrt uses the name "foo.bc.o" instead of "foo.bc" to
220 # link the its LLVM IR objects. As all libmagicrt modules use the sectionify
221 # pass below, and this step needs temporary files, we give the temporary files
222 # the .o suffix (while anything would do!), and allow the libmagicrt makefile
223 # to override the rename to the real file name to perform a copy instead. As
224 # a result, libmagicrt ends up with both the .bc and .bc.o objects, and it can
225 # pass the latter set to clang, bypassing clang's overly strict checks.
228 .S.bc
: ${.TARGET
:.bc
=.o
}
230 ln
${.TARGET
:.bc
=.o
} ${.TARGET
}
233 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
} -flto
234 if
[ -n
'${SECTIONIFY.${.IMPSRC:T}:U${SECTIONIFY}}' ]; then \
235 ${OPT} -load
${SECTIONIFYPASS} -sectionify
${SECTIONIFY.
${.IMPSRC
:T
}:U
${SECTIONIFY}} -o
${.TARGET
}.o
${.TARGET
} && ${SECTIONIFYMV} ${.TARGET
}.o
${.TARGET
}; \
238 .
cc.bc .
cxx.bc .
cpp.bc
:
240 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
} -flto
241 .
endif # defined(__MINIX) && ${USE_BITCODE:Uno} == "yes"
244 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
245 .if defined
(CTFCONVERT
)
246 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
248 .if defined
(LIBSTRIPCOBJS
)
249 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
254 ${COMPILE.c
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
255 .if defined
(CTFCONVERT
)
256 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
258 .if defined
(LIBSTRIPCOBJS
)
259 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
264 ${COMPILE.c
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
268 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
269 .if defined
(LIBSTRIPSHLIBOBJS
)
270 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
273 .
cc.o .
cpp.o .
cxx.o .C.o
:
275 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
276 .if defined
(LIBSTRIPCOBJS
)
277 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
280 .
cc.po .
cpp.po .
cxx.po .C.po
:
282 ${COMPILE.
cc} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
283 .if defined
(LIBSTRIPCOBJS
)
284 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
287 .
cc.go .
cpp.go .
cxx.go .C.go
:
289 ${COMPILE.
cc} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
291 .
cc.pico .
cpp.pico .
cxx.pico .C.pico
:
293 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
294 .if defined
(LIBSTRIPSHLIBOBJS
)
295 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
300 ${COMPILE.f
} ${.IMPSRC
} -o
${.TARGET
}
301 .if defined
(CTFCONVERT
)
302 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
304 .if defined
(LIBSTRIPFOBJS
)
305 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
310 ${COMPILE.f
} ${PROFFLAGS} -pg
${.IMPSRC
} -o
${.TARGET
}
311 .if defined
(CTFCONVERT
)
312 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
314 .if defined
(LIBSTRIPFOBJS
)
315 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
320 ${COMPILE.f
} ${DEBUGFLAGS} -g
${.IMPSRC
} -o
${.TARGET
}
324 ${COMPILE.f
} ${PICFLAGS} ${.IMPSRC
} -o
${.TARGET
}
325 .if defined
(LIBSTRIPFOBJS
)
326 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
331 @echo Skipping lint for Fortran libraries.
335 ${COMPILE.m
} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
336 .if defined
(CTFCONVERT
)
337 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
339 .if defined
(LIBSTRIPOBJCOBJS
)
340 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
345 ${COMPILE.m
} ${PROFFLAGS} -pg
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
346 .if defined
(CTFCONVERT
)
347 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
349 .if defined
(LIBSTRIPOBJCOBJS
)
350 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
355 ${COMPILE.m
} ${DEBUGFLAGS} -g
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
356 .if defined
(LIBSTRIPOBJCOBJS
)
357 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
362 ${COMPILE.m
} ${CSHLIBFLAGS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
363 .if defined
(LIBSTRIPOBJCOBJS
)
364 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
369 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
370 .if defined
(CTFCONVERT
)
371 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
373 .if defined
(LIBSTRIPAOBJS
)
374 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
379 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
380 .if defined
(CTFCONVERT
)
381 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
383 .if defined
(LIBSTRIPAOBJS
)
384 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
389 ${COMPILE.s
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
390 .if defined
(CTFCONVERT
)
391 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
393 .if defined
(LIBSTRIPAOBJS
)
394 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
399 ${COMPILE.S
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
400 .if defined
(CTFCONVERT
)
401 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
403 .if defined
(LIBSTRIPAOBJS
)
404 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
409 ${COMPILE.s
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
413 ${COMPILE.S
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
417 ${COMPILE.s
} ${PICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
418 .if defined
(LIBSTRIPAOBJS
)
419 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
424 ${COMPILE.S
} ${PICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
425 .if defined
(LIBSTRIPAOBJS
)
426 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
429 # Declare a few variables to make our life easier later.
430 _LIB
:=${_LIB_PREFIX}${LIB}
432 _LIB_p.a
:=${_LIB}_p.a
433 _LIB_g.a
:=${_LIB}_g.a
434 _LIB_pic.a
:=${_LIB}_pic.a
435 _LIB.ln
:=llib-l
${LIB}.ln
436 .if defined
(__MINIX
) && ${USE_BITCODE
:Uno
} == "yes"
437 _LIB_bc.a
:=${_LIB}_bc.a
438 .
endif # defined(__MINIX)
440 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
442 _LIB.so.major
:=${_LIB}.so.
${SHLIB_MAJOR}
443 _LIB.so.full
:=${_LIB}.so.
${SHLIB_FULLVERSION}
444 _LIB.so.link
:=${_LIB}.so.
${SHLIB_FULLVERSION}.link
445 .if
${MKDEBUG} != "no"
446 _LIB.so.debug
:=${_LIB.so.full
}.debug
450 _DEST.LIB
:=${DESTDIR}${LIBDIR}
451 _DEST.OBJ
:=${DESTDIR}${_LIBSODIR}
452 _DEST.LINT
:=${DESTDIR}${LINTLIBDIR}
453 _DEST.DEBUG
:=${DESTDIR}${DEBUGDIR}${LIBDIR}
454 _DEST.ODEBUG
:=${DESTDIR}${DEBUGDIR}${_LIBSODIR}
457 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
458 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
464 .if
${LIBISPRIVATE} != "no" \
465 && (defined
(USE_COMBINE
) && ${USE_COMBINE} == "yes" \
466 && !defined
(NOCOMBINE
)) # {
467 .for f in
${SRCS
:N
*.h
:N
*.sh
:C
/\.
[yl
]$/.c
/g
}
468 COMBINEFLAGS.
${LIB}.
$f := ${CPPFLAGS.
$f:D1
} ${CPUFLAGS.
$f:D2
} ${COPTS.
$f:D3
} ${OBJCOPTS.
$f:D4
} ${CXXFLAGS.
$f:D5
}
469 .if empty
(COMBINEFLAGS.
${LIB}.
${f}) && !defined
(NOCOMBINE.
$f)
473 OBJS
+= ${f
:R
:S
/$/.o
/}
477 .if
!empty
(COMBINESRCS
)
478 OBJS
+= ${_LIB}_combine.o
479 ${_LIB}_combine.o
: ${COMBINESRCS}
481 ${COMPILE.c
} -MD
--combine
${.ALLSRC
} -o
${.TARGET
}
482 .if defined
(LIBSTRIPOBJS
)
483 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
486 CLEANFILES
+= ${_LIB}_combine.d
488 .if exists
("${_LIB}_combine.d")
489 .
include "${_LIB}_combine.d"
491 .
endif # empty(XSRCS.${LIB})
493 OBJS
+=${SRCS
:N
*.h
:N
*.sh
:R
:S
/$/.o
/g
}
498 LOBJS
+=${LSRCS
:.c
=.ln
} ${SRCS
:M
*.c
:.c
=.ln
}
500 .if
${LIBISPRIVATE} != "no"
501 # No installation is required
505 .if
${MKDEBUGLIB} != "no"
507 GOBJS
+=${OBJS
:.o
=.go
}
511 .if
${MKPROFILE} != "no"
513 POBJS
+=${OBJS
:.o
=.po
}
514 PROFFLAGS?
=-DGPROF
-DPROF
517 .if
${MKPIC} != "no" # {
518 .if
${MKPICLIB} == "no"
519 .if
${MKSHLIBOBJS} != "no"
520 # make _pic.a, which isn't really pic,
521 # since it's needed for making shared lib.
522 # but don't install it.
524 SOBJS
+=${OBJS
:.o
=.pico
}
531 SOBJS
+=${OBJS
:.o
=.pico
}
533 .if defined
(SHLIB_FULLVERSION
)
534 _LIBS
+=${_LIB.so.full
}
538 .if
${MKLINT} != "no" && !empty
(LOBJS
)
543 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
544 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
547 ALLOBJS
+=${POBJS} ${SOBJS}
548 .if
${MKLINT} != "no" && !empty
(LOBJS
)
551 .
else # !defined(LIB) # } {
554 .
endif # !defined(LIB) # }
556 _YLSRCS
= ${SRCS
:M
*.
[ly
]:C
/\..
$/.c
/} ${YHEADER
:D
${SRCS
:M
*.y
:.y
=.h
}}
558 .if
${USE_BITCODE
:Uno
} == "yes"
562 .
endif # ${USE_BITCODE:Uno} == "yes"
564 .NOPATH
: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
566 realall
: ${SRCS} ${ALLOBJS
:O
} ${_LIBS} ${_LIB.so.debug
}
568 MKARZERO?
= ${MKREPRO
:Uno
}
570 .if
${MKARZERO} == "yes"
577 .if
${USE_BITCODE
:Uno
} == "yes"
578 _INSTRANLIB
=${empty
(PRESERVE
):?
-a
"${AR} --plugin ${GOLD_PLUGIN} -s":}
580 _INSTRANLIB
=${empty
(PRESERVE
):?
-a
"${RANLIB} -t":}
581 .
endif # ${USE_BITCODE:Uno} == "yes"
584 # If you change this, please consider reflecting the change in
585 # the override in sys/rump/Makefile.rump.
586 .if
!target
(__archivebuild
)
590 ${AR} ${_ARFL} ${.TARGET
} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
593 .if
!target
(__archiveinstall
)
594 __archiveinstall
: .USE
596 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
597 ${_INSTRANLIB} ${.ALLSRC
} ${.TARGET
}
600 __archivesymlinkpic
: .USE
602 ${INSTALL_SYMLINK} ${.ALLSRC
} ${.TARGET
}
605 CLEANFILES
+= ${_YLSRCS}
607 ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
609 .if
${USE_BITCODE
:Uno
} == "yes"
611 .if
!target
(__archivebuildbc
)
612 __archivebuildbc
: .USE
615 ${AR} ${_ARFL} --plugin
${GOLD_PLUGIN} ${.TARGET
} ${.ALLSRC
:M
*bc
}
618 # LSC: Ignore libunwind in the bitcode archive, otherwise final linking chokes
619 # on libunwind hidden assembly symbols.
620 BCOBJS
+=${OBJS
:Nlibunwind.
*:.o
=.bc
}
622 ${_LIB_bc.a
}:: ${BCOBJS} __archivebuildbc
624 .
endif # ${USE_BITCODE:Uno} == "yes"
626 ${_LIB.a
}:: ${STOBJS} __archivebuild
628 ${_LIB_p.a
}:: ${POBJS} __archivebuild
630 ${_LIB_pic.a
}:: ${SOBJS} __archivebuild
632 ${_LIB_g.a
}:: ${GOBJS} __archivebuild
636 .if
${SHLIBDIR} != "/usr/lib"
637 _LIBLDOPTS
+= -Wl
,-rpath
,${SHLIBDIR} \
639 .elif
${SHLIBINSTALLDIR} != "/usr/lib"
640 _LIBLDOPTS
+= -Wl
,-rpath-link
,${DESTDIR}${SHLIBINSTALLDIR} \
641 -L
=${SHLIBINSTALLDIR}
644 # gcc -shared now adds -lc automatically. For libraries other than libc and
645 # libgcc* we add as a dependency the installed shared libc. For libc and
646 # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
647 # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
648 # to add standard libraries, not the linker.
651 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
654 .if
${LIB} != "c" && ${LIB
:Mgcc
*} == "" \
655 && ${LIB} != "sys" && ${LIB} != "minc" && ${LIB} != "mthread" # Minix-specific libs
657 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
660 LDLIBC ?
= -nodefaultlibs
661 .if
${HAVE_LIBGCC} == "yes" && (${LIB} == "c" ||
${LIB} == "minc")
662 .if
!defined
(__MINIX
)
665 LDADD
+= ${${ACTIVE_CC} == "gcc":?
-lgcc
:}
666 .if
${MACHINE_ARCH} == "earm"
667 LDADD
+= ${${ACTIVE_CC} == "gcc":?
-lgcc_eh
:}
668 .
endif # ${MACHINE_ARCH} == "earm"
669 .
endif # !defined(__MINIX)
674 .if
${LIBISCXX} != "no"
676 . if
${MKLIBCXX} == "yes"
677 LIBDPLIBS
+= c
++ ${.CURDIR
}/..
/..
/..
/..
/..
/external
/bsd
/libc
++/lib
679 LIBDPLIBS
+= stdc
++ ${.CURDIR
}/..
/..
/..
/..
/..
/external
/gpl3
/${EXTERNAL_GCC_SUBDIR}/lib
/libstdc
++-v3
685 _LDADD.
${_LIB}= ${LDADD} ${LDADD.
${_LIB}}
686 _LDFLAGS.
${_LIB}= ${LDFLAGS} ${LDFLAGS.
${_LIB}}
688 _MAINLIBDEPS
= ${SOLIB} ${DPADD} ${DPLIBC} \
689 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
691 .if defined
(_LIB.so.debug
)
692 ${_LIB.so.debug
}: ${_LIB.so.link
}
694 ( ${OBJCOPY} --only-keep-debug \
695 ${_LIB.so.link
} ${_LIB.so.debug
} \
696 ) ||
(rm -f
${.TARGET
}; false
)
697 ${_LIB.so.full
}: ${_LIB.so.link
} ${_LIB.so.debug
}
699 ( ${OBJCOPY} --strip-debug
-p
-R .gnu_debuglink \
700 --add-gnu-debuglink
=${_LIB.so.debug
} \
701 ${_LIB.so.link
} ${_LIB.so.full
} \
702 ) ||
(rm -f
${.TARGET
}; false
)
703 ${_LIB.so.link
}: ${_MAINLIBDEPS}
704 .
else # aka no MKDEBUG
705 ${_LIB.so.full
}: ${_MAINLIBDEPS}
709 ${LIBCC} ${LDLIBC} -Wl
,-x
-shared
${SHLIB_SHFLAGS} \
710 ${_LDFLAGS.
${_LIB}} -o
${.TARGET
} ${_LIBLDOPTS} \
711 -Wl
,--whole-archive
${SOLIB} \
712 -Wl
,--no-whole-archive
${_LDADD.
${_LIB}}
713 # We don't use INSTALL_SYMLINK here because this is just
714 # happening inside the build directory/objdir. XXX Why does
715 # this spend so much effort on libraries that aren't live??? XXX
716 # XXX Also creates dead symlinks until the .full rule runs
717 # above and creates the main link
718 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
719 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
720 ${HOST_LN} -sf
${_LIB.so.full
} ${_LIB.so.major
}.tmp
721 mv
-f
${_LIB.so.major
}.tmp
${_LIB.so.major
}
723 ${HOST_LN} -sf
${_LIB.so.full
} ${_LIB.so
}.tmp
724 mv
-f
${_LIB.so
}.tmp
${_LIB.so
}
725 .if
${MKSTRIPIDENT} != "no"
726 ${OBJCOPY} -R .ident
${.TARGET
}
729 .if
!empty
(LOBJS
) # {
735 ${LINT} -C
${LIB} ${.ALLSRC
} -L
${DESTDIR}/usr
/libdata
${LLIBS}
737 ${LINT} -C
${LIB} ${.ALLSRC
} ${LLIBS}
742 .if defined
(LOBJS
) && !empty
(LOBJS
)
743 ${LINT} ${LINTFLAGS} ${LOBJS}
747 # If the number of entries in CLEANFILES is too large, then the
748 # commands in bsd.clean.mk encounter errors like "exec(/bin/sh)
749 # failed (Argument list too long)". Avoid that by splitting the
750 # files to clean into several lists using different variable names.
751 # __cleanuse is an internal target in bsd.clean.mk; the way we
752 # use it here mimics the way it's used by the clean target in
755 clean: libclean1 libclean2 libclean3 libclean4 libclean5
756 libclean1
: .PHONY .MADE __cleanuse LIBCLEANFILES1
757 libclean2
: .PHONY .MADE __cleanuse LIBCLEANFILES2
758 libclean3
: .PHONY .MADE __cleanuse LIBCLEANFILES3
759 libclean4
: .PHONY .MADE __cleanuse LIBCLEANFILES4
760 libclean5
: .PHONY .MADE __cleanuse LIBCLEANFILES5
762 # MINIX: core conflicts with core/ in lib/liblwip
763 CLEANFILES
+= a.out
[Ee
]rrs mklog
*.core
765 CLEANFILES
+= a.out
[Ee
]rrs mklog core
*.core
766 .
endif # defined(__MINIX)
767 LIBCLEANFILES1
+= ${_LIB.a
} ${STOBJS} ${STOBJS
:=.tmp
}
768 LIBCLEANFILES2
+= ${_LIB_p.a
} ${POBJS} ${POBJS
:=.tmp
}
769 LIBCLEANFILES3
+= ${_LIB_g.a
} ${GOBJS} ${GOBJS
:=.tmp
}
770 LIBCLEANFILES4
+= ${_LIB_pic.a
}
771 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
772 LIBCLEANFILES4
+= ${_LIB.so
}.
* ${_LIB.so
} ${_LIB.so.debug
}
774 LIBCLEANFILES4
+= ${SOBJS} ${SOBJS
:=.tmp
}
775 LIBCLEANFILES5
+= ${_LIB.ln
} ${LOBJS}
779 libclean6
: .PHONY .MADE __cleanuse LIBCLEANFILES6
780 LIBCLEANFILES6
+= ${_LIB_bc.a
} ${BCOBJS} ${BCOBJS
:=.tmp
}
783 .if
!target
(libinstall
) # {
784 # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
787 .if
${USE_BITCODE
:Uno
} == "yes"
788 libinstall
:: ${_DEST.LIB
}/bc
/${_LIB.a
}
789 .PRECIOUS
: ${_DEST.LIB
}/bc
/${_LIB.a
}
791 .if
${MKUPDATE} == "no"
792 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_bc.a
})
793 ${_DEST.LIB
}/bc
/${_LIB.a
}! .MADE
795 ${_DEST.LIB
}/bc
/${_LIB.a
}! ${_LIB_bc.a
} __archiveinstall
797 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_bc.a
})
798 ${_DEST.LIB
}/bc
/${_LIB.a
}: .MADE
800 ${_DEST.LIB
}/bc
/${_LIB.a
}: ${_LIB_bc.a
} __archiveinstall
802 .
endif # ${USE_BITCODE:Uno} == "yes"
804 .if
${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
805 libinstall
:: ${_DEST.LIB
}/${_LIB.a
}
806 .PRECIOUS
: ${_DEST.LIB
}/${_LIB.a
}
808 .if
${MKUPDATE} == "no"
809 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.a
})
810 ${_DEST.LIB
}/${_LIB.a
}! .MADE
812 ${_DEST.LIB
}/${_LIB.a
}! ${_LIB.a
} __archiveinstall
814 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.a
})
815 ${_DEST.LIB
}/${_LIB.a
}: .MADE
817 ${_DEST.LIB
}/${_LIB.a
}: ${_LIB.a
} __archiveinstall
821 .if
${MKPROFILE} != "no"
822 libinstall
:: ${_DEST.LIB
}/${_LIB_p.a
}
823 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_p.a
}
825 .if
${MKUPDATE} == "no"
826 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_p.a
})
827 ${_DEST.LIB
}/${_LIB_p.a
}! .MADE
829 ${_DEST.LIB
}/${_LIB_p.a
}! ${_LIB_p.a
} __archiveinstall
831 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_p.a
})
832 ${_DEST.LIB
}/${_LIB_p.a
}: .MADE
834 ${_DEST.LIB
}/${_LIB_p.a
}: ${_LIB_p.a
} __archiveinstall
838 .if
${MKDEBUGLIB} != "no"
839 libinstall
:: ${_DEST.LIB
}/${_LIB_g.a
}
840 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_g.a
}
842 .if
${MKUPDATE} == "no"
843 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_g.a
})
844 ${_DEST.LIB
}/${_LIB_g.a
}! .MADE
846 ${_DEST.LIB
}/${_LIB_g.a
}! ${_LIB_g.a
} __archiveinstall
848 .if
!defined
(BUILD
) && !make
(all) && !make
(${LIB_g.a
})
849 ${_DEST.LIB
}/${_LIB_g.a
}: .MADE
851 ${_DEST.LIB
}/${_LIB_g.a
}: ${_LIB_g.a
} __archiveinstall
855 .if
${MKPIC} != "no" && ${MKPICINSTALL} != "no"
856 libinstall
:: ${_DEST.LIB
}/${_LIB_pic.a
}
857 .PRECIOUS
: ${_DEST.LIB
}/${_LIB_pic.a
}
859 .if
${MKUPDATE} == "no"
860 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_pic.a
})
861 ${_DEST.LIB
}/${_LIB_pic.a
}! .MADE
863 .if
${MKPICLIB} == "no"
864 ${_DEST.LIB
}/${_LIB_pic.a
}! ${_LIB.a
} __archivesymlinkpic
866 ${_DEST.LIB
}/${_LIB_pic.a
}! ${_LIB_pic.a
} __archiveinstall
869 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB_pic.a
})
870 ${_DEST.LIB
}/${_LIB_pic.a
}: .MADE
872 .if
${MKPICLIB} == "no"
873 ${_DEST.LIB
}/${_LIB_pic.a
}: ${_LIB.a
} __archivesymlinkpic
875 ${_DEST.LIB
}/${_LIB_pic.a
}: ${_LIB_pic.a
} __archiveinstall
880 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
882 libinstall
:: ${_DEST.OBJ
}/${_LIB.so.full
}
883 .PRECIOUS
: ${_DEST.OBJ
}/${_LIB.so.full
}
885 .if
${MKUPDATE} == "no"
886 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.so.full
})
887 ${_DEST.OBJ
}/${_LIB.so.full
}! .MADE
889 ${_DEST.OBJ
}/${_LIB.so.full
}! ${_LIB.so.full
}
891 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.so.full
})
892 ${_DEST.OBJ
}/${_LIB.so.full
}: .MADE
894 ${_DEST.OBJ
}/${_LIB.so.full
}: ${_LIB.so.full
}
897 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
898 ${.ALLSRC
} ${.TARGET
}
899 .if
${_LIBSODIR} != ${LIBDIR}
900 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
901 ${_DEST.LIB
}/${_LIB.so.full
}
903 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
904 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
905 ${INSTALL_SYMLINK} ${_LIB.so.full
} ${_DEST.OBJ
}/${_LIB.so.major
}
906 .if
${_LIBSODIR} != ${LIBDIR}
907 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
908 ${_DEST.LIB
}/${_LIB.so.major
}
911 .if
${MKLINKLIB} != "no"
912 ${INSTALL_SYMLINK} ${_LIB.so.full
} ${_DEST.OBJ
}/${_LIB.so
}
913 .if
${_LIBSODIR} != ${LIBDIR}
914 ${INSTALL_SYMLINK} -l r
${_DEST.OBJ
}/${_LIB.so.full
} \
915 ${_DEST.LIB
}/${_LIB.so
}
920 .if defined
(_LIB.so.debug
)
921 libinstall
:: ${_DEST.DEBUG
}/${_LIB.so.debug
}
922 .PRECIOUS
: ${_DEST.DEBUG
}/${_LIB.so.debug
}
924 ${_DEST.DEBUG
}/${_LIB.so.debug
}: ${_LIB.so.debug
}
926 ${INSTALL_FILE} -o
${DEBUGOWN} -g
${DEBUGGRP} -m
${DEBUGMODE} \
927 ${.ALLSRC
} ${.TARGET
}
928 .if
${_LIBSODIR} != ${LIBDIR}
929 ${INSTALL_SYMLINK} -l r
${_DEST.DEBUG
}/${_LIB.so.debug
} \
930 ${_DEST.ODEBUG
}/${_LIB.so.debug
}
934 .if
${MKLINT} != "no" && !empty
(LOBJS
)
935 libinstall
:: ${_DEST.LINT
}/${_LIB.ln
}
936 .PRECIOUS
: ${_DEST.LINT
}/${_LIB.ln
}
938 .if
${MKUPDATE} == "no"
939 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.ln
})
940 ${_DEST.LINT
}/${_LIB.ln
}! .MADE
942 ${_DEST.LINT
}/${_LIB.ln
}! ${_LIB.ln
}
944 .if
!defined
(BUILD
) && !make
(all) && !make
(${_LIB.ln
})
945 ${_DEST.LINT
}/${_LIB.ln
}: .MADE
947 ${_DEST.LINT
}/${_LIB.ln
}: ${_LIB.ln
}
950 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
951 ${.ALLSRC
} ${_DEST.LINT
}
953 .
endif # !target(libinstall) # }
955 ##### Pull in related .mk logic
958 LINKSMODE?
= ${LIBMODE}
959 .
include <bsd.man.mk
>
960 .
include <bsd.nls.mk
>
961 .
include <bsd.files.mk
>
962 .
include <bsd.inc.mk
>
963 .
include <bsd.links.mk
>
964 .
include <bsd.dep.mk
>
965 .
include <bsd.clang-analyze.mk
>
966 .
include <bsd.
clean.mk
>
968 ${TARGETS}: # ensure existence