]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | ## -*-sh-*- |
374ca955 | 2 | ## BEGIN of icu-config-bottom. |
f3c0d7a5 A |
3 | ## Copyright (C) 2016 and later: Unicode, Inc. and others. |
4 | ## License & terms of use: http://www.unicode.org/copyright.html | |
57a6839d | 5 | ## Copyright (c) 2002-2013, International Business Machines Corporation and |
b75a7d8f A |
6 | ## others. All Rights Reserved. |
7 | ||
729e4ab9 A |
8 | ICUUC_FILE="${libdir}/${ICULIBS_COMMON_LIB_NAME}" |
9 | ICUUC_FILE_A="${libdir}/${ICULIBS_COMMON_LIB_NAME_A}" | |
57a6839d | 10 | |
b75a7d8f A |
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 | ||
73c04bcf | 20 | ME=`basename "$0"` |
b75a7d8f A |
21 | |
22 | allflags() | |
23 | { | |
729e4ab9 | 24 | echo " --noverify Don't verify that ICU is actually installed." |
b75a7d8f A |
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" | |
57a6839d | 47 | echo " --invoke=<prog> Print commands to invoke an ICU program named <prog> (ex: genrb)" |
b75a7d8f | 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. " |
b75a7d8f A |
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)" | |
374ca955 | 52 | echo " --ldflags-icuio Print ICU icuio link directive. Use in addition to --ldflags " |
b75a7d8f A |
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)" | |
729e4ab9 A |
64 | echo " --incfile Print path to Makefile.inc" |
65 | echo " --incpkgdatafile Print path to pkgdata.inc (for -O option of pkgdata)" | |
46f4442e | 66 | echo " --install Print path to install-sh" |
729e4ab9 | 67 | echo " --mkinstalldirs Print path to mkinstalldirs" |
b75a7d8f A |
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 | ||
57a6839d | 89 | echo |
b75a7d8f A |
90 | echo " [Brackets] show MAKE variable equivalents, (parenthesis) show example output" |
91 | echo | |
57a6839d A |
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> " | |
b75a7d8f A |
96 | } |
97 | ||
98 | ## Check the sanity of current variables | |
99 | sanity() | |
100 | { | |
729e4ab9 | 101 | if [ ! -f "${ICUUC_FILE}" -a ! -f "${ICUUC_FILE_A}" ] && [ ${IGNORE_ICUUC_FILE_CHECK} = "no" ] && [ ${SANITY} = "sane" ]; |
b75a7d8f A |
102 | then |
103 | echo "### $ME: Can't find ${ICUUC_FILE} - ICU prefix is wrong." 1>&2 | |
729e4ab9 A |
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 | |
b75a7d8f A |
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 | ||
729e4ab9 A |
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 | ||
57a6839d | 132 | case "$1" in |
729e4ab9 A |
133 | *prefix*) |
134 | IGNORE_ICUUC_FILE_CHECK="yes" | |
135 | ;; | |
136 | esac | |
b75a7d8f A |
137 | |
138 | # Load our variables from autoconf | |
139 | # ALWAYS load twice because of dependencies | |
140 | loaddefs | |
141 | loaddefs | |
729e4ab9 A |
142 | |
143 | if [ $# -gt 0 -a $1 = "--selfcheck" ]; | |
144 | then | |
145 | echo "passed" | |
57a6839d | 146 | exit |
729e4ab9 A |
147 | # EXIT for self check |
148 | fi | |
149 | ||
b75a7d8f A |
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. | |
729e4ab9 | 160 | --debug) |
b75a7d8f A |
161 | set -x |
162 | ;; | |
57a6839d | 163 | |
729e4ab9 A |
164 | --noverify) |
165 | echo "### $ME: Error: --noverify must be the first argument." 1>&2 | |
166 | exit 1 | |
b75a7d8f | 167 | ;; |
57a6839d | 168 | |
729e4ab9 A |
169 | --so) |
170 | echo $SO | |
171 | ;; | |
b75a7d8f A |
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 | ||
46f4442e A |
189 | --mkinstalldirs) |
190 | echo ${MKINSTALLDIRS} | |
191 | ;; | |
192 | ||
193 | --install) | |
194 | echo ${INSTALL} | |
195 | ;; | |
196 | ||
b75a7d8f | 197 | --invoke=*) |
46f4442e | 198 | QUOT="\"" |
b75a7d8f A |
199 | CMD="${var}" |
200 | ||
57a6839d A |
201 | # If it's not a locally executable command (1st choice) then |
202 | # search for it in the ICU directories. | |
b75a7d8f A |
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) | |
46f4442e | 216 | QUOT="\"" |
b75a7d8f A |
217 | echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} |
218 | ;; | |
219 | ||
220 | --cflags) | |
729e4ab9 | 221 | echo $ECHO_N "${CFLAGS} ${ECHO_C}" |
b75a7d8f | 222 | ;; |
57a6839d | 223 | |
b75a7d8f | 224 | --cc) |
729e4ab9 | 225 | echo $ECHO_N "${CC} ${ECHO_C}" |
b75a7d8f | 226 | ;; |
57a6839d | 227 | |
b75a7d8f | 228 | --cxx) |
729e4ab9 | 229 | echo $ECHO_N "${CXX} ${ECHO_C}" |
b75a7d8f A |
230 | ;; |
231 | ||
232 | --cxxflags) | |
729e4ab9 | 233 | echo $ECHO_N "${CXXFLAGS} ${ECHO_C}" |
b75a7d8f A |
234 | ;; |
235 | ||
236 | --cppflags) | |
237 | # Don't echo the -I. - it's unneeded. | |
729e4ab9 | 238 | echo $ECHO_N "${CPPFLAGS} ${ECHO_C}" | sed -e 's/-I. //' |
b75a7d8f A |
239 | ;; |
240 | ||
241 | --cppflags-searchpath) | |
729e4ab9 | 242 | echo $ECHO_N "-I${prefix}/include ${ECHO_C}" |
b75a7d8f A |
243 | ;; |
244 | ||
245 | --cppflags-dynamic) | |
729e4ab9 | 246 | echo $ECHO_N "${SHAREDLIBCPPFLAGS} ${ECHO_C}" |
b75a7d8f A |
247 | ;; |
248 | ||
249 | --cxxflags-dynamic) | |
729e4ab9 | 250 | echo $ECHO_N "${SHAREDLIBCXXFLAGS} ${ECHO_C}" |
b75a7d8f A |
251 | ;; |
252 | ||
253 | --cflags-dynamic) | |
729e4ab9 | 254 | echo $ECHO_N "${SHAREDLIBCFLAGS} ${ECHO_C}" |
b75a7d8f A |
255 | ;; |
256 | ||
257 | --ldflags-system) | |
729e4ab9 | 258 | echo $ECHO_N "${LIBS} ${ECHO_C}" |
b75a7d8f A |
259 | ;; |
260 | ||
261 | --ldflags) | |
57a6839d | 262 | echo $ECHO_N "${LDFLAGS} ${ICULIBS} ${ECHO_C}" |
b75a7d8f A |
263 | # $RPATH_LDFLAGS |
264 | ;; | |
265 | ||
266 | --ldflags-libsonly) | |
729e4ab9 | 267 | echo $ECHO_N "${ICULIBS_I18N} ${ICULIBS_COMMON} ${ICULIBS_DATA} ${ECHO_C}" |
b75a7d8f A |
268 | ;; |
269 | ||
374ca955 | 270 | --ldflags-icuio) |
729e4ab9 | 271 | echo $ECHO_N " ${ICULIBS_ICUIO} ${ECHO_C}" |
b75a7d8f A |
272 | ;; |
273 | ||
274 | --ldflags-obsolete) | |
729e4ab9 | 275 | echo $ECHO_N "${ICULIBS_OBSOLETE} ${ECHO_C}" |
b75a7d8f A |
276 | ;; |
277 | ||
278 | --ldflags-toolutil) | |
729e4ab9 | 279 | echo $ECHO_N " ${ICULIBS_TOOLUTIL} ${ECHO_C}" |
b75a7d8f A |
280 | ;; |
281 | ||
282 | --ldflags-layout) | |
f3c0d7a5 A |
283 | echo ${ME}: ERROR: the old layout engine has been removed. use HarfBuzz. |
284 | exit 1 | |
b75a7d8f A |
285 | ;; |
286 | ||
287 | --ldflags-searchpath) | |
729e4ab9 | 288 | echo $ECHO_N "-L${libdir} ${ECHO_C}" |
b75a7d8f A |
289 | ;; |
290 | ||
291 | --detect-prefix) | |
292 | HERE=`echo $0 | sed -e "s/$ME//g"` | |
729e4ab9 A |
293 | if [ -f "${HERE}/../lib/${ICULIBS_COMMON_LIB_NAME}" -o -f "${HERE}/../lib/${ICULIBS_COMMON_LIB_NAME_A}" ]; then |
294 | prefix="${HERE}/.." | |
b75a7d8f A |
295 | echo "## Using --prefix=${prefix}" 1>&2 |
296 | fi | |
297 | loaddefs | |
298 | loaddefs | |
b75a7d8f A |
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 | |
b75a7d8f A |
313 | ;; |
314 | ||
315 | --sysconfdir) | |
316 | echo $sysconfdir | |
317 | ;; | |
318 | ||
319 | --mandir) | |
320 | echo $mandir | |
321 | ;; | |
322 | ||
323 | --shared-datadir) | |
729e4ab9 | 324 | echo $ECHO_N "${datadir} ${ECHO_C}" |
b75a7d8f A |
325 | ;; |
326 | ||
327 | --incfile) | |
729e4ab9 A |
328 | echo $ECHO_N "${pkglibdir}/Makefile.inc ${ECHO_C}" |
329 | ;; | |
330 | ||
331 | --incpkgdatafile) | |
332 | echo $ECHO_N "${pkglibdir}/pkgdata.inc ${ECHO_C}" | |
b75a7d8f A |
333 | ;; |
334 | ||
335 | --icudata) | |
729e4ab9 | 336 | echo $ECHO_N "${ICUDATA_NAME} ${ECHO_C}" |
b75a7d8f A |
337 | ;; |
338 | ||
339 | --icudata-mode) | |
729e4ab9 | 340 | echo $ECHO_N "${PKGDATA_MODE} ${ECHO_C}" |
b75a7d8f A |
341 | ;; |
342 | ||
343 | --icudata-install-dir) | |
729e4ab9 | 344 | echo $ECHO_N "${ICUPKGDATA_DIR} ${ECHO_C}" |
b75a7d8f | 345 | ;; |
57a6839d | 346 | |
b75a7d8f | 347 | --icudatadir) |
729e4ab9 | 348 | echo $ECHO_N "${ICUDATA_DIR} ${ECHO_C}" |
b75a7d8f A |
349 | ;; |
350 | ||
351 | --shlib-c) | |
729e4ab9 | 352 | echo $ECHO_N "${SHLIB_c} ${ECHO_C}" |
b75a7d8f A |
353 | ;; |
354 | ||
355 | --shlib-cc) | |
729e4ab9 | 356 | echo $ECHO_N "${SHLIB_cc} ${ECHO_C}" |
b75a7d8f A |
357 | ;; |
358 | ||
359 | --version) | |
4388f060 A |
360 | echo $ECHO_N $VERSION |
361 | ;; | |
b75a7d8f | 362 | |
4388f060 A |
363 | --unicode-version) |
364 | echo $ECHO_N $UNICODE_VERSION | |
365 | ;; | |
57a6839d | 366 | |
4388f060 A |
367 | --host) |
368 | echo $host | |
369 | exit 0 | |
370 | ;; | |
b75a7d8f A |
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 | |
57a6839d | 401 | |
729e4ab9 A |
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 | |
b75a7d8f | 407 | done |
729e4ab9 | 408 | echo |
b75a7d8f A |
409 | # Check once before we quit (will check last used prefix) |
410 | sanity | |
411 | ## END of icu-config-bottom | |
412 | ||
413 | exit 0 |