Skip to contentSkip to conversation

examples: api: allow build with private libgcc

PATCH Superseded Che-Liang Chiou 3 participants 5 messages Sep 29, 2011 – Oct 21, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples: api: allow build with private libgcc

The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc.

Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc.

For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard.

+#define CONFIG_API
+#define CONFIG_SYS_MMC_MAX_DEVICE 2
+#define CONFIG_CMD_NET
+#define CONFIG_NET_MULTI

---
 Makefile              |   16 ++++++++++------
 examples/api/Makefile |    4 +---
 2 files changed, 11 insertions(+), 9 deletions(-)
Makefile +10 -6
index dfe939f..550088f 100644
@@ -137,9 +137,11 @@ unexport CDPATH
 
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
-SUBDIRS	= tools \
-	  examples/standalone \
-	  examples/api
+# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
+# is "yes"), so compile examples after U-Boot is compiled.
+SUBDIR_TOOLS = tools
+SUBDIR_EXAMPLES = examples/standalone examples/api
+SUBDIRS = $(SUBDIR_TOOLS) $(SUBDIR_EXAMPLES)
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE)
 
@@ -350,7 +352,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
 ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin
 ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
 
-all:		$(ALL-y)
+all:		$(ALL-y) $(SUBDIR_EXAMPLES)
 
 $(obj)u-boot.hex:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
@@ -405,7 +407,7 @@ GEN_UBOOT = \
 			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 $(obj)u-boot:	depend \
-		$(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
+		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
 		$(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
 		smap=`$(call SYSTEM_MAP,u-boot) | \
@@ -418,7 +420,7 @@ endif
 $(OBJS):	depend
 		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
 
-$(LIBS):	depend $(SUBDIRS)
+$(LIBS):	depend $(SUBDIR_TOOLS)
 		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
 $(LIBBOARD):	depend $(LIBS)
@@ -427,6 +429,8 @@ $(LIBBOARD):	depend $(LIBS)
 $(SUBDIRS):	depend
 		$(MAKE) -C $@ all
 
+$(SUBDIR_EXAMPLES): $(obj)u-boot
+
 $(LDSCRIPT):	depend
 		$(MAKE) -C $(dir $@) $(notdir $@)
 
examples/api/Makefile +1 -3
index 5b5f7a6..bad05af 100644
@@ -62,8 +62,6 @@ OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
-
 CPPFLAGS += -I..
 
 all:	$(obj).depend $(OUTPUT)
@@ -71,7 +69,7 @@ all:	$(obj).depend $(OUTPUT)
 #########################################################################
 
 $(OUTPUT):	$(OBJS)
-		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
+		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
 		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
 
 # Rule to build generic library C files
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH 1/1 examples: api: allow build with private libgcc

Quoted 8 lines · On Wednesday, September 28, 2011 23:36:24 Che-Liang Chiou wrote:

The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc.

Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc.

the SUBDIR logic in the toplevel Makefile is a bit ugly, but i don't have anything better to propose

-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110929/6d0d7640/attachment.pgp

#2 lore raw

PATCH v2 1/1 examples: api: allow build with private libgcc

In reply to Che-Liang Chiou

The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc.

Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc.

For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard.

+#define CONFIG_API
+#define CONFIG_SYS_MMC_MAX_DEVICE 2
+#define CONFIG_CMD_NET
+#define CONFIG_NET_MULTI

---

Changes in V2
Rebase to ToT

 Makefile              |   18 +++++++++---------
 examples/api/Makefile |    4 +---
 2 files changed, 10 insertions(+), 12 deletions(-)
Makefile +9 -9
index e9d75f8..26956ae 100644
@@ -141,7 +141,10 @@ unexport CDPATH
 # is "yes"), so compile examples after U-Boot is compiled.
 SUBDIR_TOOLS = tools
 SUBDIR_EXAMPLES = examples/standalone examples/api
-SUBDIRS = $(SUBDIR_TOOLS) $(SUBDIR_EXAMPLES)
+SUBDIRS = $(SUBDIR_TOOLS)
+ifndef CONFIG_SANDBOX
+SUBDIRS += $(SUBDIR_EXAMPLES)
+endif
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
 
@@ -158,11 +161,6 @@ sinclude $(obj)include/autoconf.mk
 include $(obj)include/config.mk
 export	ARCH CPU BOARD VENDOR SOC
 
-ifndef CONFIG_SANDBOX
-SUBDIRS += examples/standalone \
-	  examples/api
-endif
-
 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=
@@ -359,7 +357,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
 ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin
 ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
 
-all:		$(ALL-y)
+all:		$(ALL-y) $(SUBDIR_EXAMPLES)
 
 $(obj)u-boot.hex:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
@@ -422,7 +420,7 @@ GEN_UBOOT = \
 endif
 
 $(obj)u-boot:	depend \
-		$(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
+		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
 		$(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
 		smap=`$(call SYSTEM_MAP,u-boot) | \
@@ -435,7 +433,7 @@ endif
 $(OBJS):	depend
 		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
 
-$(LIBS):	depend $(SUBDIRS)
+$(LIBS):	depend $(SUBDIR_TOOLS)
 		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
 $(LIBBOARD):	depend $(LIBS)
@@ -444,6 +442,8 @@ $(LIBBOARD):	depend $(LIBS)
 $(SUBDIRS):	depend
 		$(MAKE) -C $@ all
 
+$(SUBDIR_EXAMPLES): $(obj)u-boot
+
 $(LDSCRIPT):	depend
 		$(MAKE) -C $(dir $@) $(notdir $@)
 
examples/api/Makefile +1 -3
index 5b5f7a6..bad05af 100644
@@ -62,8 +62,6 @@ OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
-
 CPPFLAGS += -I..
 
 all:	$(obj).depend $(OUTPUT)
@@ -71,7 +69,7 @@ all:	$(obj).depend $(OUTPUT)
 #########################################################################
 
 $(OUTPUT):	$(OBJS)
-		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
+		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
 		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
 
 # Rule to build generic library C files
Signature · 1 line
1.7.3.1
#3 lore raw

PATCH v2 1/1 examples: api: allow build with private libgcc

In reply to Che-Liang Chiou

The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc.

Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc.

For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard.

+#define CONFIG_API
+#define CONFIG_SYS_MMC_MAX_DEVICE 2
+#define CONFIG_CMD_NET
+#define CONFIG_NET_MULTI

---

Sorry, please ignore the previous V2 patch. I missed to git-add a couple of lines to that patch.

Changes in V2
Rebase to ToT

 Makefile              |   22 +++++++++++++---------
 examples/api/Makefile |    4 +---
 2 files changed, 14 insertions(+), 12 deletions(-)
Makefile +13 -9
index e9a153c..26956ae 100644
@@ -137,7 +137,14 @@ unexport CDPATH
 
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
-SUBDIRS	= tools
+# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
+# is "yes"), so compile examples after U-Boot is compiled.
+SUBDIR_TOOLS = tools
+SUBDIR_EXAMPLES = examples/standalone examples/api
+SUBDIRS = $(SUBDIR_TOOLS)
+ifndef CONFIG_SANDBOX
+SUBDIRS += $(SUBDIR_EXAMPLES)
+endif
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
 
@@ -154,11 +161,6 @@ sinclude $(obj)include/autoconf.mk
 include $(obj)include/config.mk
 export	ARCH CPU BOARD VENDOR SOC
 
-ifndef CONFIG_SANDBOX
-SUBDIRS += examples/standalone \
-	  examples/api
-endif
-
 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=
@@ -355,7 +357,7 @@ ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
 ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin
 ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
 
-all:		$(ALL-y)
+all:		$(ALL-y) $(SUBDIR_EXAMPLES)
 
 $(obj)u-boot.hex:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
@@ -418,7 +420,7 @@ GEN_UBOOT = \
 endif
 
 $(obj)u-boot:	depend \
-		$(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
+		$(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
 		$(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
 		smap=`$(call SYSTEM_MAP,u-boot) | \
@@ -431,7 +433,7 @@ endif
 $(OBJS):	depend
 		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
 
-$(LIBS):	depend $(SUBDIRS)
+$(LIBS):	depend $(SUBDIR_TOOLS)
 		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
 $(LIBBOARD):	depend $(LIBS)
@@ -440,6 +442,8 @@ $(LIBBOARD):	depend $(LIBS)
 $(SUBDIRS):	depend
 		$(MAKE) -C $@ all
 
+$(SUBDIR_EXAMPLES): $(obj)u-boot
+
 $(LDSCRIPT):	depend
 		$(MAKE) -C $(dir $@) $(notdir $@)
 
examples/api/Makefile +1 -3
index 5b5f7a6..bad05af 100644
@@ -62,8 +62,6 @@ OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
-
 CPPFLAGS += -I..
 
 all:	$(obj).depend $(OUTPUT)
@@ -71,7 +69,7 @@ all:	$(obj).depend $(OUTPUT)
 #########################################################################
 
 $(OUTPUT):	$(OBJS)
-		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
+		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
 		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
 
 # Rule to build generic library C files
Signature · 1 line
1.7.3.1
#4 lore raw

PATCH v2 1/1 examples: api: allow build with private libgcc

Dear Che-Liang Chiou,

Quoted 24 lines · In message <[email protected]> you wrote:

The examples/api is not configured with USE_PRIVATE_LIBGCC. This makes building examples/api break on certain boards that do not/cannot use the public libgcc.

Nevertheless, this patch has to also touch the top-level Makefile to fix this problem because the current top-level Makefile does not specify libgcc as a prerequisite of examples/api, and explicitly builds examples/api _before_ libgcc.

For testing this patch, I added the following to configs/seaboard.h and ran demo.bin on a Seaboard.

(quoted diff) +4 -0
+#define CONFIG_API
+#define CONFIG_SYS_MMC_MAX_DEVICE 2
+#define CONFIG_CMD_NET
+#define CONFIG_NET_MULTI

---

Sorry, please ignore the previous V2 patch. I missed to git-add a couple of lines to that patch.

Quoted 6 lines

Changes in V2
Rebase to ToT

 Makefile              |   22 +++++++++++++---------
 examples/api/Makefile |    4 +---
 2 files changed, 14 insertions(+), 12 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Vulcan can  no  sooner  be  disloyal  than  he  can  exist  without
breathing.
	-- Kirk, "The Menagerie", stardate 3012.4