This patch adds additional pic-only search path to mklibs. pic-only means that this path will only be considered when looking for pic.a and pic.map files.

Reason why freetz and only freetz needs this patch: there are a couple of libraries which are both available in original AVM firmware and provided by freetz,
e.g. libcapi20. freetz also provides some so called remove-patches making it possible to remove AVM versions of the libraries provided they are not necessary.
freetz however doesn't track dependencies of AVM binaries (just because it's quite hard to do it for all the firmwares available). In case of an error in one
of the remove-patches this error might remain undetected just because library with the same name or even other library providing the same symbol is available
in freetz staging dir (it might get included into the image, it however might also NOT get included into it). To avoid such errors or to detect them
much earlier we separate shared-libraries-search-path (-L option) from pic.a/pic.map-files-search-path (-P option). Shared-libraries will be searched only
in directories specified using -L option, pic-files will be searched in all directories, i.e. in those specified with -P and those specified with -L.

-L should only be used for directories containing the files included into the image.
-P might contain also the files not included into the image.

This patch makes also "missing select"-errors easier to see even if this kind of errors are quite seldom.

--- src/mklibs
+++ src/mklibs
@@ -241,7 +241,7 @@
 # Find a PIC archive for the library
 def find_pic(lib):
     base_name = so_pattern.match(lib).group(1)
-    for path in lib_path:
+    for path in piconly_lib_path+lib_path:
         for file in glob.glob(sysroot + path + "/" + base_name + "_pic.a"):
             if os.access(file, os.F_OK):
                 return resolve_link(file)
@@ -250,7 +250,7 @@
 # Find a PIC .map file for the library
 def find_pic_map(lib):
     base_name = so_pattern.match(lib).group(1)
-    for path in lib_path:
+    for path in piconly_lib_path+lib_path:
         for file in glob.glob(sysroot + path + "/" + base_name + "_pic.map"):
             if os.access(file, os.F_OK):
                 return resolve_link(file)
@@ -292,6 +292,7 @@
     print >> outfd, "  -d, --dest-dir DIRECTORY     create libraries in DIRECTORY"
     print >> outfd, "  -D, --no-default-lib         omit default libpath (", ':'.join(default_lib_path), ")"
     print >> outfd, "  -L DIRECTORY[:DIRECTORY]...  add DIRECTORY(s) to the library search path"
+    print >> outfd, "  -P DIRECTORY[:DIRECTORY]...  add DIRECTORY(s) to the pic.a/pic.map search path"
     print >> outfd, "  -l LIBRARY                   add LIBRARY always"
     print >> outfd, "      --ldlib LDLIB            use LDLIB for the dynamic linker"
     print >> outfd, "      --libc-extras-dir DIRECTORY  look for libc extra files in DIRECTORY"
@@ -332,7 +333,7 @@
 os.environ['LC_ALL'] = "C"
 
 # Argument parsing
-opts = "L:DnvVhd:r:l:"
+opts = "L:P:DnvVhd:r:l:"
 longopts = ["no-default-lib", "dry-run", "verbose", "version", "help",
             "dest-dir=", "ldlib=", "libc-extras-dir=", "target=", "root=",
             "sysroot=", "gcc-options=", "libdir="]
@@ -340,6 +341,7 @@
 # some global variables
 lib_rpath = []
 lib_path = []
+piconly_lib_path = []
 dest_path = "DEST"
 ldlib = "LDLIB"
 include_default_lib_path = "yes"
@@ -367,6 +369,8 @@
             debuglevel = debuglevel + 1
     elif opt == "-L":
         lib_path.extend(string.split(arg, ":"))
+    elif opt == "-P":
+        piconly_lib_path.extend(string.split(arg, ":"))
     elif opt in ("-d", "--dest-dir"):
         dest_path = arg
     elif opt in ("-D", "--no-default-lib"):
@@ -625,7 +629,7 @@
             cmd.append(pic_file)
             cmd.extend(extra_post_obj)
             cmd.extend(extra_flags)
-            cmd.extend(["-L%s" % a for a in [dest_path] + [sysroot + b for b in lib_path if sysroot == "" or b not in ("/" + libdir + "/", "/usr/" + libdir + "/")]])
+            cmd.extend(["-L%s" % a for a in [dest_path] + [sysroot + b for b in lib_path+piconly_lib_path if sysroot == "" or b not in ("/" + libdir + "/", "/usr/" + libdir + "/")]])
             if soname != "libgcc_s.so.1":
                 cmd.append(library_depends_gcc_libnames(so_file, soname))
                 cmd.append(libgcc_link)
