1 |
#!/bin/sh |
2 |
## -*-sh-*- |
3 |
#set -x |
4 |
# BEGIN of icu-config-top |
5 |
#****************************************************************************** |
6 |
# Copyright (C) 1999-2004, International Business Machines |
7 |
# Corporation and others. All Rights Reserved. |
8 |
#****************************************************************************** |
9 |
# This script is designed to aid configuration of ICU. |
10 |
# rpath links a library search path right into the binaries. |
11 |
|
12 |
|
13 |
### END of icu-config-top |
14 |
|
15 |
## Zero out prefix. |
16 |
exec_prefix=`pkg-config --variable=exec_prefix icu` |
17 |
execprefix=$exec_prefix |
18 |
prefix=`pkg-config --variable=prefix icu` |
19 |
|
20 |
|
21 |
loaddefs() |
22 |
{ |
23 |
LDLIBRARYPATH_ENVVAR="LD_LIBRARY_PATH" |
24 |
bindir=`pkg-config --variable=bindir icu` |
25 |
sbindir=`pkg-config --variable=sbindir icu` |
26 |
libdir=`pkg-config --variable=libdir icu` |
27 |
sysconfdir=`pkg-config --variable=sysconfdir icu` |
28 |
mandir=`pkg-config --variable=mandir icu` |
29 |
datadir=`pkg-config --variable=datadir icu` |
30 |
pkglibdir=`pkg-config --variable=pkglibdir icu` |
31 |
ICULIBS_COMMON_LIB_NAME=`pkg-config --variable=ICULIBS_COMMON_LIB_NAME icu` |
32 |
UNICODE_VERSION=`pkg-config --variable=UNICODE_VERSION icu` |
33 |
VERSION=`pkg-config --modversion icu` |
34 |
SO=`pkg-config --variable=SO icu` |
35 |
|
36 |
## -*-sh-*- |
37 |
## BEGIN of icu-config-bottom. |
38 |
## Copyright (c) 2002-2004, International Business Machines Corporation and |
39 |
## others. All Rights Reserved. |
40 |
|
41 |
ICUUC_FILE=${libdir}/${ICULIBS_COMMON_LIB_NAME} |
42 |
|
43 |
# echo ENABLE RPATH $ENABLE_RPATH and RPATHLDFLAGS=${RPATH_LDFLAGS} |
44 |
if [ "x$PKGDATA_MODE" = "x" ]; then |
45 |
PKGDATA_MODE=dll |
46 |
fi |
47 |
|
48 |
} |
49 |
|
50 |
## The actual code of icu-config goes here. |
51 |
|
52 |
ME=`basename $0` |
53 |
|
54 |
allflags() |
55 |
{ |
56 |
echo " --bindir Print binary directory path (bin)" |
57 |
echo " --cc Print C compiler used [CC]" |
58 |
echo " --cflags Print C compiler flags [CFLAGS]" |
59 |
echo " --cflags-dynamic Print additional C flags for" |
60 |
echo " building shared libraries." |
61 |
echo " --cppflags Print C Preprocessor flags [CPPFLAGS]" |
62 |
echo " --cppflags-dynamic Print additional C Preprocessor flags for" |
63 |
echo " building shared libraries." |
64 |
echo " --cppflags-searchpath Print only -I include directives (-Iinclude)" |
65 |
echo " --cxx Print C++ compiler used [CXX]" |
66 |
echo " --cxxflags Print C++ compiler flags [CXXFLAGS]" |
67 |
echo " --cxxflags-dynamic Print additional C++ flags for" |
68 |
echo " building shared libraries." |
69 |
echo " --detect-prefix Attempt to detect prefix based on PATH" |
70 |
echo " --exec-prefix Print prefix for executables (/bin)" |
71 |
echo " --exists Return with 0 status if ICU exists else fail" |
72 |
echo " --help, -?, --usage Print this message" |
73 |
echo " --icudata Print shortname of ICU data file (icudt21l)" |
74 |
echo " --icudata-install-dir Print path to install data to - use as --install option to pkgdata(1)" |
75 |
echo " --icudata-mode Print default ICU pkgdata mode (dll) - use as --mode option to pkgdata(1)." |
76 |
echo " --icudatadir Print path to packaged archive data. Can set as [ICU_DATA]" |
77 |
echo " --invoke Print commands to invoke an ICU program" |
78 |
echo " --invoke=<prog> Print commands to invoke an ICU program named <prog> (ex: genrb)" |
79 |
echo " --ldflags Print -L search path and -l libraries to link with ICU [LDFLAGS]. This is for the data, uc (common), and i18n libraries only. " |
80 |
echo " --ldflags-layout Print ICU layout engine link directive. Use in addition to --ldflags" |
81 |
echo " --ldflags-libsonly Same as --ldflags, but only the -l directives" |
82 |
echo " --ldflags-searchpath Print only -L (search path) directive" |
83 |
echo " --ldflags-system Print only system libs ICU links with (-lpthread, -lm)" |
84 |
echo " --ldflags-icuio Print ICU icuio link directive. Use in addition to --ldflags " |
85 |
echo " --ldflags-obsolete Print ICU obsolete link directive. Use in addition to --ldflags. (requires icuapps/obsolete to be built and installed.) " |
86 |
echo " --mandir Print manpage (man) path" |
87 |
echo " --prefix Print PREFIX to icu install (/usr/local)" |
88 |
echo " --prefix=XXX Set prefix to XXX for remainder of command" |
89 |
echo " --sbindir Print system binary path (sbin) " |
90 |
echo " --shared-datadir Print shared data (share) path. This is NOT the ICU data dir." |
91 |
echo " --shlib-c Print the command to compile and build C shared libraries with ICU" |
92 |
echo " --shlib-cc Print the command to compile and build C++ shared libraries with ICU" |
93 |
echo " --sysconfdir Print system config (etc) path" |
94 |
echo " --unicode-version Print version of Unicode data used in ICU ($UNICODE_VERSION)" |
95 |
echo " --version Print ICU version ($VERSION)" |
96 |
echo " --incfile Print path to Makefile.inc (for -O option of pkgdata)" |
97 |
} |
98 |
|
99 |
## Print the normal usage message |
100 |
shortusage() |
101 |
{ |
102 |
echo "usage: ${ME} " `allflags | cut -c-25 | sed -e 's%.*%[ & ]%'` |
103 |
} |
104 |
|
105 |
|
106 |
usage() |
107 |
{ |
108 |
echo "${ME}: icu-config: ICU configuration helper script" |
109 |
echo |
110 |
echo "The most commonly used options will be --cflags, --cxxflags, --cppflags, and --ldflags." |
111 |
echo 'Example (in make): CPFLAGS=$(shell icu-config --cppflags)' |
112 |
echo ' LDFLAGS=$(shell icu-config --ldflags)' |
113 |
echo " (etc).." |
114 |
echo |
115 |
echo "Usage:" |
116 |
allflags |
117 |
|
118 |
echo |
119 |
echo " [Brackets] show MAKE variable equivalents, (parenthesis) show example output" |
120 |
echo |
121 |
echo "Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved." |
122 |
} |
123 |
|
124 |
## Check the sanity of current variables |
125 |
sanity() |
126 |
{ |
127 |
if [ ! -f ${ICUUC_FILE} ]; |
128 |
then |
129 |
echo "### $ME: Can't find ${ICUUC_FILE} - ICU prefix is wrong." 1>&2 |
130 |
echo "### Try the --prefix= or --exec-prefix= options " 1>&2 |
131 |
echo "### or --detect-prefix" |
132 |
echo "### $ME: Exitting." 1>&2 |
133 |
exit 2 |
134 |
fi |
135 |
} |
136 |
|
137 |
## Main starts here. |
138 |
|
139 |
if [ $# -lt 1 ]; then |
140 |
shortusage |
141 |
exit 1 |
142 |
fi |
143 |
|
144 |
|
145 |
# Load our variables from autoconf |
146 |
# ALWAYS load twice because of dependencies |
147 |
loaddefs |
148 |
loaddefs |
149 |
sanity |
150 |
|
151 |
while [ $# -gt 0 ]; |
152 |
do |
153 |
arg="$1" |
154 |
var=`echo $arg | sed -e 's/^[^=]*=//'` |
155 |
# echo "### processing $arg" 1>&2 |
156 |
case "$arg" in |
157 |
|
158 |
# undocumented. |
159 |
--debug) |
160 |
set -x |
161 |
;; |
162 |
|
163 |
--so) |
164 |
echo $SO |
165 |
;; |
166 |
|
167 |
--bindir) |
168 |
echo $bindir |
169 |
;; |
170 |
|
171 |
--libdir) |
172 |
echo $libdir |
173 |
;; |
174 |
|
175 |
--exists) |
176 |
sanity |
177 |
;; |
178 |
|
179 |
--sbindir) |
180 |
echo $sbindir |
181 |
;; |
182 |
|
183 |
--invoke=*) |
184 |
QUOT="'" |
185 |
CMD="${var}" |
186 |
|
187 |
# If it's not a locally executable command (1st choice) then |
188 |
# search for it in the ICU directories. |
189 |
if [ ! -x ${CMD} ]; then |
190 |
if [ -x ${bindir}/${var} ]; then |
191 |
CMD="${bindir}/${var}" |
192 |
fi |
193 |
if [ -x ${sbindir}/${var} ]; then |
194 |
CMD="${sbindir}/${var}" |
195 |
fi |
196 |
fi |
197 |
|
198 |
echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} ${CMD} |
199 |
;; |
200 |
|
201 |
--invoke) |
202 |
QUOT="'" |
203 |
echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} |
204 |
;; |
205 |
|
206 |
--cflags) |
207 |
pkg-config --variable=CFLAGS icu |
208 |
;; |
209 |
|
210 |
--cc) |
211 |
echo cc |
212 |
;; |
213 |
|
214 |
--cxx) |
215 |
echo c++ |
216 |
;; |
217 |
|
218 |
--cxxflags) |
219 |
pkg-config --variable=CXXFLAGS icu |
220 |
;; |
221 |
|
222 |
--cppflags) |
223 |
# Don't echo the -I. - it's unneeded. |
224 |
CPPFLAGS=`pkg-config --variable=CPPFLAGS icu` |
225 |
echo $CPPFLAGS | sed -e 's/-I. //' |
226 |
;; |
227 |
|
228 |
--cppflags-searchpath) |
229 |
echo -I${prefix}/include |
230 |
;; |
231 |
|
232 |
--cppflags-dynamic) |
233 |
pkg-config --variable=SHAREDLIBCPPFLAGS icu |
234 |
;; |
235 |
|
236 |
--cxxflags-dynamic) |
237 |
pkg-config --variable=SHAREDLIBCXXFLAGS icu |
238 |
;; |
239 |
|
240 |
--cflags-dynamic) |
241 |
pkg-config --variable=SHAREDLIBCFLAGS icu |
242 |
;; |
243 |
|
244 |
--ldflags-system) |
245 |
pkg-config --variable=ICULIBS_SYSTEMLIBS icu |
246 |
;; |
247 |
|
248 |
--ldflags) |
249 |
pkg-config --libs icu |
250 |
# $RPATH_LDFLAGS |
251 |
;; |
252 |
|
253 |
--ldflags-libsonly) |
254 |
pkg-config --variable=ICULIBS_LIBSONLY icu |
255 |
;; |
256 |
|
257 |
--ldflags-icuio) |
258 |
pkg-config --variable=ICULIBS_ICUIO icu |
259 |
;; |
260 |
|
261 |
--ldflags-obsolete) |
262 |
pkg-config --variable=ICULIBS_OBSOLETE icu |
263 |
;; |
264 |
|
265 |
--ldflags-toolutil) |
266 |
pkg-config --variable=ICULIBS_TOOLUTIL icu |
267 |
;; |
268 |
|
269 |
--ldflags-layout) |
270 |
pkg-config --variable=ICULIBS_LAYOUT icu |
271 |
;; |
272 |
|
273 |
--ldflags-searchpath) |
274 |
echo -L${libdir} |
275 |
;; |
276 |
|
277 |
--detect-prefix) |
278 |
HERE=`echo $0 | sed -e "s/$ME//g"` |
279 |
if [ -f $HERE/../lib/${ICULIBS_COMMON_LIB_NAME} ]; then |
280 |
prefix=$HERE/.. |
281 |
echo "## Using --prefix=${prefix}" 1>&2 |
282 |
fi |
283 |
loaddefs |
284 |
loaddefs |
285 |
sanity |
286 |
;; |
287 |
|
288 |
--exec-prefix) |
289 |
echo $exec_prefix |
290 |
;; |
291 |
|
292 |
--prefix) |
293 |
echo $prefix |
294 |
;; |
295 |
|
296 |
--prefix=*) |
297 |
prefix=$var |
298 |
loaddefs |
299 |
loaddefs |
300 |
sanity |
301 |
;; |
302 |
|
303 |
--sysconfdir) |
304 |
echo $sysconfdir |
305 |
;; |
306 |
|
307 |
--mandir) |
308 |
echo $mandir |
309 |
;; |
310 |
|
311 |
--shared-datadir) |
312 |
echo $datadir |
313 |
;; |
314 |
|
315 |
--incfile) |
316 |
echo $pkglibdir/Makefile.inc |
317 |
;; |
318 |
|
319 |
--icudata) |
320 |
pkg-config --variable=ICUDATA_NAME icu |
321 |
;; |
322 |
|
323 |
--icudata-mode) |
324 |
echo $PKGDATA_MODE |
325 |
;; |
326 |
|
327 |
--icudata-install-dir) |
328 |
pkg-config --variable=ICUPKGDATA_DIR icu |
329 |
;; |
330 |
|
331 |
--icudatadir) |
332 |
pkg-config --variable=ICUDATA_DIR icu |
333 |
;; |
334 |
|
335 |
--shlib-c) |
336 |
pkg-config --variable=SHLIB_c icu |
337 |
;; |
338 |
|
339 |
--shlib-cc) |
340 |
pkg-config --variable=SHLIB_cc icu |
341 |
;; |
342 |
|
343 |
--version) |
344 |
echo $VERSION |
345 |
;; |
346 |
|
347 |
--unicode-version) |
348 |
echo $UNICODE_VERSION |
349 |
;; |
350 |
|
351 |
--help) |
352 |
usage |
353 |
exit 0 |
354 |
;; |
355 |
|
356 |
--usage) |
357 |
usage |
358 |
exit 0 |
359 |
;; |
360 |
|
361 |
# --enable-rpath=*) |
362 |
# ENABLE_RPATH=$var |
363 |
# loaddefs |
364 |
# ;; |
365 |
|
366 |
-?) |
367 |
usage |
368 |
exit 0 |
369 |
;; |
370 |
|
371 |
*) |
372 |
echo ${ME}: ERROR Unknown Option $arg 1>&2 |
373 |
echo 1>&2 |
374 |
shortusage 1>&2 |
375 |
echo "### $ME: Exitting." 1>&2 |
376 |
exit 1; |
377 |
;; |
378 |
esac |
379 |
shift |
380 |
done |
381 |
|
382 |
# Check once before we quit (will check last used prefix) |
383 |
sanity |
384 |
## END of icu-config-bottom |
385 |
|
386 |
exit 0 |
387 |
|