1 | #!/bin/sh |
---|
2 | |
---|
3 | # utt configure file |
---|
4 | # creates config.mak which is used by other makefiles |
---|
5 | |
---|
6 | # variables for dynamically selecting whether to compile utf8 versions |
---|
7 | CUR_DIR=$(pwd) |
---|
8 | SRC_DIR="${CUR_DIR}/src" |
---|
9 | |
---|
10 | # list of components to compile |
---|
11 | CMPLIST="compdic cor dgc dgp fla gph grp gue kon kor kot lem mar rm12 rs12 sen sen-nl ser tags tok.c tok.l tok.pl tre unfla" |
---|
12 | COMP= |
---|
13 | |
---|
14 | |
---|
15 | # sets all variables to a defined value |
---|
16 | set_all(){ |
---|
17 | value=$1 |
---|
18 | shift |
---|
19 | for var in $*; do |
---|
20 | eval $var=$value |
---|
21 | done |
---|
22 | } |
---|
23 | |
---|
24 | # enables a feature |
---|
25 | enable(){ |
---|
26 | set_all yes $* |
---|
27 | } |
---|
28 | |
---|
29 | # disables a feature |
---|
30 | disable(){ |
---|
31 | set_all no $* |
---|
32 | } |
---|
33 | |
---|
34 | # checks whether a feature is enabled |
---|
35 | enabled(){ |
---|
36 | eval test "x\$$1" = "xyes" |
---|
37 | } |
---|
38 | |
---|
39 | # checks whether a feature is disabled |
---|
40 | disabled(){ |
---|
41 | eval test "x\$$1" = "xno" |
---|
42 | } |
---|
43 | |
---|
44 | show_help(){ |
---|
45 | echo "Usage configure [options]" |
---|
46 | echo "Options: [defaults in brackets after descriptions]" |
---|
47 | echo "All \"enable\" options have \"disable\" counterparts" |
---|
48 | echo |
---|
49 | echo " --help print this message" |
---|
50 | echo " --prefix=PREFIX install in PREFIX [$PREFIX]" |
---|
51 | echo " --bindir=BINDIR install binaries in BINDIR [$bindir]" |
---|
52 | echo " --confdir=CONFDIR install configuration in CONFDIR [$confdir]" |
---|
53 | echo " --sharedir=SHAREDIR install shared in SHAREDIR [$sharedir]" |
---|
54 | echo " --docdir=DOCDIR install doc in DOCDIR [$docdir]" |
---|
55 | echo " --langdir=LANGDIR install lang in LANGDIR [$langdir]" |
---|
56 | echo " --libdir=LIBDIR install libraries in LIBDIR [$libdir]" |
---|
57 | echo |
---|
58 | echo " --language=LANGUAGE select language" |
---|
59 | echo |
---|
60 | echo " --enable-static build static versions [no]" |
---|
61 | echo " --enable-doc build documentation [yes]" |
---|
62 | echo " --enable-utf8 build UTF-8 versions of applications [no]" |
---|
63 | echo |
---|
64 | echo " --cc=CC use C compiler CC [$cc_default]" |
---|
65 | echo " --cxx=CXX use C++ compiler CXX [$cxx_default]" |
---|
66 | echo " --gengetopt=GGO use gengetopt GGO [$gengetopt_default]" |
---|
67 | echo " --flex=FLEX use flex FLEX [$flex_default]" |
---|
68 | echo " --makeinfo=MAKEINFO use makeinfo MAKEINFO [$makeinfo_default]" |
---|
69 | echo " --texi2dvi=TEXI2DVI use texi2dvi TEXI2DVI [$texi2dvi_default]" |
---|
70 | echo " --texi2pdf=TEXI2PDF use texi2pdf TEXI2PDF [$texi2pdf_default]" |
---|
71 | echo " --dvips=DVIPS use dvips DVIPS [$dvips_default]" |
---|
72 | exit 1 |
---|
73 | } |
---|
74 | |
---|
75 | die_unknown(){ |
---|
76 | echo "Unknown option \"$1\"." |
---|
77 | echo "See $0 --help for availible options." |
---|
78 | exit 1 |
---|
79 | } |
---|
80 | |
---|
81 | # |
---|
82 | # default values |
---|
83 | PREFIX="/usr/local" |
---|
84 | |
---|
85 | bindir="${PREFIX}/bin" |
---|
86 | confdir="/etc/utt" |
---|
87 | sharedir="${PREFIX}/share" |
---|
88 | docdir="${PREFIX}/share/doc/utt" |
---|
89 | langdir="${PREFIX}/share/utt" |
---|
90 | libdir="${PREFIX}/lib/utt" |
---|
91 | |
---|
92 | languages="pl_PL.ISO-8859-2" |
---|
93 | language="pl_PL.ISO-8859-2" |
---|
94 | |
---|
95 | cc_default="gcc" |
---|
96 | cxx_default="g++" |
---|
97 | gengetopt_default="gengetopt" |
---|
98 | flex_default="flex" |
---|
99 | makeinfo_default="makeinfo" |
---|
100 | texi2dvi_default="texi2dvi" |
---|
101 | texi2pdf_default="texi2pdf" |
---|
102 | dvips_default="dvips" |
---|
103 | |
---|
104 | # default switch values |
---|
105 | DEFAULT=" |
---|
106 | " |
---|
107 | |
---|
108 | DEFAULT_NO="static |
---|
109 | utf8 |
---|
110 | " |
---|
111 | |
---|
112 | DEFAULT_YES="doc |
---|
113 | " |
---|
114 | |
---|
115 | CMDLINE_SELECT="$DEFAULT |
---|
116 | $DEFAULT_NO |
---|
117 | $DEFAULT_YES |
---|
118 | " |
---|
119 | |
---|
120 | enable $DEFAULT_YES |
---|
121 | disable $DEFAULT_NO |
---|
122 | |
---|
123 | for opt do |
---|
124 | optval="${opt#*=}" |
---|
125 | case "$opt" in |
---|
126 | --help) |
---|
127 | show_help |
---|
128 | ;; |
---|
129 | --prefix=*) |
---|
130 | PREFIX="$optval" |
---|
131 | bindir="$optval/bin" |
---|
132 | sharedir="$optval/share" |
---|
133 | docdir="$optval/share/doc/utt" |
---|
134 | langdir="$optval/share/utt" |
---|
135 | libdir="$optval/lib/utt" |
---|
136 | ;; |
---|
137 | --bindir=*) |
---|
138 | bindir="$optval" |
---|
139 | ;; |
---|
140 | --confdir=*) |
---|
141 | confdir="$optval" |
---|
142 | ;; |
---|
143 | --sharedir=*) |
---|
144 | sharedir="$optval" |
---|
145 | ;; |
---|
146 | --docdir=*) |
---|
147 | docdir="$optval" |
---|
148 | ;; |
---|
149 | --langdir=*) |
---|
150 | langdir="$optval" |
---|
151 | ;; |
---|
152 | --libdir=*) |
---|
153 | libdir="$optval" |
---|
154 | ;; |
---|
155 | --language=*) |
---|
156 | language="$optval" |
---|
157 | ;; |
---|
158 | --cc=*) |
---|
159 | cc="$optval" |
---|
160 | ;; |
---|
161 | --cxx=*) |
---|
162 | cxx="$optval" |
---|
163 | ;; |
---|
164 | --gengetopt=*) |
---|
165 | gengetopt="$optval" |
---|
166 | ;; |
---|
167 | --flex=*) |
---|
168 | flex="$optval" |
---|
169 | ;; |
---|
170 | --makeinfo=*) |
---|
171 | makeinfo="$optval" |
---|
172 | ;; |
---|
173 | --texi2dvi=*) |
---|
174 | texi2dvi="$optval" |
---|
175 | ;; |
---|
176 | --texi2pdf=*) |
---|
177 | texi2pdf="$optval" |
---|
178 | ;; |
---|
179 | --dvips=*) |
---|
180 | dvips="$optval" |
---|
181 | ;; |
---|
182 | --enable-?*|--disable-?*) |
---|
183 | eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` |
---|
184 | echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt |
---|
185 | $action $option |
---|
186 | ;; |
---|
187 | *) |
---|
188 | die_unknown $opt |
---|
189 | ;; |
---|
190 | esac |
---|
191 | done |
---|
192 | |
---|
193 | if ! test -z $cc; then |
---|
194 | cc_default="${cc}" |
---|
195 | fi |
---|
196 | cc="${cc_default}" |
---|
197 | |
---|
198 | if ! test -z $cxx; then |
---|
199 | cxx_default="${cxx}" |
---|
200 | fi |
---|
201 | |
---|
202 | cxx="${cxx_default}" |
---|
203 | |
---|
204 | if ! test -z $gengetopt; then |
---|
205 | gengetopt_default="${gengetopt}" |
---|
206 | fi |
---|
207 | |
---|
208 | gengetopt="${gengetopt_default}" |
---|
209 | |
---|
210 | if ! test -z $flex; then |
---|
211 | flex_default="$flex" |
---|
212 | fi |
---|
213 | |
---|
214 | flex="${flex_default}" |
---|
215 | |
---|
216 | enabled doc && { |
---|
217 | if ! test -z $makeinfo; then |
---|
218 | makeinfo_default="${makeinfo}" |
---|
219 | fi |
---|
220 | if ! test -z $texi2dvi; then |
---|
221 | texi2dvi_default="${texi2dvi}" |
---|
222 | fi |
---|
223 | if ! test -z $texi2pdf; then |
---|
224 | texi2pdf_default="${texi2pdf}" |
---|
225 | fi |
---|
226 | if ! test -z $dvips; then |
---|
227 | dvips_default="${dvips}" |
---|
228 | fi |
---|
229 | |
---|
230 | makeinfo="${makeinfo_default}" |
---|
231 | texi2dvi="${texi2dvi_default}" |
---|
232 | texi2pdf="${texi2pdf_default}" |
---|
233 | dvips="${dvips_default}" |
---|
234 | } |
---|
235 | |
---|
236 | # generating config.mak |
---|
237 | |
---|
238 | echo "# Automatically generated by configure" > config.mak |
---|
239 | echo "PREFIX=$PREFIX" >> config.mak |
---|
240 | echo "BIN_DIR=$bindir" >> config.mak |
---|
241 | echo "CONF_DIR=$confdir" >> config.mak |
---|
242 | echo "SHARE_DIR=$sharedir" >> config.mak |
---|
243 | echo "DOC_DIR=$docdir" >> config.mak |
---|
244 | echo "LANG_DIR=$langdir" >> config.mak |
---|
245 | echo "LIB_DIR=$libdir" >> config.mak |
---|
246 | echo "LANGUAGES=$languages" >> config.mak |
---|
247 | echo "LANGUAGE=$language" >> config.mak |
---|
248 | echo "CC=$cc" >> config.mak |
---|
249 | echo "CXX=$cxx" >> config.mak |
---|
250 | echo "GENGETOPT=$gengetopt" >> config.mak |
---|
251 | echo "FLEX=$flex" >> config.mak |
---|
252 | enabled doc && { |
---|
253 | echo "MAKEINFO=$makeinfo" >> config.mak |
---|
254 | echo "TEXI2DVI=$texi2dvi" >> config.mak |
---|
255 | echo "TEXI2PDF=$texi2pdf" >> config.mak |
---|
256 | echo "DVIPS=$dvips" >> config.mak |
---|
257 | } |
---|
258 | echo "BUILD_UTF8=$utf8" >> config.mak |
---|
259 | echo "BUILD_STATIC=$static" >> config.mak |
---|
260 | echo "BUILD_DOC=$doc" >> config.mak |
---|
261 | |
---|
262 | enabled utf8 && { |
---|
263 | for cmp in $CMPLIST; do |
---|
264 | if [ -d "${SRC_DIR}/${cmp}_utf8" ]; then |
---|
265 | COMPONENTS="${COMPONENTS} ${cmp}_utf8" |
---|
266 | else |
---|
267 | COMPONENTS="${COMPONENTS} ${cmp}" |
---|
268 | fi |
---|
269 | done |
---|
270 | } |
---|
271 | |
---|
272 | disabled utf8 && { |
---|
273 | for cmp in $CMPLIST; do |
---|
274 | COMPONENTS="${COMPONENTS} ${cmp}" |
---|
275 | done |
---|
276 | } |
---|
277 | COMPONENTS=$(echo $COMPONENTS | cut -c1-) |
---|
278 | echo "COMPONENTS=$COMPONENTS" >> config.mak |
---|
279 | |
---|
280 | # echoing the configuration to console |
---|
281 | echo "prefix: $PREFIX" |
---|
282 | echo "bindir: $bindir" |
---|
283 | echo "confdir: $confdir" |
---|
284 | echo "sharedir: $sharedir" |
---|
285 | echo "docdir: $docdir" |
---|
286 | echo "langdir: $langdir" |
---|
287 | echo "libdir: $libdir" |
---|
288 | echo "languages: $languages" |
---|
289 | echo "language: $language" |
---|
290 | enabled doc && { |
---|
291 | echo "makeinfo: $makeinfo" |
---|
292 | echo "texi2dvi: $texi2dvi" |
---|
293 | echo "texi2pdf: $texi2pdf" |
---|
294 | echo "dvips: $dvips" |
---|
295 | } |
---|
296 | echo "cc: $cc" |
---|
297 | echo "cxx: $cxx" |
---|
298 | echo "gengetopt: $gengetopt" |
---|
299 | echo "flex: $flex" |
---|
300 | echo "utf8: $utf8" |
---|
301 | echo "static: $static" |
---|
302 | echo "doc: $doc" |
---|