summaryrefslogtreecommitdiff
path: root/src/third_party/scripts/zlib_get_sources.sh
blob: ab9d16cb008f7f3677c697c646169523ef671f61 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash

set -o verbose
set -o errexit

# This script downloads and import zlib
# Zlib does not need to use any autotools/cmake/config system to it is a simple import.
# This script is designed to run on most unix-like OSes
#

VERSION=1.2.13
NAME=zlib
TARBALL=${NAME}-${VERSION}.tar.gz
TARBALL_DEST_DIR=${NAME}-${VERSION}
DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/${NAME}-${VERSION}

echo ${DEST_DIR}

rm -fr ${TARBALL_DEST_DIR}
rm -f ${TARBALL}

if [ ! -f ${TARBALL} ]; then
    echo "Get tarball"
    wget https://www.zlib.net/${TARBALL}
fi

tar -zxvf ${TARBALL}

rm -rf ${DEST_DIR}
mkdir ${DEST_DIR}

# Just move the sources
mv ${TARBALL_DEST_DIR}/*.{h,c} ${DEST_DIR}

# Move the readme and such.
mv ${TARBALL_DEST_DIR}/{README,FAQ,INDEX} ${DEST_DIR}

rm -fR ${TARBALL_DEST_DIR}


# Generate the SConscript
( cat > ${DEST_DIR}/SConscript ) << ___EOF___
# -*- mode: python; -*-
# NOTE: This file is auto-generated by "$(basename $0)" - DO NOT EDIT

Import("env")

env = env.Clone()

env.Append(CPPDEFINES=["HAVE_STDARG_H"])
if not env.TargetOSIs('windows'):
    env.Append(CPPDEFINES=["HAVE_UNISTD_H"])

env.Library(
    target="zlib",
    source=[
        'adler32.c',
        'crc32.c',
        'compress.c',
        'deflate.c',
        'infback.c',
        'inffast.c',
        'inflate.c',
        'inftrees.c',
        'trees.c',
        'uncompr.c',
        'zutil.c',
    ],
    LIBDEPS_TAGS=[
        'init-no-global-side-effects',
    ],
)
___EOF___

rm -f ${TARBALL}


# Note: There are no config.h or other build artifacts to generate
echo "Done"