[dpdk-dev] [PATCH v2 1/2] Simplify the ifdefs in rte.app.mk.

2015-04-29 Thread Bruce Richardson
On Wed, Apr 29, 2015 at 09:37:42AM -0500, Keith Wiles wrote:
> Trying to simplify the ifdefs in rte.app.mk to make the code
> more readable and maintainable by moving LDLIBS variable to use
> the same style as LDLIBS-y being used in the rest of the code.
> 
> Added a new variable called EXTRA_LDLIBS to be used by example apps
> instead of using LDLIBS directly.
> 
> Signed-off-by: Keith Wiles 

Since EXTRA_* flags are designed that they can be overridden on the makefile,
what happens if someone does a compile via: "EXTRA_LDLIBS=X make"? Does the 
compile/link still work?

/Bruce


> ---
>  examples/dpdk_qat/Makefile |   4 +-
>  examples/vm_power_manager/Makefile |   2 +-
>  mk/rte.app.mk  | 254 
> ++---
>  mk/rte.hostapp.mk  |   4 +-
>  mk/rte.shared.mk   |  12 +-
>  5 files changed, 77 insertions(+), 199 deletions(-)
> 
> diff --git a/examples/dpdk_qat/Makefile b/examples/dpdk_qat/Makefile
> index f1e06a1..90ca1d3 100644
> --- a/examples/dpdk_qat/Makefile
> +++ b/examples/dpdk_qat/Makefile
> @@ -77,8 +77,8 @@ else
>  ICP_LIBRARY_PATH = $(ICP_ROOT)/build/libicp_qa_al.a
>  endif
>  
> -LDLIBS += -L$(ICP_ROOT)/build
> -LDLIBS += $(ICP_LIBRARY_PATH) \
> +EXTRA_LDLIBS += -L$(ICP_ROOT)/build
> +EXTRA_LDLIBS += $(ICP_LIBRARY_PATH) \
>  -lz \
>  -losal \
>  -ladf_proxy \
> diff --git a/examples/vm_power_manager/Makefile 
> b/examples/vm_power_manager/Makefile
> index 113dbc4..8fb78d4 100644
> --- a/examples/vm_power_manager/Makefile
> +++ b/examples/vm_power_manager/Makefile
> @@ -48,7 +48,7 @@ SRCS-y += channel_monitor.c
>  CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
>  CFLAGS += $(WERROR_FLAGS)
>  
> -LDLIBS += -lvirt
> +EXTRA_LDLIBS += -lvirt
>  
>  # workaround for a gcc bug with noreturn attribute
>  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
> diff --git a/mk/rte.app.mk b/mk/rte.app.mk
> index 62a76ae..ed471ad 100644
> --- a/mk/rte.app.mk
> +++ b/mk/rte.app.mk
> @@ -1,7 +1,7 @@
>  #   BSD LICENSE
>  #
> -#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
> -#   Copyright(c) 2014 6WIND S.A.
> +#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> +#   Copyright(c) 2015 6WIND S.A.
>  #   All rights reserved.
>  #
>  #   Redistribution and use in source and binary forms, with or without
> @@ -51,7 +51,7 @@ LDSCRIPT = $(RTE_LDSCRIPT)
>  endif
>  
>  # default path for libs
> -LDLIBS += -L$(RTE_SDK_BIN)/lib
> +LDLIBS-y = -L$(RTE_SDK_BIN)/lib
>  
>  #
>  # Include libraries depending on config if NO_AUTOLIBS is not set
> @@ -59,215 +59,93 @@ LDLIBS += -L$(RTE_SDK_BIN)/lib
>  #
>  ifeq ($(NO_AUTOLIBS),)
>  
> -LDLIBS += --whole-archive
> +LDLIBS-y += --whole-archive
>  
> -ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
> -LDLIBS += -l$(RTE_LIBNAME)
> -endif
> +LDLIBS-$(CONFIG_RTE_BUILD_COMBINE_LIBS) += -l$(RTE_LIBNAME)
>  
>  ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
>  
> -ifeq ($(CONFIG_RTE_LIBRTE_DISTRIBUTOR),y)
> -LDLIBS += -lrte_distributor
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_REORDER),y)
> -LDLIBS += -lrte_reorder
> -endif
> +LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
> +LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder
>  
> -ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
>  ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
> -LDLIBS += -lrte_kni
> -endif
> +LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni
> +LDLIBS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += -lrte_ivshmem
>  endif
>  
> -ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
> -ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
> -LDLIBS += -lrte_ivshmem
> -endif
> -endif
> +LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE)+= -lrte_pipeline
> +LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE)   += -lrte_table
> +LDLIBS-$(CONFIG_RTE_LIBRTE_PORT)+= -lrte_port
> +LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER)   += -lrte_timer
> +LDLIBS-$(CONFIG_RTE_LIBRTE_HASH)+= -lrte_hash
> +LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS)+= -lrte_jobstats
> +LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
> +LDLIBS-$(CONFIG_RTE_LIBRTE_POWER)   += -lrte_power
> +LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
> +LDLIBS-$(CONFIG_RTE_LIBRTE_METER)   += -lrte_meter
>  
> -ifeq ($(CONFIG_RTE_LIBRTE_PIPELINE),y)
> -LDLIBS += -lrte_pipeline
> -endif
> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrte_sched
> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lm
> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrt
>  
> -ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
> -LDLIBS += -lrte_table
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_PORT),y)
> -LDLIBS += -lrte_port
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
> -LDLIBS += -lrte_timer
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
> -LDLIBS += -lrte_hash
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_JOBSTATS),y)
> -LDLIBS += -lrte_jobstats
> -endif
> -
> -ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
> -LDLIBS += 

[dpdk-dev] [PATCH v2 1/2] Simplify the ifdefs in rte.app.mk.

2015-04-29 Thread Wiles, Keith


On 4/29/15, 10:11 AM, "Richardson, Bruce" 
wrote:

>On Wed, Apr 29, 2015 at 09:37:42AM -0500, Keith Wiles wrote:
>> Trying to simplify the ifdefs in rte.app.mk to make the code
>> more readable and maintainable by moving LDLIBS variable to use
>> the same style as LDLIBS-y being used in the rest of the code.
>> 
>> Added a new variable called EXTRA_LDLIBS to be used by example apps
>> instead of using LDLIBS directly.
>> 
>> Signed-off-by: Keith Wiles 
>
>Since EXTRA_* flags are designed that they can be overridden on the
>makefile,
>what happens if someone does a compile via: "EXTRA_LDLIBS=X make"? Does
>the 
>compile/link still work?

The code in rte.app.mk adds the EXTRA_LDLIBS to the end of LDLIBS-y
>
>/Bruce
>
>
>> ---
>>  examples/dpdk_qat/Makefile |   4 +-
>>  examples/vm_power_manager/Makefile |   2 +-
>>  mk/rte.app.mk  | 254
>>++---
>>  mk/rte.hostapp.mk  |   4 +-
>>  mk/rte.shared.mk   |  12 +-
>>  5 files changed, 77 insertions(+), 199 deletions(-)
>> 
>> diff --git a/examples/dpdk_qat/Makefile b/examples/dpdk_qat/Makefile
>> index f1e06a1..90ca1d3 100644
>> --- a/examples/dpdk_qat/Makefile
>> +++ b/examples/dpdk_qat/Makefile
>> @@ -77,8 +77,8 @@ else
>>  ICP_LIBRARY_PATH = $(ICP_ROOT)/build/libicp_qa_al.a
>>  endif
>>  
>> -LDLIBS += -L$(ICP_ROOT)/build
>> -LDLIBS += $(ICP_LIBRARY_PATH) \
>> +EXTRA_LDLIBS += -L$(ICP_ROOT)/build
>> +EXTRA_LDLIBS += $(ICP_LIBRARY_PATH) \
>>  -lz \
>>  -losal \
>>  -ladf_proxy \
>> diff --git a/examples/vm_power_manager/Makefile
>>b/examples/vm_power_manager/Makefile
>> index 113dbc4..8fb78d4 100644
>> --- a/examples/vm_power_manager/Makefile
>> +++ b/examples/vm_power_manager/Makefile
>> @@ -48,7 +48,7 @@ SRCS-y += channel_monitor.c
>>  CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
>>  CFLAGS += $(WERROR_FLAGS)
>>  
>> -LDLIBS += -lvirt
>> +EXTRA_LDLIBS += -lvirt
>>  
>>  # workaround for a gcc bug with noreturn attribute
>>  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
>> diff --git a/mk/rte.app.mk b/mk/rte.app.mk
>> index 62a76ae..ed471ad 100644
>> --- a/mk/rte.app.mk
>> +++ b/mk/rte.app.mk
>> @@ -1,7 +1,7 @@
>>  #   BSD LICENSE
>>  #
>> -#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
>> -#   Copyright(c) 2014 6WIND S.A.
>> +#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
>> +#   Copyright(c) 2015 6WIND S.A.
>>  #   All rights reserved.
>>  #
>>  #   Redistribution and use in source and binary forms, with or without
>> @@ -51,7 +51,7 @@ LDSCRIPT = $(RTE_LDSCRIPT)
>>  endif
>>  
>>  # default path for libs
>> -LDLIBS += -L$(RTE_SDK_BIN)/lib
>> +LDLIBS-y = -L$(RTE_SDK_BIN)/lib
>>  
>>  #
>>  # Include libraries depending on config if NO_AUTOLIBS is not set
>> @@ -59,215 +59,93 @@ LDLIBS += -L$(RTE_SDK_BIN)/lib
>>  #
>>  ifeq ($(NO_AUTOLIBS),)
>>  
>> -LDLIBS += --whole-archive
>> +LDLIBS-y += --whole-archive
>>  
>> -ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
>> -LDLIBS += -l$(RTE_LIBNAME)
>> -endif
>> +LDLIBS-$(CONFIG_RTE_BUILD_COMBINE_LIBS) += -l$(RTE_LIBNAME)
>>  
>>  ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
>>  
>> -ifeq ($(CONFIG_RTE_LIBRTE_DISTRIBUTOR),y)
>> -LDLIBS += -lrte_distributor
>> -endif
>> -
>> -ifeq ($(CONFIG_RTE_LIBRTE_REORDER),y)
>> -LDLIBS += -lrte_reorder
>> -endif
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder
>>  
>> -ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
>>  ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
>> -LDLIBS += -lrte_kni
>> -endif
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += -lrte_ivshmem
>>  endif
>>  
>> -ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
>> -ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
>> -LDLIBS += -lrte_ivshmem
>> -endif
>> -endif
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE)+= -lrte_pipeline
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE)   += -lrte_table
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_PORT)+= -lrte_port
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER)   += -lrte_timer
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_HASH)+= -lrte_hash
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS)+= -lrte_jobstats
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_POWER)   += -lrte_power
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_METER)   += -lrte_meter
>>  
>> -ifeq ($(CONFIG_RTE_LIBRTE_PIPELINE),y)
>> -LDLIBS += -lrte_pipeline
>> -endif
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrte_sched
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lm
>> +LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrt
>>  
>> -ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
>> -LDLIBS += -lrte_table
>> -endif
>> -
>> -ifeq ($(CONFIG_RTE_LIBRTE_PORT),y)
>> -LDLIBS += -lrte_port
>> -endif
>> -
>> -ifeq 

[dpdk-dev] [PATCH v2 1/2] Simplify the ifdefs in rte.app.mk.

2015-04-29 Thread Keith Wiles
Trying to simplify the ifdefs in rte.app.mk to make the code
more readable and maintainable by moving LDLIBS variable to use
the same style as LDLIBS-y being used in the rest of the code.

Added a new variable called EXTRA_LDLIBS to be used by example apps
instead of using LDLIBS directly.

Signed-off-by: Keith Wiles 
---
 examples/dpdk_qat/Makefile |   4 +-
 examples/vm_power_manager/Makefile |   2 +-
 mk/rte.app.mk  | 254 ++---
 mk/rte.hostapp.mk  |   4 +-
 mk/rte.shared.mk   |  12 +-
 5 files changed, 77 insertions(+), 199 deletions(-)

diff --git a/examples/dpdk_qat/Makefile b/examples/dpdk_qat/Makefile
index f1e06a1..90ca1d3 100644
--- a/examples/dpdk_qat/Makefile
+++ b/examples/dpdk_qat/Makefile
@@ -77,8 +77,8 @@ else
 ICP_LIBRARY_PATH = $(ICP_ROOT)/build/libicp_qa_al.a
 endif

-LDLIBS += -L$(ICP_ROOT)/build
-LDLIBS += $(ICP_LIBRARY_PATH) \
+EXTRA_LDLIBS += -L$(ICP_ROOT)/build
+EXTRA_LDLIBS += $(ICP_LIBRARY_PATH) \
 -lz \
 -losal \
 -ladf_proxy \
diff --git a/examples/vm_power_manager/Makefile 
b/examples/vm_power_manager/Makefile
index 113dbc4..8fb78d4 100644
--- a/examples/vm_power_manager/Makefile
+++ b/examples/vm_power_manager/Makefile
@@ -48,7 +48,7 @@ SRCS-y += channel_monitor.c
 CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
 CFLAGS += $(WERROR_FLAGS)

-LDLIBS += -lvirt
+EXTRA_LDLIBS += -lvirt

 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 62a76ae..ed471ad 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -1,7 +1,7 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   Copyright(c) 2015 6WIND S.A.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@ LDSCRIPT = $(RTE_LDSCRIPT)
 endif

 # default path for libs
-LDLIBS += -L$(RTE_SDK_BIN)/lib
+LDLIBS-y = -L$(RTE_SDK_BIN)/lib

 #
 # Include libraries depending on config if NO_AUTOLIBS is not set
@@ -59,215 +59,93 @@ LDLIBS += -L$(RTE_SDK_BIN)/lib
 #
 ifeq ($(NO_AUTOLIBS),)

-LDLIBS += --whole-archive
+LDLIBS-y += --whole-archive

-ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
-LDLIBS += -l$(RTE_LIBNAME)
-endif
+LDLIBS-$(CONFIG_RTE_BUILD_COMBINE_LIBS) += -l$(RTE_LIBNAME)

 ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)

-ifeq ($(CONFIG_RTE_LIBRTE_DISTRIBUTOR),y)
-LDLIBS += -lrte_distributor
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_REORDER),y)
-LDLIBS += -lrte_reorder
-endif
+LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
+LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder

-ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
-LDLIBS += -lrte_kni
-endif
+LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni
+LDLIBS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += -lrte_ivshmem
 endif

-ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
-ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
-LDLIBS += -lrte_ivshmem
-endif
-endif
+LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE)+= -lrte_pipeline
+LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE)   += -lrte_table
+LDLIBS-$(CONFIG_RTE_LIBRTE_PORT)+= -lrte_port
+LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER)   += -lrte_timer
+LDLIBS-$(CONFIG_RTE_LIBRTE_HASH)+= -lrte_hash
+LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS)+= -lrte_jobstats
+LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
+LDLIBS-$(CONFIG_RTE_LIBRTE_POWER)   += -lrte_power
+LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
+LDLIBS-$(CONFIG_RTE_LIBRTE_METER)   += -lrte_meter

-ifeq ($(CONFIG_RTE_LIBRTE_PIPELINE),y)
-LDLIBS += -lrte_pipeline
-endif
+LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrte_sched
+LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lm
+LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)   += -lrt

-ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
-LDLIBS += -lrte_table
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_PORT),y)
-LDLIBS += -lrte_port
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_TIMER),y)
-LDLIBS += -lrte_timer
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
-LDLIBS += -lrte_hash
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_JOBSTATS),y)
-LDLIBS += -lrte_jobstats
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
-LDLIBS += -lrte_lpm
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_POWER),y)
-LDLIBS += -lrte_power
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
-LDLIBS += -lrte_acl
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_METER),y)
-LDLIBS += -lrte_meter
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y)
-LDLIBS += -lrte_sched
-LDLIBS += -lm
-LDLIBS += -lrt
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_VHOST), y)
-LDLIBS += -lrte_vhost
-endif
+LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)   += -lrte_vhost

 endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS

-ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
-LDLIBS += -lpcap
-endif