-
Notifications
You must be signed in to change notification settings - Fork 86
/
configure
executable file
·188 lines (148 loc) · 4.38 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#! /usr/bin/env bash
#
# copyright (c) 2015 Zhang Rui <[email protected]>
#
# This file is part of jni4android.
#
# jni4android is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# jni4android is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with jni4android; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#/
build_root_dir=`pwd`
die_unknown(){
echo "Unknown option \"$1\"."
echo "See $0 --help for available options."
exit 1
}
is_in(){
value=$1
shift
for var in $*; do
[ $var = $value ] && return 0
done
return 1
}
#----- define options -----
PATHS_LIST="
bindir
incdir
prefix
"
CMDLINE_SET="
$PATHS_LIST
cxx
yacc
yylex
"
#----- init options -----
opt_prefix_default="output"
opt_cxx_default="clang++"
opt_yacc_default="bison"
opt_yylex_default="flex"
# auto detect bison
YACC_LIST="
$build_root_dir/contrib/build/bin/bison
/usr/local/opt/bison/bin/bison
"
for alter_yacc in $YACC_LIST; do
if [ -f $alter_yacc ]; then
opt_yacc_default=$alter_yacc
break
fi
done
#if [ -f "$build_root_dir/contrib/bin/bison" ]; then
# opt_yacc_default="$build_root_dir/contrib/bin/bison"
#elif [ -f "/usr/local/opt/bison/bin/bison" ]; then
# opt_yacc_default="/usr/local/opt/bison/bin/bison"
#fi
for optname in $CMDLINE_SET; do
eval opt_$optname=
done
show_help(){
cat <<EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
Help options:
--help print this message
Standard options:
--prefix=PREFIX install in PREFIX [$prefix]
--bindir=DIR install binaries in DIR [PREFIX/bin]
--incdir=DIR install includes in DIR [PREFIX/include]
Toolchain options:
--cxx=CXX use C compiler CXX [$opt_cxx_default]
--yylex=YYLEX use yylex YYLEX [$opt_yylex_default]
--yacc=YACC use yacc YACC [$opt_yacc_default]
NOTE: Object files are built at the place where configure is launched.
EOF
exit 0
}
#----- parse options -----
for opt do
optval="${opt#*=}"
case "$opt" in
--help|-h)
show_help
;;
--prefix=*|--bindir=*|--incdir=*)
optname="${opt%%=*}"
optname="${optname#--}"
optname=$(echo "$optname" | sed 's/-/_/g')
eval opt_$optname='$optval'
;;
*)
optname="${opt%%=*}"
optname="${optname#--}"
optname=$(echo "$optname" | sed 's/-/_/g')
if is_in $optname $CMDLINE_SET; then
eval opt_$optname='$optval'
elif is_in $optname $CMDLINE_APPEND; then
append opt_$optname "$optval"
else
die_unknown $opt
fi
;;
esac
done
#----- check options -----
if [ "$opt_prefix" == "" ]; then opt_prefix="$opt_prefix_default"; fi
if [ "$opt_bindir" == "" ]; then opt_bindir="$opt_prefix/bin"; fi
if [ "$opt_incdir" == "" ]; then opt_incdir="$opt_prefix/include"; fi
for optname in $CMDLINE_SET; do
opt_optname="opt_$optname"
eval opt_optvalue=\$$opt_optname
opt_optname_default="opt_""$optname""_default"
eval opt_optvalue_default=\$$opt_optname_default
if [ "$opt_optvalue" == "" ]; then
eval $opt_optname=$opt_optvalue_default
fi
done
#----- print evaluated options -----
echo "install prefix: $opt_prefix"
echo " binary directory: $opt_bindir"
echo " include directory: $opt_incdir"
echo "cxx: $opt_cxx"
echo "yylex: $opt_yylex"
echo "yacc: $opt_yacc"
#----- output -----
cat > config.mak <<EOF
# Automatically generated by configure - do not modify!
PREFIX=$opt_prefix
BINDIR=$opt_bindir
INCDIR=$opt_incdir
CXX=$opt_cxx
YYLEX=$opt_yylex
YACC=$opt_yacc
EOF
cat > config.h <<EOF
/* Automatically generated by configure - do not modify! */
EOF