Skip to contentSkip to conversation

Enable Makefile conditional compilation

PATCH New Grant Likely 2 participants 5 messages Nov 21, 2007 – Dec 18, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Enable Makefile conditional compilation

These 2 patches enable conditional compilation at the Makefile level in u-boot. Using this we can finally start getting rid of the #ifdef/#endif wrappers around every .c file.

Wolfgang, I've also pushed this to the 5xxx git tree (see below). This change is much easier to merge, but is far more risky (because it's the first one). If we're doing a short cycle just for build changes, then this is probably the best time to do it.

I've tested with MAKEALL and verified image sizes didn't change when working with an earlier version of this series. Only things that have changes since them is dependency calculation on the new autoconf.mk file and rebasing to top of tree.

Cheers,
g.

The following changes since commit f92edbd8a0ef16a2b9127cbb564c09685728e4b0:
Grant Likely (1):
Merge branch 'origin' into kconfig-for-1.3.1

are available in the git repository at:

git://www.denx.de/git/u-boot-mpc5xxx.git master

Grant Likely (2):
[BUILD] Generate include/autoconf.mk from board config files [BUILD] conditionally compile common/cmd_*.c in common/Makefile

 Makefile                    |   18 +++++++++-
 common/Makefile             |   82 +++++++++++++++++++++++-------------------
 common/cmd_bdinfo.c         |    2 -
 common/cmd_bedbug.c         |    3 --
 common/cmd_bmp.c            |    4 --
 common/cmd_console.c        |    4 --
 common/cmd_date.c           |    4 --
 common/cmd_dcr.c            |    4 --
 common/cmd_diag.c           |    4 --
 common/cmd_display.c        |    4 --
 common/cmd_doc.c            |    5 ---
 common/cmd_dtt.c            |    4 --
 common/cmd_elf.c            |    4 --
 common/cmd_ext2.c           |    4 --
 common/cmd_fat.c            |    7 ----
 common/cmd_fdos.c           |    4 --
 common/cmd_fdt.c            |    5 ---
 common/cmd_flash.c          |    4 --
 common/cmd_fpga.c           |    3 --
 common/cmd_i2c.c            |    5 ---
 common/cmd_ide.c            |    4 --
 common/cmd_immap.c          |    5 +--
 common/cmd_itest.c          |    3 --
 common/cmd_jffs2.c          |    5 ---
 common/cmd_log.c            |    4 --
 common/cmd_mfsl.c           |    4 --
 common/cmd_mii.c            |    4 --
 common/cmd_misc.c           |    4 --
 common/cmd_mmc.c            |    5 ---
 common/cmd_net.c            |    4 --
 common/cmd_pci.c            |    9 -----
 common/cmd_portio.c         |    4 --
 common/cmd_reginfo.c        |    5 ---
 common/cmd_reiser.c         |    4 --
 common/cmd_scsi.c           |    4 --
 common/cmd_spi.c            |    4 --
 common/cmd_universe.c       |    4 --
 common/cmd_usb.c            |   10 -----
 config.mk                   |    3 ++
 include/configs/sbc2410x.h  |    1 -
 include/configs/smdk2410.h  |    1 -
 tools/scripts/define2mk.sed |   29 +++++++++++++++
 42 files changed, 95 insertions(+), 199 deletions(-)

--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.

#1 lore raw

PATCH 1/2 Generate include/autoconf.mk from board config files

From: Grant Likely <[email protected]>

Use cpp and sed to postprocess config.h and import the defined values into include/autoconf.mk. autoconf.mk is then included by config.mk to give 'make' access to the board configuration.

Doing this enables conditional compilation at the Makefile level instead of by wrapping every .c file with #ifdef/#endif wrappers.

---

 Makefile                    |   18 +++++++++++++++++-
 config.mk                   |    3 +++
 tools/scripts/define2mk.sed |   29 +++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletions(-)
Makefile +17 -1
index ac4b430..407b938 100644
@@ -342,6 +342,21 @@ $(obj)System.map:	$(obj)u-boot
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
 		sort > $(obj)System.map
 
+#
+# Auto-generate the autoconf.mk file (which is included by all makefiles)
+#
+# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
+# the dep file is only include in this top level makefile to determine when
+# to regenerate the autoconf.mk file.
+$(OBJTREE)/include/autoconf.mk: $(obj)include/config.h
+	@echo Generating include/autoconf.mk
+	@# Generate the dependancies
+	@$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > [email protected]
+	@# Extract the config macros
+	@$(CPP) $(CFLAGS) -dM include/common.h | sed -n -f tools/scripts/define2mk.sed >> $@
+
+sinclude $(OBJTREE)/include/autoconf.mk.dep
+
 #########################################################################
 else
 all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
@@ -361,7 +376,8 @@ CHANGELOG:
 
 unconfig:
 	@rm -f $(obj)include/config.h $(obj)include/config.mk \
-		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp
+		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
+		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep
 
 #========================================================================
 # PowerPC
config.mk +3 -0
index 37d61a0..79e5a31 100644
@@ -87,6 +87,9 @@ ifdef	BOARD
 sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
 endif
 
+# Load generated board configuration
+sinclude $(OBJTREE)/include/autoconf.mk
+
 #########################################################################
 
 CONFIG_SHELL	:= $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
tools/scripts/define2mk.sed new file +29 -0
new file mode 100644
index 0000000..6464627
@@ -0,0 +1,29 @@
+#
+# Sed script to parse CPP macros and generate output usable by make
+#
+# It is expected that this script is fed the output of 'gpp -dM'
+# which preprocesses the common.h header files and outputs the final
+# list of CPP macros (and whitespace is sanitized)
+#
+
+# Only process values prefixed with #define CONFIG_
+/^#define CONFIG_[A-Za-z0-9_]\+/ {
+	# Strip the #define prefix
+	s/#define *//;
+	# Change to form CONFIG_*=VALUE
+	s/ \+/=/;
+	# Drop trailing spaces
+	s/ *$//;
+	# drop quotes around string values
+	s/="\(.*\)"$/=\1/;
+	# Concatenate string values
+	s/" *"//g;
+	# Wrap non-numeral values with quotes
+	s/=\(.*\?[^0-9].*\)$/=\"\1\"/;
+	# Change '1' and empty values to "y" (not perfect, but
+	# supports conditional compilation in the makefiles
+	s/=$/=y/;
+	s/=1$/=y/;
+	# print the line
+	p
+}
#2 lore raw

PATCH 1/2 Generate include/autoconf.mk from board config files

Quoted 7 lines · In message <[email protected]> you…

Use cpp and sed to postprocess config.h and import the defined values into include/autoconf.mk. autoconf.mk is then included by config.mk to give 'make' access to the board configuration.

Doing this enables conditional compilation at the Makefile level instead of by wrapping every .c file with #ifdef/#endif wrappers.

Unfortunately this breaks building with older (GCC-3.x) compilers.

Makefile $(obj)System.map: $(obj)u-boot · line 354

Quoted 4 lines

+$(OBJTREE)/include/autoconf.mk: $(obj)include/config.h

Makefile +3 -0
+	@echo Generating include/autoconf.mk
+	@# Generate the dependancies
+	@$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $@ include/common.h > [email protected]

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Does not work with GCC-3.x:

+ ppc_8xx-gcc -M -g -Os -fPIC -ffixed-r14 -meabi -fno-strict-aliasing -D__KERNEL__ -DTEXT_BASE=0x40000000 -I/home/wd/git/u-boot/work/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/eldk-3.1.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/include -pipe -DCONFIG_PPC -D__powerpc__ -DCONFIG_8xx -ffixed-r2 -ffixed-r29 -mstring -mcpu=860 -msoft-float -MQ /home/wd/git/u-boot/work/include/autoconf.mk include/common.h
ppc_8xx-gcc: compilation of header file requested
+ echo RC=1
RC=1

[Tested with ELDK 3.1.1]

The effect is even more nasty, as make will not stop afgter the error; if you ignore the "compilation of header file requested" message, but continues until it runs into problems later (when linking).

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
C makes it easy for you to shoot yourself in the foot. C++ makes that
harder, but when you do, it blows away your whole leg.
                                                 -- Bjarne Stroustrup
#3 lore raw

PATCH 2/2 conditionally compile common/cmd_*.c in common/Makefile

In reply to Grant Likely

From: Grant Likely <[email protected]>

Modify common/Makefile to conditionally compile the cmd_*.c files based on the board config.

---

 common/Makefile            |   82 ++++++++++++++++++++++++--------------------
 common/cmd_bdinfo.c        |    2 -
 common/cmd_bedbug.c        |    3 --
 common/cmd_bmp.c           |    4 --
 common/cmd_console.c       |    4 --
 common/cmd_date.c          |    4 --
 common/cmd_dcr.c           |    4 --
 common/cmd_diag.c          |    4 --
 common/cmd_display.c       |    4 --
 common/cmd_doc.c           |    5 ---
 common/cmd_dtt.c           |    4 --
 common/cmd_elf.c           |    4 --
 common/cmd_ext2.c          |    4 --
 common/cmd_fat.c           |    7 ----
 common/cmd_fdos.c          |    4 --
 common/cmd_fdt.c           |    5 ---
 common/cmd_flash.c         |    4 --
 common/cmd_fpga.c          |    3 --
 common/cmd_i2c.c           |    5 ---
 common/cmd_ide.c           |    4 --
 common/cmd_immap.c         |    5 +--
 common/cmd_itest.c         |    3 --
 common/cmd_jffs2.c         |    5 ---
 common/cmd_log.c           |    4 --
 common/cmd_mfsl.c          |    4 --
 common/cmd_mii.c           |    4 --
 common/cmd_misc.c          |    4 --
 common/cmd_mmc.c           |    5 ---
 common/cmd_net.c           |    4 --
 common/cmd_pci.c           |    9 -----
 common/cmd_portio.c        |    4 --
 common/cmd_reginfo.c       |    5 ---
 common/cmd_reiser.c        |    4 --
 common/cmd_scsi.c          |    4 --
 common/cmd_spi.c           |    4 --
 common/cmd_universe.c      |    4 --
 common/cmd_usb.c           |   10 -----
 include/configs/sbc2410x.h |    1 -
 include/configs/smdk2410.h |    1 -
 39 files changed, 46 insertions(+), 198 deletions(-)
common/Makefile +45 -37
index 5c2592f..ace8cc7 100644
@@ -33,53 +33,61 @@ COBJS-y += altera.o
 COBJS-y += bedbug.o
 COBJS-y += circbuf.o
 COBJS-y += cmd_autoscript.o
-COBJS-y += cmd_bdinfo.o
-COBJS-y += cmd_bedbug.o
-COBJS-y += cmd_bmp.o
+COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o
+COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
+COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-y += cmd_boot.o
 COBJS-y += cmd_bootm.o
-COBJS-y += cmd_cache.o
-COBJS-y += cmd_console.o
-COBJS-y += cmd_date.o
-COBJS-y += cmd_dcr.o
-COBJS-y += cmd_diag.o
-COBJS-y += cmd_display.o
-COBJS-y += cmd_doc.o
-COBJS-y += cmd_dtt.o
+COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
+COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
+COBJS-$(CONFIG_CMD_DATE) += cmd_date.o
+ifdef CONFIG_4xx
+COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
+endif
+ifdef CONFIG_POST
+COBJS-$(CONFIG_CMD_DIAG) += cmd_diag.o
+endif
+COBJS-$(CONFIG_CMD_DISPLAY) += cmd_display.o
+COBJS-$(CONFIG_CMD_DOC) += cmd_doc.o
+COBJS-$(CONFIG_CMD_DTT) += cmd_dtt.o
 COBJS-y += cmd_eeprom.o
-COBJS-y += cmd_elf.o
-COBJS-y += cmd_ext2.o
-COBJS-y += cmd_fat.o
+COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
+COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
+COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
 COBJS-y += cmd_fdc.o
-COBJS-y += cmd_fdt.o
-COBJS-y += cmd_fdos.o
-COBJS-y += cmd_flash.o
-COBJS-y += cmd_fpga.o
-COBJS-y += cmd_i2c.o
-COBJS-y += cmd_ide.o
-COBJS-y += cmd_immap.o
-COBJS-y += cmd_itest.o
-COBJS-y += cmd_jffs2.o
+COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o
+COBJS-$(CONFIG_CMD_FDOS) += cmd_fdos.o
+COBJS-$(CONFIG_CMD_FLASH) += cmd_flash.o
+ifdef CONFIG_FPGA
+COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o
+endif
+COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
+COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o
+COBJS-$(CONFIG_CMD_IMMAP) += cmd_immap.o
+COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
+COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
 COBJS-y += cmd_load.o
-COBJS-y += cmd_log.o
+COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
 COBJS-y += cmd_mem.o
-COBJS-y += cmd_mii.o
-COBJS-y += cmd_misc.o
-COBJS-y += cmd_mmc.o
+COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
+COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
+COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
 COBJS-y += cmd_nand.o
-COBJS-y += cmd_net.o
+COBJS-$(CONFIG_CMD_NET) += cmd_net.o
 COBJS-y += cmd_nvedit.o
 COBJS-y += cmd_onenand.o
-COBJS-y += cmd_pci.o
+ifdef CONFIG_PCI
+COBJS-$(CONFIG_CMD_PCI) += cmd_pci.o
+endif
 COBJS-y += cmd_pcmcia.o
-COBJS-y += cmd_portio.o
-COBJS-y += cmd_reginfo.o
-COBJS-y += cmd_reiser.o
+COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o
+COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
+COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o
 COBJS-y += cmd_sata.o
-COBJS-y += cmd_scsi.o
-COBJS-y += cmd_spi.o
-COBJS-y += cmd_universe.o
-COBJS-y += cmd_usb.o
+COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o
+COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
+COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
+COBJS-$(CONFIG_CMD_USB) += cmd_usb.o
 COBJS-y += cmd_vfd.o
 COBJS-y += command.o
 COBJS-y += console.o
@@ -123,7 +131,7 @@ COBJS-y += xilinx.o
 COBJS-y += crc16.o
 COBJS-y += xyzModem.o
 COBJS-y += cmd_mac.o
-COBJS-y += cmd_mfsl.o
+COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(AOBJS:.o=.S) $(COBJS:.o=.c)
common/cmd_bdinfo.c +0 -2
index ef15a00..d059983 100644
@@ -30,7 +30,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_BDI)
 static void print_num(const char *, ulong);
 
 #ifndef CONFIG_ARM	/* PowerPC and other */
@@ -350,4 +349,3 @@ U_BOOT_CMD(
 	"bdinfo  - print Board Info structure\n",
 	NULL
 );
-#endif
common/cmd_bedbug.c +0 -3
index 1c3547a..94f7e08 100644
@@ -13,8 +13,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_BEDBUG)
-
 #ifndef MAX
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #endif
@@ -413,7 +411,6 @@ int do_bedbug_rdump (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD (rdump, 1, 1, do_bedbug_rdump,
 	    "rdump   - Show registers.\n", " - Show registers.\n");
 /* ====================================================================== */
-#endif
 
 
 /*
common/cmd_bmp.c +0 -4
index 241aa83..907f9a2 100644
@@ -31,8 +31,6 @@
 #include <asm/byteorder.h>
 #include <malloc.h>
 
-#if defined(CONFIG_CMD_BMP)
-
 static int bmp_info (ulong addr);
 static int bmp_display (ulong addr, int x, int y);
 
@@ -187,5 +185,3 @@ static int bmp_display(ulong addr, int x, int y)
 # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
 #endif
 }
-
-#endif /* defined(CONFIG_CMD_BMP) */
common/cmd_console.c +0 -4
index 5e0f990..50ddb01 100644
@@ -28,8 +28,6 @@
 #include <command.h>
 #include <devices.h>
 
-#if defined(CONFIG_CMD_CONSOLE)
-
 extern void _do_coninfo (void);
 int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[])
 {
@@ -67,5 +65,3 @@ U_BOOT_CMD(
 	"coninfo - print console devices and information\n",
 	""
 );
-
-#endif
common/cmd_date.c +0 -4
index 4a42534..7511598 100644
@@ -31,8 +31,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_DATE)
-
 const char *weekdays[] = {
 	"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
 };
@@ -210,5 +208,3 @@ U_BOOT_CMD(
 	"  - with numeric argument: set the system date & time\n"
 	"  - with 'reset' argument: reset the RTC\n"
 );
-
-#endif
common/cmd_dcr.c +0 -4
index 12fa9db..a053343 100644
@@ -29,8 +29,6 @@
 #include <config.h>
 #include <command.h>
 
-#if defined(CONFIG_4xx) && defined(CONFIG_CMD_SETGETDCR)
-
 unsigned long get_dcr (unsigned short);
 unsigned long set_dcr (unsigned short, unsigned long);
 
@@ -245,5 +243,3 @@ U_BOOT_CMD(
 	"setidcr - Set a register value via indirect DCR addressing\n",
 	"adr_dcrn[.dat_dcrn] offset value - write offset to adr_dcrn, write value to dat_dcrn.\n"
 );
-
-#endif
common/cmd_diag.c +0 -4
index cb99b77..82d5ad3 100644
@@ -28,8 +28,6 @@
 #include <command.h>
 #include <post.h>
 
-#if defined(CONFIG_CMD_DIAG) && defined(CONFIG_POST)
-
 int do_diag (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
 	unsigned int i;
@@ -76,5 +74,3 @@ U_BOOT_CMD(
 	"diag run [test1 [test2]]\n"
 	"         - run specified tests\n"
 );
-
-#endif
common/cmd_display.c +0 -4
index d19f412..a29345c 100644
@@ -24,8 +24,6 @@
 #include <common.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_DISPLAY)
-
 #undef DEBUG_DISP
 
 #define DISP_SIZE	8
@@ -78,5 +76,3 @@ U_BOOT_CMD(
 	"    - with <string> argument: display <string> on dot matrix display\n"
 	"    - without arguments: clear dot matrix display\n"
 );
-
-#endif
common/cmd_doc.c +0 -5
index d6d3aff..3d717c0 100644
@@ -11,9 +11,6 @@
 #include <command.h>
 #include <malloc.h>
 #include <asm/io.h>
-
-#if defined(CONFIG_CMD_DOC)
-
 #include <linux/mtd/nftl.h>
 #include <linux/mtd/doc2000.h>
 
@@ -1607,5 +1604,3 @@ void doc_probe(unsigned long physadr)
 		puts ("No DiskOnChip found\n");
 	}
 }
-
-#endif
common/cmd_dtt.c +0 -4
index 804d467..956dc69 100644
@@ -25,8 +25,6 @@
 #include <config.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_DTT)
-
 #include <dtt.h>
 #include <i2c.h>
 
@@ -60,5 +58,3 @@ U_BOOT_CMD(
 	  "dtt     - Digital Thermometer and Thermostat\n",
 	  "        - Read temperature from digital thermometer and thermostat.\n"
 );
-
-#endif
common/cmd_elf.c +0 -4
index 63a5593..2eb7453 100644
@@ -23,8 +23,6 @@
 DECLARE_GLOBAL_DATA_PTR;
 #endif
 
-#if defined(CONFIG_CMD_ELF)
-
 #ifndef MAX
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #endif
@@ -323,5 +321,3 @@ U_BOOT_CMD(
 	"bootvx  - Boot vxWorks from an ELF image\n",
 	" [address] - load address of vxWorks ELF image.\n"
 );
-
-#endif
common/cmd_ext2.c +0 -4
index 8bd2b47..f569406 100644
@@ -34,8 +34,6 @@
  */
 #include <common.h>
 #include <part.h>
-
-#if defined(CONFIG_CMD_EXT2)
 #include <config.h>
 #include <command.h>
 #include <image.h>
@@ -259,5 +257,3 @@ U_BOOT_CMD(
 	"    - load binary file 'filename' from 'dev' on 'interface'\n"
 	"      to address 'addr' from ext2 filesystem\n"
 );
-
-#endif
common/cmd_fat.c +0 -7
index 54f0f9f..9576cdf 100644
@@ -30,11 +30,6 @@
 #include <net.h>
 #include <ata.h>
 #include <part.h>
-
-#if defined(CONFIG_CMD_FAT)
-
-#undef	DEBUG
-
 #include <fat.h>
 
 
@@ -323,5 +318,3 @@ void hexdump (int cnt, unsigned char *data)
 	}
 }
 #endif	/* NOT_IMPLEMENTED_YET */
-
-#endif
common/cmd_fdos.c +0 -4
index f9da98d..b3dbd19 100644
@@ -31,8 +31,6 @@
 #include <command.h>
 #include <fdc.h>
 
-#if defined(CONFIG_CMD_FDOS)
-
 /*-----------------------------------------------------------------------------
  * do_fdosboot --
  *-----------------------------------------------------------------------------
@@ -153,5 +151,3 @@ U_BOOT_CMD(
 	"fdosls  - list files in a directory\n",
 	"[directory]\n"
 );
-
-#endif
common/cmd_fdt.c +0 -5
index 571b8f1..f18c583 100644
@@ -28,9 +28,6 @@
 #include <command.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
-
-#ifdef CONFIG_OF_LIBFDT
-
 #include <asm/global_data.h>
 #include <fdt.h>
 #include <libfdt.h>
@@ -692,5 +689,3 @@ U_BOOT_CMD(
 	"          fdt print /cpus \"#address-cells\"\n"
 	"          fdt set   /cpus \"#address-cells\" \"[00 00 00 01]\"\n"
 );
-
-#endif /* CONFIG_OF_LIBFDT */
common/cmd_flash.c +0 -4
index 11c8857..f56443e 100644
@@ -31,8 +31,6 @@
 #include <dataflash.h>
 #endif
 
-#if defined(CONFIG_CMD_FLASH)
-
 #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
 #include <jffs2/jffs2.h>
 
@@ -731,5 +729,3 @@ U_BOOT_CMD(
 #undef	TMP_ERASE
 #undef	TMP_PROT_ON
 #undef	TMP_PROT_OFF
-
-#endif
common/cmd_fpga.c +0 -3
index cce23ad..377a692 100644
@@ -43,8 +43,6 @@
 #define PRINTF(fmt,args...)
 #endif
 
-#if defined (CONFIG_FPGA) && defined(CONFIG_CMD_FPGA)
-
 /* Local functions */
 static void fpga_usage (cmd_tbl_t * cmdtp);
 static int fpga_get_op (char *opstr);
@@ -321,4 +319,3 @@ U_BOOT_CMD (fpga, 6, 1, do_fpga,
 	    "\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n"
 	    "\tloadmk\tLoad device generated with mkimage\n"
 	    "\tdump\tLoad device to memory buffer\n");
-#endif
common/cmd_i2c.c +0 -5
index a684a58..10cab46 100644
@@ -86,9 +86,6 @@
 #include <i2c.h>
 #include <asm/byteorder.h>
 
-#if defined(CONFIG_CMD_I2C)
-
-
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
@@ -1024,5 +1021,3 @@ U_BOOT_CMD(
 	"      (valid chip values 50..57)\n"
 );
 #endif
-
-#endif
common/cmd_ide.c +0 -4
index 2202009..821dcff 100644
@@ -68,8 +68,6 @@ DECLARE_GLOBAL_DATA_PTR;
 # define SYNC		/* nothing */
 #endif
 
-#if defined(CONFIG_CMD_IDE)
-
 #ifdef CONFIG_IDE_8xx_DIRECT
 /* Timings for IDE Interface
  *
@@ -2081,5 +2079,3 @@ U_BOOT_CMD(
 	"diskboot- boot from IDE device\n",
 	"loadAddr dev:part\n"
 );
-
-#endif
common/cmd_immap.c +1 -4
index ae95758..d758269 100644
@@ -28,8 +28,7 @@
 #include <common.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_IMMAP) && \
-    (defined(CONFIG_8xx) || defined(CONFIG_8260))
+#if defined(CONFIG_8xx) || defined(CONFIG_8260)
 
 #if defined(CONFIG_8xx)
 #include <asm/8xx_immap.h>
@@ -41,9 +40,7 @@
 #include <asm/iopin_8260.h>
 #endif
 
-#if defined(CONFIG_8xx) || defined(CONFIG_8260)
 DECLARE_GLOBAL_DATA_PTR;
-#endif
 
 static void
 unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
common/cmd_itest.c +0 -3
index 8e20517..ce98872 100644
@@ -32,8 +32,6 @@
 #include <config.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_ITEST)
-
 #define EQ	0
 #define NE	1
 #define LT	2
@@ -197,4 +195,3 @@ U_BOOT_CMD(
 	"itest\t- return true/false on integer compare\n",
 	"[.b, .w, .l, .s] [*]value1 <op> [*]value2\n"
 );
-#endif
common/cmd_jffs2.c +0 -5
index 513a226..efe9eb7 100644
@@ -93,9 +93,6 @@
 #include <jffs2/jffs2.h>
 #include <linux/list.h>
 #include <linux/ctype.h>
-
-#if defined(CONFIG_CMD_JFFS2)
-
 #include <cramfs/cramfs_fs.h>
 
 #if defined(CONFIG_CMD_NAND)
@@ -2191,5 +2188,3 @@ U_BOOT_CMD(
 #endif /* #ifdef CONFIG_JFFS2_CMDLINE */
 
 /***************************************************/
-
-#endif
common/cmd_log.c +0 -4
index fba8bd8..e593dbe 100644
@@ -48,8 +48,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_LOGBUFFER)
-
 /* Local prototypes */
 static void logbuff_putc (const char c);
 static void logbuff_puts (const char *s);
@@ -287,5 +285,3 @@ static int logbuff_printk(const char *line)
 	}
 	return i;
 }
-
-#endif /* (CONFIG_LOGBUFFER) */
common/cmd_mfsl.c +0 -4
index 9d1d875..5982b76 100644
@@ -29,8 +29,6 @@
 #include <common.h>
 #include <config.h>
 #include <command.h>
-
-#if defined(CONFIG_CMD_MFSL)
 #include <asm/asm.h>
 
 int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
@@ -413,5 +411,3 @@ U_BOOT_CMD (rspr, 3, 1, do_rspr,
 		" 1 - MSR - Machine status register\n"
 		" 3 - EAR - Exception address register\n"
 		" 5 - ESR - Exception status register\n");
-
-#endif
common/cmd_mii.c +0 -4
index 3b4dc8a..f530a38 100644
@@ -27,8 +27,6 @@
 
 #include <common.h>
 #include <command.h>
-
-#if defined(CONFIG_CMD_MII)
 #include <miiphy.h>
 
 #ifdef CONFIG_TERSE_MII
@@ -598,5 +596,3 @@ U_BOOT_CMD(
 );
 
 #endif /* CONFIG_TERSE_MII */
-
-#endif
common/cmd_misc.c +0 -4
index c0c6b8f..126b538 100644
@@ -27,8 +27,6 @@
 #include <common.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_MISC)
-
 int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong start = get_timer(0);
@@ -68,5 +66,3 @@ U_BOOT_CMD(
 	"N\n"
 	"    - delay execution for N seconds (N is _decimal_ !!!)\n"
 );
-
-#endif
common/cmd_mmc.c +0 -5
index 069c6d0..25c9702 100644
@@ -23,9 +23,6 @@
 
 #include <common.h>
 #include <command.h>
-
-#if defined(CONFIG_CMD_MMC)
-
 #include <mmc.h>
 
 int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -42,5 +39,3 @@ U_BOOT_CMD(
 	"mmcinit - init mmc card\n",
 	NULL
 );
-
-#endif
common/cmd_net.c +0 -4
index 0715fbc..21682c0 100644
@@ -28,8 +28,6 @@
 #include <command.h>
 #include <net.h>
 
-#if defined(CONFIG_CMD_NET)
-
 extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
 
 static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
@@ -343,5 +341,3 @@ U_BOOT_CMD(
 	"[NTP server IP]\n"
 );
 #endif
-
-#endif
common/cmd_pci.c +0 -9
index 8be6da9..82d9717 100644
@@ -30,16 +30,11 @@
  */
 
 #include <common.h>
-
-#ifdef CONFIG_PCI
-
 #include <command.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 #include <pci.h>
 
-#if defined(CONFIG_CMD_PCI)
-
 extern int cmd_get_data_size(char* arg, int default_size);
 
 unsigned char	ShortPCIListing = 1;
@@ -564,7 +559,3 @@ U_BOOT_CMD(
 	"pci write[.b, .w, .l] b.d.f address value\n"
 	"    - write to CFG address\n"
 );
-
-#endif
-
-#endif /* CONFIG_PCI */
common/cmd_portio.c +0 -4
index bfe33e3..a06cac0 100644
@@ -30,8 +30,6 @@
 #include <common.h>
 #include <command.h>
 
-#if defined(CONFIG_CMD_PORTIO)
-
 extern int cmd_get_data_size (char *arg, int default_size);
 
 /* Display values from last command.
@@ -165,5 +163,3 @@ U_BOOT_CMD(
 	"[.b, .w, .l] port\n"
 	"    - read datum from IO port\n"
 );
-
-#endif
common/cmd_reginfo.c +0 -5
index 17e9cd9..bb6aa30 100644
@@ -33,8 +33,6 @@
 #include <mpc5xxx.h>
 #endif
 
-#if defined(CONFIG_CMD_REGINFO)
-
 int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 #if defined(CONFIG_8xx)
@@ -335,9 +333,6 @@ int do_reginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	return 0;
 }
 
-#endif
-
-
  /**************************************************/
 
 #if ( defined(CONFIG_8xx)   || defined(CONFIG_405GP) || \
common/cmd_reiser.c +0 -4
index 1ba3929..b7395d7 100644
@@ -27,8 +27,6 @@
  * Reiserfs support
  */
 #include <common.h>
-
-#if defined(CONFIG_CMD_REISER)
 #include <config.h>
 #include <command.h>
 #include <image.h>
@@ -239,5 +237,3 @@ U_BOOT_CMD(
 	"    - load binary file 'filename' from 'dev' on 'interface'\n"
 	"      to address 'addr' from dos filesystem\n"
 );
-
-#endif
common/cmd_scsi.c +0 -4
index b2d4eb6..1cdec15 100644
@@ -34,8 +34,6 @@
 #include <image.h>
 #include <pci.h>
 
-#if defined(CONFIG_CMD_SCSI)
-
 #ifdef CONFIG_SCSI_SYM53C8XX
 #define SCSI_VEND_ID	0x1000
 #ifndef CONFIG_SCSI_DEV_ID
@@ -611,5 +609,3 @@ U_BOOT_CMD(
 	"scsiboot- boot from SCSI device\n",
 	"loadAddr dev:part\n"
 );
-
-#endif
common/cmd_spi.c +0 -4
index 3118d27..7604422 100644
@@ -29,8 +29,6 @@
 #include <command.h>
 #include <spi.h>
 
-#if defined(CONFIG_CMD_SPI)
-
 /*-----------------------------------------------------------------------
  * Definitions
  */
@@ -139,5 +137,3 @@ U_BOOT_CMD(
 	"<bit_len> - Number of bits to send (base 10)\n"
 	"<dout>    - Hexadecimal string that gets sent\n"
 );
-
-#endif
common/cmd_universe.c +0 -4
index 8bf0b1f..ea97782 100644
@@ -28,8 +28,6 @@
 
 #include <universe.h>
 
-#if defined(CONFIG_CMD_UNIVERSE)
-
 #define PCI_VENDOR PCI_VENDOR_ID_TUNDRA
 #define PCI_DEVICE PCI_DEVICE_ID_TUNDRA_CA91C042
 
@@ -386,5 +384,3 @@ U_BOOT_CMD(
 	"                                      02 -> D16 Data Width\n"
 	"                                      03 -> D32 Data Width\n"
 );
-
-#endif
common/cmd_usb.c +0 -10
index 45e07f1..c6b17c2 100644
@@ -29,9 +29,6 @@
 #include <command.h>
 #include <asm/byteorder.h>
 #include <part.h>
-
-#if defined(CONFIG_CMD_USB)
-
 #include <usb.h>
 
 #ifdef CONFIG_USB_STORAGE
@@ -608,12 +605,6 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	return 1;
 }
 
-
-#endif
-
-
-#if defined(CONFIG_CMD_USB)
-
 #ifdef CONFIG_USB_STORAGE
 U_BOOT_CMD(
 	usb,	5,	1,	do_usb,
@@ -645,4 +636,3 @@ U_BOOT_CMD(
 	"usb  info [dev] - show available USB devices\n"
 );
 #endif
-#endif
include/configs/sbc2410x.h +0 -1
index b4a063a..9b05bd6 100644
@@ -103,7 +103,6 @@
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_ELF
 #define CONFIG_CMD_PING
-#define CONFIG_CMD_REGINFO
 
 
 #define CONFIG_BOOTDELAY	3
include/configs/smdk2410.h +0 -1
index ca404ff..18a036c 100644
@@ -88,7 +88,6 @@
 #include <config_cmd_default.h>
 
 #define CONFIG_CMD_CACHE
-#define CONFIG_CMD_REGINFO
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_ELF
 
#4 lore raw

cover Enable Makefile conditional compilation

In reply to Grant Likely
Quoted 21 lines · In message <[email protected]> you…

These 2 patches enable conditional compilation at the Makefile level in u-boot. Using this we can finally start getting rid of the #ifdef/#endif wrappers around every .c file.

Wolfgang, I've also pushed this to the 5xxx git tree (see below). This change is much easier to merge, but is far more risky (because it's the first one). If we're doing a short cycle just for build changes, then this is probably the best time to do it.

I've tested with MAKEALL and verified image sizes didn't change when working with an earlier version of this series. Only things that have changes since them is dependency calculation on the new autoconf.mk file and rebasing to top of tree.

Cheers,
g.

The following changes since commit f92edbd8a0ef16a2b9127cbb564c09685728e4b0:
Grant Likely (1):
Merge branch 'origin' into kconfig-for-1.3.1

Quoted 7 lines

are available in the git repository at:

git://www.denx.de/git/u-boot-mpc5xxx.git master

Grant Likely (2):
[BUILD] Generate include/autoconf.mk from board config files [BUILD] conditionally compile common/cmd_*.c in common/Makefile

Merged into u-boot-testing repo.

Previous state is now in mainline.

Thanks a lot.

Best regards,

Wolfgang Denk

Signature · 5 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
Documentation is like sex: when it is good, it is  very,  very  good;
and when it is bad, it is better than nothing.         - Dick Brandon