Skip to contentSkip to conversation

Simplify the ifdefs in rte.app.mk.

PATCH Superseded Keith Wiles 1 participant 2 messages Apr 29, 2015 1 message not in the archive

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 Simplify the ifdefs in rte.app.mk.

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.

---
 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(-)
examples/dpdk_qat/Makefile +2 -2
index f1e06a1..90ca1d3 100644
@@ -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 \
examples/vm_power_manager/Makefile +1 -1
index 113dbc4..8fb78d4 100644
@@ -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
mk/rte.app.mk +66 -188

317 lines not on this page · raw message

mk/rte.hostapp.mk +2 -2
index c44d0f8..51e8c1d 100644
@@ -58,7 +58,7 @@ build: _postbuild
 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 
 O_TO_EXE = $(HOSTCC) $(HOST_LDFLAGS) $(LDFLAGS_$(@)) \
-	$(EXTRA_HOST_LDFLAGS) -o $@ $(OBJS-y) $(LDLIBS)
+	$(EXTRA_HOST_LDFLAGS) -o $@ $(OBJS-y) $(LDLIBS-y)
 O_TO_EXE_STR = $(subst ','\'',$(O_TO_EXE)) #'# fix syntax highlight
 O_TO_EXE_DISP = $(if $(V),"$(O_TO_EXE_STR)","  HOSTLD $(@)")
 O_TO_EXE_CMD = "cmd_$@ = $(O_TO_EXE_STR)"
@@ -72,7 +72,7 @@ O_TO_EXE_DO = @set -e; \
 # list of .a files that are linked to this application
 LDLIBS_FILES := $(wildcard \
 	$(addprefix $(RTE_OUTPUT)/lib/, \
-	$(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))))
+	$(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS-y)))))
 
 #
 # Compile executable file if needed
mk/rte.shared.mk +6 -6
index fc6b0b4..56f20bb 100644
@@ -60,10 +60,10 @@ exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 ifeq ($(LINK_USING_CC),1)
 override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS))
 O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
-	-shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
+	-shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS-y))
 else
 O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
-	-shared -o $@ $(OBJS-y) $(LDLIBS)
+	-shared -o $@ $(OBJS-y) $(LDLIBS-y)
 endif
 
 O_TO_SO_STR = $(subst ','\'',$(O_TO_SO)) #'# fix syntax highlight
@@ -77,12 +77,12 @@ O_TO_SO_DO = @set -e; \
 -include .$(SHARED).cmd
 
 # path where libraries are retrieved
-LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS)))
-LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS)))
+LDLIBS_PATH := $(subst -Wl$(comma)-L,,$(filter -Wl$(comma)-L%,$(LDLIBS-y)))
+LDLIBS_PATH += $(subst -L,,$(filter -L%,$(LDLIBS-y)))
 
 # list of .a files that are linked to this application
-LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS)))
-LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS)))
+LDLIBS_NAMES := $(patsubst -l%,lib%.a,$(filter -l%,$(LDLIBS-y)))
+LDLIBS_NAMES += $(patsubst -Wl$(comma)-l%,lib%.a,$(filter -Wl$(comma)-l%,$(LDLIBS-y)))
 
 # list of found libraries files (useful for deps). If not found, the
 # library is silently ignored and dep won't be checked
Signature · 1 line
2.3.0
#2 lore raw

PATCH v3 2/2 Update Docs for new EXTRA_LDLIBS variable

In reply to a message not in the archive
---
 doc/build-sdk-quick.txt                          | 1 +
 doc/guides/prog_guide/build_app.rst              | 2 +-
 doc/guides/prog_guide/dev_kit_build_system.rst   | 2 ++
 doc/guides/prog_guide/dev_kit_root_make_help.rst | 2 +-
 4 files changed, 5 insertions(+), 2 deletions(-)
doc/build-sdk-quick.txt +1 -0
index 041a40e..26d5442 100644
@@ -13,6 +13,7 @@ Build variables
 	EXTRA_CPPFLAGS   preprocessor options
 	EXTRA_CFLAGS     compiler options
 	EXTRA_LDFLAGS    linker options
+	EXTRA_LDLIBS     linker libary options
 	RTE_KERNELDIR    linux headers path
 	CROSS     toolchain prefix
 	V         verbose
doc/guides/prog_guide/build_app.rst +1 -1
index d4a3261..0680dee 100644
@@ -123,6 +123,6 @@ chapter for details.
 
 *   CPPFLAGS: The flags to use to provide flags to the C preprocessor (only useful when assembling .S files)
 
-*   LDLIBS: A list of libraries to link with (for example, -L /path/to/libfoo - lfoo)
+*   LDLIBS-y: A list of libraries to link with (for example, -L /path/to/libfoo - lfoo) Use EXTRA_LDLIBS to add more options.
 
 *   NO_AUTOLIBS: If set, the libraries provided by the framework will not be included in the LDLIBS variable automatically.
doc/guides/prog_guide/dev_kit_build_system.rst +2 -0
index cf5c96f..b8ef167 100644
@@ -413,6 +413,8 @@ Variables that Can be Set/Overridden by the User in a Makefile or Command Line
 
 *   EXTRA_LDFLAGS: The content of this variable is appended after LDFLAGS when linking.
 
+*   EXTRA_LDLIBS: The content of this variable is appended after LDLIBS when linking.
+
 *   EXTRA_ASFLAGS: The content of this variable is appended after ASFLAGS when assembling.
 
 *   EXTRA_CPPFLAGS: The content of this variable is appended after CPPFLAGS when using a C preprocessor on assembly files.
doc/guides/prog_guide/dev_kit_root_make_help.rst +1 -1
index 4f30192..fdc5fea 100644
@@ -205,7 +205,7 @@ The following variables can be specified on the command line:
 
     Enable dependency debugging. This provides some useful information about why a target is built or not.
 
-*   EXTRA_CFLAGS=, EXTRA_LDFLAGS=, EXTRA_ASFLAGS=, EXTRA_CPPFLAGS=
+*   EXTRA_CFLAGS=, EXTRA_LDFLAGS=, EXTRA_LDLIBS=, EXTRA_ASFLAGS=, EXTRA_CPPFLAGS=
 
     Append specific compilation, link or asm flags.
 
Signature · 1 line
2.3.0