summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/scripts/build.sh
blob: 47e5dcc795bfaa19a7fe27cef65b6e71b58d03a1 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# shellcheck source=./rebash/core.sh
source "$(dirname "${BASH_SOURCE[0]}")/rebash/core.sh"
core.import logging

build_compile_qemu_xmount() {
    local __doc__='
    Compiles qemu libxmount.
    NOTE: expects xmount installation under
    $1/../xmount/trunk/build/release_build/

    Provides the following file:
    "$1/libxmount_input_qemu.so"

    Example:

    `build_compile_qemu_xmount /qemu_source /xmount/installation`
    '
    pushd "$1"
    local xmount_installation="../xmount/trunk/build/release_build/usr"
    [ ! -z "$2" ] && xmount_installation="$2"
    ./configure --enable-xmount-input --python="$(which python2)" \
        --extra-cflags="-fPIC" \
        --extra-cflags="-std=gnu99" \
        --extra-cflags="-I${xmount_installation}/include" \
        --extra-cflags="-I${xmount_installation}/include/xmount" \
        --disable-fdt --target-list=""
    make -j4 libxmount_input_qemu.so
    local ret=$?
    popd
    return $ret
}
build_clean_qemu_xmount() {
    local __doc__='Clean the build of `build_compile_qemu_xmount`.'
    pushd "$1"
    make clean
    popd
    return $?
}
build_compile_xmount() {
    local __doc__='
    Compiles xmount.

    Provides the xmount installation under:
    "$1/trunk/build/release_build/"

    Example:

    `build_compile_xmount /xmount_source /xmount_source/build /usr`
    '
    pushd "$1"

    local destination_directory="./release_build"
    [ ! -z "$2" ] && destination_directory="$2"
    local install_prefix="/usr"
    [ ! -z "$3" ] && install_prefix="$3"

    mkdir --parents trunk/build
    cd trunk/build || return 1
    cmake -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX="$install_prefix" ..
    make -j4
    make install DESTDIR="$destination_directory"
    local ret=$?
    popd
    return $ret
}
build_clean_xmount() {
    local __doc__='Clean the build of `build_compile_xmount`.'
    rm --recursive --force "$1/trunk/build"
}
build_compile_dnbd3() {
    local __doc__='
    Compiles dnbd3 kernel module and client.

    Provides the following file:
    "$1/build/dnbd3.ko"
    "$1/build/dnbd3-client"

    Examples:

    `build_compile_dnbd3 path/to/dnbd3/source/`
    '
    pushd "$1"
    # NOTE: The generic way would be: "./build.sh" but this tries to build
    # more than we really need and takes more time.
    mkdir --parents build
    pushd build
    cmake ../
    make -j4 dnbd3 dnbd3-client
    popd
    return $?
}
build_clean_dnbd3() {
    local __doc__='Clean the build of `build_compile_dnbd3`.'
    rm --recursive --force "$1/build"
    return $?
}
build_compile_systemd_preserve_process_marker() {
    local __doc__='
    Compiles simple c program.

    Examples:

    `build_compile_systemd_preserve_process_marker path/to/program/folder`
    '
    pushd "$1"
    make
    popd
    return $?
}
build_clean_systemd_preserve_process_marker() {
    local __doc__='
    Clean the build of
    `build_compile_systemd_preserve_process_marker`.
    '
    pushd "$1"
    make clean
    popd
    return $?
}
# region vim modline
# vim: set tabstop=4 shiftwidth=4 expandtab:
# vim: foldmethod=marker foldmarker=region,endregion:
# endregion