lib: build with meson
[dpdk.git] / lib / meson.build
index 7cafe66..a4f5f28 100644 (file)
 #   (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
+# NOTE: for speed of meson runs, the dependencies in the subdirectories
+# 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
+       'metrics', # bitrate/latency stats depends on this
+       'hash',    # efd depends on this
+       'kvargs',  # cryptodev depends on this
+       'acl', 'bbdev', 'bitratestats', 'cfgfile',
+       'cmdline', 'cryptodev',
+       'distributor', 'efd', 'eventdev',
+       'gro', 'gso', 'ip_frag', 'jobstats',
+       'kni', 'latencystats', 'lpm', 'member',
+       'meter', 'power', 'pdump',
+       'reorder', 'sched', 'security', 'timer', 'vhost',
+       # add pkt framework libs which use other libs from above
+       'port', 'table', 'pipeline',
+       # flow_classify lib depends on pkt framework table lib
+       'flow_classify']
+
+foreach l:libraries
+       build = true
+       name = l
+       version = 1
+       allow_experimental_apis = false
+       sources = []
+       headers = []
+       cflags = []
+       objs = [] # other object files to link against, used e.g. for instruction-
+                 # optimized versions of code
+       # use "deps" for internal DPDK dependencies, and "ext_deps" for
+       # external package/library requirements
+       deps = ['eal']
+       ext_deps = []
+
+       dir_name = 'librte_' + l
+       subdir(dir_name)
+
+       if build
+               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
+
+               if allow_experimental_apis
+                       cflags += '-DALLOW_EXPERIMENTAL_API'
+               endif
+
+               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: '@0@.1'.format(version),
+                               install: true)
+               dep = declare_dependency(link_with: lib,
+                               include_directories: include_directories(dir_name),
+                               dependencies: dep_objs)
+               set_variable('dep_' + libname, dep)
+
+               dpdk_libraries = [lib] + dpdk_libraries
+       endif
+endforeach