summaryrefslogtreecommitdiff
path: root/configure
blob: 57a8b95374c1fab0b3e2ab41b2dde6213ef3bb51 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash

set -eu

prefix=/usr/local

usage() {
  echo "Usage: ./configure [OPTION]"
  echo
  echo "Configuration:"
  echo "  -h, --help              display this help and exit"
  echo
  echo "Installation directories:"
  echo "  --prefix=PREFIX         install architecture-independent files in PREFIX [$prefix]"
}


# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
    echo 'getopt not available'
    exit 1
fi

LONGOPTS=prefix:,help
OPTIONS=h

! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
    # e.g. return value is 1
    #  then getopt has complained about wrong arguments to stdout
    exit 2
fi

# read getopt’s output this way to handle the quoting right:
eval set -- "$PARSED"

while true; do
    case "$1" in
      --prefix)
        prefix="$2"
        shift 2
        ;;
      -h|--help)
        usage
        exit 1
        ;;
      --)
        shift
        break
        ;;
      *)
        echo "Programming error"
        exit 3
        ;;
    esac
done

cat << EOF > config.mk
# this file is autogenerated by ./configure
prefix=$prefix
EOF

node_version=$(node --version)
if [ ! "$?" -eq 0 ]; then
  echo 'Error: node executable not found.'
  echo 'If you are using ubuntu or debian, try installing the'
  echo 'node-legacy package or symlink node to nodejs.'
  exit 1
fi
echo "Using node ${node_version}"

if ! node -p 'process.exit(!(/v([0-9]+)/.exec(process.version)[1] >= 4))'; then
  echo 'Your node version is too old, use something >v4.x.x'
  exit 1
fi

if ! yarn --version &>/dev/null; then
  echo 'Error: yarn missing. See https://yarnpkg.com/en/docs/install'
  exit 1
fi

if ! find --version &>/dev/null; then
  echo 'Error: find missing'
  exit 1
fi

if ! xargs --version &>/dev/null; then
  echo 'Error: xargs missing'
  exit 1
fi

if ! msgmerge --version &>/dev/null; then
  echo "Warning: msgmerge missing, i18n won't work"
  exit 1
fi