Move build/config to config (#426)

* move build_config to config

* mv build/scripts

* Restyled by clang-format

* move build/autoconf to autoconf

Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/.gitignore b/.gitignore
index 3b25d08..95d640e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,18 +15,7 @@
 aclocal.m4
 autom4te.cache
 output/
-build/*
-!build/README.md
-!build/autoconf/m4/chip_check_project_config_includes.m4
-!build/autoconf/m4/nl_with_lwip.m4
-!build/config/standalone/CHIPProjectConfig.h
-!build/config/standalone/SystemProjectConfig.h
-!build/config/standalone/darwin/CHIPProjectConfig.h
-!build/config/standalone/no-openssl/CHIPProjectConfig.h
-!build/efr32/
-!build/esp32/
-!build/nrf5/
-!build/scripts/gen-chip-version
+build/
 examples/**/build
 config.log
 config.status
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 98fa992..07eb9c7 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -5,8 +5,8 @@
         "${workspaceFolder}/build/default/src/**",
         "${workspaceFolder}/build/default/src/include/**",
         "${workspaceFolder}/build/default/src/lib/**",
-        "${workspaceFolder}/build/config/standalone/",
-        "${workspaceFolder}/build/config/standalone/**",
+        "${workspaceFolder}/config/standalone/",
+        "${workspaceFolder}/config/standalone/**",
         "${workspaceFolder}/examples/**",
         "${workspaceFolder}/src/**",
         "${workspaceFolder}/src/include/",
diff --git a/Makefile-Android b/Makefile-Android
index 168e249..ae44277 100644
--- a/Makefile-Android
+++ b/Makefile-Android
@@ -66,7 +66,7 @@
 # Tools and Executables
 #
 
-android-ndk-which               = $(shell $(AbsTopSourceDir)/build/scripts/android-ndk-which --ndk-home $(ANDROID_NDK_HOME) $(1) $(TARGET_ABI))
+android-ndk-which               = $(shell $(AbsTopSourceDir)/scripts/android-ndk-which --ndk-home $(ANDROID_NDK_HOME) $(1) $(TARGET_ABI))
 
 AR                              = $(call android-ndk-which,ar)
 AS                              = $(call android-ndk-which,as)
@@ -114,7 +114,7 @@
 #
 # Compilation/Build Flags
 #
- 
+
 CPPFLAGS                        = --sysroot=$(ABI_SYSROOT) $(DEFINES) $(INCLUDES) $(ABI_CPPFLAGS)
 CFLAGS                          = $(CPPFLAGS) -ffunction-sections -funwind-tables $(ABI_CFLAGS)
 CXXFLAGS                        = $(CPPFLAGS) -fno-rtti $(ABI_CXXFLAGS)
@@ -142,7 +142,7 @@
 ifeq ($(DEBUG),1)
 CONFIGURE_OPTIONS              	+= --enable-debug --enable-optimization=no
 else
-CONFIGURE_OPTIONS              	+= 
+CONFIGURE_OPTIONS              	+=
 endif
 
 
@@ -162,7 +162,7 @@
 AbsTopResultDir                 = $(PWD)/$(TopResultDir)
 
 # NB: Regardless of where JAVA_HOME points, always use the JNI headers from the Android NDK,
-# and only include the top-most directory (include), not the system directory (include/linux). 
+# and only include the top-most directory (include), not the system directory (include/linux).
 # Because the NDK mixes the JNI headers in with the linux headers, listing the system
 # directory in the -I flags will result in strange compilation errors.  And unlike the standard
 # Java jni.h, the jni.h that comes with the Android NDK does not depend on any system-specific
@@ -257,7 +257,7 @@
 --host=$(ABI_CONFIG_TUPLE_$(1)) \
 --with-sysroot=$(ABI_SYSROOT) \
 --with-libtool-sysroot=$(ABI_SYSROOT) \
---with-chip-project-includes=$(AbsTopSourceDir)/build/config/android \
+--with-chip-project-includes=$(AbsTopSourceDir)/config/android \
 --prefix=/ \
 --exec-prefix=/$(ABI_CONFIG_TUPLE_$(1)) \
 $(CONFIGURE_OPTIONS))
@@ -444,7 +444,7 @@
 
 help:
 	$(ECHO) ""
-	$(ECHO) "Type 'make -f $(firstword $(MAKEFILE_LIST))' to build CHIP for Android for the following" 
+	$(ECHO) "Type 'make -f $(firstword $(MAKEFILE_LIST))' to build CHIP for Android for the following"
 	$(ECHO) "API level and ABIs: "
 	$(ECHO) ""
 	$(ECHO) "    API Level $(ANDROID_API)"
diff --git a/Makefile-Standalone b/Makefile-Standalone
index 29b79ab..fe1da6a 100644
--- a/Makefile-Standalone
+++ b/Makefile-Standalone
@@ -66,9 +66,9 @@
 TargetTuple                     = $(shell ${AbsTopSourceDir}/third_party/nlbuild-autotools/repo/third_party/autoconf/config.guess | sed -e 's/[[:digit:].]*$$//g')
 
 ifeq ($(HOSTOS),darwin)
-ProjectConfigDir               ?= $(AbsTopSourceDir)/build/config/standalone/darwin
+ProjectConfigDir               ?= $(AbsTopSourceDir)/config/standalone/darwin
 else
-ProjectConfigDir               ?= $(AbsTopSourceDir)/build/config/standalone
+ProjectConfigDir               ?= $(AbsTopSourceDir)/config/standalone
 endif
 
 ifeq ($(ARCH),x86_64)
@@ -120,7 +120,7 @@
 configure_OPTIONS              += --with-openssl=$(OPENSSL)
 ifeq ($(OPENSSL),no)
 configure_OPTIONS              += --disable-tools
-ProjectConfigDir                = $(AbsTopSourceDir)/build/config/standalone/no-openssl
+ProjectConfigDir                = $(AbsTopSourceDir)/config/standalone/no-openssl
 endif
 
 # If the user has asserted USE_FUZZING enable fuzzing build
diff --git a/Makefile-iOS b/Makefile-iOS
index 4624df4..851cf77 100644
--- a/Makefile-iOS
+++ b/Makefile-iOS
@@ -276,7 +276,7 @@
 --target=$($(1)_arch_AUTOTOOLS)-$(TargetTupleStem) \
 --prefix=/ \
 --exec-prefix=/$(1)-$(TargetTuple) \
---with-chip-project-includes=$(AbsTopSourceDir)/build/config/ios \
+--with-chip-project-includes=$(AbsTopSourceDir)/config/ios \
 --with-logging-style=external \
 --enable-cocoa \
 --disable-docs \
diff --git a/Makefile.am b/Makefile.am
index a8cd233..73949d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -53,10 +53,10 @@
     bootstrap-configure                    \
     repos.conf                             \
     $(srcdir)/build/autoconf               \
-    $(srcdir)/build/config                 \
-    $(srcdir)/build/efr32                  \
-    $(srcdir)/build/nrf5                   \
-    $(srcdir)/build/scripts                \
+    $(srcdir)/config                 \
+    $(srcdir)/config/efr32                  \
+    $(srcdir)/config/nrf5                   \
+    $(srcdir)/scripts                       \
     $(NULL)
 
 BUILT_SOURCES                            = \
diff --git a/build/autoconf/m4/chip_check_project_config_includes.m4 b/autoconf/m4/chip_check_project_config_includes.m4
similarity index 100%
rename from build/autoconf/m4/chip_check_project_config_includes.m4
rename to autoconf/m4/chip_check_project_config_includes.m4
diff --git a/build/autoconf/m4/nl_with_lwip.m4 b/autoconf/m4/nl_with_lwip.m4
similarity index 100%
rename from build/autoconf/m4/nl_with_lwip.m4
rename to autoconf/m4/nl_with_lwip.m4
diff --git a/build/README.md b/build/README.md
deleted file mode 100644
index 0a5c5d6..0000000
--- a/build/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# /build directory
-
-The /build directory serves 2 purposes in the tree:
-
-1. some top-level makefiles and developer workflows use build/XXX as the configured build tree
-2. some parts of the CHIP build system live here
-
-For this reason, most of this directory is "ignore".
-
-If you update the contents of this directory, please also update the top level
-.gitignore file.
diff --git a/build/efr32/efr32-app.mk b/config/efr32/efr32-app.mk
similarity index 99%
rename from build/efr32/efr32-app.mk
rename to config/efr32/efr32-app.mk
index 672e74a..c21eb2b 100644
--- a/build/efr32/efr32-app.mk
+++ b/config/efr32/efr32-app.mk
@@ -34,7 +34,7 @@
 #
 #       PROJECT_ROOT = $(realpath .)
 #
-#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/build/efr32
+#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/config/efr32
 #
 #       include $(BUILD_SUPPORT_DIR)/efr32-app.mk
 #       include $(BUILD_SUPPORT_DIR)/efr32-chip.mk
diff --git a/build/efr32/efr32-chip.mk b/config/efr32/efr32-chip.mk
similarity index 99%
rename from build/efr32/efr32-chip.mk
rename to config/efr32/efr32-chip.mk
index 3fa9f53..430e662 100644
--- a/build/efr32/efr32-chip.mk
+++ b/config/efr32/efr32-chip.mk
@@ -28,7 +28,7 @@
 #
 #       PROJECT_ROOT = $(realpath .)
 #
-#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/build/efr32
+#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/config/efr32
 #
 #       include $(BUILD_SUPPORT_DIR)/efr32-app.mk
 #       include $(BUILD_SUPPORT_DIR)/efr32-chip.mk
diff --git a/build/efr32/efr32-freertos.mk b/config/efr32/efr32-freertos.mk
similarity index 99%
rename from build/efr32/efr32-freertos.mk
rename to config/efr32/efr32-freertos.mk
index 56bb8f3..49dde99 100644
--- a/build/efr32/efr32-freertos.mk
+++ b/config/efr32/efr32-freertos.mk
@@ -30,7 +30,7 @@
 #
 #       PROJECT_ROOT = $(realpath .)
 #
-#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/openweave-core/build/efr32
+#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/openweave-core/config/efr32
 #
 #       include $(BUILD_SUPPORT_DIR)/efr32-app.mk
 #       include $(BUILD_SUPPORT_DIR)/efr32-openweave.mk
diff --git a/build/nrf5/nrf5-app.mk b/config/nrf5/nrf5-app.mk
similarity index 99%
rename from build/nrf5/nrf5-app.mk
rename to config/nrf5/nrf5-app.mk
index 2e8867e..544e32b 100644
--- a/build/nrf5/nrf5-app.mk
+++ b/config/nrf5/nrf5-app.mk
@@ -34,7 +34,7 @@
 #   
 #       PROJECT_ROOT = $(realpath .)
 #
-#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/build/nrf5
+#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/config/nrf5
 #       
 #       include $(BUILD_SUPPORT_DIR)/nrf5-app.mk
 #       
diff --git a/build/nrf5/nrf5-chip.mk b/config/nrf5/nrf5-chip.mk
similarity index 99%
rename from build/nrf5/nrf5-chip.mk
rename to config/nrf5/nrf5-chip.mk
index 3f3434d..991271e 100644
--- a/build/nrf5/nrf5-chip.mk
+++ b/config/nrf5/nrf5-chip.mk
@@ -28,7 +28,7 @@
 #
 #       PROJECT_ROOT = $(realpath .)
 #
-#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/build/nrf5
+#       BUILD_SUPPORT_DIR = $(PROJECT_ROOT)/third_party/connectedhomeip/config/nrf5
 #       
 #       include $(BUILD_SUPPORT_DIR)/nrf5-app.mk
 #       include $(BUILD_SUPPORT_DIR)/nrf5-chip.mk
diff --git a/build/config/standalone/CHIPProjectConfig.h b/config/standalone/CHIPProjectConfig.h
similarity index 96%
rename from build/config/standalone/CHIPProjectConfig.h
rename to config/standalone/CHIPProjectConfig.h
index b686028..df0c7ce 100644
--- a/build/config/standalone/CHIPProjectConfig.h
+++ b/config/standalone/CHIPProjectConfig.h
@@ -24,7 +24,6 @@
 #ifndef CHIPPROJECTCONFIG_H
 #define CHIPPROJECTCONFIG_H
 
-
 #define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1
 
 // Configure WDM for event offload
@@ -57,7 +56,7 @@
 #define WDM_ENFORCE_EXPIRY_TIME 1
 
 // Increase session idle timeout in stand-alone builds for the convenience of developers.
-#define CHIP_CONFIG_DEFAULT_SECURITY_SESSION_IDLE_TIMEOUT           120000
+#define CHIP_CONFIG_DEFAULT_SECURITY_SESSION_IDLE_TIMEOUT 120000
 
 #define CHIP_CONFIG_ENABLE_WDM_UPDATE 1
 
diff --git a/build/config/standalone/SystemProjectConfig.h b/config/standalone/SystemProjectConfig.h
similarity index 100%
rename from build/config/standalone/SystemProjectConfig.h
rename to config/standalone/SystemProjectConfig.h
diff --git a/build/config/standalone/darwin/CHIPProjectConfig.h b/config/standalone/darwin/CHIPProjectConfig.h
similarity index 100%
rename from build/config/standalone/darwin/CHIPProjectConfig.h
rename to config/standalone/darwin/CHIPProjectConfig.h
diff --git a/build/config/standalone/no-openssl/CHIPProjectConfig.h b/config/standalone/no-openssl/CHIPProjectConfig.h
similarity index 100%
rename from build/config/standalone/no-openssl/CHIPProjectConfig.h
rename to config/standalone/no-openssl/CHIPProjectConfig.h
diff --git a/configure.ac b/configure.ac
index 081112e..a79a753 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,7 @@
 # Tell autoconf where to find auxilliary M4 macros
 # Note that nlbuild-autotools has macros in two subdirs, for local vs third-party scripts
 #
-AC_CONFIG_MACRO_DIRS([build/autoconf/m4 third_party/nlbuild-autotools/repo/third_party/autoconf/m4 third_party/nlbuild-autotools/repo/autoconf/m4])
+AC_CONFIG_MACRO_DIRS([build/autoconf/m4 autoconf/m4 third_party/nlbuild-autotools/repo/third_party/autoconf/m4 third_party/nlbuild-autotools/repo/autoconf/m4])
 
 #
 # Tell autoconf what file the package is using to aggregate C preprocessor
@@ -1274,23 +1274,23 @@
 
 # SystemLayer
 
-CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-system-project-includes, SYSTEM_PROJECT_CONFIG_INCLUDE, SystemProjectConfig.h, CHIP System Layer, ${ac_abs_confdir}/build/config/standalone)
+CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-system-project-includes, SYSTEM_PROJECT_CONFIG_INCLUDE, SystemProjectConfig.h, CHIP System Layer, ${ac_abs_confdir}/config/standalone)
 
 # BleLayer
 
 if test ${CONFIG_NETWORK_LAYER_BLE} = 1; then
-    CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-ble-project-includes, BLE_PROJECT_CONFIG_INCLUDE, BleProjectConfig.h, CHIP BLE Layer, ${ac_abs_confdir}/build/config/standalone)
+    CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-ble-project-includes, BLE_PROJECT_CONFIG_INCLUDE, BleProjectConfig.h, CHIP BLE Layer, ${ac_abs_confdir}/config/standalone)
 fi
 
 # InetLayer
 
 if test ${CONFIG_NETWORK_LAYER_INET} = 1; then
-    CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-inet-project-includes, INET_PROJECT_CONFIG_INCLUDE, InetProjectConfig.h, CHIP Inet Layer, ${ac_abs_confdir}/build/config/standalone)
+    CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-inet-project-includes, INET_PROJECT_CONFIG_INCLUDE, InetProjectConfig.h, CHIP Inet Layer, ${ac_abs_confdir}/config/standalone)
 fi
 
 # Core
 
-CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-project-includes, CHIP_PROJECT_CONFIG_INCLUDE, CHIPProjectConfig.h, CHIP Core, ${ac_abs_confdir}/build/config/standalone)
+CHIP_CHECK_PROJECT_CONFIG_INCLUDES(chip-project-includes, CHIP_PROJECT_CONFIG_INCLUDE, CHIPProjectConfig.h, CHIP Core, ${ac_abs_confdir}/config/standalone)
 
 # Device Layer
 
diff --git a/examples/lock-app/efr32/Makefile b/examples/lock-app/efr32/Makefile
index f973221..50cfc78 100644
--- a/examples/lock-app/efr32/Makefile
+++ b/examples/lock-app/efr32/Makefile
@@ -67,7 +67,7 @@
 
 all : |
 
-BUILD_SUPPORT_DIR := $(CHIP_ROOT)/build/efr32
+BUILD_SUPPORT_DIR := $(CHIP_ROOT)/config/efr32
 
 include $(BUILD_SUPPORT_DIR)/efr32-app.mk
 include $(BUILD_SUPPORT_DIR)/efr32-chip.mk
diff --git a/examples/lock-app/nrf5/Makefile b/examples/lock-app/nrf5/Makefile
index 5ae5a30..7ad618e 100644
--- a/examples/lock-app/nrf5/Makefile
+++ b/examples/lock-app/nrf5/Makefile
@@ -25,7 +25,7 @@
 PROJECT_ROOT := $(realpath .)
 
 CHIP_ROOT ?= $(realpath $(PROJECT_ROOT)/third_party/connectedhomeip)
-BUILD_SUPPORT_DIR = $(CHIP_ROOT)/build/nrf5
+BUILD_SUPPORT_DIR = $(CHIP_ROOT)/config/nrf5
 
 include $(BUILD_SUPPORT_DIR)/nrf5-app.mk
 include $(BUILD_SUPPORT_DIR)/nrf5-chip.mk
diff --git a/build/scripts/gen-chip-version b/scripts/gen-chip-version
similarity index 100%
rename from build/scripts/gen-chip-version
rename to scripts/gen-chip-version
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index f696a95..1a3eda9 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -47,7 +47,7 @@
 CHIPVersion.h: force
 
 define check-file-CHIPVersion.h
-$(top_srcdir)/build/scripts/gen-chip-version "`cat $(1)`" -o "$(2)"
+$(top_srcdir)/scripts/gen-chip-version "`cat $(1)`" -o "$(2)"
 endef # check-file-CHIPVersion.h
 
 MAKEDIR_TARGETS=$(top_builddir)/.local-version