make: Libraries/Search

1 
1 4.5.6 Directory Search for Link Libraries
1 -----------------------------------------
1 
1 Directory search applies in a special way to libraries used with the
1 linker.  This special feature comes into play when you write a
1 prerequisite whose name is of the form '-lNAME'.  (You can tell
1 something strange is going on here because the prerequisite is normally
1 the name of a file, and the _file name_ of a library generally looks
1 like 'libNAME.a', not like '-lNAME'.)
1 
1    When a prerequisite's name has the form '-lNAME', 'make' handles it
1 specially by searching for the file 'libNAME.so', and, if it is not
1 found, for the file 'libNAME.a' in the current directory, in directories
1 specified by matching 'vpath' search paths and the 'VPATH' search path,
1 and then in the directories '/lib', '/usr/lib', and 'PREFIX/lib'
1 (normally '/usr/local/lib', but MS-DOS/MS-Windows versions of 'make'
1 behave as if PREFIX is defined to be the root of the DJGPP installation
1 tree).
1 
1    For example, if there is a '/usr/lib/libcurses.a' library on your
1 system (and no '/usr/lib/libcurses.so' file), then
1 
1      foo : foo.c -lcurses
1              cc $^ -o $@
1 
1 would cause the command 'cc foo.c /usr/lib/libcurses.a -o foo' to be
1 executed when 'foo' is older than 'foo.c' or than
1 '/usr/lib/libcurses.a'.
1 
1    Although the default set of files to be searched for is 'libNAME.so'
1 and 'libNAME.a', this is customizable via the '.LIBPATTERNS' variable.
1 Each word in the value of this variable is a pattern string.  When a
1 prerequisite like '-lNAME' is seen, 'make' will replace the percent in
1 each pattern in the list with NAME and perform the above directory
1 searches using each library file name.
1 
1    The default value for '.LIBPATTERNS' is 'lib%.so lib%.a', which
1 provides the default behavior described above.
1 
1    You can turn off link library expansion completely by setting this
1 variable to an empty value.
1