toolchain-external: Install blackfin FDPIC and FLAT libraries

For certain situations, users may want to install shared FLAT
libraries to the target filesystem even if FDPIC is used as the
primary binary format, or symmetrically users may want to install FDPIC
libraries to the target filesystem even if shared FLAT is used as the
primary binary format.

This commit allows that by:

 * Offering additional Kconfig options to install shared FLAT or FDPIC
   libraries even when those libraries are not selected as the primary
   binary format.

 * Preserving all Blackfin toolchain folders under the
   TOOLCHAIN_EXTERNAL_DIR, instead of keeping only the one related to
   the selected binary format.

 * Adding some additional install targets that do the installation of
   either the shared FLAT or FDPIC libraries when requested.

[Thomas: refactored code, adjusted commit log]
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in
index 4dc45cd..94b8158 100644
--- a/toolchain/toolchain-external/Config.in
+++ b/toolchain/toolchain-external/Config.in
@@ -939,5 +939,32 @@
 	  Copy the gdbserver provided by the external toolchain to the
 	  target.
 
+# When the FDPIC shared binary format is used, the corresponding libraries are
+# always installed. When a different binary format is used, we offer the option
+# of installing the FDPIC shared libraries.
+config BR2_BFIN_INSTALL_FDPIC_SHARED
+       bool "Install FDPIC shared libraries"
+       depends on BR2_bfin && !BR2_BINFMT_FDPIC
+       help
+         The Linux kernel supports running both FDPIC and FLAT applications
+         concurrently if the binary format specific libraries are installed
+         properly. This option allows developer to install FDPIC libraries
+         into a buildroot rootfs image built with binary format that is not
+         FDPIC.
+
+# When the FLAT shared binary format is used, we force the installation
+# of the corresponding libraries. When a different binary format is
+# used, we offer the option of installing the FLAT shared libraries.
+config BR2_BFIN_INSTALL_FLAT_SHARED
+       bool "Install FLAT shared libraries" if !BR2_BINFMT_FLAT_SHARED
+       depends on BR2_bfin
+       default y if BR2_BINFMT_FLAT_SHARED
+       help
+         The Linux kernel supports running both FDPIC and FLAT applications
+         concurrently if the binary format specific libraries are installed
+         properly. This option allows developer to install FLAT libraries
+         into a buildroot rootfs image built with binary format that is not
+         shared FLAT.
+
 endif # BR2_TOOLCHAIN_EXTERNAL