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