xref: /openbsd-src/share/man/man7/library-specs.7 (revision 9766c3691b8848a7f6b6022bd381999b0b3efd40)
1*9766c369Sjmc.\" $OpenBSD: library-specs.7,v 1.13 2018/07/09 15:34:10 jmc Exp $
2c8840a0bSespie.\"
3371857e3Sespie.\" Copyright (c) 2001-2010 Marc Espie
4c8840a0bSespie.\"
5c8840a0bSespie.\" All rights reserved.
6c8840a0bSespie.\"
7c8840a0bSespie.\" Redistribution and use in source and binary forms, with or without
8c8840a0bSespie.\" modification, are permitted provided that the following conditions
9c8840a0bSespie.\" are met:
10c8840a0bSespie.\" 1. Redistributions of source code must retain the above copyright
11c8840a0bSespie.\"    notice, this list of conditions and the following disclaimer.
12c8840a0bSespie.\" 2. Redistributions in binary form must reproduce the above copyright
13c8840a0bSespie.\"    notice, this list of conditions and the following disclaimer in the
14c8840a0bSespie.\"    documentation and/or other materials provided with the distribution.
15c8840a0bSespie.\"
16c8840a0bSespie.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17c8840a0bSespie.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18c8840a0bSespie.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19c8840a0bSespie.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20c8840a0bSespie.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21c8840a0bSespie.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22c8840a0bSespie.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23c8840a0bSespie.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24c8840a0bSespie.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25c8840a0bSespie.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26c8840a0bSespie.\"
27*9766c369Sjmc.Dd $Mdocdate: July 9 2018 $
28c8840a0bSespie.Dt LIBRARY-SPECS 7
29c8840a0bSespie.Os
30c8840a0bSespie.Sh NAME
31c8840a0bSespie.Nm library-specs
32c8840a0bSespie.Nd shared library name specifications
33c8840a0bSespie.Sh DESCRIPTION
34c8840a0bSespieEach
35c4a184d2Sespie.Ev WANTLIB
36371857e3Sespieitem in the ports tree conforms to
37c4a184d2Sespie.Bd -literal -offset indent
38371857e3Sespie[path/]libname[=major[.minor]]
39c4a184d2Sespie.Ed
40c8840a0bSespie.Pp
41c4a184d2Sespieor
42c4a184d2Sespie.Bd -literal -offset indent
43371857e3Sespie[path/]libname[>=major[.minor]]
44c4a184d2Sespie.Ed
45c4a184d2Sespie.Pp
46c4a184d2SespieAll libraries that a package needs must be mentioned in that list.
47c4a184d2SespieExcept for system and X11 libraries, they all must be reachable through
48c4a184d2Sespie.Ev LIB_DEPENDS
49c4a184d2Sespieand
50c4a184d2Sespie.Ev RUN_DEPENDS ,
51c4a184d2Sespiedirectly, or indirectly through recursive dependencies.
52c4a184d2Sespie.Pp
53c4a184d2SespieConversely, the ports tree
54c4a184d2Sespieuses
55c4a184d2Sespie.Ev WANTLIB
56c4a184d2Sespieto check whether a given
57c4a184d2Sespie.Ev LIB_DEPENDS
58c4a184d2Sespiewill be required at runtime for shared libraries, and thus turn it into a
59c4a184d2Sespie.Cm @depend
60c4a184d2Sespieline
61c4a184d2Sespie.Po
62c4a184d2Sespiesee
63c4a184d2Sespie.Xr pkg_create 1
64c4a184d2Sespie.Pc .
65c8840a0bSespie.Pp
66c8840a0bSespieThe package system will embed correct dependency checks in the built
67c4a184d2Sespiepackage in the form of
68c4a184d2Sespie.Cm @wantlib
69c4a184d2Sespielines, according to the normal shared library semantics: any library with
70c8840a0bSespiethe same major number, and a greater or equal minor number will do.
71c8840a0bSespie.Pp
72c4a184d2SespieNote that static libraries can only satisfy a library specification if
73c4a184d2Sespieno shared library has been found.
74371857e3SespieThus, if WANTLIB = foo>=5, and both libfoo.so.4.0 and libfoo.a are present,
75c4a184d2Sespiethe check will fail.
76c4a184d2Sespie.Pp
77c8840a0bSespieTherefore, porters must strive to respect correct shared library semantics
78c8840a0bSespiein their own ports: by bumping the minor number each time the interface is
79c8840a0bSespieaugmented, and by bumping the major number each time the interface changes.
80c8840a0bSespieNote that adding functions to a library is an interface augmentation.
81c8840a0bSespieRemoving functions is an interface change.
82c8840a0bSespie.Pp
83d7f7b87cSjmcThe major.minor components of the library specification are used only as a
84371857e3Sespiebuild-time check, the run-time checks are computed by
85*9766c369Sjmc.Xr port-resolve-lib-helper 1 .
861946962aSespieFor
87371857e3Sespie.Sq libname>=major[.minor] ,
881946962aSespieany library which is more recent than the given major.minor version will
89c8840a0bSespiedo.
90c8840a0bSespieIf a specific major number is needed, use the form
91371857e3Sespie.Sq libname=major[.minor] .
921946962aSespieIf the minor component is left empty, any minor will do.
931946962aSespieIf both components are left empty, any version will do.
94c8840a0bSespie.Pp
95371857e3SespieMost specifications won't mention a
96371857e3Sespie.Pa path :
97*9766c369Sjmc.Xr port-resolve-lib-helper 1
98371857e3Sespiewill look in the default
99371857e3Sespie.Xr ldconfig 8
100371857e3Sespiepath automatically, namely
101371857e3Sespie.Pa /usr/local/lib ,
102371857e3Sespie.Pa /usr/X11R6/lib ,
103371857e3Sespie.Pa /usr/lib .
104371857e3SespieIt is generally a bad idea to put libraries elsewhere as they won't be
105371857e3Sespiereached directly.
106371857e3Sespie.Pp
107371857e3SespieHowever, distinct ports may install different major versions of the same
108371857e3Sespielibrary in
109371857e3Sespie.Pa /usr/local/lib ,
11070b536fcSjmcand disambiguate the build by creating a link in a separate directory,
111371857e3Sespieand specifying the right options to the linker.
112371857e3Sespie.Pp
113371857e3SespieThese libraries will require a
114371857e3Sespie.Pa path
115371857e3Sespiecomponent in the corresponding
116371857e3Sespie.Ev WANTLIB
117371857e3Sespieto make sure the right library is resolved.
118371857e3SespieThis path is rooted under
119371857e3Sespie.Pa /usr/local .
120371857e3SespieFor instance, to refer to
121371857e3Sespie.Pa /usr/local/lib/qt3/libqt-mt.so.33.0 ,
122371857e3Sespieone would use
123371857e3Sespie.Sq lib/qt3/qt-mt>=33 .
124c8840a0bSespie.Sh SEE ALSO
125371857e3Sespie.Xr check-lib-depends 1 ,
126371857e3Sespie.Xr ld 1 ,
127371857e3Sespie.Xr ld.so 1 ,
128c8840a0bSespie.Xr pkg_add 1 ,
129*9766c369Sjmc.Xr port-resolve-lib-helper 1 ,
130c8840a0bSespie.Xr bsd.port.mk 5 ,
131c8840a0bSespie.Xr packages 7 ,
132754142a9Sjmc.Xr packages-specs 7 ,
133371857e3Sespie.Xr ports 7 ,
134371857e3Sespie.Xr ldconfig 8
135754142a9Sjmc.Sh HISTORY
136754142a9SjmcFull support for library specifications first appeared in
137754142a9Sjmc.Ox 3.1 .
1381946962aSespieThe format of specifications changed slightly to include
1391946962aSespie.Sq >=
1401946962aSespiebefore
1411946962aSespie.Ox 4.0 .
142c4a184d2SespieThe interactions between
143c4a184d2Sespie.Ev LIB_DEPENDS
144c4a184d2Sespieand
145c4a184d2Sespie.Ev WANTLIB
146c4a184d2Sespiewere modified and clarified for
147c4a184d2Sespie.Ox 4.8 .
148371857e3SespieThe format of specifications changed again before
149371857e3Sespie.Ox 4.9
150371857e3Sespieto remove extra noise.
151