add support for an optional staging directory for debug binaries
authorFelix Fietkau <nbd@openwrt.org>
Tue, 13 Jan 2009 03:21:25 +0000 (03:21 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 13 Jan 2009 03:21:25 +0000 (03:21 +0000)
SVN-Revision: 14018

Config.in
include/package-debug.mk [new file with mode: 0644]
include/package.mk
package/base-files/Makefile
rules.mk

index a952f462f87807e89242429482d184aeb452e9bb..a5b3364612c5bb85f220e7fa9bec0f4b19d0dbca 100644 (file)
--- a/Config.in
+++ b/Config.in
@@ -106,6 +106,13 @@ config DEBUG
        help
                Disables stripping and adds -g3 to the CFLAGS
 
+config DEBUG_DIR
+       bool "Install debugging binaries into a staging directory"
+       default n
+       help
+               This will install all compiled package binaries into build_dir/target-*/debug-*/,
+               useful for cross-debugging via gdb/gdbserver
+
 config NO_STRIP
        bool "Install unstripped binary on the target (useful for native compiling/debugging)"
        default n
diff --git a/include/package-debug.mk b/include/package-debug.mk
new file mode 100644 (file)
index 0000000..2a85bfe
--- /dev/null
@@ -0,0 +1,26 @@
+# 
+# Copyright (C) 2006,2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifeq ($(DUMP),)
+  define BuildTarget/debug
+
+    DEBUG_STAMP_$(1) := $(DEBUG_DIR)/stamp/$(1)
+
+    ifdef Package/$(1)/install
+      ifneq ($(CONFIG_PACKAGE_$(1))$(SDK)$(DEVELOPER),)
+        compile: $$(DEBUG_STAMP_$(1))
+      endif
+    endif
+
+    $$(DEBUG_STAMP_$(1)): $(PKG_BUILD_DIR)/.built
+               mkdir -p $(DEBUG_DIR)/stamp
+               $(call Package/$(1)/install,$(DEBUG_DIR))
+               touch $$(DEBUG_STAMP_$(1))
+
+
+  endef
+endif
index 4e31258305df1a46759f8d31606ba6870b1e13ff..04625d9b946a6da7cad8c2756b88b15198dab344 100644 (file)
@@ -27,6 +27,7 @@ include $(INCLUDE_DIR)/quilt.mk
 include $(INCLUDE_DIR)/package-defaults.mk
 include $(INCLUDE_DIR)/package-dumpinfo.mk
 include $(INCLUDE_DIR)/package-ipkg.mk
+include $(INCLUDE_DIR)/package-debug.mk
 include $(INCLUDE_DIR)/package-bin.mk
 include $(INCLUDE_DIR)/autotools.mk
 
@@ -146,7 +147,7 @@ endif
     $(Dumpinfo), \
     $(foreach target, \
       $(if $(Package/$(1)/targets),$(Package/$(1)/targets), \
-        $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg ) \
+        $(if $(PKG_TARGETS),$(PKG_TARGETS), ipkg $(if $(CONFIG_DEBUG_DIR),debug)) \
       ), $(BuildTarget/$(target)) \
     ) \
   )
index 52e70e5ce6eb5ec28a69245e04b91ad771540e33..581aa9365c61b63cc9694d8ab2c404e156eba3bd 100644 (file)
@@ -160,6 +160,7 @@ define Package/base-files$(TARGET)/install
                $(SED) 's/$$$$/:13848:0:99999:7:::/' $(1)/etc/shadow \
        )
        $(SED) 's,$$$$R,$(REVISION),g' $(1)/etc/banner
+       mkdir -p $(1)/CONTROL
        mkdir -p $(1)/dev
        mkdir -p $(1)/etc/crontabs
        mkdir -p $(1)/jffs
index bb46f16b2d8b3de92b957f5365738a876ee7b6d7..5e447562143394b1c6a32b88b923fe63ca5ebb9b 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -64,6 +64,7 @@ PACKAGE_DIR:=$(BIN_DIR)/packages/$(ARCH)
 STAMP_DIR:=$(BUILD_DIR)/stamp
 STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp
 TARGET_DIR:=$(BUILD_DIR)/root-$(BOARD)
+DEBUG_DIR:=$(BUILD_DIR)/debug-$(BOARD)
 IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
 
 TARGET_PATH:=$(TOOLCHAIN_DIR)/usr/bin:$(STAGING_DIR_HOST)/bin:$(STAGING_DIR)/host/bin:$(PATH)