aboutsummaryrefslogtreecommitdiff
path: root/meson.build
blob: b4a8a0459f89cead445363bfec760c291979cb11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
project('lpm',
    ['c'],
    version : '1.0.4',
    license : 'LPM',
    meson_version : '>= 0.56',
)

cc = meson.get_compiler('c')

zlib_dep = dependency('zlib')
mbedtls_dep = dependency('mbedtls', required: false)
libgit2_dep = dependency('libgit2')
libzip_dep = dependency('libzip')
lua_dep = dependency('lua')
microtar_dep = dependency('microtar', required: false)

if not mbedtls_dep.found()
    mbedtls_dep = [
        cc.find_library('mbedtls'),
        cc.find_library('mbedx509'),
        cc.find_library('mbedcrypto'),
    ]
endif

if not microtar_dep.found()
    microtar_lib = static_library('microtar', files('lib/microtar/src/microtar.c'))

    microtar_dep = declare_dependency(
        link_whole: [microtar_lib],
        include_directories: ['lib/microtar/src']
    )

    message('Using git module for microtar')
endif

lpm_source = files('src/lpm.c')
cargs = []
if get_option('static')
    lua_exe = find_program('lua')
    xxd_exe = find_program('xxd')

    lpm_luac = configure_file(
        capture: false,
        command: [lua_exe, '-e', 'io.open("@OUTPUT0@", "wb"):write(string.dump(assert(loadfile("@INPUT0@"))))'],
        input: files('src/lpm.lua'),
        output: 'lpm.luac'
    )

    lpm_source += configure_file(
        capture: true,
        command: [xxd_exe, '-i', '@INPUT@'],
        input: lpm_luac,
        output: 'lpm.lua.c'
    )

endif

executable('lpm', lpm_source, dependencies: [zlib_dep, mbedtls_dep, libgit2_dep, libzip_dep, lua_dep, microtar_dep])