summaryrefslogtreecommitdiff
path: root/packaging/nacl/ports/zlib/build.sh
blob: 96c860fd078671aa349ff3a4171aec8e66d6e4ad (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
#!/bin/bash
# Copyright (c) 2011 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# zlib doesn't support custom build directories so we have
# to build directly in the source dir.
BUILD_DIR=${SRC_DIR}
EXECUTABLES="minigzip${NACL_EXEEXT} example${NACL_EXEEXT}"
if [ "${NACL_SHARED}" = "1" ]; then
  EXECUTABLES+=" libz.so.1"
fi

ConfigureStep() {
  LogExecute rm -f libz.*
  SetupCrossEnvironment
  CHOST=${NACL_CROSS_PREFIX} LogExecute ./configure --prefix=${PREFIX}
}


RunMinigzip() {
#  export LD_LIBRARY_PATH=.
#  if echo "hello world" | ./minigzip | ./minigzip -d; then
#    echo '  *** minigzip test OK ***'
#  else
#    echo '  *** minigzip test FAILED ***'
#    exit 1
#  fi
#  unset LD_LIBRARY_PATH
    return 0
}


RunExample() {
  export LD_LIBRARY_PATH=.
  # This second test does not yet work on nacl (gzopen fails)
  #if ./example; then \
    #echo '  *** zlib test OK ***'; \
  #else \
    #echo '  *** zlib test FAILED ***'; \
    #exit 1
  #fi
  unset LD_LIBRARY_PATH
}


TestStep() {
  if [ "${NACL_LIBC}" = "glibc" ]; then
    # Tests do not currently run on GLIBC due to fdopen() not working
    # TODO(sbc): Remove this once glibc is fixed:
    # https://code.google.com/p/nativeclient/issues/detail?id=3362
    return
  fi

  if [ "${NACL_ARCH}" = "pnacl" ]; then
    local minigzip_pexe="minigzip${NACL_EXEEXT}"
    local example_pexe="example${NACL_EXEEXT}"
    local minigzip_script="minigzip"
    local example_script="example"
    TranslateAndWriteSelLdrScript ${minigzip_pexe} x86-32 \
      minigzip.x86-32.nexe ${minigzip_script}
    RunMinigzip
    TranslateAndWriteSelLdrScript ${minigzip_pexe} x86-64 \
      minigzip.x86-64.nexe ${minigzip_script}
    RunMinigzip
    TranslateAndWriteSelLdrScript ${example_pexe} x86-32 \
      example.x86-32.nexe ${example_script}
    RunExample
    TranslateAndWriteSelLdrScript ${example_pexe} x86-64 \
      example.x86-64.nexe ${example_script}
    RunExample
  else
    RunMinigzip
    RunExample
  fi
}