-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·128 lines (112 loc) · 2.58 KB
/
configure
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
127
128
#!/bin/sh
set -eu
DOCKER='docker'
DOCKER_GOLANG_IMG='golang:latest'
GO='go'
M4='m4'
USE_DOCKER='TEST'
USE_DOCKER_GO='TEST'
HELP_MSG="./configure [ OPTIONS ]
Available options:
-h, --help
Print this message.
--with-m4=CMD
Explicitly specify m4 command.
Default: ${M4}
--with-docker[=CMD]
Explicitly specify use of Docker. Optionally specify base
docker command to use (not including mount option, image name,
or go command).
Default: ${DOCKER} (if present)
--without-docker
Explicitly specify not to use Docker.
Default: use if present
--with-docker-golang[=IMG]
Explicitly specify the use of Docker-based golang instead of
the host golang binary (which will be used by default if it
exists). Optionally specify the image name to use.
Default: ${DOCKER_GOLANG_IMG} (if no local go binary)
--with-go=CMD
Explicitly specify golang command.
Default: ${GO} (if present)
"
while [ $# -ne 0 ]; do
case $1 in
--with-m4=*)
M4="`echo -n ${1} | sed 's/^--with-m4=\(.*\)$/\1/'`"
;;
--with-docker=*)
DOCKER="`echo -n ${1} | sed 's/^--with-docker=\(.*\)$/\1/'`"
USE_DOCKER='TRUE'
;;
--with-docker)
USE_DOCKER='TRUE'
;;
--without-docker)
USE_DOCKER='FALSE'
;;
--with-docker-golang=*)
DOCKER_GOLANG_IMG="`echo -n ${1} \
| sed 's/^--with-docker-golang=\(.*\)$/\1/'`"
USE_DOCKER='TRUE'
USE_DOCKER_GO='TRUE'
;;
--with-docker-golang)
USE_DOCKER='TRUE'
USE_DOCKER_GO='TRUE'
;;
--with-go=*)
GO="`echo -n ${1} | sed 's/^--with-go=\(.*\)$/\1/'`"
;;
--help|-h)
echo "${HELP_MSG}"
exit 0
;;
*)
echo "${HELP_MSG}" >&2
exit 1
;;
esac
shift
done
if [ "x${USE_DOCKER}" = 'xTEST' ]; then
echo -n 'checking for docker... '
if command -V docker; then
USE_DOCKER='TRUE'
else
USE_DOCKER='FALSE'
fi
fi
if [ "x${USE_DOCKER_GO}" = 'xTEST' ]; then
echo -n 'checking for go... '
if command -V go; then
USE_DOCKER_GO='FALSE'
else
USE_DOCKER_GO='TRUE'
echo 'no local go binary, dockerized golang required'
fi
fi
if [ "x${USE_DOCKER_GO}" = 'xTRUE' ]; then
if [ "x${USE_DOCKER}" = 'xFALSE' ]; then
echo 'docker required for dockerized golang, aborting' >&2
exit 1
fi
fi
if [ "x${USE_DOCKER}" = 'xTRUE' ]; then
USE_DOCKER_FLAG='-D _USE_DOCKER_'
else
USE_DOCKER_FLAG='-U _USE_DOCKER_'
fi
if [ "x${USE_DOCKER_GO}" = 'xTRUE' ]; then
USE_DOCKER_GO_FLAG='-D _USE_DOCKER_GO_'
else
USE_DOCKER_GO_FLAG='-U _USE_DOCKER_GO_'
fi
echo -n "\nwriting out Makefile... "
${M4} \
-D _GO_CMD_="${GO}" \
-D _DOCKER_CMD_="${DOCKER}" \
-D _DOCKER_GOLANG_IMG_="${DOCKER_GOLANG_IMG}" \
${USE_DOCKER_FLAG} ${USE_DOCKER_GO_FLAG} \
< Makefile.in > Makefile
echo 'done'