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