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 | language="pl_PL.ISO-8859-2" |
---|
93 | |
---|
94 | cc_default="gcc" |
---|
95 | cxx_default="g++" |
---|
96 | gengetopt_default="gengetopt" |
---|
97 | flex_default="flex" |
---|
98 | makeinfo_default="makeinfo" |
---|
99 | texi2dvi_default="texi2dvi" |
---|
100 | texi2pdf_default="texi2pdf" |
---|
101 | dvips_default="dvips" |
---|
102 | |
---|
103 | # default switch values |
---|
104 | DEFAULT=" |
---|
105 | " |
---|
106 | |
---|
107 | DEFAULT_NO="static |
---|
108 | utf8 |
---|
109 | " |
---|
110 | |
---|
111 | DEFAULT_YES="doc |
---|
112 | " |
---|
113 | |
---|
114 | CMDLINE_SELECT="$DEFAULT |
---|
115 | $DEFAULT_NO |
---|
116 | $DEFAULT_YES |
---|
117 | " |
---|
118 | |
---|
119 | enable $DEFAULT_YES |
---|
120 | disable $DEFAULT_NO |
---|
121 | |
---|
122 | for opt do |
---|
123 | optval="${opt#*=}" |
---|
124 | case "$opt" in |
---|
125 | --help) |
---|
126 | show_help |
---|
127 | ;; |
---|
128 | --prefix=*) |
---|
129 | PREFIX="$optval" |
---|
130 | bindir="$optval/bin" |
---|
131 | sharedir="$optval/share" |
---|
132 | docdir="$optval/share/doc/utt" |
---|
133 | langdir="$optval/share/utt" |
---|
134 | libdir="$optval/lib/utt" |
---|
135 | ;; |
---|
136 | --bindir=*) |
---|
137 | bindir="$optval" |
---|
138 | ;; |
---|
139 | --confdir=*) |
---|
140 | confdir="$optval" |
---|
141 | ;; |
---|
142 | --sharedir=*) |
---|
143 | sharedir="$optval" |
---|
144 | ;; |
---|
145 | --docdir=*) |
---|
146 | docdir="$optval" |
---|
147 | ;; |
---|
148 | --langdir=*) |
---|
149 | langdir="$optval" |
---|
150 | ;; |
---|
151 | --libdir=*) |
---|
152 | libdir="$optval" |
---|
153 | ;; |
---|
154 | --language=*) |
---|
155 | language="$optval" |
---|
156 | ;; |
---|
157 | --cc=*) |
---|
158 | cc="$optval" |
---|
159 | ;; |
---|
160 | --cxx=*) |
---|
161 | cxx="$optval" |
---|
162 | ;; |
---|
163 | --gengetopt=*) |
---|
164 | gengetopt="$optval" |
---|
165 | ;; |
---|
166 | --flex=*) |
---|
167 | flex="$optval" |
---|
168 | ;; |
---|
169 | --makeinfo=*) |
---|
170 | makeinfo="$optval" |
---|
171 | ;; |
---|
172 | --texi2dvi=*) |
---|
173 | texi2dvi="$optval" |
---|
174 | ;; |
---|
175 | --texi2pdf=*) |
---|
176 | texi2pdf="$optval" |
---|
177 | ;; |
---|
178 | --dvips=*) |
---|
179 | dvips="$optval" |
---|
180 | ;; |
---|
181 | --enable-?*|--disable-?*) |
---|
182 | eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` |
---|
183 | echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt |
---|
184 | $action $option |
---|
185 | ;; |
---|
186 | *) |
---|
187 | die_unknown $opt |
---|
188 | ;; |
---|
189 | esac |
---|
190 | done |
---|
191 | |
---|
192 | if ! test -z $cc; then |
---|
193 | cc_default="${cc}" |
---|
194 | fi |
---|
195 | cc="${cc_default}" |
---|
196 | |
---|
197 | if ! test -z $cxx; then |
---|
198 | cxx_default="${cxx}" |
---|
199 | fi |
---|
200 | |
---|
201 | cxx="${cxx_default}" |
---|
202 | |
---|
203 | if ! test -z $gengetopt; then |
---|
204 | gengetopt_default="${gengetopt}" |
---|
205 | fi |
---|
206 | |
---|
207 | gengetopt="${gengetopt_default}" |
---|
208 | |
---|
209 | if ! test -z $flex; then |
---|
210 | flex_default="$flex" |
---|
211 | fi |
---|
212 | |
---|
213 | flex="${flex_default}" |
---|
214 | |
---|
215 | enabled doc && { |
---|
216 | if ! test -z $makeinfo; then |
---|
217 | makeinfo_default="${makeinfo}" |
---|
218 | fi |
---|
219 | if ! test -z $texi2dvi; then |
---|
220 | texi2dvi_default="${texi2dvi}" |
---|
221 | fi |
---|
222 | if ! test -z $texi2pdf; then |
---|
223 | texi2pdf_default="${texi2pdf}" |
---|
224 | fi |
---|
225 | if ! test -z $dvips; then |
---|
226 | dvips_default="${dvips}" |
---|
227 | fi |
---|
228 | |
---|
229 | makeinfo="${makeinfo_default}" |
---|
230 | texi2dvi="${texi2dvi_default}" |
---|
231 | texi2pdf="${texi2pdf_default}" |
---|
232 | dvips="${dvips_default}" |
---|
233 | } |
---|
234 | |
---|
235 | # generating config.mak |
---|
236 | |
---|
237 | echo "# Automatically generated by configure" > config.mak |
---|
238 | echo "PREFIX=$PREFIX" >> config.mak |
---|
239 | echo "BIN_DIR=$bindir" >> config.mak |
---|
240 | echo "CONF_DIR=$confdir" >> config.mak |
---|
241 | echo "SHARE_DIR=$sharedir" >> config.mak |
---|
242 | echo "DOC_DIR=$docdir" >> config.mak |
---|
243 | echo "LANG_DIR=$langdir" >> config.mak |
---|
244 | echo "LIB_DIR=$libdir" >> config.mak |
---|
245 | echo "LANGUAGE=$language" >> config.mak |
---|
246 | echo "CC=$cc" >> config.mak |
---|
247 | echo "CXX=$cxx" >> config.mak |
---|
248 | echo "GENGETOPT=$gengetopt" >> config.mak |
---|
249 | echo "FLEX=$flex" >> config.mak |
---|
250 | enabled doc && { |
---|
251 | echo "MAKEINFO=$makeinfo" >> config.mak |
---|
252 | echo "TEXI2DVI=$texi2dvi" >> config.mak |
---|
253 | echo "TEXI2PDF=$texi2pdf" >> config.mak |
---|
254 | echo "DVIPS=$dvips" >> config.mak |
---|
255 | } |
---|
256 | echo "BUILD_UTF8=$utf8" >> config.mak |
---|
257 | echo "BUILD_STATIC=$static" >> config.mak |
---|
258 | echo "BUILD_DOC=$doc" >> config.mak |
---|
259 | |
---|
260 | enabled utf8 && { |
---|
261 | for cmp in $CMPLIST; do |
---|
262 | if [ -d "${SRC_DIR}/${cmp}_utf8" ]; then |
---|
263 | COMPONENTS="${COMPONENTS} ${cmp}_utf8" |
---|
264 | else |
---|
265 | COMPONENTS="${COMPONENTS} ${cmp}" |
---|
266 | fi |
---|
267 | done |
---|
268 | } |
---|
269 | |
---|
270 | disabled utf8 && { |
---|
271 | for cmp in $CMPLIST; do |
---|
272 | COMPONENTS="${COMPONENTS} ${cmp}" |
---|
273 | done |
---|
274 | } |
---|
275 | COMPONENTS=$(echo $COMPONENTS | cut -c1-) |
---|
276 | echo "COMPONENTS=$COMPONENTS" >> config.mak |
---|
277 | |
---|
278 | # echoing the configuration to console |
---|
279 | echo "prefix: $PREFIX" |
---|
280 | echo "bindir: $bindir" |
---|
281 | echo "confdir: $confdir" |
---|
282 | echo "sharedir: $sharedir" |
---|
283 | echo "docdir: $docdir" |
---|
284 | echo "langdir: $langdir" |
---|
285 | echo "libdir: $libdir" |
---|
286 | echo "language: $language" |
---|
287 | enabled doc && { |
---|
288 | echo "makeinfo: $makeinfo" |
---|
289 | echo "texi2dvi: $texi2dvi" |
---|
290 | echo "texi2pdf: $texi2pdf" |
---|
291 | echo "dvips: $dvips" |
---|
292 | } |
---|
293 | echo "cc: $cc" |
---|
294 | echo "cxx: $cxx" |
---|
295 | echo "gengetopt: $gengetopt" |
---|
296 | echo "flex: $flex" |
---|
297 | echo "utf8: $utf8" |
---|
298 | echo "static: $static" |
---|
299 | echo "doc: $doc" |
---|