michael@0: ## -*-sh-*- michael@0: ## BEGIN of icu-config-bottom. michael@0: ## Copyright (c) 2002-2013, International Business Machines Corporation and michael@0: ## others. All Rights Reserved. michael@0: michael@0: ICUUC_FILE="${libdir}/${ICULIBS_COMMON_LIB_NAME}" michael@0: ICUUC_FILE_A="${libdir}/${ICULIBS_COMMON_LIB_NAME_A}" michael@0: michael@0: # echo ENABLE RPATH $ENABLE_RPATH and RPATHLDFLAGS=${RPATH_LDFLAGS} michael@0: if [ "x$PKGDATA_MODE" = "x" ]; then michael@0: PKGDATA_MODE=dll michael@0: fi michael@0: michael@0: } michael@0: michael@0: ## The actual code of icu-config goes here. michael@0: michael@0: ME=`basename "$0"` michael@0: michael@0: allflags() michael@0: { michael@0: echo " --noverify Don't verify that ICU is actually installed." michael@0: echo " --bindir Print binary directory path (bin)" michael@0: echo " --cc Print C compiler used [CC]" michael@0: echo " --cflags Print C compiler flags [CFLAGS]" michael@0: echo " --cflags-dynamic Print additional C flags for" michael@0: echo " building shared libraries." michael@0: echo " --cppflags Print C Preprocessor flags [CPPFLAGS]" michael@0: echo " --cppflags-dynamic Print additional C Preprocessor flags for" michael@0: echo " building shared libraries." michael@0: echo " --cppflags-searchpath Print only -I include directives (-Iinclude)" michael@0: echo " --cxx Print C++ compiler used [CXX]" michael@0: echo " --cxxflags Print C++ compiler flags [CXXFLAGS]" michael@0: echo " --cxxflags-dynamic Print additional C++ flags for" michael@0: echo " building shared libraries." michael@0: echo " --detect-prefix Attempt to detect prefix based on PATH" michael@0: echo " --exec-prefix Print prefix for executables (/bin)" michael@0: echo " --exists Return with 0 status if ICU exists else fail" michael@0: echo " --help, -?, --usage Print this message" michael@0: echo " --icudata Print shortname of ICU data file (icudt21l)" michael@0: echo " --icudata-install-dir Print path to install data to - use as --install option to pkgdata(1)" michael@0: echo " --icudata-mode Print default ICU pkgdata mode (dll) - use as --mode option to pkgdata(1)." michael@0: echo " --icudatadir Print path to packaged archive data. Can set as [ICU_DATA]" michael@0: echo " --invoke Print commands to invoke an ICU program" michael@0: echo " --invoke= Print commands to invoke an ICU program named (ex: genrb)" michael@0: 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. " michael@0: echo " --ldflags-layout Print ICU layout engine link directive. Use in addition to --ldflags" michael@0: echo " --ldflags-libsonly Same as --ldflags, but only the -l directives" michael@0: echo " --ldflags-searchpath Print only -L (search path) directive" michael@0: echo " --ldflags-system Print only system libs ICU links with (-lpthread, -lm)" michael@0: echo " --ldflags-icuio Print ICU icuio link directive. Use in addition to --ldflags " michael@0: echo " --ldflags-obsolete Print ICU obsolete link directive. Use in addition to --ldflags. (requires icuapps/obsolete to be built and installed.) " michael@0: echo " --mandir Print manpage (man) path" michael@0: echo " --prefix Print PREFIX to icu install (/usr/local)" michael@0: echo " --prefix=XXX Set prefix to XXX for remainder of command" michael@0: echo " --sbindir Print system binary path (sbin) " michael@0: echo " --shared-datadir Print shared data (share) path. This is NOT the ICU data dir." michael@0: echo " --shlib-c Print the command to compile and build C shared libraries with ICU" michael@0: echo " --shlib-cc Print the command to compile and build C++ shared libraries with ICU" michael@0: echo " --sysconfdir Print system config (etc) path" michael@0: echo " --unicode-version Print version of Unicode data used in ICU ($UNICODE_VERSION)" michael@0: echo " --version Print ICU version ($VERSION)" michael@0: echo " --incfile Print path to Makefile.inc" michael@0: echo " --incpkgdatafile Print path to pkgdata.inc (for -O option of pkgdata)" michael@0: echo " --install Print path to install-sh" michael@0: echo " --mkinstalldirs Print path to mkinstalldirs" michael@0: } michael@0: michael@0: ## Print the normal usage message michael@0: shortusage() michael@0: { michael@0: echo "usage: ${ME} " `allflags | cut -c-25 | sed -e 's%.*%[ & ]%'` michael@0: } michael@0: michael@0: michael@0: usage() michael@0: { michael@0: echo "${ME}: icu-config: ICU configuration helper script" michael@0: echo michael@0: echo "The most commonly used options will be --cflags, --cxxflags, --cppflags, and --ldflags." michael@0: echo 'Example (in make): CPFLAGS=$(shell icu-config --cppflags)' michael@0: echo ' LDFLAGS=$(shell icu-config --ldflags)' michael@0: echo " (etc).." michael@0: echo michael@0: echo "Usage:" michael@0: allflags michael@0: michael@0: echo michael@0: echo " [Brackets] show MAKE variable equivalents, (parenthesis) show example output" michael@0: echo michael@0: echo "Copyright (c) 2002-2013, International Business Machines Corporation and others. All Rights Reserved." michael@0: echo michael@0: echo "NOTE: Please consider using the pkg-config (.pc) files instead of icu-config." michael@0: echo " See: " michael@0: } michael@0: michael@0: ## Check the sanity of current variables michael@0: sanity() michael@0: { michael@0: if [ ! -f "${ICUUC_FILE}" -a ! -f "${ICUUC_FILE_A}" ] && [ ${IGNORE_ICUUC_FILE_CHECK} = "no" ] && [ ${SANITY} = "sane" ]; michael@0: then michael@0: echo "### $ME: Can't find ${ICUUC_FILE} - ICU prefix is wrong." 1>&2 michael@0: echo "### Try the --prefix= option " 1>&2 michael@0: echo "### or --detect-prefix" 1>&2 michael@0: echo "### (If you want to disable this check, use the --noverify option)" 1>&2 michael@0: echo "### $ME: Exitting." 1>&2 michael@0: exit 2 michael@0: fi michael@0: } michael@0: michael@0: ## Main starts here. michael@0: michael@0: if [ $# -lt 1 ]; then michael@0: shortusage michael@0: exit 1 michael@0: fi michael@0: michael@0: # For certain options (e.g. --detect-prefix) don't check for icuuc library file. michael@0: michael@0: IGNORE_ICUUC_FILE_CHECK="no"; michael@0: michael@0: SANITY="sane" michael@0: michael@0: case "$1" in michael@0: --noverify) michael@0: SANITY="nosanity" michael@0: shift michael@0: ;; michael@0: esac michael@0: michael@0: case "$1" in michael@0: *prefix*) michael@0: IGNORE_ICUUC_FILE_CHECK="yes" michael@0: ;; michael@0: esac michael@0: michael@0: # Load our variables from autoconf michael@0: # ALWAYS load twice because of dependencies michael@0: loaddefs michael@0: loaddefs michael@0: michael@0: if [ $# -gt 0 -a $1 = "--selfcheck" ]; michael@0: then michael@0: echo "passed" michael@0: exit michael@0: # EXIT for self check michael@0: fi michael@0: michael@0: sanity michael@0: michael@0: while [ $# -gt 0 ]; michael@0: do michael@0: arg="$1" michael@0: var=`echo $arg | sed -e 's/^[^=]*=//'` michael@0: # echo "### processing $arg" 1>&2 michael@0: case "$arg" in michael@0: michael@0: # undocumented. michael@0: --debug) michael@0: set -x michael@0: ;; michael@0: michael@0: --noverify) michael@0: echo "### $ME: Error: --noverify must be the first argument." 1>&2 michael@0: exit 1 michael@0: ;; michael@0: michael@0: --so) michael@0: echo $SO michael@0: ;; michael@0: michael@0: --bindir) michael@0: echo $bindir michael@0: ;; michael@0: michael@0: --libdir) michael@0: echo $libdir michael@0: ;; michael@0: michael@0: --exists) michael@0: sanity michael@0: ;; michael@0: michael@0: --sbindir) michael@0: echo $sbindir michael@0: ;; michael@0: michael@0: --mkinstalldirs) michael@0: echo ${MKINSTALLDIRS} michael@0: ;; michael@0: michael@0: --install) michael@0: echo ${INSTALL} michael@0: ;; michael@0: michael@0: --invoke=*) michael@0: QUOT="\"" michael@0: CMD="${var}" michael@0: michael@0: # If it's not a locally executable command (1st choice) then michael@0: # search for it in the ICU directories. michael@0: if [ ! -x ${CMD} ]; then michael@0: if [ -x ${bindir}/${var} ]; then michael@0: CMD="${bindir}/${var}" michael@0: fi michael@0: if [ -x ${sbindir}/${var} ]; then michael@0: CMD="${sbindir}/${var}" michael@0: fi michael@0: fi michael@0: michael@0: echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} ${CMD} michael@0: ;; michael@0: michael@0: --invoke) michael@0: QUOT="\"" michael@0: echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} michael@0: ;; michael@0: michael@0: --cflags) michael@0: echo $ECHO_N "${CFLAGS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cc) michael@0: echo $ECHO_N "${CC} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cxx) michael@0: echo $ECHO_N "${CXX} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cxxflags) michael@0: echo $ECHO_N "${CXXFLAGS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cppflags) michael@0: # Don't echo the -I. - it's unneeded. michael@0: echo $ECHO_N "${CPPFLAGS} ${ECHO_C}" | sed -e 's/-I. //' michael@0: ;; michael@0: michael@0: --cppflags-searchpath) michael@0: echo $ECHO_N "-I${prefix}/include ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cppflags-dynamic) michael@0: echo $ECHO_N "${SHAREDLIBCPPFLAGS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cxxflags-dynamic) michael@0: echo $ECHO_N "${SHAREDLIBCXXFLAGS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --cflags-dynamic) michael@0: echo $ECHO_N "${SHAREDLIBCFLAGS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-system) michael@0: echo $ECHO_N "${LIBS} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags) michael@0: echo $ECHO_N "${LDFLAGS} ${ICULIBS} ${LIBS} ${ECHO_C}" michael@0: # $RPATH_LDFLAGS michael@0: ;; michael@0: michael@0: --ldflags-libsonly) michael@0: echo $ECHO_N "${ICULIBS_I18N} ${ICULIBS_COMMON} ${ICULIBS_DATA} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-icuio) michael@0: echo $ECHO_N " ${ICULIBS_ICUIO} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-obsolete) michael@0: echo $ECHO_N "${ICULIBS_OBSOLETE} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-toolutil) michael@0: echo $ECHO_N " ${ICULIBS_TOOLUTIL} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-layout) michael@0: echo $ECHO_N "${ICULIBS_LAYOUT} ${ICULIBS_LAYOUTEX} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --ldflags-searchpath) michael@0: echo $ECHO_N "-L${libdir} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --detect-prefix) michael@0: HERE=`echo $0 | sed -e "s/$ME//g"` michael@0: if [ -f "${HERE}/../lib/${ICULIBS_COMMON_LIB_NAME}" -o -f "${HERE}/../lib/${ICULIBS_COMMON_LIB_NAME_A}" ]; then michael@0: prefix="${HERE}/.." michael@0: echo "## Using --prefix=${prefix}" 1>&2 michael@0: fi michael@0: loaddefs michael@0: loaddefs michael@0: ;; michael@0: michael@0: --exec-prefix) michael@0: echo $exec_prefix michael@0: ;; michael@0: michael@0: --prefix) michael@0: echo $prefix michael@0: ;; michael@0: michael@0: --prefix=*) michael@0: prefix=$var michael@0: loaddefs michael@0: loaddefs michael@0: ;; michael@0: michael@0: --sysconfdir) michael@0: echo $sysconfdir michael@0: ;; michael@0: michael@0: --mandir) michael@0: echo $mandir michael@0: ;; michael@0: michael@0: --shared-datadir) michael@0: echo $ECHO_N "${datadir} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --incfile) michael@0: echo $ECHO_N "${pkglibdir}/Makefile.inc ${ECHO_C}" michael@0: ;; michael@0: michael@0: --incpkgdatafile) michael@0: echo $ECHO_N "${pkglibdir}/pkgdata.inc ${ECHO_C}" michael@0: ;; michael@0: michael@0: --icudata) michael@0: echo $ECHO_N "${ICUDATA_NAME} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --icudata-mode) michael@0: echo $ECHO_N "${PKGDATA_MODE} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --icudata-install-dir) michael@0: echo $ECHO_N "${ICUPKGDATA_DIR} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --icudatadir) michael@0: echo $ECHO_N "${ICUDATA_DIR} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --shlib-c) michael@0: echo $ECHO_N "${SHLIB_c} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --shlib-cc) michael@0: echo $ECHO_N "${SHLIB_cc} ${ECHO_C}" michael@0: ;; michael@0: michael@0: --version) michael@0: echo $ECHO_N $VERSION michael@0: ;; michael@0: michael@0: --unicode-version) michael@0: echo $ECHO_N $UNICODE_VERSION michael@0: ;; michael@0: michael@0: --host) michael@0: echo $host michael@0: exit 0 michael@0: ;; michael@0: michael@0: --help) michael@0: usage michael@0: exit 0 michael@0: ;; michael@0: michael@0: --usage) michael@0: usage michael@0: exit 0 michael@0: ;; michael@0: michael@0: # --enable-rpath=*) michael@0: # ENABLE_RPATH=$var michael@0: # loaddefs michael@0: # ;; michael@0: michael@0: -?) michael@0: usage michael@0: exit 0 michael@0: ;; michael@0: michael@0: *) michael@0: echo ${ME}: ERROR Unknown Option $arg 1>&2 michael@0: echo 1>&2 michael@0: shortusage 1>&2 michael@0: echo "### $ME: Exitting." 1>&2 michael@0: exit 1; michael@0: ;; michael@0: esac michael@0: shift michael@0: michael@0: # Reset the ignore icuuc file check flag michael@0: if [ $IGNORE_ICUUC_FILE_CHECK = "yes" ]; then michael@0: IGNORE_ICUUC_FILE_CHECK="no" michael@0: sanity michael@0: fi michael@0: done michael@0: echo michael@0: # Check once before we quit (will check last used prefix) michael@0: sanity michael@0: ## END of icu-config-bottom michael@0: michael@0: exit 0