* [dpdk-dev] [PATCH 1/6] build: remove library special cases
2017-12-12 16:59 [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
@ 2017-12-12 16:59 ` Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 2/6] eal: fix list of source files to meson build Bruce Richardson
` (6 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2017-12-12 16:59 UTC (permalink / raw)
To: dev; +Cc: luca.boccassi, aconole, Bruce Richardson
The EAL and compat libraries were special-cases in the library build
process, the former because of it's complexity, and the latter because
it only consists of a single header file.
By reworking the EAL meson.build files, we can eliminate the need for it to
be a special case, by having it build up and return the list of sources,
headers, and objects and return those to the higher level build file. This
should also simplify the building of EAL, as we can eliminate a number of
meson.build files that would no longer be needed, and have fewer, but
larger meson.build files (9 now vs 14 previous) - thereby making the logic
easier to follow and items easier to find.
Once done, we can pull eal into the main library loop, with some
modifications to support it. Compat can also be pulled it once we add in a
check to handle the case of an empty sources list.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test-pmd/meson.build | 1 -
config/meson.build | 14 ++++
doc/guides/contributing/coding_style.rst | 9 +++
drivers/net/e1000/base/meson.build | 2 +-
drivers/net/fm10k/base/meson.build | 2 +-
drivers/net/i40e/base/meson.build | 2 +-
drivers/net/ixgbe/base/meson.build | 2 +-
lib/librte_eal/bsdapp/eal/meson.build | 34 +---------
lib/librte_eal/bsdapp/meson.build | 55 ----------------
lib/librte_eal/common/arch/meson.build | 33 ----------
lib/librte_eal/common/include/arch/meson.build | 33 ----------
lib/librte_eal/common/include/meson.build | 71 ---------------------
lib/librte_eal/common/meson.build | 66 +++++++++++++++++--
lib/librte_eal/linuxapp/eal/meson.build | 36 ++---------
lib/librte_eal/linuxapp/igb_uio/meson.build | 8 ++-
lib/librte_eal/linuxapp/meson.build | 42 ------------
lib/librte_eal/meson.build | 45 +++++++++++--
lib/meson.build | 88 +++++++++++++++-----------
18 files changed, 193 insertions(+), 350 deletions(-)
delete mode 100644 lib/librte_eal/bsdapp/meson.build
delete mode 100644 lib/librte_eal/common/arch/meson.build
delete mode 100644 lib/librte_eal/common/include/arch/meson.build
delete mode 100644 lib/librte_eal/common/include/meson.build
delete mode 100644 lib/librte_eal/linuxapp/meson.build
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 72fe818c7..3e591683d 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -75,6 +75,5 @@ executable('dpdk-testpmd',
sources,
link_whole: link_libs,
dependencies: dep_objs,
- link_args: eal_extra_link_arg, # add -ldl for linux, -lexecinfo for BSD
install_rpath: join_paths(get_option('prefix'), driver_install_path),
install: true)
diff --git a/config/meson.build b/config/meson.build
index 8e4a703c7..d7fb64422 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -33,10 +33,24 @@
machine = get_option('machine')
dpdk_conf.set('RTE_MACHINE', machine)
add_project_arguments('-march=@0@'.format(machine), language: 'c')
+
+# use pthreads
+add_project_link_arguments('-pthread', language: 'c')
+dpdk_extra_ldflags += '-pthread'
+
# some libs depend on maths lib
add_project_link_arguments('-lm', language: 'c')
dpdk_extra_ldflags += '-lm'
+# for linux link against dl, for bsd execinfo
+if host_machine.system() == 'linux'
+ link_lib = 'dl'
+else
+ link_lib = 'execinfo'
+endif
+add_project_link_arguments('-l' + link_lib, language: 'c')
+dpdk_extra_ldflags += '-l' + link_lib
+
# check for libraries used in multiple places in DPDK
has_libnuma = 0
numa_dep = cc.find_library('numa', required: false)
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 3c59cbca5..ba85cab6f 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -840,6 +840,15 @@ headers
source files, these should be specified using the meson ``files()``
function.
+includes:
+ **Default Value = []**.
+ Used to indicate any additional header file paths which should be
+ added to the header search path for other libs depending on this
+ library. EAL uses this so that other libraries building against it
+ can find the headers in subdirectories of the main EAL directory. The
+ base directory of each library is always given in the include path,
+ it does not need to be specified here.
+
name
**Default Value = library name derived from the directory name**.
If a library's .so or .a file differs from that given in the directory
diff --git a/drivers/net/e1000/base/meson.build b/drivers/net/e1000/base/meson.build
index 9592762c9..7c0710ec9 100644
--- a/drivers/net/e1000/base/meson.build
+++ b/drivers/net/e1000/base/meson.build
@@ -60,6 +60,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('e1000_base', sources,
- dependencies: rte_eal,
+ dependencies: dep_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/fm10k/base/meson.build b/drivers/net/fm10k/base/meson.build
index e351f96da..8a371b6ca 100644
--- a/drivers/net/fm10k/base/meson.build
+++ b/drivers/net/fm10k/base/meson.build
@@ -50,6 +50,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('fm10k_base', sources,
- dependencies: rte_eal,
+ dependencies: dep_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/i40e/base/meson.build b/drivers/net/i40e/base/meson.build
index 2eae30fc7..8b491ad89 100644
--- a/drivers/net/i40e/base/meson.build
+++ b/drivers/net/i40e/base/meson.build
@@ -51,6 +51,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('i40e_base', sources,
- dependencies: rte_eal,
+ dependencies: dep_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/ixgbe/base/meson.build b/drivers/net/ixgbe/base/meson.build
index 5a3d73311..1781f2eb3 100644
--- a/drivers/net/ixgbe/base/meson.build
+++ b/drivers/net/ixgbe/base/meson.build
@@ -55,6 +55,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('ixgbe_base', sources,
- dependencies: rte_eal,
+ dependencies: dep_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/lib/librte_eal/bsdapp/eal/meson.build b/lib/librte_eal/bsdapp/eal/meson.build
index f9473a1d0..df93a00f4 100644
--- a/lib/librte_eal/bsdapp/eal/meson.build
+++ b/lib/librte_eal/bsdapp/eal/meson.build
@@ -29,7 +29,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-sources = ['eal_alarm.c',
+env_objs = []
+env_headers = []
+env_sources = files('eal_alarm.c',
'eal_debug.c',
'eal_hugepage_info.c',
'eal_interrupts.c',
@@ -38,35 +40,5 @@ sources = ['eal_alarm.c',
'eal_timer.c',
'eal.c',
'eal_memory.c',
-]
-
-eal_extra_link_arg = '-lexecinfo'
-
-if get_option('per_library_versions')
- lib_version = '@0@.1'.format(version)
- so_version = '@0@'.format(version)
-else
- pver = meson.project_version().split('.')
- lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
- so_version = lib_version
-endif
-
-eal_lib = library('rte_eal', sources, eal_common_sources, eal_common_arch_sources,
- dependencies: dependency('threads'),
- include_directories : eal_inc,
- version: lib_version,
- soversion: so_version,
- c_args: '-D_GNU_SOURCE',
- link_depends: version_map,
- link_args: [eal_extra_link_arg,
- '-Wl,--version-script=' + version_map],
- install: true
)
-dpdk_libraries += eal_lib
-dpdk_extra_ldflags += ['-pthread', eal_extra_link_arg]
-
-rte_eal = declare_dependency(link_with: eal_lib,
- include_directories: eal_inc,
- dependencies: dependency('threads'))
-set_variable('dep_rte_eal', rte_eal)
diff --git a/lib/librte_eal/bsdapp/meson.build b/lib/librte_eal/bsdapp/meson.build
deleted file mode 100644
index eadfca438..000000000
--- a/lib/librte_eal/bsdapp/meson.build
+++ /dev/null
@@ -1,55 +0,0 @@
-# BSD LICENSE
-#
-# Copyright(c) 2017 Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-subdir('eal')
-kmods = ['contigmem', 'nic_uio']
-
-# for building kernel modules, we use kernel build system using make, as
-# with Linux. We have a skeleton BSDmakefile, which pulls many of its
-# values from the environment. Each module only has a single source file
-# right now, which allows us to simplify things. We pull in the source files
-# from the individual meson.build files, and then use a custom target to call
-# make, passing in the values as environmental parameters.
-kmod_cflags = ['-I' + meson.build_root(),
- '-I' + join_paths(meson.source_root(), 'config'),
- '-include rte_config.h']
-foreach k:kmods
- subdir(k)
- custom_target(k,
- input: [files('BSDmakefile.meson'), sources],
- output: k + '.ko',
- command: ['make', '-f', '@INPUT0@',
- 'KMOD_SRC=@INPUT1@',
- 'KMOD=' + k,
- 'VPATH=' + join_paths(meson.current_source_dir(), k),
- 'KMOD_CFLAGS=' + ' '.join(kmod_cflags)],
- build_by_default: get_option('enable_kmods'))
-endforeach
diff --git a/lib/librte_eal/common/arch/meson.build b/lib/librte_eal/common/arch/meson.build
deleted file mode 100644
index 9e2539fde..000000000
--- a/lib/librte_eal/common/arch/meson.build
+++ /dev/null
@@ -1,33 +0,0 @@
-# BSD LICENSE
-#
-# Copyright(c) 2017 Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-eal_inc += include_directories(arch_subdir)
-subdir(arch_subdir)
diff --git a/lib/librte_eal/common/include/arch/meson.build b/lib/librte_eal/common/include/arch/meson.build
deleted file mode 100644
index 9e2539fde..000000000
--- a/lib/librte_eal/common/include/arch/meson.build
+++ /dev/null
@@ -1,33 +0,0 @@
-# BSD LICENSE
-#
-# Copyright(c) 2017 Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-eal_inc += include_directories(arch_subdir)
-subdir(arch_subdir)
diff --git a/lib/librte_eal/common/include/meson.build b/lib/librte_eal/common/include/meson.build
deleted file mode 100644
index 57b45d1d0..000000000
--- a/lib/librte_eal/common/include/meson.build
+++ /dev/null
@@ -1,71 +0,0 @@
-# BSD LICENSE
-#
-# Copyright(c) 2017 Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-eal_inc += include_directories('.')
-
-common_headers = [
- 'rte_alarm.h',
- 'rte_branch_prediction.h',
- 'rte_bus.h',
- 'rte_bitmap.h',
- 'rte_common.h',
- 'rte_debug.h',
- 'rte_devargs.h',
- 'rte_dev.h',
- 'rte_eal.h',
- 'rte_eal_interrupts.h',
- 'rte_eal_memconfig.h',
- 'rte_errno.h',
- 'rte_hexdump.h',
- 'rte_interrupts.h',
- 'rte_keepalive.h',
- 'rte_launch.h',
- 'rte_lcore.h',
- 'rte_log.h',
- 'rte_malloc.h',
- 'rte_malloc_heap.h',
- 'rte_memory.h',
- 'rte_memzone.h',
- 'rte_pci_dev_feature_defs.h',
- 'rte_pci_dev_features.h',
- 'rte_per_lcore.h',
- 'rte_random.h',
- 'rte_service.h',
- 'rte_service_component.h',
- 'rte_string_fns.h',
- 'rte_tailq.h',
- 'rte_time.h',
- 'rte_version.h']
-
-install_headers(common_headers)
-install_subdir('generic', install_dir : get_option('includedir'))
-
-subdir('arch')
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index 3bec97c14..f806d8e42 100644
--- a/lib/librte_eal/common/meson.build
+++ b/lib/librte_eal/common/meson.build
@@ -29,9 +29,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-eal_inc += include_directories('.')
+eal_inc += include_directories('.', 'include',
+ join_paths('include/arch', arch_subdir))
-eal_common_sources = files(
+common_objs = []
+common_sources = files(
'eal_common_bus.c',
'eal_common_cpuflags.c',
'eal_common_devargs.c',
@@ -64,5 +66,61 @@ eal_common_sources = files(
'rte_service.c'
)
-subdir('include')
-subdir('arch')
+# get architecture specific sources and objs
+eal_common_arch_sources = []
+eal_common_arch_objs = []
+subdir(join_paths('arch', arch_subdir))
+common_sources += eal_common_arch_sources
+common_objs += eal_common_arch_objs
+
+common_headers = files(
+ 'include/rte_alarm.h',
+ 'include/rte_branch_prediction.h',
+ 'include/rte_bus.h',
+ 'include/rte_bitmap.h',
+ 'include/rte_common.h',
+ 'include/rte_debug.h',
+ 'include/rte_devargs.h',
+ 'include/rte_dev.h',
+ 'include/rte_eal.h',
+ 'include/rte_eal_memconfig.h',
+ 'include/rte_eal_interrupts.h',
+ 'include/rte_errno.h',
+ 'include/rte_hexdump.h',
+ 'include/rte_interrupts.h',
+ 'include/rte_keepalive.h',
+ 'include/rte_launch.h',
+ 'include/rte_lcore.h',
+ 'include/rte_log.h',
+ 'include/rte_malloc.h',
+ 'include/rte_malloc_heap.h',
+ 'include/rte_memory.h',
+ 'include/rte_memzone.h',
+ 'include/rte_pci_dev_feature_defs.h',
+ 'include/rte_pci_dev_features.h',
+ 'include/rte_per_lcore.h',
+ 'include/rte_random.h',
+ 'include/rte_service.h',
+ 'include/rte_service_component.h',
+ 'include/rte_string_fns.h',
+ 'include/rte_tailq.h',
+ 'include/rte_time.h',
+ 'include/rte_version.h')
+
+# special case install the generic headers, since they go in a subdir
+generic_headers = files(
+ 'include/generic/rte_atomic.h',
+ 'include/generic/rte_byteorder.h',
+ 'include/generic/rte_cpuflags.h',
+ 'include/generic/rte_cycles.h',
+ 'include/generic/rte_io.h',
+ 'include/generic/rte_memcpy.h',
+ 'include/generic/rte_pause.h',
+ 'include/generic/rte_prefetch.h',
+ 'include/generic/rte_rwlock.h',
+ 'include/generic/rte_spinlock.h',
+ 'include/generic/rte_vect.h')
+install_headers(generic_headers, subdir: 'generic')
+
+# get and install the architecture specific headers
+subdir(join_paths('include/arch', arch_subdir))
diff --git a/lib/librte_eal/linuxapp/eal/meson.build b/lib/librte_eal/linuxapp/eal/meson.build
index dc93a0236..ce3518aec 100644
--- a/lib/librte_eal/linuxapp/eal/meson.build
+++ b/lib/librte_eal/linuxapp/eal/meson.build
@@ -32,7 +32,9 @@
eal_inc += include_directories('include')
install_subdir('include/exec-env', install_dir: get_option('includedir'))
-sources = ['eal_alarm.c',
+env_objs = []
+env_headers = []
+env_sources = files('eal_alarm.c',
'eal_debug.c',
'eal_hugepage_info.c',
'eal_interrupts.c',
@@ -44,38 +46,8 @@ sources = ['eal_alarm.c',
'eal_vfio_mp_sync.c',
'eal.c',
'eal_memory.c',
-]
+)
-eal_extra_link_arg = '-ldl'
if has_libnuma == 1
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
endif
-
-if get_option('per_library_versions')
- lib_version = '@0@.1'.format(version)
- so_version = '@0@'.format(version)
-else
- pver = meson.project_version().split('.')
- lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
- so_version = lib_version
-endif
-
-eal_lib = library('rte_eal', sources, eal_common_sources, eal_common_arch_sources,
- dependencies: dependency('threads'),
- include_directories : eal_inc,
- version: lib_version,
- soversion: so_version,
- c_args: '-D_GNU_SOURCE',
- link_depends: version_map,
- link_args: [eal_extra_link_arg,
- '-Wl,--version-script=' + version_map],
- install: true
-)
-
-dpdk_libraries += eal_lib
-dpdk_extra_ldflags += ['-pthread', eal_extra_link_arg]
-
-rte_eal = declare_dependency(link_with: eal_lib,
- include_directories: eal_inc,
- dependencies: dependency('threads'))
-set_variable('dep_rte_eal', rte_eal)
diff --git a/lib/librte_eal/linuxapp/igb_uio/meson.build b/lib/librte_eal/linuxapp/igb_uio/meson.build
index 4712756ea..9408e312a 100644
--- a/lib/librte_eal/linuxapp/igb_uio/meson.build
+++ b/lib/librte_eal/linuxapp/igb_uio/meson.build
@@ -29,6 +29,12 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+kernel_dir = get_option('kernel_dir')
+if kernel_dir == ''
+ kernel_version = run_command('uname', '-r').stdout().strip()
+ kernel_dir = '/lib/modules/' + kernel_version + '/build'
+endif
+
mkfile = custom_target('igb_uio_makefile',
output: 'Makefile',
command: ['touch', '@OUTPUT@'])
@@ -43,4 +49,4 @@ custom_target('igb_uio',
'/../../common/include',
'modules'],
depends: mkfile,
- build_by_default: true)
+ build_by_default: get_option('enable_kmods'))
diff --git a/lib/librte_eal/linuxapp/meson.build b/lib/librte_eal/linuxapp/meson.build
deleted file mode 100644
index 16a3f6b8b..000000000
--- a/lib/librte_eal/linuxapp/meson.build
+++ /dev/null
@@ -1,42 +0,0 @@
-# BSD LICENSE
-#
-# Copyright(c) 2017 Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Intel Corporation nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-subdir('eal')
-
-if get_option('enable_kmods')
- kernel_dir = get_option('kernel_dir')
- if kernel_dir == ''
- kernel_version = run_command('uname', '-r').stdout().strip()
- kernel_dir = '/lib/modules/' + kernel_version + '/build'
- endif
-
- subdir('igb_uio')
-endif
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 71f973991..a2dceee23 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -29,17 +29,52 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-version = 4 # the version of the EAL API
+# Custom EAL processing. EAL is complicated enough that it can't just
+# have a straight list of headers and source files.
+# Initially pull in common settings
eal_inc = [global_inc]
-subdir('common')
+subdir('common') # defines common_sources, common_objs, etc.
-version_map = join_paths(meson.current_source_dir(), 'rte_eal_version.map')
+# Now do OS/exec-env specific settings, including building kernel modules
+# The <exec-env>/eal/meson.build file should define env_sources, etc.
if host_machine.system() == 'linux'
dpdk_conf.set('RTE_EXEC_ENV_LINUXAPP', 1)
- subdir('linuxapp')
+ subdir('linuxapp/eal')
+ subdir('linuxapp/igb_uio')
+
elif host_machine.system() == 'freebsd'
dpdk_conf.set('RTE_EXEC_ENV_BSDAPP', 1)
- subdir('bsdapp')
+ subdir('bsdapp/eal')
+ kmods = ['contigmem', 'nic_uio']
+
+ # for building kernel modules, we use kernel build system using make, as
+ # with Linux. We have a skeleton BSDmakefile, which pulls many of its
+ # values from the environment. Each module only has a single source file
+ # right now, which allows us to simplify things. We pull in the sourcer
+ # files from the individual meson.build files, and then use a custom
+ # target to call make, passing in the values as env parameters.
+ kmod_cflags = ['-I' + meson.build_root(),
+ '-I' + join_paths(meson.source_root(), 'config'),
+ '-include rte_config.h']
+ foreach k:kmods
+ subdir(join_paths('bsdapp', k))
+ custom_target(k,
+ input: [files('bsdapp/BSDmakefile.meson'), sources],
+ output: k + '.ko',
+ command: ['make', '-f', '@INPUT0@',
+ 'KMOD_SRC=@INPUT1@',
+ 'KMOD=' + k,
+ 'VPATH=' + join_paths(meson.current_source_dir(), k),
+ 'KMOD_CFLAGS=' + ' '.join(kmod_cflags)],
+ build_by_default: get_option('enable_kmods'))
+ endforeach
else
error('unsupported system type @0@'.format(hostmachine.system()))
endif
+
+version = 6 # the version of the EAL API
+cflags += '-D_GNU_SOURCE'
+sources = common_sources + env_sources
+objs = common_objs + env_objs
+headers = common_headers + env_headers
+includes = eal_inc
diff --git a/lib/meson.build b/lib/meson.build
index b0e405f1e..76cac1023 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -29,9 +29,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# special case for eal, not a simple lib, and compat, just a header
-subdir('librte_eal')
-subdir('librte_compat')
# process all libraries equally, as far as possible
# "core" libs first, then others alphebetically as far as possible
@@ -39,7 +36,8 @@ subdir('librte_compat')
# sometimes skip deps that would be implied by others, e.g. if mempool is
# given as a dep, no need to mention ring. This is especially true for the
# core libs which are widely reused, so their deps are kept to a minimum.
-libraries = ['ring', 'mempool', 'mbuf', 'net', 'ether', 'pci', # core
+libraries = [ 'compat', # just a header, used for versioning
+ 'eal', 'ring', 'mempool', 'mbuf', 'net', 'ether', 'pci', # core
'metrics', # bitrate/latency stats depends on this
'hash', # efd depends on this
'kvargs', # cryptodev depends on this
@@ -60,13 +58,18 @@ foreach l:libraries
version = 1
sources = []
headers = []
+ includes = []
cflags = []
- objs = [] # other object files to link against, used e.g. for instruction-
- # optimized versions of code
+ objs = [] # other object files to link against, used e.g. for
+ # instruction-set optimized versions of code
+
# use "deps" for internal DPDK dependencies, and "ext_deps" for
# external package/library requirements
- deps = ['eal']
ext_deps = []
+ deps = ['eal'] # eal is standard dependency except for itself
+ if l == 'eal'
+ deps = []
+ endif
dir_name = 'librte_' + l
subdir(dir_name)
@@ -75,39 +78,48 @@ foreach l:libraries
dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1)
install_headers(headers)
- dep_objs = ext_deps
- foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
- endforeach
+ libname = 'rte_' + name
+ includes += include_directories(dir_name)
- if get_option('per_library_versions')
- lib_version = '@0@.1'.format(version)
- so_version = '@0@'.format(version)
+ if sources.length() == 0
+ # if no C files, just set a dependency on header path
+ dep = declare_dependency(include_directories: includes)
else
- pver = meson.project_version().split('.')
- lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
- so_version = lib_version
- endif
+ dep_objs = ext_deps
+ foreach d:deps
+ dep_objs += [get_variable('dep_rte_' + d)]
+ endforeach
- version_map = '@0@/@1@/rte_@2@_version.map'.format(
- meson.current_source_dir(), dir_name, name)
- libname = 'rte_' + name
- lib = library(libname,
- sources,
- objects: objs,
- c_args: cflags,
- dependencies: dep_objs,
- include_directories: include_directories(dir_name),
- link_args: '-Wl,--version-script=' + version_map,
- link_depends: version_map,
- version: lib_version,
- soversion: so_version,
- install: true)
- dep = declare_dependency(link_with: lib,
- include_directories: include_directories(dir_name),
- dependencies: dep_objs)
- set_variable('dep_' + libname, dep)
+ if get_option('per_library_versions')
+ lib_version = '@0@.1'.format(version)
+ so_version = '@0@'.format(version)
+ else
+ prj_ver = meson.project_version().split('.')
+ lib_version = '@0@.@1@'.format(
+ prj_ver.get(0), prj_ver.get(1))
+ so_version = lib_version
+ endif
- dpdk_libraries = [lib] + dpdk_libraries
- endif
+ version_map = '@0@/@1@/rte_@2@_version.map'.format(
+ meson.current_source_dir(), dir_name, name)
+ lib = library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: dep_objs,
+ include_directories: includes,
+ link_args: '-Wl,--version-script=' + version_map,
+ link_depends: version_map,
+ version: lib_version,
+ soversion: so_version,
+ install: true)
+ dep = declare_dependency(link_with: lib,
+ include_directories: includes,
+ dependencies: dep_objs)
+
+ dpdk_libraries = [lib] + dpdk_libraries
+ endif # sources.length() > 0
+
+ set_variable('dep_' + libname, dep)
+ endif # if build
endforeach
--
2.14.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 3/6] build: build all libs and drivers as both static and shared
2017-12-12 16:59 [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 1/6] build: remove library special cases Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 2/6] eal: fix list of source files to meson build Bruce Richardson
@ 2017-12-12 16:59 ` Bruce Richardson
2017-12-12 16:59 ` [dpdk-dev] [PATCH 4/6] build: change default library type to static Bruce Richardson
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2017-12-12 16:59 UTC (permalink / raw)
To: dev; +Cc: luca.boccassi, aconole, Bruce Richardson
This patch changes the build process to group all .o files for a driver or
library into a static archive first, and then link the .o files together
into a shared library. This eliminates the need for separate static or
shared object builds when packaging, for instance.
The "default_library" configuration option now only affects the apps and
examples, which are either linked against the static or shared library
versions depending on the value of the option.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test-pmd/meson.build | 4 ++--
drivers/meson.build | 43 +++++++++++++++++++++++++++-----------
drivers/net/e1000/base/meson.build | 2 +-
drivers/net/fm10k/base/meson.build | 2 +-
drivers/net/i40e/base/meson.build | 2 +-
drivers/net/ixgbe/base/meson.build | 2 +-
examples/meson.build | 2 +-
lib/meson.build | 37 ++++++++++++++++++++++++--------
meson.build | 22 +++++++------------
9 files changed, 73 insertions(+), 43 deletions(-)
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 3e591683d..b1820c77d 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -46,7 +46,7 @@ sources = files('cmdline.c',
'testpmd.c',
'txonly.c')
-deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter']
+deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
if dpdk_conf.has('RTE_LIBRTE_PDUMP')
deps += 'pdump'
endif
@@ -63,7 +63,7 @@ endif
dep_objs = []
foreach d:deps
- dep_objs += get_variable('dep_rte_' + d)
+ dep_objs += get_variable(get_option('default_library') + '_rte_' + d)
endforeach
link_libs = []
diff --git a/drivers/meson.build b/drivers/meson.build
index 889058d19..bb9a23523 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -69,11 +69,14 @@ foreach class:driver_classes
dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
# get dependency objs from strings
- dep_objs = []
+ shared_objs = []
+ static_objs = []
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ shared_objs += [get_variable('shared_rte_' + d)]
+ static_objs += [get_variable('static_rte_' + d)]
endforeach
- dep_objs += ext_deps
+ shared_objs += ext_deps
+ static_objs += ext_deps
dpdk_extra_ldflags += pkgconfig_extra_libs
# generate pmdinfo sources
@@ -83,7 +86,7 @@ foreach class:driver_classes
out_filename = '@0@.pmd.c'.format(src.split('/')[-1])
tmp_lib = static_library('tmp_@0@'.format(src.underscorify()),
src, include_directories: includes,
- dependencies: dep_objs,
+ dependencies: static_objs,
c_args: cflags)
sources += custom_target(out_filename,
command: [pmdinfo, tmp_lib.full_path(),
@@ -102,16 +105,27 @@ foreach class:driver_classes
so_version = lib_version
endif
- # now build the driver itself, and add to the drivers list
+ # now build the static driver
lib_name = driver_name_fmt.format(name)
+ static_lib = static_library(lib_name,
+ sources,
+ objects: objs,
+ include_directories: includes,
+ dependencies: static_objs,
+ c_args: cflags,
+ install: true)
+
+ # now build the shared driver
+ sources = []
+ objs += static_lib.extract_all_objects()
version_map = '@0@/@1@/@2@_version.map'.format(
meson.current_source_dir(),
drv_path, lib_name)
- lib = library(lib_name,
+ shared_lib = shared_library(lib_name,
sources,
objects: objs,
include_directories: includes,
- dependencies: dep_objs,
+ dependencies: shared_objs,
c_args: cflags,
link_args: '-Wl,--version-script=' + version_map,
link_depends: version_map,
@@ -120,14 +134,19 @@ foreach class:driver_classes
install: true,
install_dir: driver_install_path)
- dpdk_drivers += lib
-
# create a dependency object and add it to the global dictionary so
# testpmd or other built-in apps can find it if necessary
- set_variable('dep_@0@'.format(lib_name),
- declare_dependency(link_with: lib,
+ shared_dep = declare_dependency(link_with: shared_lib,
+ include_directories: includes,
+ dependencies: shared_objs)
+ static_dep = declare_dependency(link_with: static_lib,
include_directories: includes,
- dependencies: dep_objs))
+ dependencies: static_objs)
+
+ dpdk_drivers += static_lib
+
+ set_variable('shared_@0@'.format(lib_name), shared_dep)
+ set_variable('static_@0@'.format(lib_name), static_dep)
endif # build
endforeach
endforeach
diff --git a/drivers/net/e1000/base/meson.build b/drivers/net/e1000/base/meson.build
index 7c0710ec9..dfd2b914c 100644
--- a/drivers/net/e1000/base/meson.build
+++ b/drivers/net/e1000/base/meson.build
@@ -60,6 +60,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('e1000_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/fm10k/base/meson.build b/drivers/net/fm10k/base/meson.build
index 8a371b6ca..490f64918 100644
--- a/drivers/net/fm10k/base/meson.build
+++ b/drivers/net/fm10k/base/meson.build
@@ -50,6 +50,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('fm10k_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/i40e/base/meson.build b/drivers/net/i40e/base/meson.build
index 8b491ad89..9128a9c61 100644
--- a/drivers/net/i40e/base/meson.build
+++ b/drivers/net/i40e/base/meson.build
@@ -51,6 +51,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('i40e_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/drivers/net/ixgbe/base/meson.build b/drivers/net/ixgbe/base/meson.build
index 1781f2eb3..3d0404bd0 100644
--- a/drivers/net/ixgbe/base/meson.build
+++ b/drivers/net/ixgbe/base/meson.build
@@ -55,6 +55,6 @@ foreach flag: error_cflags
endforeach
base_lib = static_library('ixgbe_base', sources,
- dependencies: dep_rte_eal,
+ dependencies: static_rte_eal,
c_args: c_args)
base_objs = base_lib.extract_all_objects()
diff --git a/examples/meson.build b/examples/meson.build
index a17241817..d5397cdd0 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -45,7 +45,7 @@ foreach example: get_option('examples').split(',')
dep_objs = ext_deps
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ dep_objs += [get_variable(get_option('default_library') + '_rte_' + d)]
endforeach
executable('dpdk-' + name, sources,
include_directories: includes,
diff --git a/lib/meson.build b/lib/meson.build
index 76cac1023..d12816f55 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -83,11 +83,14 @@ foreach l:libraries
if sources.length() == 0
# if no C files, just set a dependency on header path
- dep = declare_dependency(include_directories: includes)
+ shared_dep = declare_dependency(include_directories: includes)
+ static_dep = shared_dep
else
- dep_objs = ext_deps
+ shared_deps = ext_deps
+ static_deps = ext_deps
foreach d:deps
- dep_objs += [get_variable('dep_rte_' + d)]
+ shared_deps += [get_variable('shared_rte_' + d)]
+ static_deps += [get_variable('static_rte_' + d)]
endforeach
if get_option('per_library_versions')
@@ -100,26 +103,42 @@ foreach l:libraries
so_version = lib_version
endif
+ # first build static lib
+ static_lib = static_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: static_deps,
+ include_directories: includes,
+ install: true)
+ static_dep = declare_dependency(link_with: static_lib,
+ include_directories: includes,
+ dependencies: static_deps)
+
+ # then use pre-build objects to build shared lib
+ sources = []
+ objs += static_lib.extract_all_objects()
version_map = '@0@/@1@/rte_@2@_version.map'.format(
meson.current_source_dir(), dir_name, name)
- lib = library(libname,
+ shared_lib = shared_library(libname,
sources,
objects: objs,
c_args: cflags,
- dependencies: dep_objs,
+ dependencies: shared_deps,
include_directories: includes,
link_args: '-Wl,--version-script=' + version_map,
link_depends: version_map,
version: lib_version,
soversion: so_version,
install: true)
- dep = declare_dependency(link_with: lib,
+ shared_dep = declare_dependency(link_with: shared_lib,
include_directories: includes,
- dependencies: dep_objs)
+ dependencies: shared_deps)
- dpdk_libraries = [lib] + dpdk_libraries
+ dpdk_libraries = [shared_lib] + dpdk_libraries
endif # sources.length() > 0
- set_variable('dep_' + libname, dep)
+ set_variable('shared_' + libname, shared_dep)
+ set_variable('static_' + libname, static_dep)
endif # if build
endforeach
diff --git a/meson.build b/meson.build
index ad9eabb0f..28d37ff7a 100644
--- a/meson.build
+++ b/meson.build
@@ -43,15 +43,8 @@ dpdk_libraries = []
dpdk_drivers = []
dpdk_extra_ldflags = []
-# for static libs, treat the drivers as regular libraries, otherwise
-# for shared libs, put them in a driver folder
-if get_option('default_library') == 'static'
- driver_install_path = get_option('libdir')
- eal_pmd_path = ''
-else
- driver_install_path = join_paths(get_option('libdir'), 'dpdk/drivers')
- eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
-endif
+driver_install_path = join_paths(get_option('libdir'), 'dpdk/drivers')
+eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
# configure the build, and make sure configs here and in config folder are
# able to be included in any file. We also store a global array of include dirs
@@ -80,18 +73,17 @@ configure_file(output: build_cfg,
install_dir: join_paths(get_option('includedir'),
get_option('include_subdir_arch')))
-# for static builds, include the drivers as libs, and also any
-# other dependent libs that DPDK needs to link against
-if get_option('default_library') == 'static'
- dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
- dpdk_libraries = dpdk_drivers + dpdk_libraries + dpdk_extra_ldflags
-endif
+# for static builds, include the drivers as libs and we need to "whole-archive"
+# them.
+dpdk_drivers = ['-Wl,--whole-archive'] + dpdk_drivers + ['-Wl,--no-whole-archive']
pkg = import('pkgconfig')
pkg.generate(name: meson.project_name(),
filebase: 'lib' + meson.project_name().to_lower(),
version: meson.project_version(),
libraries: dpdk_libraries,
+ libraries_private: dpdk_drivers + dpdk_libraries +
+ ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
description: 'The Data Plane Development Kit (DPDK)',
subdirs: [get_option('include_subdir_arch'), '.'],
extra_cflags: ['-include "rte_config.h"', '-march=@0@'.format(machine)]
--
2.14.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 6/6] examples: enable linking examples both static and shared
2017-12-12 16:59 [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
` (4 preceding siblings ...)
2017-12-12 16:59 ` [dpdk-dev] [PATCH 5/6] build: symlink drivers to library directory Bruce Richardson
@ 2017-12-12 16:59 ` Bruce Richardson
2017-12-12 17:14 ` [dpdk-dev] [PATCH 0/6] next-build: create both static and shared libs Bruce Richardson
2017-12-13 12:11 ` Luca Boccassi
7 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2017-12-12 16:59 UTC (permalink / raw)
To: dev; +Cc: luca.boccassi, aconole, Bruce Richardson
Since the DPDK build now includes both static and shared libraries, we need
a new way to enable building the examples using either method from the one
installation. To do this, we add in a default "shared" target, and a
separate "static" target which links in the DPDK static libraries. In both
cases, the final application name is symlinked to the last-built static or
shared target, with both binaries able to co-exist in the build directory.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
examples/bond/Makefile | 21 ++++++++++++++++-----
examples/cmdline/Makefile | 21 ++++++++++++++++-----
examples/distributor/Makefile | 21 ++++++++++++++++-----
examples/eventdev_pipeline_sw_pmd/Makefile | 21 ++++++++++++++++-----
examples/exception_path/Makefile | 21 ++++++++++++++++-----
examples/flow_classify/Makefile | 21 ++++++++++++++++-----
examples/flow_filtering/Makefile | 21 ++++++++++++++++-----
examples/helloworld/Makefile | 21 ++++++++++++++++-----
examples/ip_fragmentation/Makefile | 21 ++++++++++++++++-----
examples/ip_pipeline/Makefile | 21 ++++++++++++++++-----
examples/ip_reassembly/Makefile | 21 ++++++++++++++++-----
examples/ipsec-secgw/Makefile | 21 ++++++++++++++++-----
examples/ipv4_multicast/Makefile | 21 ++++++++++++++++-----
examples/kni/Makefile | 21 ++++++++++++++++-----
examples/l2fwd-cat/Makefile | 21 ++++++++++++++++-----
examples/l2fwd-crypto/Makefile | 21 ++++++++++++++++-----
examples/l2fwd-jobstats/Makefile | 21 ++++++++++++++++-----
examples/l2fwd-keepalive/Makefile | 21 ++++++++++++++++-----
examples/l2fwd/Makefile | 21 ++++++++++++++++-----
examples/l3fwd-acl/Makefile | 21 ++++++++++++++++-----
examples/l3fwd-power/Makefile | 21 ++++++++++++++++-----
examples/l3fwd-vf/Makefile | 21 ++++++++++++++++-----
examples/l3fwd/Makefile | 21 ++++++++++++++++-----
examples/link_status_interrupt/Makefile | 21 ++++++++++++++++-----
examples/load_balancer/Makefile | 21 ++++++++++++++++-----
examples/packet_ordering/Makefile | 21 ++++++++++++++++-----
examples/ptpclient/Makefile | 21 ++++++++++++++++-----
examples/qos_meter/Makefile | 21 ++++++++++++++++-----
examples/qos_sched/Makefile | 21 ++++++++++++++++-----
examples/rxtx_callbacks/Makefile | 21 ++++++++++++++++-----
examples/service_cores/Makefile | 21 ++++++++++++++++-----
examples/skeleton/Makefile | 21 ++++++++++++++++-----
examples/tep_termination/Makefile | 21 ++++++++++++++++-----
examples/timer/Makefile | 21 ++++++++++++++++-----
examples/vhost/Makefile | 21 ++++++++++++++++-----
examples/vhost_scsi/Makefile | 21 ++++++++++++++++-----
examples/vmdq/Makefile | 21 ++++++++++++++++-----
examples/vmdq_dcb/Makefile | 21 ++++++++++++++++-----
38 files changed, 608 insertions(+), 190 deletions(-)
diff --git a/examples/bond/Makefile b/examples/bond/Makefile
index 47e9adc77..6dc4d8279 100644
--- a/examples/bond/Makefile
+++ b/examples/bond/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/cmdline/Makefile b/examples/cmdline/Makefile
index a9b61c508..8c2edabfe 100644
--- a/examples/cmdline/Makefile
+++ b/examples/cmdline/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c commands.c parse_obj_list.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/distributor/Makefile b/examples/distributor/Makefile
index 96b250407..aa82e564e 100644
--- a/examples/distributor/Makefile
+++ b/examples/distributor/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/eventdev_pipeline_sw_pmd/Makefile b/examples/eventdev_pipeline_sw_pmd/Makefile
index 18fd35a55..9a8ac64f9 100644
--- a/examples/eventdev_pipeline_sw_pmd/Makefile
+++ b/examples/eventdev_pipeline_sw_pmd/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/exception_path/Makefile b/examples/exception_path/Makefile
index 60bcf63fa..c0af595cc 100644
--- a/examples/exception_path/Makefile
+++ b/examples/exception_path/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile
index 4a08165ae..da9ad8034 100644
--- a/examples/flow_classify/Makefile
+++ b/examples/flow_classify/Makefile
@@ -39,19 +39,30 @@ SRCS-y := flow_classify.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/flow_filtering/Makefile b/examples/flow_filtering/Makefile
index ba15651ab..01bb4cd81 100644
--- a/examples/flow_filtering/Makefile
+++ b/examples/flow_filtering/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/helloworld/Makefile b/examples/helloworld/Makefile
index e5378f118..4b5be6056 100644
--- a/examples/helloworld/Makefile
+++ b/examples/helloworld/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/ip_fragmentation/Makefile b/examples/ip_fragmentation/Makefile
index b879ed694..6c183be5e 100644
--- a/examples/ip_fragmentation/Makefile
+++ b/examples/ip_fragmentation/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 0d36ff223..a69d18bd4 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -62,9 +62,17 @@ SRCS-y += pipeline_routing.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
VPATH += pipeline
CFLAGS += -I. -I./pipeline/
@@ -74,15 +82,18 @@ OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
build/%.o: %.c Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) -c $< -o $@
-build/$(APP): $(OBJS)
- $(CC) $(OBJS) -o $@ $(LDFLAGS)
+build/$(APP)-shared: $(OBJS)
+ $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
+
+build/$(APP)-static: $(OBJS)
+ $(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP) build/*.o
+ rm -f build/$(APP)* build/*.o
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/ip_reassembly/Makefile b/examples/ip_reassembly/Makefile
index f20f89744..650bede8c 100644
--- a/examples/ip_reassembly/Makefile
+++ b/examples/ip_reassembly/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/ipsec-secgw/Makefile b/examples/ipsec-secgw/Makefile
index a299e45ce..e0e93e2ec 100644
--- a/examples/ipsec-secgw/Makefile
+++ b/examples/ipsec-secgw/Makefile
@@ -49,19 +49,30 @@ CFLAGS += -gdwarf-2
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/ipv4_multicast/Makefile b/examples/ipv4_multicast/Makefile
index 5278c15ef..e33c7fc2f 100644
--- a/examples/ipv4_multicast/Makefile
+++ b/examples/ipv4_multicast/Makefile
@@ -40,19 +40,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/kni/Makefile b/examples/kni/Makefile
index 63d57472c..fc6b89bf6 100644
--- a/examples/kni/Makefile
+++ b/examples/kni/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index 308a4e078..6182dbde0 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -39,22 +39,33 @@ SRCS-y := l2fwd-cat.c cat.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
CFLAGS += -D_GNU_SOURCE
LDFLAGS += -lpqos
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
+
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index afa32b010..bc9f65987 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l2fwd-jobstats/Makefile b/examples/l2fwd-jobstats/Makefile
index 315daf691..779d3c652 100644
--- a/examples/l2fwd-jobstats/Makefile
+++ b/examples/l2fwd-jobstats/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l2fwd-keepalive/Makefile b/examples/l2fwd-keepalive/Makefile
index a4daeeb04..b5dbf41c1 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -40,19 +40,30 @@ LDFLAGS += -lrt
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile
index 55a67d636..3cc347830 100644
--- a/examples/l2fwd/Makefile
+++ b/examples/l2fwd/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile
index afd7421ff..78f6df7e5 100644
--- a/examples/l3fwd-acl/Makefile
+++ b/examples/l3fwd-acl/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l3fwd-power/Makefile b/examples/l3fwd-power/Makefile
index c17e66db3..c0cddcb5c 100644
--- a/examples/l3fwd-power/Makefile
+++ b/examples/l3fwd-power/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l3fwd-vf/Makefile b/examples/l3fwd-vf/Makefile
index f3b324db0..d7aae9e10 100644
--- a/examples/l3fwd-vf/Makefile
+++ b/examples/l3fwd-vf/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 41abfe7f6..a1f505ac4 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/link_status_interrupt/Makefile b/examples/link_status_interrupt/Makefile
index 0e36eac0c..8ed14f120 100644
--- a/examples/link_status_interrupt/Makefile
+++ b/examples/link_status_interrupt/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/load_balancer/Makefile b/examples/load_balancer/Makefile
index 458e712de..d767b4302 100644
--- a/examples/load_balancer/Makefile
+++ b/examples/load_balancer/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c config.c init.c runtime.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/packet_ordering/Makefile b/examples/packet_ordering/Makefile
index a9b4eb016..78e26fad0 100644
--- a/examples/packet_ordering/Makefile
+++ b/examples/packet_ordering/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/ptpclient/Makefile b/examples/ptpclient/Makefile
index 7ed57d9fc..bf5d2991e 100644
--- a/examples/ptpclient/Makefile
+++ b/examples/ptpclient/Makefile
@@ -39,19 +39,30 @@ SRCS-y := ptpclient.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 34879e105..01c7804ca 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c rte_policer.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/qos_sched/Makefile b/examples/qos_sched/Makefile
index f33c5b61d..f082e06fd 100644
--- a/examples/qos_sched/Makefile
+++ b/examples/qos_sched/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c args.c init.c app_thread.c cfg_file.c cmdline.c stats.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
index 40989fdd5..88f17f63f 100644
--- a/examples/rxtx_callbacks/Makefile
+++ b/examples/rxtx_callbacks/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/service_cores/Makefile b/examples/service_cores/Makefile
index aada19497..09cbc49ed 100644
--- a/examples/service_cores/Makefile
+++ b/examples/service_cores/Makefile
@@ -38,19 +38,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else
diff --git a/examples/skeleton/Makefile b/examples/skeleton/Makefile
index ff13e7888..e8a621b07 100644
--- a/examples/skeleton/Makefile
+++ b/examples/skeleton/Makefile
@@ -39,19 +39,30 @@ SRCS-y := basicfwd.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile
index 52149a4b0..0354733fe 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c vxlan_setup.c vxlan.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/timer/Makefile b/examples/timer/Makefile
index dc1fb74ce..716a2780e 100644
--- a/examples/timer/Makefile
+++ b/examples/timer/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index de0c8d872..562e56e19 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c virtio_net.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/vhost_scsi/Makefile b/examples/vhost_scsi/Makefile
index 29b654da6..593ca8962 100644
--- a/examples/vhost_scsi/Makefile
+++ b/examples/vhost_scsi/Makefile
@@ -41,19 +41,30 @@ CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index bd2aae34c..0a0eae714 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
diff --git a/examples/vmdq_dcb/Makefile b/examples/vmdq_dcb/Makefile
index d75498c45..1cd2ec1ea 100644
--- a/examples/vmdq_dcb/Makefile
+++ b/examples/vmdq_dcb/Makefile
@@ -39,19 +39,30 @@ SRCS-y := main.c
$(shell pkg-config --exists libdpdk)
ifeq ($(.SHELLSTATUS),0)
+all: shared
+.PHONY: shared static
+shared: build/$(APP)-shared
+ ln -sf $(APP)-shared build/$(APP)
+static: build/$(APP)-static
+ ln -sf $(APP)-static build/$(APP)
+
PC_FILE := $(shell pkg-config --path libdpdk)
-CFLAGS += $(shell pkg-config --cflags libdpdk)
-LDFLAGS += $(shell pkg-config --libs libdpdk)
+CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
+LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
+LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP): $(SRCS-y) Makefile $(PC_FILE) | build
- $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS)
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@mkdir -p $@
.PHONY: clean
clean:
- rm -f build/$(APP)
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
rmdir --ignore-fail-on-non-empty build
else # Build using legacy build system
--
2.14.3
^ permalink raw reply [flat|nested] 14+ messages in thread