[dpdk-dev,v5] mk: add sensible default target with defconfig

Message ID 1501843142-22208-1-git-send-email-david.hunt@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hunt, David Aug. 4, 2017, 10:39 a.m. UTC
  Users can now use 'make defconfig' to generate a configuration using
the most appropriate defaults for the current machine.

<arch-machine-execenv-toolchain>
  arch taken from uname -m
  machine defaults to native
  execenv is taken from uname, Linux=linuxapp, otherwise bsdapp
  toolchain is taken from $CC -v to see which compiler to use

Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 doc/build-sdk-quick.txt |  3 +++
 mk/rte.sdkconfig.mk     | 28 +++++++++++++++++++++++++---
 mk/rte.sdkroot.mk       |  4 ++--
 3 files changed, 30 insertions(+), 5 deletions(-)
  

Comments

Thomas Monjalon Aug. 5, 2017, 8:24 a.m. UTC | #1
04/08/2017 12:39, David Hunt:
> Users can now use 'make defconfig' to generate a configuration using
> the most appropriate defaults for the current machine.
> 
> <arch-machine-execenv-toolchain>
>   arch taken from uname -m
>   machine defaults to native
>   execenv is taken from uname, Linux=linuxapp, otherwise bsdapp
>   toolchain is taken from $CC -v to see which compiler to use
> 
> Signed-off-by: David Hunt <david.hunt@intel.com>
> Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
> Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
[...]
> --- a/doc/build-sdk-quick.txt
> +++ b/doc/build-sdk-quick.txt
> @@ -1,7 +1,10 @@
>  Basic build
> +	make defconfig && make
> +	or
>  	make config T=x86_64-native-linuxapp-gcc && make

Nice :)

> +	@echo "Configuration done using "$(shell basename \
> +		$(RTE_CONFIG_TEMPLATE) | sed "s/defconfig_//g")

Excuse me for being pedantic with Makefile, I will avoid shell invocation:

+       @echo "Configuration done using" \
+               $(patsubst defconfig_%,%,$(notdir $(RTE_CONFIG_TEMPLATE)))


Applied with my pedantic change, thanks :)
  

Patch

diff --git a/doc/build-sdk-quick.txt b/doc/build-sdk-quick.txt
index 8d41052..2b5d493 100644
--- a/doc/build-sdk-quick.txt
+++ b/doc/build-sdk-quick.txt
@@ -1,7 +1,10 @@ 
 Basic build
+	make defconfig && make
+	or
 	make config T=x86_64-native-linuxapp-gcc && make
 Build commands
 	config           get configuration from target template (T=)
+	defconfig        auto-select target template based on arch, OS, etc.
 	all              same as build (default rule)
 	build            build in a configured directory
 	clean            remove files but keep configuration
diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index 1f2d6bd..fc03fe3 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -60,16 +60,38 @@  showconfigs:
 
 .PHONY: notemplate
 notemplate:
-	@printf "No template specified. "
-	@echo "Use T=template among the following list:"
+	@printf "No template specified. Use 'make defconfig' or "
+	@echo "use T=template from the following list:"
 	@$(MAKE) -rR showconfigs | sed 's,^,  ,'
 
+
+.PHONY: defconfig
+defconfig:
+	@$(MAKE) config T=$(shell \
+                uname -m | awk '{ \
+                if ($$0 == "aarch64") { \
+                        print "arm64-armv8a"} \
+                else if ($$0 == "armv7l") { \
+                        print "arm-armv7a"} \
+                else if ($$0 == "ppc64") { \
+                        print "ppc_64-power8"} \
+                else { \
+                        printf "%s-native", $$0} }')-$(shell \
+                uname | awk '{ \
+                if ($$0 == "Linux") { \
+                        print "linuxapp"} \
+                else { \
+                        print "bsdapp"} }')-$(shell \
+                ${CC} -v 2>&1 | \
+                grep " version " | cut -d ' ' -f 1)
+
 .PHONY: config
 ifeq ($(RTE_CONFIG_TEMPLATE),)
 config: notemplate
 else
 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
-	@echo "Configuration done"
+	@echo "Configuration done using "$(shell basename \
+		$(RTE_CONFIG_TEMPLATE) | sed "s/defconfig_//g")
 endif
 
 $(RTE_OUTPUT):
diff --git a/mk/rte.sdkroot.mk b/mk/rte.sdkroot.mk
index 2843b7d..076a2d7 100644
--- a/mk/rte.sdkroot.mk
+++ b/mk/rte.sdkroot.mk
@@ -88,8 +88,8 @@  export ROOTDIRS-y ROOTDIRS- ROOTDIRS-n
 .PHONY: default
 default: all
 
-.PHONY: config showconfigs showversion showversionum
-config showconfigs showversion showversionum:
+.PHONY: defconfig config showconfigs showversion showversionum
+defconfig config showconfigs showversion showversionum:
 	$(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkconfig.mk $@
 
 .PHONY: cscope gtags tags etags