toolchain-external: extract installation of gdbserver to separate define
authorThomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Fri, 12 Feb 2016 19:20:24 +0000 (20:20 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 25 Apr 2016 20:05:45 +0000 (22:05 +0200)
The installation of the gdbserver binary has no relation to the installation
of the target libraries. Moving it to a separate define improves the
understandability of the code and makes later refactoring easier.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
[Thomas:
 - move the BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY condition as a make
   condition rather than a shell condition, as suggested by Romain
   Naour.
 - rename the TOOLCHAIN_EXTERNAL_INSTALL_GDBSERVER variable to
   TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER as suggested by Arnout.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
toolchain/toolchain-external/toolchain-external.mk

index ef16da14dd0f44423d544291d7899d419a805e73..d989e5e9c5b0547ac9fd9b00385ef826851ee0c1 100644 (file)
@@ -634,26 +634,31 @@ define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS
                for libs in $(USR_LIB_EXTERNAL_LIBS); do \
                        $(call copy_toolchain_lib_root,$${ARCH_SYSROOT_DIR},$${SUPPORT_LIB_DIR},$${ARCH_LIB_DIR},$$libs,/usr/lib); \
                done ; \
-       fi ; \
-       if test "$(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY)" = "y"; then \
-               $(call MESSAGE,"Copying gdbserver") ; \
-               gdbserver_found=0 ; \
-               for d in $${ARCH_SYSROOT_DIR}/usr \
-                        $${ARCH_SYSROOT_DIR}/../debug-root/usr \
-                        $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
-                        $(TOOLCHAIN_EXTERNAL_INSTALL_DIR); do \
-                       if test -f $${d}/bin/gdbserver ; then \
-                               install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
-                               gdbserver_found=1 ; \
-                               break ; \
-                       fi ; \
-               done ; \
-               if [ $${gdbserver_found} -eq 0 ] ; then \
-                       echo "Could not find gdbserver in external toolchain" ; \
-                       exit 1 ; \
+       fi
+endef
+
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY),y)
+define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER
+       $(Q)ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+       ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+       $(call MESSAGE,"Copying gdbserver") ; \
+       gdbserver_found=0 ; \
+       for d in $${ARCH_SYSROOT_DIR}/usr \
+                $${ARCH_SYSROOT_DIR}/../debug-root/usr \
+                $${ARCH_SYSROOT_DIR}/usr/$${ARCH_LIB_DIR} \
+                $(TOOLCHAIN_EXTERNAL_INSTALL_DIR); do \
+               if test -f $${d}/bin/gdbserver ; then \
+                       install -m 0755 -D $${d}/bin/gdbserver $(TARGET_DIR)/usr/bin/gdbserver ; \
+                       gdbserver_found=1 ; \
+                       break ; \
                fi ; \
+       done ; \
+       if [ $${gdbserver_found} -eq 0 ] ; then \
+               echo "Could not find gdbserver in external toolchain" ; \
+               exit 1 ; \
        fi
 endef
+endif
 
 define TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS
        $(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
@@ -804,6 +809,7 @@ endef
 define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
        $(TOOLCHAIN_EXTERNAL_CREATE_TARGET_LIB_SYMLINK)
        $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
+       $(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_GDBSERVER)
        $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC)
        $(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT)
        $(TOOLCHAIN_EXTERNAL_FIXUP_UCLIBCNG_LDSO)