xref: /dpdk/app/meson.build (revision be22019a58c484c0b43ec32de8cd4e58a91aa53f)
16c9457c2SBruce Richardson# SPDX-License-Identifier: BSD-3-Clause
2fa647c57SAnand Rawat# Copyright(c) 2017-2019 Intel Corporation
3fa647c57SAnand Rawat
4f15114c6STyler Retzlaffif is_ms_compiler
5f15114c6STyler Retzlaff    subdir_done()
6f15114c6STyler Retzlaffendif
7f15114c6STyler Retzlaff
8ecf75180SDavid Marchanddisable_apps = ',' + get_option('disable_apps')
9ecf75180SDavid Marchanddisable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
10ecf75180SDavid Marchand
11ecf75180SDavid Marchandenable_apps = ',' + get_option('enable_apps')
12ecf75180SDavid Marchandenable_apps = run_command(list_dir_globs, enable_apps, check: true).stdout().split()
135d98c8fdSDavid Marchandrequire_apps = true
14ecf75180SDavid Marchandif enable_apps.length() == 0
155d98c8fdSDavid Marchand    require_apps = false
16ecf75180SDavid Marchand    enable_apps = run_command(list_dir_globs, '*', check: true).stdout().split()
17ecf75180SDavid Marchandendif
18ab2bb504SMarkus Theil
190c36081dSBruce Richardsonapps = [
20cbb44143SStephen Hemminger        'dumpcap',
215b21ffb2SSunil Kumar Kori        'graph',
220c36081dSBruce Richardson        'pdump',
23996ef117SBruce Richardson        'proc-info',
2475795fabSBruce Richardson        'test-acl',
25996ef117SBruce Richardson        'test-bbdev',
260c36081dSBruce Richardson        'test-cmdline',
27e0b6287cSTomasz Jozwiak        'test-compress-perf',
28996ef117SBruce Richardson        'test-crypto-perf',
29623dc936SCheng Jiang        'test-dma-perf',
30996ef117SBruce Richardson        'test-eventdev',
31dc38ae8dSVladimir Medvedkin        'test-fib',
323344cf2eSWisam Jaddo        'test-flow-perf',
338b8036a6SElena Agostini        'test-gpudev',
34ac930a55SSrikanth Yalavarthi        'test-mldev',
35474572d2SBruce Richardson        'test-pipeline',
36908be065SVladimir Medvedkin        'test-pmd',
37de06137cSYuval Avnery        'test-regex',
3823bd8128SBruce Richardson        'test-sad',
391f5cfe96SAnoob Joseph        'test-security-perf',
4023bd8128SBruce Richardson]
41fa036e70SBruce Richardson
4250823f30SBruce Richardsonif get_option('tests')
4350823f30SBruce Richardson# build the auto test app if enabled.
4450823f30SBruce Richardson    apps += 'test'
4550823f30SBruce Richardsonendif
4650823f30SBruce Richardson
47acec04c4SPavan Nikhileshdefault_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
48b031e13dSOlivier Matzdefault_ldflags = []
49da042bcfSDmitry Kozlyukif get_option('default_library') == 'static' and not is_windows
50b031e13dSOlivier Matz    default_ldflags += ['-Wl,--export-dynamic']
51b031e13dSOlivier Matzendif
525d7b673dSAnatoly Burakov
53fa036e70SBruce Richardsonforeach app:apps
54fa036e70SBruce Richardson    name = app
55ecf75180SDavid Marchand    build = true
56ecf75180SDavid Marchand    reason = '<unknown reason>' # set if build == false to explain
57fa036e70SBruce Richardson    sources = []
58*be22019aSStephen Hemminger    resources = []
59fa036e70SBruce Richardson    includes = []
605d7b673dSAnatoly Burakov    cflags = default_cflags
61b031e13dSOlivier Matz    ldflags = default_ldflags
62fa036e70SBruce Richardson    objs = [] # other object files to link against, used e.g. for
63fa036e70SBruce Richardson              # instruction-set optimized versions of code
64fa036e70SBruce Richardson
65fa036e70SBruce Richardson    # use "deps" for internal DPDK dependencies, and "ext_deps" for
66fa036e70SBruce Richardson    # external package/library requirements
67fa036e70SBruce Richardson    ext_deps = []
68607164e2SBruce Richardson    deps = []
69fa036e70SBruce Richardson
70ecf75180SDavid Marchand    if not enable_apps.contains(app)
71ecf75180SDavid Marchand        build = false
72ecf75180SDavid Marchand        reason = 'not in enabled apps build config'
73ecf75180SDavid Marchand    elif disable_apps.contains(app)
74ecf75180SDavid Marchand        build = false
75ecf75180SDavid Marchand        reason = 'explicitly disabled via build config'
76ab2bb504SMarkus Theil    endif
77ab2bb504SMarkus Theil
78ecf75180SDavid Marchand    if build
79fa036e70SBruce Richardson        subdir(name)
805d98c8fdSDavid Marchand        if not build and require_apps
815d98c8fdSDavid Marchand            error('Cannot build explicitly requested app "@0@".\n'.format(name)
825d98c8fdSDavid Marchand                  + '\tReason: ' + reason)
835d98c8fdSDavid Marchand        endif
84ecf75180SDavid Marchand    endif
85fa036e70SBruce Richardson
86cbff4d8dSDavid Marchand    if build
87cbff4d8dSDavid Marchand        dep_objs = []
88cbff4d8dSDavid Marchand        foreach d:deps
89cbff4d8dSDavid Marchand            var_name = get_option('default_library') + '_rte_' + d
90cbff4d8dSDavid Marchand            if not is_variable(var_name)
91cbff4d8dSDavid Marchand                build = false
92ecf75180SDavid Marchand                reason = 'missing internal dependency, "@0@"'.format(d)
93cbff4d8dSDavid Marchand                message('Missing dependency "@0@" for app "@1@"'.format(d, name))
945d98c8fdSDavid Marchand                if require_apps
955d98c8fdSDavid Marchand                    error('Cannot build explicitly requested app "@0@".\n'.format(name)
965d98c8fdSDavid Marchand                          + '\tPlease add missing dependency "@0@" to "enable_libs" option'.format(d))
975d98c8fdSDavid Marchand                endif
98cbff4d8dSDavid Marchand                break
99cbff4d8dSDavid Marchand            endif
100cbff4d8dSDavid Marchand            dep_objs += [get_variable(var_name)]
101cbff4d8dSDavid Marchand        endforeach
102cbff4d8dSDavid Marchand    endif
103cbff4d8dSDavid Marchand
10423bd8128SBruce Richardson    if not build
105ecf75180SDavid Marchand        if reason != ''
106ecf75180SDavid Marchand            dpdk_apps_disabled += app
107a206a015SDavid Marchand            set_variable('app_' + app.underscorify() + '_disable_reason', reason)
108ecf75180SDavid Marchand        endif
10923bd8128SBruce Richardson        continue
11023bd8128SBruce Richardson    endif
11123bd8128SBruce Richardson
112405737aaSDavid Marchand    dpdk_apps_enabled += app
113fa036e70SBruce Richardson    link_libs = []
114fa036e70SBruce Richardson    if get_option('default_library') == 'static'
11557ae0ec6SKevin Laatz        link_libs = dpdk_static_libraries + dpdk_drivers
116fa036e70SBruce Richardson    endif
117fa036e70SBruce Richardson
1180aeaf75dSBruce Richardson    exec = executable('dpdk-' + name,
119*be22019aSStephen Hemminger            [ sources, resources ],
120fa036e70SBruce Richardson            c_args: cflags,
121b031e13dSOlivier Matz            link_args: ldflags,
122fa036e70SBruce Richardson            link_whole: link_libs,
1230eb62bf2SDavid Marchand            dependencies: ext_deps + dep_objs,
12464fd2124SBruce Richardson            include_directories: includes,
12523bd8128SBruce Richardson            install_rpath: join_paths(get_option('prefix'), driver_install_path),
126fa036e70SBruce Richardson            install: true)
1270aeaf75dSBruce Richardson    if name == 'test'
1280aeaf75dSBruce Richardson        dpdk_test = exec
1290aeaf75dSBruce Richardson        autotest_sources = sources
1300aeaf75dSBruce Richardson        subdir('test/suites')  # define the pre-canned test suites
1310aeaf75dSBruce Richardson    endif
132fa036e70SBruce Richardsonendforeach
133