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