File: build-mbedtls

package info (click to toggle)
openvpn3-client 24.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 19,384 kB
  • sloc: cpp: 180,128; python: 11,591; ansic: 1,878; sh: 1,767; java: 402; lisp: 81; makefile: 44
file content (100 lines) | stat: -rwxr-xr-x 2,044 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -e
if [ -z "$O3" ]; then
    echo O3 var must point to ovpn3 tree
    exit 1
fi
if [ -z "$DEP_DIR" ]; then
    echo DEP_DIR var must point to dependency build folder
    exit 1
fi
if [ -z "$DL" ]; then
    echo DL var must point to the download folder
    exit 1
fi

if [ -z "$TARGET" ]; then
    echo TARGET var must be defined
    exit 1
fi

# source vars
. $O3/core/vars/vars-${TARGET}
. $O3/core/deps/lib-versions

# source helper functions
. $O3/core/deps/functions.sh

FNAME=${MBEDTLS_VERSION}.tar.gz
PN=${MBEDTLS_VERSION#*-}
URL=https://github.com/ARMmbed/mbedtls/archive/refs/tags/v${PN}.tar.gz
CSUM=${MBEDTLS_CSUM}

download

# put build targets here
DIST=$(pwd)/mbedtls/mbedtls-$PLATFORM
rm -rf $DIST
mkdir -p $DIST

if [ "$NO_WIPE" = "1" ]; then
    echo RETAIN existing source
    cd $MBEDTLS_VERSION
else
    echo WIPE and reunzip source
    rm -rf $MBEDTLS_VERSION
    [ -z "$DL" ] && DL=~/Downloads
    tar xfz $DL/$MBEDTLS_VERSION.tar.gz
    cd $MBEDTLS_VERSION

    # enable MD4 (needed for NTLM auth)
    perl -pi -e 's/^\/\/// if /#define MBEDTLS_MD4_C/' include/mbedtls/config.h
fi

if [ "x$NO_BUILD" == x1 ]; then
   echo "Not building"
   exit 0
fi

if [[ "x$TARGET" == xlinux* || "x$TARGET" == xosx* ]]; then
    # run unit tests and then clean
    echo RUNNING CHECK
    make check
    echo CLEANING
    make clean
fi

echo BUILDING

# compiler vars
CC=cc
LD=ld
AR="ar rc"
RANLIB=ranlib
[ "$GCC_CMD" ] && CC=$GCC_CMD
[ "$LD_CMD" ] && LD=$LD_CMD
[ "$AR_CMD" ] && AR="$AR_CMD"
[ "$RANLIB_CMD" ] && RANLIB="$RANLIB_CMD"

# build it
SRC=$(pwd)
cd library
rm -f *.o
for c in *.c ; do
    CMD="$CC -I../include -DMBEDTLS_RELAXED_X509_DATE \
         $PLATFORM_FLAGS $(lto_flags $c) $OTHER_COMPILER_FLAGS $LIB_OPT_LEVEL $LIB_FPIC -c $c"
    echo $CMD
    $CMD
done

# create archive
cd $DIST
mkdir library
$AR library/libmbedtls.a $SRC/library/*.o
$RANLIB library/libmbedtls.a 2>&1 | grep -v "has no symbols" || true

# copy headers
mkdir -p include/mbedtls
cp $SRC/include/mbedtls/*.h include/mbedtls/
exit 0