Makesystem changes to better support different SoCs


git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@184 42af7a65-404d-4744-a932-0658087f49c3
diff --git a/ChangeLog b/ChangeLog
index b4364a3..84ef495 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,4 +114,5 @@
 0.2.4 2007-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
 
 	* Verfied c5471 build under Cygwin on WinXP
+	* Makesystem changes to better support different SoCs.
 	* Started m68322
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 90dfcec..c0cd8ea 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -331,16 +331,24 @@
     The purpose of this port is primarily to support OS feature developement.
     This port does not support interrupts or a real timer (and hence no
     round robin scheduler)  Otherwise, it is complete.
+
   <li><code>arch/c5471</code>:
     TI TMS320C5471 (also called TMS320DM180 or just C5471).
     NuttX operates on the ARM7 of this dual core processor.
     This port is complete, verified, and included in the NuttX release 0.1.1.
+
+  <li><code>configs/mcu123-lpc214x</code>:
+    The mcu123.com lpc214x development board.
+    This is a work in progress.
+
   <li><code>arch/dm320</code>:
-      TI TMS320DM320 (also called just DM320).
-      NuttX operates on the ARM9EJS of this dual core processor.
-      This port complete, verified, and included in the NuttX release 0.2.1.
+    TI TMS320DM320 (also called just DM320).
+    NuttX operates on the ARM9EJS of this dual core processor.
+    This port complete, verified, and included in the NuttX release 0.2.1.
+
   <li><code>arch/m68322</code>
-      A work in progress.</li>
+    A work in progress.</li>
+
   <li><code>arch/pjrc-8051</code>:
     8051 Microcontroller.  This port is not quite ready for prime time.</li>
 </ul>
@@ -463,6 +471,10 @@
     with a GNU arm-elf toolchain*. This port is complete, verified, and
     included in the NuttX release.</li>
 
+  <li><code>configs/mcu123-lpc214x</code>:
+    This is a port to the mcu123.com lpc214x development board.
+    This OS is also built with the arm-elf toolchain*.</li>
+
   <li><code>configs/ntosd-dm320</code>:
     This port uses the Neuros OSD with a GNU arm-elf toolchain*.
     See <a href="http://wiki.neurostechnology.com/index.php/Developer_Welcome">Neuros Wiki</a>
@@ -1035,8 +1047,19 @@
 <h2>Architecture selection</h2>
 
 <ul>
-  <li><code>CONFIG_ARCH</code>: identifies the arch subdirectory
-  <li><code>CONFIG_ARCH_name</code>: for use in C code
+  <li><code>CONFIG_ARCH</code>:
+    Identifies the arch subdirectory</li>
+  <li><code>CONFIG_ARCH_name</code>:
+    For use in C code</li>
+  <li><code>CONFIG_ARCH_CHIP</code>:
+    Identifies the arch/*/chip subdirectory</li>
+  <li><code>CONFIG_ARCH_CHIP_name</code>:
+    For use in C code</li>
+  <li><code>CONFIG_ARCH_BOARD</code>:
+     Identifies the configs subdirectory and hence, the board that supports
+     the particular chip or SoC.</li>
+  <li><code>CONFIG_ARCH_BOARD_name</code>:
+     For use in C code</li>
 </ul>
 
 <h2>General OS setup</h2>
diff --git a/Makefile b/Makefile
index 9a76f07..b0af8e9 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@
 ARCH_DIR	= arch/$(CONFIG_ARCH)
 ARCH_SRC	= $(ARCH_DIR)/src
 ARCH_INC	= $(ARCH_DIR)/include
-BOARD_DIR	= configs/$(CONFIG_BOARD)
+BOARD_DIR	= configs/$(CONFIG_ARCH_BOARD)
 
 SUBDIRS		= sched lib $(ARCH_SRC) mm fs drivers examples/$(CONFIG_EXAMPLE)
 
@@ -53,12 +53,15 @@
 all: $(BIN)
 .PHONY: clean context clean_context distclean
 
+# Build the mkconfig tool used to create include/nuttx/config.h
 tools/mkconfig:
 	$(MAKE) -C tools -f Makefile.mkconfig TOPDIR=$(TOPDIR)  mkconfig
 
+# Create the include/nuttx/config.h file
 include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig
 	tools/mkconfig $(TOPDIR) > include/nuttx/config.h
 
+# link the arch/<arch-name>/include dir to include/arch
 include/arch: Make.defs
 	@if [ -e include/arch ]; then \
 		if [ -h include/arch ]; then \
@@ -70,6 +73,7 @@
 	fi
 	@ln -s $(TOPDIR)/$(ARCH_DIR)/include include/arch
 
+# Link the configs/<board-name>/include dir to include/arch/board
 include/arch/board: Make.defs include/arch
 	@if [ -e include/arch/board ]; then \
 		if [ -h include/arch/board ]; then \
@@ -81,6 +85,7 @@
 	fi
 	@ln -s $(TOPDIR)/$(BOARD_DIR)/include include/arch/board
 
+# Link the configs/<board-name>/src dir to arch/<arch-name>/src/board
 $(ARCH_SRC)/board: Make.defs
 	@if [ -e $(ARCH_SRC)/board ]; then \
 		if [ -h $(ARCH_SRC)/board ]; then \
@@ -92,10 +97,45 @@
 	fi
 	@ln -s $(TOPDIR)/$(BOARD_DIR)/src $(ARCH_SRC)/board
 
-context: check_context include/nuttx/config.h include/arch include/arch/board $(ARCH_SRC)/board
+# Link arch/<arch-name>/include/<chip-name> to arch/<arch-name>/include/chip
+$(ARCH_SRC)/chip: Make.defs
+ifneq ($(CONFIG_ARCH_CHIP),)
+	@if [ -e $(ARCH_SRC)/chip ]; then \
+		if [ -h $(ARCH_SRC)/chip ]; then \
+			rm -f $(ARCH_SRC)/chip ; \
+		else \
+			echo "$(ARCH_SRC)/chip exists but is not a symbolic link" ; \
+			exit 1 ; \
+		fi ; \
+	fi
+	@ln -s $(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
+endif
+
+# Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
+$(ARCH_INC)/chip: Make.defs
+ifneq ($(CONFIG_ARCH_CHIP),)
+	@if [ -e $(ARCH_INC)/chip ]; then \
+		if [ -h $(ARCH_INC)/chip ]; then \
+			rm -f $(ARCH_INC)/chip ; \
+		else \
+			echo "$(ARCH_INC)/chip exists but is not a symbolic link" ; \
+			exit 1 ; \
+		fi ; \
+	fi
+	@ln -s $(CONFIG_ARCH_CHIP) $(ARCH_INC)/chip
+endif
+
+dirlinks: include/arch include/arch/board $(ARCH_SRC)/board $(ARCH_SRC)/chip $(ARCH_INC)/chip
+
+context: check_context include/nuttx/config.h dirlinks
 
 clean_context:
-	rm -f include/nuttx/config.h include/arch $(ARCH_INC)/board $(ARCH_SRC)/board
+	@rm -f include/nuttx/config.h include/arch
+	@if [ -h include/arch ]; then rm -f include/arch ; fi
+	@if [ -h $(ARCH_INC)/board ]; then rm -f $(ARCH_INC)/board ; fi
+	@if [ -h $(ARCH_SRC)/board ]; then rm -f $(ARCH_SRC)/board ; fi
+	@if [ -h $(ARCH_INC)/chip ]; then rm -f $(ARCH_INC)/chip ; fi
+	@if [ -h $(ARCH_SRC)/chip ]; then rm -f $(ARCH_SRC)/chip ; fi
 
 check_context:
 	@if [ ! -e ${TOPDIR}/.config -o ! -e ${TOPDIR}/Make.defs ]; then \
diff --git a/arch/c5471/src/c5471.h b/arch/c5471/src/c5471.h
index b91c9f3..9c085d7 100644
--- a/arch/c5471/src/c5471.h
+++ b/arch/c5471/src/c5471.h
@@ -46,7 +46,7 @@
 # include <sys/types.h>
 #endif
 
-#if defined(CONFIG_BOARD_C5471EVM)
+#if defined(CONFIG_ARCH_BOARD_C5471EVM)
 # include <arch/board/c5471evm.h>
 #else
 # warning "Undefined C5471 Board"
diff --git a/arch/c5471/src/up_internal.h b/arch/c5471/src/up_internal.h
index fc5f92f..c032fa5 100644
--- a/arch/c5471/src/up_internal.h
+++ b/arch/c5471/src/up_internal.h
@@ -42,7 +42,7 @@
 
 #include <nuttx/config.h>
 
-#if defined(CONFIG_BOARD_C5471EVM)
+#if defined(CONFIG_ARCH_BOARD_C5471EVM)
 # include <arch/board/c5471evm.h>
 #else
 # warning "Undefined C5471 Board"
diff --git a/arch/dm320/src/dm320.h b/arch/dm320/src/dm320.h
index 6f0f89e..a147abd 100644
--- a/arch/dm320/src/dm320.h
+++ b/arch/dm320/src/dm320.h
@@ -47,7 +47,7 @@
 
 #include "arm9.h"
 
-#if defined(CONFIG_BOARD_NTOSD_DM320)
+#if defined(CONFIG_ARCH_BOARD_NTOSD_DM320)
 # include <arch/board/ntosd.h>
 #else
 # warning "Unknown DM320 board"
diff --git a/arch/pjrc-8051/src/up_internal.h b/arch/pjrc-8051/src/up_internal.h
index 90ba556..8b2e201 100644
--- a/arch/pjrc-8051/src/up_internal.h
+++ b/arch/pjrc-8051/src/up_internal.h
@@ -43,7 +43,7 @@
 #include <nuttx/config.h>
 #include <arch/irq.h>
 
-#if defined(CONFIG_BOARD_PJRC_87C52)
+#if defined(CONFIG_ARCH_BOARD_PJRC_87C52)
 # include <arch/board/pjrc.h>
 #else
 # warning "805x board not recognized"
diff --git a/configs/README.txt b/configs/README.txt
index f09046d..ac1565f 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -104,8 +104,13 @@
 
 	Architecture selection:
 
-		CONFIG_ARCH - identifies the arch/ subdirectory
-		CONFIG_ARCH_name - for use in C code
+		CONFIG_ARCH - Identifies the arch/ subdirectory
+		CONFIG_ARCH_name - For use in C code
+		CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
+		CONFIG_ARCH_CHIP_name - For use in C code
+		CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
+		   hence, the board that supports the particular chip or SoC.
+		CONFIG_ARCH_BOARD_name - For use in C code
 
 	General OS setup
 
@@ -220,6 +225,10 @@
     with a GNU arm-elf toolchain*. This port is complete, verified, and
     included in the NuttX release.
 
+configs/mcu123-lpc214x
+    This is a port to the mcu123.com lpc214x development board.
+    This OS is also built with the the arm-elf toolchain*
+
 configs/ntosd-dm320
     This port uses the Neuros OSD with a GNU arm-elf toolchain*:
     see http://wiki.neurostechnology.com/index.php/Developer_Welcome .
diff --git a/configs/c5471evm/Make.defs b/configs/c5471evm/Make.defs
index f0ef5c8..8baeb3f 100644
--- a/configs/c5471evm/Make.defs
+++ b/configs/c5471evm/Make.defs
@@ -47,7 +47,7 @@
 ARCHWARNINGS		= -Wall -Wstrict-prototypes -Wshadow
 ARCHDEFINES		=
 ARCHINCLUDES		= -I. -isystem $(TOPDIR)/include
-ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_BOARD)/ld.script
+ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ld.script
 
 CROSSDEV		= arm-elf-
 CC			= $(CROSSDEV)gcc
diff --git a/configs/c5471evm/defconfig b/configs/c5471evm/defconfig
index 2971805..3fd6a2e 100644
--- a/configs/c5471evm/defconfig
+++ b/configs/c5471evm/defconfig
@@ -40,9 +40,9 @@
 # CONFIG_ARCH_name - for use in C code.  This identifies the
 #   particular chip or SoC that the architecture is implemented
 #   in.
-# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
 #   the board that supports the particular chip or SoC.
-# CONFIG_BOARD_name - for use in C code
+# CONFIG_ARCH_BOARD_name - for use in C code
 # CONFIG_ROM_VECTORS - unique to c5471
 # CONFIG_DRAM_END - the size of installed DRAM.
 #   Unique to c5471
@@ -51,8 +51,8 @@
 #
 CONFIG_ARCH=c5471
 CONFIG_ARCH_C5471=y
-CONFIG_BOARD=c5471evm
-CONFIG_BOARD_C5471EVM=y
+CONFIG_ARCH_BOARD=c5471evm
+CONFIG_ARCH_BOARD_C5471EVM=y
 CONFIG_ROM_VECTORS=n
 CONFIG_DRAM_END=0x11000000
 CONFIG_ARCH_LEDS=y
diff --git a/configs/m68332evb/Make.defs b/configs/m68332evb/Make.defs
index 2dc2d5b..74f14b9 100644
--- a/configs/m68332evb/Make.defs
+++ b/configs/m68332evb/Make.defs
@@ -47,7 +47,7 @@
 ARCHWARNINGS		= -Wall -Wstrict-prototypes -Wshadow
 ARCHDEFINES		=
 ARCHINCLUDES		= -I. -isystem $(TOPDIR)/include
-ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_BOARD)/ld.script
+ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ld.script
 
 CROSSDEV		= m68k-elf-
 CC			= $(CROSSDEV)gcc
diff --git a/configs/m68332evb/defconfig b/configs/m68332evb/defconfig
index c63dc6a..2562563 100644
--- a/configs/m68332evb/defconfig
+++ b/configs/m68332evb/defconfig
@@ -40,17 +40,17 @@
 # CONFIG_ARCH_name - for use in C code.  This identifies the
 #   particular chip or SoC that the architecture is implemented
 #   in.
-# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
 #   the board that supports the particular chip or SoC.
-# CONFIG_BOARD_name - for use in C code
+# CONFIG_ARCH_BOARD_name - for use in C code
 # CONFIG_DRAM_SIZE - Describes the installed DRAM.
 # CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
 #
 CONFIG_ARCH=m68332evb
 CONFIG_ARCH_M68332=y
 CONFIG_ARCH_M68332EVB=y
-CONFIG_BOARD=m68332evb
-CONFIG_BOARD_M68332EVB=y
+CONFIG_ARCH_BOARD=m68332evb
+CONFIG_ARCH_BOARD_M68332EVB=y
 CONFIG_DRAM_SIZE=0x003000
 CONFIG_DRAM_NUTTXENTRY=0x003000
 CONFIG_ARCH_STACKDUMP=y
diff --git a/configs/ntosd-dm320/Make.defs b/configs/ntosd-dm320/Make.defs
index 8fbe748..62302a2 100644
--- a/configs/ntosd-dm320/Make.defs
+++ b/configs/ntosd-dm320/Make.defs
@@ -47,7 +47,7 @@
 ARCHWARNINGS		= -Wall -Wstrict-prototypes -Wshadow
 ARCHDEFINES		=
 ARCHINCLUDES		= -I. -isystem $(TOPDIR)/include
-ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_BOARD)/ld.script
+ARCHSCRIPT		= -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ld.script
 
 CROSSDEV		= arm-elf-
 CC			= $(CROSSDEV)gcc
diff --git a/configs/ntosd-dm320/defconfig b/configs/ntosd-dm320/defconfig
index 7ea06e2..bb20353 100644
--- a/configs/ntosd-dm320/defconfig
+++ b/configs/ntosd-dm320/defconfig
@@ -40,17 +40,17 @@
 # CONFIG_ARCH_name - for use in C code.  This identifies the
 #   particular chip or SoC that the architecture is implemented
 #   in.
-# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
 #   the board that supports the particular chip or SoC.
-# CONFIG_BOARD_name - for use in C code
+# CONFIG_ARCH_BOARD_name - for use in C code
 # CONFIG_ROM_VECTORS - unique to dm320
 # CONFIG_DRAM_SIZE - Describes the installed DRAM.
 # CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
 #
 CONFIG_ARCH=dm320
 CONFIG_ARCH_DM320=y
-CONFIG_BOARD=ntosd-dm320
-CONFIG_BOARD_NTOSD_DM320=y
+CONFIG_ARCH_BOARD=ntosd-dm320
+CONFIG_ARCH_BOARD_NTOSD_DM320=y
 CONFIG_ROM_VECTORS=n
 CONFIG_DRAM_SIZE=0x01000000
 CONFIG_DRAM_NUTTXENTRY=0x01008000
diff --git a/configs/pjrc-8051/defconfig b/configs/pjrc-8051/defconfig
index cc5da93..a3aabdb 100644
--- a/configs/pjrc-8051/defconfig
+++ b/configs/pjrc-8051/defconfig
@@ -39,17 +39,15 @@
 #   processor architecture.
 # CONFIG_ARCH_8051 - Set if processor is 8051 family
 # CONFIG_ARCH_8052 = Set if processor is 8052 family
-# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
 #   the board that supports the particular chip or SoC.
-# CONFIG_BOARD_name - for use in C code
-# CONFIG_BOARD - identifies the configs subdirectory
-# CONFIG_BARD_name - for use in C code
+# CONFIG_ARCH_BOARD_name - for use in C code
 #
 CONFIG_ARCH=pjrc-8051
 CONFIG_ARCH_8051=n
 CONFIG_ARCH_8052=y
-CONFIG_BOARD=pjrc-8051
-CONFIG_BOARD_PJRC_87C52=y
+CONFIG_ARCH_BOARD=pjrc-8051
+CONFIG_ARCH_BOARD_PJRC_87C52=y
 
 #
 # Architecture-specific settings.  These may mean nothing to
diff --git a/configs/sim/defconfig b/configs/sim/defconfig
index 935ca1d..7736a65 100644
--- a/configs/sim/defconfig
+++ b/configs/sim/defconfig
@@ -40,14 +40,14 @@
 # CONFIG_ARCH_name - for use in C code.  This identifies the
 #   particular chip or SoC that the architecture is implemented
 #   in.
-# CONFIG_BOARD - identifies the configs subdirectory and, hence,
+# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
 #   the board that supports the particular chip or SoC.
-# CONFIG_BOARD_name - for use in C code
+# CONFIG_ARCH_BOARD_name - for use in C code
 #
 CONFIG_ARCH=sim
 CONFIG_ARCH_SIM=y
-CONFIG_BOARD=sim
-CONFIG_BOARD_SIM=y
+CONFIG_ARCH_BOARD=sim
+CONFIG_ARCH_BOARD_SIM=y
 
 #
 # General OS setup