1 # $NetBSD: bsd.lib.mk,v 1.324 2012/08/23 21:21:16 joerg 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
16 .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 LDADD
+= -L
${LIBDO.
${_lib}} -l
${_lib}
58 DPADD
+= ${LIBDO.
${_lib}}/lib
${_lib}.so
62 ##### Build and install rules
63 MKDEP_SUFFIXES?
= .o .po .pico .go .ln
65 .if
!defined
(SHLIB_MAJOR
) && exists
(${SHLIB_VERSION_FILE}) # {
66 SHLIB_MAJOR
!= .
${SHLIB_VERSION_FILE} ; echo
$$major
67 SHLIB_MINOR
!= .
${SHLIB_VERSION_FILE} ; echo
$$minor
68 SHLIB_TEENY
!= .
${SHLIB_VERSION_FILE} ; echo
$$teeny
70 DPADD
+= ${SHLIB_VERSION_FILE}
72 # Check for higher installed library versions.
73 .if
!defined
(NOCHECKVER
) && !defined
(NOCHECKVER_
${LIB}) && \
74 exists
(${NETBSDSRCDIR}/lib
/checkver
)
76 @
(cd
"${.CURDIR}" && \
77 HOST_SH
=${HOST_SH
:Q
} AWK
=${TOOL_AWK
:Q
} \
78 ${HOST_SH} ${NETBSDSRCDIR}/lib
/checkver
-v
${SHLIB_VERSION_FILE} \
79 -d
${DESTDIR}${_LIBSODIR} ${LIB})
88 .if defined
(SHLIB_MAJOR
) && ${MKPIC} != "no"
95 .if defined
(SHLIB_MINOR
) && ${MKPIC} != "no"
102 .if defined
(SHLIB_TEENY
) && ${MKPIC} != "no"
108 .if defined
(SHLIB_MAJOR
) && !empty
(SHLIB_MAJOR
) # {
109 .if defined
(SHLIB_MINOR
) && !empty
(SHLIB_MINOR
)
110 .if defined
(SHLIB_TEENY
) && !empty
(SHLIB_TEENY
)
111 SHLIB_FULLVERSION
=${SHLIB_MAJOR}.
${SHLIB_MINOR}.
${SHLIB_TEENY}
113 SHLIB_FULLVERSION
=${SHLIB_MAJOR}.
${SHLIB_MINOR}
116 SHLIB_FULLVERSION
=${SHLIB_MAJOR}
120 # add additional suffixes not exported.
121 # .po is used for profiling object files.
122 # .pico is used for PIC object files.
123 .SUFFIXES
: .out .a .ln .pico .po .go .o .s .S .c .
cc .
cpp .
cxx .C .m .F .f .r .y .l .cl .p .h
124 .SUFFIXES
: .sh .m4 .m
127 # Set PICFLAGS to cc flags for producing position-independent code,
128 # if not already set. Includes -DPIC, if required.
130 # Data-driven table using make variables to control how shared libraries
131 # are built for different platforms and object formats.
132 # SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version
133 # numbers of shared library
134 # SHLIB_SOVERSION: version number to be compiled into a shared library
135 # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
136 # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
138 # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
139 # with ELF, also set shared-lib version for ld.so.
140 # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
141 # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
142 # FPICFLAGS: flags for ${FC} to compile .[fF] files to .pico objects.
143 # CPPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
144 # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
145 # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .pico objects.
146 # (usually includes ${CPICFLAGS})
147 # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
148 # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
149 # APICFLAGS: flags for ${AS} to assemble .[sS] to .pico objects.
151 .if
${MACHINE_ARCH} == "alpha" # {
154 CPICFLAGS ?
= -fPIC
-DPIC
156 CAPICFLAGS?
= ${CPPPICFLAGS} ${CPICFLAGS}
159 .elif
(${MACHINE_ARCH} == "sparc" ||
${MACHINE_ARCH} == "sparc64") # } {
161 # If you use -fPIC you need to define BIGPIC to turn on 32-bit
162 # relocations in asm code
164 CPICFLAGS ?
= -fPIC
-DPIC
165 CPPPICFLAGS?
= -DPIC
-DBIGPIC
166 CAPICFLAGS?
= ${CPPPICFLAGS} ${CPICFLAGS}
171 # Platform-independent flags for NetBSD shared libraries
172 SHLIB_SOVERSION
=${SHLIB_FULLVERSION}
175 CPICFLAGS?
= -fPIC
-DPIC
177 CAPICFLAGS?
= ${CPPPICFLAGS} ${CPICFLAGS}
182 .if
${MKPICLIB} != "no"
183 CSHLIBFLAGS
+= ${CPICFLAGS}
186 .if defined
(CSHLIBFLAGS
) && !empty
(CSHLIBFLAGS
)
192 # Platform-independent linker flags for ELF shared libraries
193 SHLIB_SOVERSION
= ${SHLIB_MAJOR}
194 SHLIB_SHFLAGS
= -Wl
,-soname
,${_LIB_PREFIX}${LIB}.so.
${SHLIB_SOVERSION}
195 SHLIB_SHFLAGS
+= -Wl
,--warn-shared-textrel
196 SHLIB_LDSTARTFILE?
= ${_GCC_CRTI} ${_GCC_CRTBEGINS}
197 SHLIB_LDENDFILE?
= ${_GCC_CRTENDS} ${_GCC_CRTN}
200 OBJCFLAGS
+= ${OBJCOPTS}
204 .if defined
(CTFCONVERT
)
205 .if defined
(CFLAGS
) && !empty
(CFLAGS
:M
*-g
*)
212 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
213 .if defined
(CTFCONVERT
)
214 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
216 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
217 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
222 ${COMPILE.c
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
223 .if defined
(CTFCONVERT
)
224 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
226 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
227 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
232 ${COMPILE.c
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
236 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
237 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
238 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
241 .
cc.o .
cpp.o .
cxx.o .C.o
:
243 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
244 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
245 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
248 .
cc.po .
cpp.po .
cxx.po .C.po
:
250 ${COMPILE.
cc} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -pg
${.IMPSRC
} -o
${.TARGET
}
251 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
252 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
255 .
cc.go .
cpp.go .
cxx.go .C.go
:
257 ${COMPILE.
cc} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} -g
${.IMPSRC
} -o
${.TARGET
}
259 .
cc.pico .
cpp.pico .
cxx.pico .C.pico
:
261 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${CSHLIBFLAGS} ${.IMPSRC
} -o
${.TARGET
}
262 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
263 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
268 ${COMPILE.f
} ${.IMPSRC
} -o
${.TARGET
}
269 .if defined
(CTFCONVERT
)
270 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
272 .if
!defined
(FOPTS
) || empty
(FOPTS
:M
*-g
*)
273 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
278 ${COMPILE.f
} ${PROFFLAGS} -pg
${.IMPSRC
} -o
${.TARGET
}
279 .if defined
(CTFCONVERT
)
280 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
282 .if
!defined
(FOPTS
) || empty
(FOPTS
:M
*-g
*)
283 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
288 ${COMPILE.f
} ${DEBUGFLAGS} -g
${.IMPSRC
} -o
${.TARGET
}
292 ${COMPILE.f
} ${FPICFLAGS} ${.IMPSRC
} -o
${.TARGET
}
293 .if
!defined
(FOPTS
) || empty
(FOPTS
:M
*-g
*)
294 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
299 @echo Skipping lint for Fortran libraries.
303 ${COMPILE.m
} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
304 .if defined
(CTFCONVERT
)
305 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
307 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
308 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
313 ${COMPILE.m
} ${PROFFLAGS} -pg
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
314 .if defined
(CTFCONVERT
)
315 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
317 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
318 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
323 ${COMPILE.m
} ${DEBUGFLAGS} -g
${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
324 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
325 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
330 ${COMPILE.m
} ${CSHLIBFLAGS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
331 .if
!defined
(OBJCFLAGS
) || empty
(OBJCFLAGS
:M
*-g
*)
332 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
337 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
338 .if defined
(CTFCONVERT
)
339 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
341 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
345 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
346 .if defined
(CTFCONVERT
)
347 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
349 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
353 ${COMPILE.s
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
354 .if defined
(CTFCONVERT
)
355 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
357 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
361 ${COMPILE.S
} ${PROFFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
362 .if defined
(CTFCONVERT
)
363 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
365 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
369 ${COMPILE.s
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
373 ${COMPILE.S
} ${DEBUGFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
377 ${COMPILE.s
} ${CAPICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
378 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
382 ${COMPILE.S
} ${CAPICFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} -o
${.TARGET
}
383 ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET
}
386 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
387 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
393 .if
${LIBISPRIVATE} != "no" \
394 && (defined
(USE_COMBINE
) && ${USE_COMBINE} == "yes" \
395 && !defined
(NOCOMBINE
)) # {
396 .for f in
${SRCS
:N
*.h
:N
*.sh
:C
/\.
[yl
]$/.c
/g
}
397 COMBINEFLAGS.
${LIB}.
$f := ${CPPFLAGS.
$f:D1
} ${CPUFLAGS.
$f:D2
} ${COPTS.
$f:D3
} ${OBJCOPTS.
$f:D4
} ${CXXFLAGS.
$f:D5
}
398 .if empty
(COMBINEFLAGS.
${LIB}.
${f}) && !defined
(NOCOMBINE.
$f)
402 OBJS
+= ${f
:R
:S
/$/.o
/}
406 .if
!empty
(COMBINESRCS
)
407 OBJS
+= lib
${LIB}_combine.o
408 lib
${LIB}_combine.o
: ${COMBINESRCS}
410 ${COMPILE.c
} -MD
--combine
${.ALLSRC
} -o
${.TARGET
}
411 .if
!defined
(CFLAGS
) || empty
(CFLAGS
:M
*-g
*)
412 ${OBJCOPY} -x
${.TARGET
}
415 CLEANFILES
+= lib
${LIB}_combine.d
417 .if exists
("lib${LIB}_combine.d")
418 .
include "lib${LIB}_combine.d"
420 .
endif # empty(XSRCS.${LIB})
422 OBJS
+=${SRCS
:N
*.h
:N
*.sh
:R
:S
/$/.o
/g
}
427 LOBJS
+=${LSRCS
:.c
=.ln
} ${SRCS
:M
*.c
:.c
=.ln
}
429 .if
${LIBISPRIVATE} != "no"
430 # No installation is required
434 .if
${MKDEBUGLIB} != "no"
436 GOBJS
+=${OBJS
:.o
=.go
}
440 .if
${MKPROFILE} != "no"
442 POBJS
+=${OBJS
:.o
=.po
}
443 PROFFLAGS?
=-DGPROF
-DPROF
446 .if
${MKPIC} != "no" # {
447 .if
${MKPICLIB} == "no"
448 .if
${MKSHLIBOBJS} != "no"
449 # make _pic.a, which isn't really pic,
450 # since it's needed for making shared lib.
451 # but don't install it.
452 SOLIB
=lib
${LIB}_pic.a
453 SOBJS
+=${OBJS
:.o
=.pico
}
458 SOLIB
=lib
${LIB}_pic.a
460 SOBJS
+=${OBJS
:.o
=.pico
}
462 .if defined
(SHLIB_FULLVERSION
)
463 _LIB.so
:=lib
${LIB}.so.
${SHLIB_FULLVERSION}
464 .if
${MKDEBUG} != "no"
465 _LIB.debug
:=${_LIB.so
}.debug
467 _LIBS
+=lib
${LIB}.so.
${SHLIB_FULLVERSION}
471 .if
${MKLINT} != "no" && !empty
(LOBJS
)
472 _LIBS
+=llib-l
${LIB}.ln
476 .if
(${MKPIC} == "no" ||
(defined
(LDSTATIC
) && ${LDSTATIC} != "") \
477 ||
${MKLINKLIB} != "no") && ${MKSTATICLIB} != "no"
480 ALLOBJS
+=${POBJS} ${SOBJS}
481 .if
${MKLINT} != "no" && !empty
(LOBJS
)
484 .
else # !defined(LIB) # } {
487 .
endif # !defined(LIB) # }
489 _YLSRCS
= ${SRCS
:M
*.
[ly
]:C
/\..
$/.c
/} ${YHEADER
:D
${SRCS
:M
*.y
:.y
=.h
}}
491 .NOPATH
: ${ALLOBJS} ${_LIBS} ${_YLSRCS}
493 realall
: ${SRCS} ${ALLOBJS
:O
} ${_LIBS} ${_LIB.debug
}
497 .if
${MKARZERO} == "yes"
504 _INSTRANLIB
=${empty
(PRESERVE
):?
-a
"${RANLIB} -t":}
507 # If you change this, please consider reflecting the change in
508 # the override in sys/rump/Makefile.rump.
509 .if
!target
(__archivebuild
)
513 ${AR} ${_ARFL} ${.TARGET
} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
516 .if
!target
(__archiveinstall
)
517 __archiveinstall
: .USE
519 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
520 ${_INSTRANLIB} ${.ALLSRC
} ${.TARGET
}
523 __archivesymlinkpic
: .USE
525 ${INSTALL_SYMLINK} ${.ALLSRC
} ${.TARGET
}
528 CLEANFILES
+= ${_YLSRCS}
530 ${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS}
532 lib
${LIB}.a
:: ${STOBJS} __archivebuild
534 lib
${LIB}_p.a
:: ${POBJS} __archivebuild
536 lib
${LIB}_pic.a
:: ${SOBJS} __archivebuild
538 lib
${LIB}_g.a
:: ${GOBJS} __archivebuild
542 .if
${SHLIBDIR} != "/usr/lib"
543 _LIBLDOPTS
+= -Wl
,-rpath
,${SHLIBDIR} \
545 .elif
${SHLIBINSTALLDIR} != "/usr/lib"
546 _LIBLDOPTS
+= -Wl
,-rpath-link
,${DESTDIR}${SHLIBINSTALLDIR} \
547 -L
=${SHLIBINSTALLDIR}
550 # gcc -shared now adds -lc automatically. For libraries other than libc and
551 # libgcc* we add as a dependency the installed shared libc. For libc and
552 # libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
553 # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not
554 # to add standard libraries, not the linker.
557 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
560 .if
${LIB} != "c" && ${LIB
:Mgcc
*} == ""
562 DPLIBC ?
= ${DESTDIR}${LIBC_SO}
565 LDLIBC ?
= -nodefaultlibs
567 LDADD
+= ${${ACTIVE_CC} == "gcc":?
-lgcc
:}
568 LDADD
+= ${${ACTIVE_CC} == "clang":?
-L
/usr
/pkg
/compiler-rt
/lib
-lCompilerRT-Generic
:}
573 .if
${LIBISCXX} != "no"
579 _LDADD.lib
${LIB}= ${LDADD} ${LDADD.lib
${LIB}}
580 _LDFLAGS.lib
${LIB}= ${LDFLAGS} ${LDFLAGS.lib
${LIB}}
582 lib
${LIB}.so.
${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
583 ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
585 rm -f lib
${LIB}.so.
${SHLIB_FULLVERSION}
586 ${LIBCC} ${LDLIBC} -Wl
,-x
-shared
${SHLIB_SHFLAGS} ${_LDFLAGS.lib
${LIB}} \
587 -o
${.TARGET
} ${_LIBLDOPTS} \
588 -Wl
,--whole-archive
${SOLIB} -Wl
,--no-whole-archive
${_LDADD.lib
${LIB}}
589 # We don't use INSTALL_SYMLINK here because this is just
590 # happening inside the build directory/objdir. XXX Why does
591 # this spend so much effort on libraries that aren't live??? XXX
592 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
593 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
594 ${HOST_LN} -sf lib
${LIB}.so.
${SHLIB_FULLVERSION} lib
${LIB}.so.
${SHLIB_MAJOR}.tmp
595 mv
-f lib
${LIB}.so.
${SHLIB_MAJOR}.tmp lib
${LIB}.so.
${SHLIB_MAJOR}
597 ${HOST_LN} -sf lib
${LIB}.so.
${SHLIB_FULLVERSION} lib
${LIB}.so.tmp
598 mv
-f lib
${LIB}.so.tmp lib
${LIB}.so
599 .if
${MKSTRIPIDENT} != "no"
600 ${OBJCOPY} -R .ident
${.TARGET
}
603 .if defined
(_LIB.debug
)
604 ${_LIB.debug
}: ${_LIB.so
}
606 ( ${OBJCOPY} --only-keep-debug
${_LIB.so
} ${_LIB.debug
} \
607 && ${OBJCOPY} --strip-debug
-p
-R .gnu_debuglink \
608 --add-gnu-debuglink
=${_LIB.debug
} ${_LIB.so
} \
609 ) ||
(rm -f
${_LIB.debug
}; false
)
612 .if
!empty
(LOBJS
) # {
614 llib-l
${LIB}.ln
: ${LOBJS}
616 rm -f llib-l
${LIB}.ln
618 ${LINT} -C
${LIB} ${.ALLSRC
} -L
${DESTDIR}/usr
/libdata
${LLIBS}
620 ${LINT} -C
${LIB} ${.ALLSRC
} ${LLIBS}
625 .if defined
(LOBJS
) && !empty
(LOBJS
)
626 ${LINT} ${LINTFLAGS} ${LOBJS}
629 # If the number of entries in CLEANFILES is too large, then the
630 # commands in bsd.clean.mk encounter errors like "exec(/bin/sh)
631 # failed (Argument list too long)". Avoid that by splitting the
632 # files to clean into several lists using different variable names.
633 # __cleanuse is an internal target in bsd.clean.mk; the way we
634 # use it here mimics the way it's used by the clean target in
637 clean: libclean1 libclean2 libclean3 libclean4 libclean5
638 libclean1
: .PHONY .MADE __cleanuse LIBCLEANFILES1
639 libclean2
: .PHONY .MADE __cleanuse LIBCLEANFILES2
640 libclean3
: .PHONY .MADE __cleanuse LIBCLEANFILES3
641 libclean4
: .PHONY .MADE __cleanuse LIBCLEANFILES4
642 libclean5
: .PHONY .MADE __cleanuse LIBCLEANFILES5
643 CLEANFILES
+= a.out
[Ee
]rrs mklog core
*.core
644 LIBCLEANFILES1
+= lib
${LIB}.a
${STOBJS} ${STOBJS
:=.tmp
}
645 LIBCLEANFILES2
+= lib
${LIB}_p.a
${POBJS} ${POBJS
:=.tmp
}
646 LIBCLEANFILES3
+= lib
${LIB}_g.a
${GOBJS} ${GOBJS
:=.tmp
}
647 LIBCLEANFILES4
+= lib
${LIB}_pic.a lib
${LIB}.so.
* lib
${LIB}.so
${_LIB.debug
}
648 LIBCLEANFILES4
+= ${SOBJS} ${SOBJS
:=.tmp
}
649 LIBCLEANFILES5
+= llib-l
${LIB}.ln
${LOBJS}
651 .if
!target
(libinstall
) # {
652 # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
655 .if
${MKLINKLIB} != "no" && ${MKSTATICLIB} != "no"
656 libinstall
:: ${DESTDIR}${LIBDIR}/lib
${LIB}.a
657 .PRECIOUS
: ${DESTDIR}${LIBDIR}/lib
${LIB}.a
659 .if
${MKUPDATE} == "no"
660 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}.a
)
661 ${DESTDIR}${LIBDIR}/lib
${LIB}.a
! .MADE
663 ${DESTDIR}${LIBDIR}/lib
${LIB}.a
! lib
${LIB}.a __archiveinstall
665 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}.a
)
666 ${DESTDIR}${LIBDIR}/lib
${LIB}.a
: .MADE
668 ${DESTDIR}${LIBDIR}/lib
${LIB}.a
: lib
${LIB}.a __archiveinstall
672 .if
${MKPROFILE} != "no"
673 libinstall
:: ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
674 .PRECIOUS
: ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
676 .if
${MKUPDATE} == "no"
677 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_p.a
)
678 ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
! .MADE
680 ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
! lib
${LIB}_p.a __archiveinstall
682 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_p.a
)
683 ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
: .MADE
685 ${DESTDIR}${LIBDIR}/lib
${LIB}_p.a
: lib
${LIB}_p.a __archiveinstall
689 .if
${MKDEBUGLIB} != "no"
690 libinstall
:: ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
691 .PRECIOUS
: ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
693 .if
${MKUPDATE} == "no"
694 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_g.a
)
695 ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
! .MADE
697 ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
! lib
${LIB}_g.a __archiveinstall
699 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_g.a
)
700 ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
: .MADE
702 ${DESTDIR}${LIBDIR}/lib
${LIB}_g.a
: lib
${LIB}_g.a __archiveinstall
706 .if
${MKPIC} != "no" && ${MKPICINSTALL} != "no"
707 libinstall
:: ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
708 .PRECIOUS
: ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
710 .if
${MKUPDATE} == "no"
711 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_pic.a
)
712 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
! .MADE
714 .if
${MKPICLIB} == "no"
715 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
! lib
${LIB}.a __archivesymlinkpic
717 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
! lib
${LIB}_pic.a __archiveinstall
720 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}_pic.a
)
721 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
: .MADE
723 .if
${MKPICLIB} == "no"
724 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
: lib
${LIB}.a __archivesymlinkpic
726 ${DESTDIR}${LIBDIR}/lib
${LIB}_pic.a
: lib
${LIB}_pic.a __archiveinstall
731 .if
${MKPIC} != "no" && defined
(SHLIB_FULLVERSION
)
732 _LIB_SO_TGT
= ${DESTDIR}${_LIBSODIR}/${_LIB_PREFIX}${LIB}.so
733 _LIB_SO_TGTLIBDIR
= ${DESTDIR}${LIBDIR}/${_LIB_PREFIX}${LIB}.so
735 libinstall
:: ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}
736 .PRECIOUS
: ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}
738 .if
${MKUPDATE} == "no"
739 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}.so.
${SHLIB_FULLVERSION})
740 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}! .MADE
742 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}! lib
${LIB}.so.
${SHLIB_FULLVERSION}
744 .if
!defined
(BUILD
) && !make
(all) && !make
(lib
${LIB}.so.
${SHLIB_FULLVERSION})
745 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}: .MADE
747 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION}: lib
${LIB}.so.
${SHLIB_FULLVERSION}
750 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
751 ${.ALLSRC
} ${.TARGET
}
752 .if
${_LIBSODIR} != ${LIBDIR}
753 ${INSTALL_SYMLINK} -l r \
754 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION} \
755 ${_LIB_SO_TGTLIBDIR}.
${SHLIB_FULLVERSION}
757 .if defined
(SHLIB_FULLVERSION
) && defined
(SHLIB_MAJOR
) && \
758 "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
760 ${_LIB_PREFIX}${LIB}.so.
${SHLIB_FULLVERSION} \
761 ${_LIB_SO_TGT}.
${SHLIB_MAJOR}
762 .if
${_LIBSODIR} != ${LIBDIR}
763 ${INSTALL_SYMLINK} -l r \
764 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION} \
765 ${_LIB_SO_TGTLIBDIR}.
${SHLIB_MAJOR}
768 .if
${MKLINKLIB} != "no"
770 ${_LIB_PREFIX}${LIB}.so.
${SHLIB_FULLVERSION} \
772 .if
${_LIBSODIR} != ${LIBDIR}
773 ${INSTALL_SYMLINK} -l r \
774 ${_LIB_SO_TGT}.
${SHLIB_FULLVERSION} \
780 .if defined
(_LIB.debug
)
781 libinstall
:: ${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug
}
782 .PRECIOUS
: ${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug
}
784 ${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug
}: ${_LIB.debug
}
786 ${INSTALL_FILE} -o
${DEBUGOWN} -g
${DEBUGGRP} -m
${DEBUGMODE} \
787 ${.ALLSRC
} ${.TARGET
}
790 .if
${MKLINT} != "no" && !empty
(LOBJS
)
791 libinstall
:: ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
792 .PRECIOUS
: ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
794 .if
${MKUPDATE} == "no"
795 .if
!defined
(BUILD
) && !make
(all) && !make
(llib-l
${LIB}.ln
)
796 ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
! .MADE
798 ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
! llib-l
${LIB}.ln
800 .if
!defined
(BUILD
) && !make
(all) && !make
(llib-l
${LIB}.ln
)
801 ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
: .MADE
803 ${DESTDIR}${LINTLIBDIR}/llib-l
${LIB}.ln
: llib-l
${LIB}.ln
806 ${INSTALL_FILE} -o
${LIBOWN} -g
${LIBGRP} -m
${LIBMODE} \
807 ${.ALLSRC
} ${DESTDIR}${LINTLIBDIR}
809 .
endif # !target(libinstall) # }
811 ##### Pull in related .mk logic
814 LINKSMODE?
= ${LIBMODE}
815 .
include <bsd.man.mk
>
816 .
include <bsd.nls.mk
>
817 .
include <bsd.files.mk
>
818 .
include <bsd.inc.mk
>
819 .
include <bsd.links.mk
>
820 .
include <bsd.dep.mk
>
821 .
include <bsd.clang-analyze.mk
>
822 .
include <bsd.
clean.mk
>
824 ${TARGETS}: # ensure existence