obexd-0.46/0000755000000000000000000000000011755212614007517 500000000000000obexd-0.46/aclocal.m40000644000000000000000000126551311755212540011312 00000000000000# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, # 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless `enable' is passed literally. # For symmetry, `disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful (and sometimes confusing) to the casual installer], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2009, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few `make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using `$V' instead of `$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) obexd-0.46/depcomp0000755000000000000000000004755611755212545011040 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: obexd-0.46/INSTALL0000644000000000000000000002245011071665561010477 00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. obexd-0.46/config.h.in0000644000000000000000000000370411755212542011466 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Directory for the configuration files */ #undef CONFIGDIR /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define if libc defines a timezone variable */ #undef HAVE_TIMEZONE /* Define if struct tm has a tm_gmtoff member */ #undef HAVE_TM_GMTOFF /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define if threading support is required */ #undef NEED_THREADS /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION obexd-0.46/btio/0000755000000000000000000000000011755212614010454 500000000000000obexd-0.46/btio/btio.c0000644000000000000000000007733311755212521011507 00000000000000/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2009-2010 Marcel Holtmann * Copyright (C) 2009-2010 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "btio.h" #ifndef BT_FLUSHABLE #define BT_FLUSHABLE 8 #endif #define ERROR_FAILED(gerr, str, err) \ g_set_error(gerr, BT_IO_ERROR, BT_IO_ERROR_FAILED, \ str ": %s (%d)", strerror(err), err) #define DEFAULT_DEFER_TIMEOUT 30 struct set_opts { bdaddr_t src; bdaddr_t dst; int defer; int sec_level; uint8_t channel; uint16_t psm; uint16_t cid; uint16_t mtu; uint16_t imtu; uint16_t omtu; int master; uint8_t mode; int flushable; uint32_t priority; }; struct connect { BtIOConnect connect; gpointer user_data; GDestroyNotify destroy; }; struct accept { BtIOConnect connect; gpointer user_data; GDestroyNotify destroy; }; struct server { BtIOConnect connect; BtIOConfirm confirm; gpointer user_data; GDestroyNotify destroy; }; static void server_remove(struct server *server) { if (server->destroy) server->destroy(server->user_data); g_free(server); } static void connect_remove(struct connect *conn) { if (conn->destroy) conn->destroy(conn->user_data); g_free(conn); } static void accept_remove(struct accept *accept) { if (accept->destroy) accept->destroy(accept->user_data); g_free(accept); } static gboolean check_nval(GIOChannel *io) { struct pollfd fds; memset(&fds, 0, sizeof(fds)); fds.fd = g_io_channel_unix_get_fd(io); fds.events = POLLNVAL; if (poll(&fds, 1, 0) > 0 && (fds.revents & POLLNVAL)) return TRUE; return FALSE; } static gboolean accept_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct accept *accept = user_data; GError *err = NULL; /* If the user aborted this accept attempt */ if ((cond & G_IO_NVAL) || check_nval(io)) return FALSE; if (cond & (G_IO_HUP | G_IO_ERR)) g_set_error(&err, BT_IO_ERROR, BT_IO_ERROR_DISCONNECTED, "HUP or ERR on socket"); accept->connect(io, err, accept->user_data); g_clear_error(&err); return FALSE; } static gboolean connect_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct connect *conn = user_data; GError *gerr = NULL; /* If the user aborted this connect attempt */ if ((cond & G_IO_NVAL) || check_nval(io)) return FALSE; if (cond & G_IO_OUT) { int err, sk_err = 0, sock = g_io_channel_unix_get_fd(io); socklen_t len = sizeof(sk_err); if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) err = -errno; else err = -sk_err; if (err < 0) g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED, "%s (%d)", strerror(-err), -err); } else if (cond & (G_IO_HUP | G_IO_ERR)) g_set_error(&gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED, "HUP or ERR on socket"); conn->connect(io, gerr, conn->user_data); if (gerr) g_error_free(gerr); return FALSE; } static gboolean server_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct server *server = user_data; int srv_sock, cli_sock; GIOChannel *cli_io; /* If the user closed the server */ if ((cond & G_IO_NVAL) || check_nval(io)) return FALSE; srv_sock = g_io_channel_unix_get_fd(io); cli_sock = accept(srv_sock, NULL, NULL); if (cli_sock < 0) return TRUE; cli_io = g_io_channel_unix_new(cli_sock); g_io_channel_set_close_on_unref(cli_io, TRUE); g_io_channel_set_flags(cli_io, G_IO_FLAG_NONBLOCK, NULL); if (server->confirm) server->confirm(cli_io, server->user_data); else server->connect(cli_io, NULL, server->user_data); g_io_channel_unref(cli_io); return TRUE; } static void server_add(GIOChannel *io, BtIOConnect connect, BtIOConfirm confirm, gpointer user_data, GDestroyNotify destroy) { struct server *server; GIOCondition cond; server = g_new0(struct server, 1); server->connect = connect; server->confirm = confirm; server->user_data = user_data; server->destroy = destroy; cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL; g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, server_cb, server, (GDestroyNotify) server_remove); } static void connect_add(GIOChannel *io, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy) { struct connect *conn; GIOCondition cond; conn = g_new0(struct connect, 1); conn->connect = connect; conn->user_data = user_data; conn->destroy = destroy; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, connect_cb, conn, (GDestroyNotify) connect_remove); } static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy) { struct accept *accept; GIOCondition cond; accept = g_new0(struct accept, 1); accept->connect = connect; accept->user_data = user_data; accept->destroy = destroy; cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL; g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, accept_cb, accept, (GDestroyNotify) accept_remove); } static int l2cap_bind(int sock, const bdaddr_t *src, uint16_t psm, uint16_t cid, GError **err) { struct sockaddr_l2 addr; memset(&addr, 0, sizeof(addr)); addr.l2_family = AF_BLUETOOTH; bacpy(&addr.l2_bdaddr, src); if (cid) addr.l2_cid = htobs(cid); else addr.l2_psm = htobs(psm); if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { int error = -errno; ERROR_FAILED(err, "l2cap_bind", errno); return error; } return 0; } static int l2cap_connect(int sock, const bdaddr_t *dst, uint16_t psm, uint16_t cid) { int err; struct sockaddr_l2 addr; memset(&addr, 0, sizeof(addr)); addr.l2_family = AF_BLUETOOTH; bacpy(&addr.l2_bdaddr, dst); if (cid) addr.l2_cid = htobs(cid); else addr.l2_psm = htobs(psm); err = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) return -errno; return 0; } static int l2cap_set_master(int sock, int master) { int flags; socklen_t len; len = sizeof(flags); if (getsockopt(sock, SOL_L2CAP, L2CAP_LM, &flags, &len) < 0) return -errno; if (master) { if (flags & L2CAP_LM_MASTER) return 0; flags |= L2CAP_LM_MASTER; } else { if (!(flags & L2CAP_LM_MASTER)) return 0; flags &= ~L2CAP_LM_MASTER; } if (setsockopt(sock, SOL_L2CAP, L2CAP_LM, &flags, sizeof(flags)) < 0) return -errno; return 0; } static int rfcomm_set_master(int sock, int master) { int flags; socklen_t len; len = sizeof(flags); if (getsockopt(sock, SOL_RFCOMM, RFCOMM_LM, &flags, &len) < 0) return -errno; if (master) { if (flags & RFCOMM_LM_MASTER) return 0; flags |= RFCOMM_LM_MASTER; } else { if (!(flags & RFCOMM_LM_MASTER)) return 0; flags &= ~RFCOMM_LM_MASTER; } if (setsockopt(sock, SOL_RFCOMM, RFCOMM_LM, &flags, sizeof(flags)) < 0) return -errno; return 0; } static int l2cap_set_lm(int sock, int level) { int lm_map[] = { 0, L2CAP_LM_AUTH, L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT, L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | L2CAP_LM_SECURE, }, opt = lm_map[level]; if (setsockopt(sock, SOL_L2CAP, L2CAP_LM, &opt, sizeof(opt)) < 0) return -errno; return 0; } static int rfcomm_set_lm(int sock, int level) { int lm_map[] = { 0, RFCOMM_LM_AUTH, RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT, RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE, }, opt = lm_map[level]; if (setsockopt(sock, SOL_RFCOMM, RFCOMM_LM, &opt, sizeof(opt)) < 0) return -errno; return 0; } static gboolean set_sec_level(int sock, BtIOType type, int level, GError **err) { struct bt_security sec; int ret; if (level < BT_SECURITY_LOW || level > BT_SECURITY_HIGH) { g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Valid security level range is %d-%d", BT_SECURITY_LOW, BT_SECURITY_HIGH); return FALSE; } memset(&sec, 0, sizeof(sec)); sec.level = level; if (setsockopt(sock, SOL_BLUETOOTH, BT_SECURITY, &sec, sizeof(sec)) == 0) return TRUE; if (errno != ENOPROTOOPT) { ERROR_FAILED(err, "setsockopt(BT_SECURITY)", errno); return FALSE; } if (type == BT_IO_L2CAP) ret = l2cap_set_lm(sock, level); else ret = rfcomm_set_lm(sock, level); if (ret < 0) { ERROR_FAILED(err, "setsockopt(LM)", -ret); return FALSE; } return TRUE; } static int l2cap_get_lm(int sock, int *sec_level) { int opt; socklen_t len; len = sizeof(opt); if (getsockopt(sock, SOL_L2CAP, L2CAP_LM, &opt, &len) < 0) return -errno; *sec_level = 0; if (opt & L2CAP_LM_AUTH) *sec_level = BT_SECURITY_LOW; if (opt & L2CAP_LM_ENCRYPT) *sec_level = BT_SECURITY_MEDIUM; if (opt & L2CAP_LM_SECURE) *sec_level = BT_SECURITY_HIGH; return 0; } static int rfcomm_get_lm(int sock, int *sec_level) { int opt; socklen_t len; len = sizeof(opt); if (getsockopt(sock, SOL_RFCOMM, RFCOMM_LM, &opt, &len) < 0) return -errno; *sec_level = 0; if (opt & RFCOMM_LM_AUTH) *sec_level = BT_SECURITY_LOW; if (opt & RFCOMM_LM_ENCRYPT) *sec_level = BT_SECURITY_MEDIUM; if (opt & RFCOMM_LM_SECURE) *sec_level = BT_SECURITY_HIGH; return 0; } static gboolean get_sec_level(int sock, BtIOType type, int *level, GError **err) { struct bt_security sec; socklen_t len; int ret; memset(&sec, 0, sizeof(sec)); len = sizeof(sec); if (getsockopt(sock, SOL_BLUETOOTH, BT_SECURITY, &sec, &len) == 0) { *level = sec.level; return TRUE; } if (errno != ENOPROTOOPT) { ERROR_FAILED(err, "getsockopt(BT_SECURITY)", errno); return FALSE; } if (type == BT_IO_L2CAP) ret = l2cap_get_lm(sock, level); else ret = rfcomm_get_lm(sock, level); if (ret < 0) { ERROR_FAILED(err, "getsockopt(LM)", -ret); return FALSE; } return TRUE; } static int l2cap_set_flushable(int sock, gboolean flushable) { int f; f = flushable; if (setsockopt(sock, SOL_BLUETOOTH, BT_FLUSHABLE, &f, sizeof(f)) < 0) return -errno; return 0; } static int set_priority(int sock, uint32_t prio) { if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)) < 0) return -errno; return 0; } static gboolean get_key_size(int sock, int *size, GError **err) { struct bt_security sec; socklen_t len; memset(&sec, 0, sizeof(sec)); len = sizeof(sec); if (getsockopt(sock, SOL_BLUETOOTH, BT_SECURITY, &sec, &len) == 0) { *size = sec.key_size; return TRUE; } return FALSE; } static gboolean l2cap_set(int sock, int sec_level, uint16_t imtu, uint16_t omtu, uint8_t mode, int master, int flushable, uint32_t priority, GError **err) { if (imtu || omtu || mode) { struct l2cap_options l2o; socklen_t len; memset(&l2o, 0, sizeof(l2o)); len = sizeof(l2o); if (getsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &len) < 0) { ERROR_FAILED(err, "getsockopt(L2CAP_OPTIONS)", errno); return FALSE; } if (imtu) l2o.imtu = imtu; if (omtu) l2o.omtu = omtu; if (mode) l2o.mode = mode; if (setsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, sizeof(l2o)) < 0) { ERROR_FAILED(err, "setsockopt(L2CAP_OPTIONS)", errno); return FALSE; } } if (master >= 0 && l2cap_set_master(sock, master) < 0) { ERROR_FAILED(err, "l2cap_set_master", errno); return FALSE; } if (flushable >= 0 && l2cap_set_flushable(sock, flushable) < 0) { ERROR_FAILED(err, "l2cap_set_flushable", errno); return FALSE; } if (priority > 0 && set_priority(sock, priority) < 0) { ERROR_FAILED(err, "set_priority", errno); return FALSE; } if (sec_level && !set_sec_level(sock, BT_IO_L2CAP, sec_level, err)) return FALSE; return TRUE; } static int rfcomm_bind(int sock, const bdaddr_t *src, uint8_t channel, GError **err) { struct sockaddr_rc addr; memset(&addr, 0, sizeof(addr)); addr.rc_family = AF_BLUETOOTH; bacpy(&addr.rc_bdaddr, src); addr.rc_channel = channel; if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { int error = -errno; ERROR_FAILED(err, "rfcomm_bind", errno); return error; } return 0; } static int rfcomm_connect(int sock, const bdaddr_t *dst, uint8_t channel) { int err; struct sockaddr_rc addr; memset(&addr, 0, sizeof(addr)); addr.rc_family = AF_BLUETOOTH; bacpy(&addr.rc_bdaddr, dst); addr.rc_channel = channel; err = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) return -errno; return 0; } static gboolean rfcomm_set(int sock, int sec_level, int master, GError **err) { if (sec_level && !set_sec_level(sock, BT_IO_RFCOMM, sec_level, err)) return FALSE; if (master >= 0 && rfcomm_set_master(sock, master) < 0) { ERROR_FAILED(err, "rfcomm_set_master", errno); return FALSE; } return TRUE; } static int sco_bind(int sock, const bdaddr_t *src, GError **err) { struct sockaddr_sco addr; memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, src); if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { int error = -errno; ERROR_FAILED(err, "sco_bind", errno); return error; } return 0; } static int sco_connect(int sock, const bdaddr_t *dst) { struct sockaddr_sco addr; int err; memset(&addr, 0, sizeof(addr)); addr.sco_family = AF_BLUETOOTH; bacpy(&addr.sco_bdaddr, dst); err = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) return -errno; return 0; } static gboolean sco_set(int sock, uint16_t mtu, GError **err) { struct sco_options sco_opt; socklen_t len; if (!mtu) return TRUE; len = sizeof(sco_opt); memset(&sco_opt, 0, len); if (getsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0) { ERROR_FAILED(err, "getsockopt(SCO_OPTIONS)", errno); return FALSE; } sco_opt.mtu = mtu; if (setsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, sizeof(sco_opt)) < 0) { ERROR_FAILED(err, "setsockopt(SCO_OPTIONS)", errno); return FALSE; } return TRUE; } static gboolean parse_set_opts(struct set_opts *opts, GError **err, BtIOOption opt1, va_list args) { BtIOOption opt = opt1; const char *str; memset(opts, 0, sizeof(*opts)); /* Set defaults */ opts->defer = DEFAULT_DEFER_TIMEOUT; opts->master = -1; opts->mode = L2CAP_MODE_BASIC; opts->flushable = -1; opts->priority = 0; while (opt != BT_IO_OPT_INVALID) { switch (opt) { case BT_IO_OPT_SOURCE: str = va_arg(args, const char *); str2ba(str, &opts->src); break; case BT_IO_OPT_SOURCE_BDADDR: bacpy(&opts->src, va_arg(args, const bdaddr_t *)); break; case BT_IO_OPT_DEST: str2ba(va_arg(args, const char *), &opts->dst); break; case BT_IO_OPT_DEST_BDADDR: bacpy(&opts->dst, va_arg(args, const bdaddr_t *)); break; case BT_IO_OPT_DEFER_TIMEOUT: opts->defer = va_arg(args, int); break; case BT_IO_OPT_SEC_LEVEL: opts->sec_level = va_arg(args, int); break; case BT_IO_OPT_CHANNEL: opts->channel = va_arg(args, int); break; case BT_IO_OPT_PSM: opts->psm = va_arg(args, int); break; case BT_IO_OPT_CID: opts->cid = va_arg(args, int); break; case BT_IO_OPT_MTU: opts->mtu = va_arg(args, int); opts->imtu = opts->mtu; opts->omtu = opts->mtu; break; case BT_IO_OPT_OMTU: opts->omtu = va_arg(args, int); if (!opts->mtu) opts->mtu = opts->omtu; break; case BT_IO_OPT_IMTU: opts->imtu = va_arg(args, int); if (!opts->mtu) opts->mtu = opts->imtu; break; case BT_IO_OPT_MASTER: opts->master = va_arg(args, gboolean); break; case BT_IO_OPT_MODE: opts->mode = va_arg(args, int); break; case BT_IO_OPT_FLUSHABLE: opts->flushable = va_arg(args, gboolean); break; case BT_IO_OPT_PRIORITY: opts->priority = va_arg(args, int); break; default: g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown option %d", opt); return FALSE; } opt = va_arg(args, int); } return TRUE; } static gboolean get_peers(int sock, struct sockaddr *src, struct sockaddr *dst, socklen_t len, GError **err) { socklen_t olen; memset(src, 0, len); olen = len; if (getsockname(sock, src, &olen) < 0) { ERROR_FAILED(err, "getsockname", errno); return FALSE; } memset(dst, 0, len); olen = len; if (getpeername(sock, dst, &olen) < 0) { ERROR_FAILED(err, "getpeername", errno); return FALSE; } return TRUE; } static int l2cap_get_info(int sock, uint16_t *handle, uint8_t *dev_class) { struct l2cap_conninfo info; socklen_t len; len = sizeof(info); if (getsockopt(sock, SOL_L2CAP, L2CAP_CONNINFO, &info, &len) < 0) return -errno; if (handle) *handle = info.hci_handle; if (dev_class) memcpy(dev_class, info.dev_class, 3); return 0; } static int l2cap_get_flushable(int sock, gboolean *flushable) { int f; socklen_t len; f = 0; len = sizeof(f); if (getsockopt(sock, SOL_BLUETOOTH, BT_FLUSHABLE, &f, &len) < 0) return -errno; if (f) *flushable = TRUE; else *flushable = FALSE; return 0; } static int get_priority(int sock, uint32_t *prio) { socklen_t len; len = sizeof(*prio); if (getsockopt(sock, SOL_SOCKET, SO_PRIORITY, prio, &len) < 0) return -errno; return 0; } static gboolean l2cap_get(int sock, GError **err, BtIOOption opt1, va_list args) { BtIOOption opt = opt1; struct sockaddr_l2 src, dst; struct l2cap_options l2o; int flags; uint8_t dev_class[3]; uint16_t handle; socklen_t len; gboolean flushable = FALSE; uint32_t priority; len = sizeof(l2o); memset(&l2o, 0, len); if (getsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &len) < 0) { ERROR_FAILED(err, "getsockopt(L2CAP_OPTIONS)", errno); return FALSE; } if (!get_peers(sock, (struct sockaddr *) &src, (struct sockaddr *) &dst, sizeof(src), err)) return FALSE; while (opt != BT_IO_OPT_INVALID) { switch (opt) { case BT_IO_OPT_SOURCE: ba2str(&src.l2_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_SOURCE_BDADDR: bacpy(va_arg(args, bdaddr_t *), &src.l2_bdaddr); break; case BT_IO_OPT_DEST: ba2str(&dst.l2_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_DEST_BDADDR: bacpy(va_arg(args, bdaddr_t *), &dst.l2_bdaddr); break; case BT_IO_OPT_DEFER_TIMEOUT: len = sizeof(int); if (getsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, va_arg(args, int *), &len) < 0) { ERROR_FAILED(err, "getsockopt(DEFER_SETUP)", errno); return FALSE; } break; case BT_IO_OPT_SEC_LEVEL: if (!get_sec_level(sock, BT_IO_L2CAP, va_arg(args, int *), err)) return FALSE; break; case BT_IO_OPT_KEY_SIZE: if (!get_key_size(sock, va_arg(args, int *), err)) return FALSE; break; case BT_IO_OPT_PSM: *(va_arg(args, uint16_t *)) = src.l2_psm ? btohs(src.l2_psm) : btohs(dst.l2_psm); break; case BT_IO_OPT_CID: *(va_arg(args, uint16_t *)) = src.l2_cid ? btohs(src.l2_cid) : btohs(dst.l2_cid); break; case BT_IO_OPT_OMTU: *(va_arg(args, uint16_t *)) = l2o.omtu; break; case BT_IO_OPT_IMTU: *(va_arg(args, uint16_t *)) = l2o.imtu; break; case BT_IO_OPT_MASTER: len = sizeof(flags); if (getsockopt(sock, SOL_L2CAP, L2CAP_LM, &flags, &len) < 0) { ERROR_FAILED(err, "getsockopt(L2CAP_LM)", errno); return FALSE; } *(va_arg(args, gboolean *)) = (flags & L2CAP_LM_MASTER) ? TRUE : FALSE; break; case BT_IO_OPT_HANDLE: if (l2cap_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "L2CAP_CONNINFO", errno); return FALSE; } *(va_arg(args, uint16_t *)) = handle; break; case BT_IO_OPT_CLASS: if (l2cap_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "L2CAP_CONNINFO", errno); return FALSE; } memcpy(va_arg(args, uint8_t *), dev_class, 3); break; case BT_IO_OPT_MODE: *(va_arg(args, uint8_t *)) = l2o.mode; break; case BT_IO_OPT_FLUSHABLE: if (l2cap_get_flushable(sock, &flushable) < 0) { ERROR_FAILED(err, "get_flushable", errno); return FALSE; } *(va_arg(args, gboolean *)) = flushable; break; case BT_IO_OPT_PRIORITY: if (get_priority(sock, &priority) < 0) { ERROR_FAILED(err, "get_priority", errno); return FALSE; } *(va_arg(args, uint32_t *)) = priority; break; default: g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown option %d", opt); return FALSE; } opt = va_arg(args, int); } return TRUE; } static int rfcomm_get_info(int sock, uint16_t *handle, uint8_t *dev_class) { struct rfcomm_conninfo info; socklen_t len; len = sizeof(info); if (getsockopt(sock, SOL_RFCOMM, RFCOMM_CONNINFO, &info, &len) < 0) return -errno; if (handle) *handle = info.hci_handle; if (dev_class) memcpy(dev_class, info.dev_class, 3); return 0; } static gboolean rfcomm_get(int sock, GError **err, BtIOOption opt1, va_list args) { BtIOOption opt = opt1; struct sockaddr_rc src, dst; int flags; socklen_t len; uint8_t dev_class[3]; uint16_t handle; if (!get_peers(sock, (struct sockaddr *) &src, (struct sockaddr *) &dst, sizeof(src), err)) return FALSE; while (opt != BT_IO_OPT_INVALID) { switch (opt) { case BT_IO_OPT_SOURCE: ba2str(&src.rc_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_SOURCE_BDADDR: bacpy(va_arg(args, bdaddr_t *), &src.rc_bdaddr); break; case BT_IO_OPT_DEST: ba2str(&dst.rc_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_DEST_BDADDR: bacpy(va_arg(args, bdaddr_t *), &dst.rc_bdaddr); break; case BT_IO_OPT_DEFER_TIMEOUT: len = sizeof(int); if (getsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, va_arg(args, int *), &len) < 0) { ERROR_FAILED(err, "getsockopt(DEFER_SETUP)", errno); return FALSE; } break; case BT_IO_OPT_SEC_LEVEL: if (!get_sec_level(sock, BT_IO_RFCOMM, va_arg(args, int *), err)) return FALSE; break; case BT_IO_OPT_CHANNEL: *(va_arg(args, uint8_t *)) = src.rc_channel ? src.rc_channel : dst.rc_channel; break; case BT_IO_OPT_SOURCE_CHANNEL: *(va_arg(args, uint8_t *)) = src.rc_channel; break; case BT_IO_OPT_DEST_CHANNEL: *(va_arg(args, uint8_t *)) = dst.rc_channel; break; case BT_IO_OPT_MASTER: len = sizeof(flags); if (getsockopt(sock, SOL_RFCOMM, RFCOMM_LM, &flags, &len) < 0) { ERROR_FAILED(err, "getsockopt(RFCOMM_LM)", errno); return FALSE; } *(va_arg(args, gboolean *)) = (flags & RFCOMM_LM_MASTER) ? TRUE : FALSE; break; case BT_IO_OPT_HANDLE: if (rfcomm_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "RFCOMM_CONNINFO", errno); return FALSE; } *(va_arg(args, uint16_t *)) = handle; break; case BT_IO_OPT_CLASS: if (rfcomm_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "RFCOMM_CONNINFO", errno); return FALSE; } memcpy(va_arg(args, uint8_t *), dev_class, 3); break; default: g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown option %d", opt); return FALSE; } opt = va_arg(args, int); } return TRUE; } static int sco_get_info(int sock, uint16_t *handle, uint8_t *dev_class) { struct sco_conninfo info; socklen_t len; len = sizeof(info); if (getsockopt(sock, SOL_SCO, SCO_CONNINFO, &info, &len) < 0) return -errno; if (handle) *handle = info.hci_handle; if (dev_class) memcpy(dev_class, info.dev_class, 3); return 0; } static gboolean sco_get(int sock, GError **err, BtIOOption opt1, va_list args) { BtIOOption opt = opt1; struct sockaddr_sco src, dst; struct sco_options sco_opt; socklen_t len; uint8_t dev_class[3]; uint16_t handle; len = sizeof(sco_opt); memset(&sco_opt, 0, len); if (getsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0) { ERROR_FAILED(err, "getsockopt(SCO_OPTIONS)", errno); return FALSE; } if (!get_peers(sock, (struct sockaddr *) &src, (struct sockaddr *) &dst, sizeof(src), err)) return FALSE; while (opt != BT_IO_OPT_INVALID) { switch (opt) { case BT_IO_OPT_SOURCE: ba2str(&src.sco_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_SOURCE_BDADDR: bacpy(va_arg(args, bdaddr_t *), &src.sco_bdaddr); break; case BT_IO_OPT_DEST: ba2str(&dst.sco_bdaddr, va_arg(args, char *)); break; case BT_IO_OPT_DEST_BDADDR: bacpy(va_arg(args, bdaddr_t *), &dst.sco_bdaddr); break; case BT_IO_OPT_MTU: case BT_IO_OPT_IMTU: case BT_IO_OPT_OMTU: *(va_arg(args, uint16_t *)) = sco_opt.mtu; break; case BT_IO_OPT_HANDLE: if (sco_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "SCO_CONNINFO", errno); return FALSE; } *(va_arg(args, uint16_t *)) = handle; break; case BT_IO_OPT_CLASS: if (sco_get_info(sock, &handle, dev_class) < 0) { ERROR_FAILED(err, "SCO_CONNINFO", errno); return FALSE; } memcpy(va_arg(args, uint8_t *), dev_class, 3); break; default: g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown option %d", opt); return FALSE; } opt = va_arg(args, int); } return TRUE; } static gboolean get_valist(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, va_list args) { int sock; sock = g_io_channel_unix_get_fd(io); switch (type) { case BT_IO_L2RAW: case BT_IO_L2CAP: case BT_IO_L2ERTM: return l2cap_get(sock, err, opt1, args); case BT_IO_RFCOMM: return rfcomm_get(sock, err, opt1, args); case BT_IO_SCO: return sco_get(sock, err, opt1, args); } g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown BtIO type %d", type); return FALSE; } gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy, GError **err) { int sock; char c; struct pollfd pfd; sock = g_io_channel_unix_get_fd(io); memset(&pfd, 0, sizeof(pfd)); pfd.fd = sock; pfd.events = POLLOUT; if (poll(&pfd, 1, 0) < 0) { ERROR_FAILED(err, "poll", errno); return FALSE; } if (!(pfd.revents & POLLOUT)) { if (read(sock, &c, 1) < 0) { ERROR_FAILED(err, "read", errno); return FALSE; } } accept_add(io, connect, user_data, destroy); return TRUE; } gboolean bt_io_set(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, ...) { va_list args; gboolean ret; struct set_opts opts; int sock; va_start(args, opt1); ret = parse_set_opts(&opts, err, opt1, args); va_end(args); if (!ret) return ret; sock = g_io_channel_unix_get_fd(io); switch (type) { case BT_IO_L2RAW: case BT_IO_L2CAP: case BT_IO_L2ERTM: return l2cap_set(sock, opts.sec_level, opts.imtu, opts.omtu, opts.mode, opts.master, opts.flushable, opts.priority, err); case BT_IO_RFCOMM: return rfcomm_set(sock, opts.sec_level, opts.master, err); case BT_IO_SCO: return sco_set(sock, opts.mtu, err); } g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown BtIO type %d", type); return FALSE; } gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, ...) { va_list args; gboolean ret; va_start(args, opt1); ret = get_valist(io, type, err, opt1, args); va_end(args); return ret; } static GIOChannel *create_io(BtIOType type, gboolean server, struct set_opts *opts, GError **err) { int sock; GIOChannel *io; switch (type) { case BT_IO_L2RAW: sock = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP); if (sock < 0) { ERROR_FAILED(err, "socket(RAW, L2CAP)", errno); return NULL; } if (l2cap_bind(sock, &opts->src, server ? opts->psm : 0, opts->cid, err) < 0) goto failed; if (!l2cap_set(sock, opts->sec_level, 0, 0, 0, -1, -1, 0, err)) goto failed; break; case BT_IO_L2CAP: sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); if (sock < 0) { ERROR_FAILED(err, "socket(SEQPACKET, L2CAP)", errno); return NULL; } if (l2cap_bind(sock, &opts->src, server ? opts->psm : 0, opts->cid, err) < 0) goto failed; if (!l2cap_set(sock, opts->sec_level, opts->imtu, opts->omtu, opts->mode, opts->master, opts->flushable, opts->priority, err)) goto failed; break; case BT_IO_L2ERTM: sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_L2CAP); if (sock < 0) { ERROR_FAILED(err, "socket(STREAM, L2CAP)", errno); return NULL; } if (l2cap_bind(sock, &opts->src, server ? opts->psm : 0, opts->cid, err) < 0) goto failed; if (!l2cap_set(sock, opts->sec_level, opts->imtu, opts->omtu, opts->mode, opts->master, opts->flushable, opts->priority, err)) goto failed; break; case BT_IO_RFCOMM: sock = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); if (sock < 0) { ERROR_FAILED(err, "socket(STREAM, RFCOMM)", errno); return NULL; } if (rfcomm_bind(sock, &opts->src, server ? opts->channel : 0, err) < 0) goto failed; if (!rfcomm_set(sock, opts->sec_level, opts->master, err)) goto failed; break; case BT_IO_SCO: sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); if (sock < 0) { ERROR_FAILED(err, "socket(SEQPACKET, SCO)", errno); return NULL; } if (sco_bind(sock, &opts->src, err) < 0) goto failed; if (!sco_set(sock, opts->mtu, err)) goto failed; break; default: g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown BtIO type %d", type); return NULL; } io = g_io_channel_unix_new(sock); g_io_channel_set_close_on_unref(io, TRUE); g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); return io; failed: close(sock); return NULL; } GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy, GError **gerr, BtIOOption opt1, ...) { GIOChannel *io; va_list args; struct set_opts opts; int err, sock; gboolean ret; va_start(args, opt1); ret = parse_set_opts(&opts, gerr, opt1, args); va_end(args); if (ret == FALSE) return NULL; io = create_io(type, FALSE, &opts, gerr); if (io == NULL) return NULL; sock = g_io_channel_unix_get_fd(io); switch (type) { case BT_IO_L2RAW: err = l2cap_connect(sock, &opts.dst, 0, opts.cid); break; case BT_IO_L2CAP: case BT_IO_L2ERTM: err = l2cap_connect(sock, &opts.dst, opts.psm, opts.cid); break; case BT_IO_RFCOMM: err = rfcomm_connect(sock, &opts.dst, opts.channel); break; case BT_IO_SCO: err = sco_connect(sock, &opts.dst); break; default: g_set_error(gerr, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Unknown BtIO type %d", type); return NULL; } if (err < 0) { g_set_error(gerr, BT_IO_ERROR, BT_IO_ERROR_CONNECT_FAILED, "connect: %s (%d)", strerror(-err), -err); g_io_channel_unref(io); return NULL; } connect_add(io, connect, user_data, destroy); return io; } GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect, BtIOConfirm confirm, gpointer user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...) { GIOChannel *io; va_list args; struct set_opts opts; int sock; gboolean ret; if (type == BT_IO_L2RAW) { g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS, "Server L2CAP RAW sockets not supported"); return NULL; } va_start(args, opt1); ret = parse_set_opts(&opts, err, opt1, args); va_end(args); if (ret == FALSE) return NULL; io = create_io(type, TRUE, &opts, err); if (io == NULL) return NULL; sock = g_io_channel_unix_get_fd(io); if (confirm) setsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, &opts.defer, sizeof(opts.defer)); if (listen(sock, 5) < 0) { ERROR_FAILED(err, "listen", errno); g_io_channel_unref(io); return NULL; } server_add(io, connect, confirm, user_data, destroy); return io; } GQuark bt_io_error_quark(void) { return g_quark_from_static_string("bt-io-error-quark"); } obexd-0.46/btio/btio.h0000644000000000000000000000532511755212521011504 00000000000000/* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2009-2010 Marcel Holtmann * Copyright (C) 2009-2010 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef BT_IO_H #define BT_IO_H #include typedef enum { BT_IO_ERROR_DISCONNECTED, BT_IO_ERROR_CONNECT_FAILED, BT_IO_ERROR_FAILED, BT_IO_ERROR_INVALID_ARGS, } BtIOError; #define BT_IO_ERROR bt_io_error_quark() GQuark bt_io_error_quark(void); typedef enum { BT_IO_L2RAW, BT_IO_L2CAP, BT_IO_L2ERTM, BT_IO_RFCOMM, BT_IO_SCO, } BtIOType; typedef enum { BT_IO_OPT_INVALID = 0, BT_IO_OPT_SOURCE, BT_IO_OPT_SOURCE_BDADDR, BT_IO_OPT_DEST, BT_IO_OPT_DEST_BDADDR, BT_IO_OPT_DEFER_TIMEOUT, BT_IO_OPT_SEC_LEVEL, BT_IO_OPT_KEY_SIZE, BT_IO_OPT_CHANNEL, BT_IO_OPT_SOURCE_CHANNEL, BT_IO_OPT_DEST_CHANNEL, BT_IO_OPT_PSM, BT_IO_OPT_CID, BT_IO_OPT_MTU, BT_IO_OPT_OMTU, BT_IO_OPT_IMTU, BT_IO_OPT_MASTER, BT_IO_OPT_HANDLE, BT_IO_OPT_CLASS, BT_IO_OPT_MODE, BT_IO_OPT_FLUSHABLE, BT_IO_OPT_PRIORITY, } BtIOOption; typedef enum { BT_IO_SEC_SDP = 0, BT_IO_SEC_LOW, BT_IO_SEC_MEDIUM, BT_IO_SEC_HIGH, } BtIOSecLevel; typedef enum { BT_IO_MODE_BASIC = 0, BT_IO_MODE_RETRANS, BT_IO_MODE_FLOWCTL, BT_IO_MODE_ERTM, BT_IO_MODE_STREAMING } BtIOMode; typedef void (*BtIOConfirm)(GIOChannel *io, gpointer user_data); typedef void (*BtIOConnect)(GIOChannel *io, GError *err, gpointer user_data); gboolean bt_io_accept(GIOChannel *io, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy, GError **err); gboolean bt_io_set(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, ...); gboolean bt_io_get(GIOChannel *io, BtIOType type, GError **err, BtIOOption opt1, ...); GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect, gpointer user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...); GIOChannel *bt_io_listen(BtIOType type, BtIOConnect connect, BtIOConfirm confirm, gpointer user_data, GDestroyNotify destroy, GError **err, BtIOOption opt1, ...); #endif obexd-0.46/install-sh0000755000000000000000000003325611755212544011456 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: obexd-0.46/missing0000755000000000000000000002415211755212544011044 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: obexd-0.46/configure.ac0000644000000000000000000001121011755212521011715 00000000000000AC_PREREQ(2.60) AC_INIT(obexd, 0.46) AM_INIT_AUTOMAKE([foreign subdir-objects color-tests]) AM_CONFIG_HEADER(config.h) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE AC_PREFIX_DEFAULT(/usr/local) if (test "${libdir}" = '${exec_prefix}/lib'); then libdir="${prefix}/lib" fi plugindir="${libdir}/obex/plugins" if (test "$sysconfdir" = '${prefix}/etc'); then configdir="${prefix}/etc/obex" else configdir="${sysconfdir}/obex" fi AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", [Directory for the configuration files]) COMPILER_FLAGS AC_LANG_C AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CC_PIE AC_PROG_INSTALL AC_PROG_SED AC_PATH_READLINE m4_define([_LT_AC_TAGCONFIG], []) m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])]) AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff, AC_TRY_COMPILE([ #include ], [ struct tm tm; tm.tm_gmtoff = 1; ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)) if (test "$ac_cv_struct_tm_gmtoff" = "yes"); then AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff member]) fi AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone, AC_TRY_COMPILE([ #include ], [ timezone = 1; ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no)) if (test "$ac_cv_var_timezone" = "yes"); then AC_DEFINE(HAVE_TIMEZONE, 1, [Define if libc defines a timezone variable]) fi AC_CHECK_LIB(dl, dlopen, dummy=yes, AC_MSG_ERROR(dynamic linking loader is required)) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes, AC_MSG_ERROR(GLib >= 2.28 is required)) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes, AC_MSG_ERROR(D-Bus >= 1.4 is required)) AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) PKG_CHECK_MODULES(BLUEZ, bluez >= 4.99, dummy=yes, AC_MSG_ERROR(BlueZ >= 4.99 is required)) AC_SUBST(BLUEZ_CFLAGS) AC_SUBST(BLUEZ_LIBS) AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization through compiler]), [ if (test "${enableval}" = "no"); then CFLAGS="$CFLAGS -O0" fi ]) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [ if (test "${enableval}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then CFLAGS="$CFLAGS -g" fi ]) messages_driver=dummy AC_ARG_WITH(messages, AC_HELP_STRING([--with-messages=DRIVER], [select messages driver]), [ if (test "${withval}" = "no"); then messages_driver=dummy; else messages_driver=${withval}; fi ]) AC_SUBST([MESSAGES_DRIVER], [messages-${messages_driver}.c]) phonebook_driver=dummy AC_ARG_WITH(phonebook, AC_HELP_STRING([--with-phonebook=DRIVER], [select phonebook driver]), [ if (test "${withval}" = "no"); then phonebook_driver=dummy; else phonebook_driver=${withval}; fi ]) if (test "${phonebook_driver}" = "dummy"); then PKG_CHECK_MODULES(LIBICAL, libical, dummy=yes, AC_MSG_ERROR(libical is required)) AC_SUBST(LIBICAL_CFLAGS) AC_SUBST(LIBICAL_LIBS) fi if (test "${phonebook_driver}" = "ebook"); then AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required]) PKG_CHECK_MODULES(EBOOK, libebook-1.2, dummy=yes, AC_MSG_ERROR(libebook is required)) AC_SUBST(EBOOK_CFLAGS) AC_SUBST(EBOOK_LIBS) PKG_CHECK_MODULES(GTHREAD, gthread-2.0, dummy=yes, AC_MSG_ERROR(libgthread is required)) AC_SUBST(GTHREAD_CFLAGS) AC_SUBST(GTHREAD_LIBS) fi if (test "${phonebook_driver}" = "tracker"); then PKG_CHECK_MODULES(TRACKER_09, tracker-sparql-0.9, [ TRACKER_CFLAGS=${TRACKER_09_CFLAGS} TRACKER_LIBS=${TRACKER_09_LIBS} ], [ PKG_CHECK_MODULES(TRACKER_10, tracker-sparql-0.10, [ TRACKER_CFLAGS=${TRACKER_10_CFLAGS} TRACKER_LIBS=${TRACKER_10_LIBS} ], AC_MSG_ERROR(libtracker-sparql is required))]) AC_SUBST(TRACKER_CFLAGS) AC_SUBST(TRACKER_LIBS) fi AC_SUBST([PHONEBOOK_DRIVER], [phonebook-${phonebook_driver}.c]) AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb], [enable USB plugin]), [ enable_usb=${enableval} ]) AM_CONDITIONAL(USB, test "${enable_usb}" = "yes") AC_ARG_ENABLE(pcsuite, AC_HELP_STRING([--enable-pcsuite], [enable Nokia PcSuite plugin]), [ enable_pcsuite=${enableval} ]) AM_CONDITIONAL(NOKIA_PCSUITE, test "${enable_pcsuite}" = "yes") AC_ARG_ENABLE(server, AC_HELP_STRING([--disable-server], [disable compilation of OBEX server]), [ enable_server=${enableval} ]) AM_CONDITIONAL(SERVER, test "${enable_server}" != "no") AC_ARG_ENABLE(client, AC_HELP_STRING([--disable-client], [disable compilation of OBEX client]), [ enable_client=${enableval} ]) AM_CONDITIONAL(CLIENT, test "${enable_client}" != "no") AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes") AC_OUTPUT(Makefile) obexd-0.46/acinclude.m40000644000000000000000000000172211755212521011627 00000000000000AC_DEFUN([AC_PROG_CC_PIE], [ AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [ echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then ac_cv_prog_cc_pie=yes else ac_cv_prog_cc_pie=no fi rm -rf conftest* ]) ]) AC_DEFUN([AC_PATH_READLINE], [ AC_CHECK_HEADER(readline/readline.h, [AC_CHECK_LIB(readline, main, [ readline_found=yes AC_SUBST(READLINE_LIBS, "-lreadline") ], readline_found=no)], []) ]) AC_DEFUN([COMPILER_FLAGS], [ if (test "${CFLAGS}" = ""); then CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2" fi if (test "$USE_MAINTAINER_MODE" = "yes"); then CFLAGS="$CFLAGS -Werror -Wextra" CFLAGS="$CFLAGS -Wno-unused-parameter" CFLAGS="$CFLAGS -Wno-missing-field-initializers" CFLAGS="$CFLAGS -Wdeclaration-after-statement" CFLAGS="$CFLAGS -Wmissing-declarations" CFLAGS="$CFLAGS -Wredundant-decls" CFLAGS="$CFLAGS -Wcast-align" CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED" fi ]) obexd-0.46/NEWS0000644000000000000000000000000011071665561010130 00000000000000obexd-0.46/configure0000755000000000000000000156221111755212546011362 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for obexd 0.46. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='obexd' PACKAGE_TARNAME='obexd' PACKAGE_VERSION='0.46' PACKAGE_STRING='obexd 0.46' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_default_prefix=/usr/local # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS READLINE_FALSE READLINE_TRUE CLIENT_FALSE CLIENT_TRUE SERVER_FALSE SERVER_TRUE NOKIA_PCSUITE_FALSE NOKIA_PCSUITE_TRUE USB_FALSE USB_TRUE PHONEBOOK_DRIVER TRACKER_LIBS TRACKER_CFLAGS TRACKER_10_LIBS TRACKER_10_CFLAGS TRACKER_09_LIBS TRACKER_09_CFLAGS GTHREAD_LIBS GTHREAD_CFLAGS EBOOK_LIBS EBOOK_CFLAGS LIBICAL_LIBS LIBICAL_CFLAGS MESSAGES_DRIVER BLUEZ_LIBS BLUEZ_CFLAGS DBUS_LIBS DBUS_CFLAGS GLIB_LIBS GLIB_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL READLINE_LIBS EGREP GREP CPP SED am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking enable_static enable_shared with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock enable_optimization enable_debug with_messages with_phonebook enable_usb enable_pcsuite enable_server enable_client ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR GLIB_CFLAGS GLIB_LIBS DBUS_CFLAGS DBUS_LIBS BLUEZ_CFLAGS BLUEZ_LIBS LIBICAL_CFLAGS LIBICAL_LIBS EBOOK_CFLAGS EBOOK_LIBS GTHREAD_CFLAGS GTHREAD_LIBS TRACKER_09_CFLAGS TRACKER_09_LIBS TRACKER_10_CFLAGS TRACKER_10_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures obexd 0.46 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/obexd] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of obexd 0.46:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-optimization disable code optimization through compiler --enable-debug enable compiling with debugging information --enable-usb enable USB plugin --enable-pcsuite enable Nokia PcSuite plugin --disable-server disable compilation of OBEX server --disable-client disable compilation of OBEX client Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-messages=DRIVER select messages driver --with-phonebook=DRIVER select phonebook driver Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config GLIB_LIBS linker flags for GLIB, overriding pkg-config DBUS_CFLAGS C compiler flags for DBUS, overriding pkg-config DBUS_LIBS linker flags for DBUS, overriding pkg-config BLUEZ_CFLAGS C compiler flags for BLUEZ, overriding pkg-config BLUEZ_LIBS linker flags for BLUEZ, overriding pkg-config LIBICAL_CFLAGS C compiler flags for LIBICAL, overriding pkg-config LIBICAL_LIBS linker flags for LIBICAL, overriding pkg-config EBOOK_CFLAGS C compiler flags for EBOOK, overriding pkg-config EBOOK_LIBS linker flags for EBOOK, overriding pkg-config GTHREAD_CFLAGS C compiler flags for GTHREAD, overriding pkg-config GTHREAD_LIBS linker flags for GTHREAD, overriding pkg-config TRACKER_09_CFLAGS C compiler flags for TRACKER_09, overriding pkg-config TRACKER_09_LIBS linker flags for TRACKER_09, overriding pkg-config TRACKER_10_CFLAGS C compiler flags for TRACKER_10, overriding pkg-config TRACKER_10_LIBS linker flags for TRACKER_10, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF obexd configure 0.46 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by obexd $as_me 0.46, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='obexd' VERSION='0.46' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ac_config_headers="$ac_config_headers config.h" # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE if (test "${libdir}" = '${exec_prefix}/lib'); then libdir="${prefix}/lib" fi plugindir="${libdir}/obex/plugins" if (test "$sysconfdir" = '${prefix}/etc'); then configdir="${prefix}/etc/obex" else configdir="${sysconfdir}/obex" fi cat >>confdefs.h <<_ACEOF #define CONFIGDIR "${configdir}" _ACEOF if (test "${CFLAGS}" = ""); then CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2" fi if (test "$USE_MAINTAINER_MODE" = "yes"); then CFLAGS="$CFLAGS -Werror -Wextra" CFLAGS="$CFLAGS -Wno-unused-parameter" CFLAGS="$CFLAGS -Wno-missing-field-initializers" CFLAGS="$CFLAGS -Wdeclaration-after-statement" CFLAGS="$CFLAGS -Wmissing-declarations" CFLAGS="$CFLAGS -Wredundant-decls" CFLAGS="$CFLAGS -Wcast-align" CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC-cc} accepts -fPIE" >&5 $as_echo_n "checking whether ${CC-cc} accepts -fPIE... " >&6; } if ${ac_cv_prog_cc_pie+:} false; then : $as_echo_n "(cached) " >&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then ac_cv_prog_cc_pie=yes else ac_cv_prog_cc_pie=no fi rm -rf conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_pie" >&5 $as_echo "$ac_cv_prog_cc_pie" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default" if test "x$ac_cv_header_readline_readline_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lreadline" >&5 $as_echo_n "checking for main in -lreadline... " >&6; } if ${ac_cv_lib_readline_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_readline_main=yes else ac_cv_lib_readline_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_main" >&5 $as_echo "$ac_cv_lib_readline_main" >&6; } if test "x$ac_cv_lib_readline_main" = xyes; then : readline_found=yes READLINE_LIBS="-lreadline" else readline_found=no fi fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=no fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tm_gmtoff in struct tm" >&5 $as_echo_n "checking for tm_gmtoff in struct tm... " >&6; } if ${ac_cv_struct_tm_gmtoff+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct tm tm; tm.tm_gmtoff = 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm_gmtoff=yes else ac_cv_struct_tm_gmtoff=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm_gmtoff" >&5 $as_echo "$ac_cv_struct_tm_gmtoff" >&6; } if (test "$ac_cv_struct_tm_gmtoff" = "yes"); then $as_echo "#define HAVE_TM_GMTOFF 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for timezone variable" >&5 $as_echo_n "checking for timezone variable... " >&6; } if ${ac_cv_var_timezone+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { timezone = 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_var_timezone=yes else ac_cv_var_timezone=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_timezone" >&5 $as_echo "$ac_cv_var_timezone" >&6; } if (test "$ac_cv_var_timezone" = "yes"); then $as_echo "#define HAVE_TIMEZONE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : dummy=yes else as_fn_error $? "dynamic linking loader is required" "$LINENO" 5 fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB" >&5 $as_echo_n "checking for GLIB... " >&6; } if test -n "$GLIB_CFLAGS"; then pkg_cv_GLIB_CFLAGS="$GLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.28\""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.28") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 >= 2.28" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GLIB_LIBS"; then pkg_cv_GLIB_LIBS="$GLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.28\""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.28") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GLIB_LIBS=`$PKG_CONFIG --libs "glib-2.0 >= 2.28" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "glib-2.0 >= 2.28" 2>&1` else GLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "glib-2.0 >= 2.28" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GLIB_PKG_ERRORS" >&5 as_fn_error $? "GLib >= 2.28 is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "GLib >= 2.28 is required" "$LINENO" 5 else GLIB_CFLAGS=$pkg_cv_GLIB_CFLAGS GLIB_LIBS=$pkg_cv_GLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS" >&5 $as_echo_n "checking for DBUS... " >&6; } if test -n "$DBUS_CFLAGS"; then pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.4\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1 >= 1.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$DBUS_LIBS"; then pkg_cv_DBUS_LIBS="$DBUS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1 >= 1.4\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbus-1 >= 1.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1 >= 1.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1 >= 1.4" 2>&1` else DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1 >= 1.4" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$DBUS_PKG_ERRORS" >&5 as_fn_error $? "D-Bus >= 1.4 is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "D-Bus >= 1.4 is required" "$LINENO" 5 else DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS DBUS_LIBS=$pkg_cv_DBUS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BLUEZ" >&5 $as_echo_n "checking for BLUEZ... " >&6; } if test -n "$BLUEZ_CFLAGS"; then pkg_cv_BLUEZ_CFLAGS="$BLUEZ_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bluez >= 4.99\""; } >&5 ($PKG_CONFIG --exists --print-errors "bluez >= 4.99") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BLUEZ_CFLAGS=`$PKG_CONFIG --cflags "bluez >= 4.99" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$BLUEZ_LIBS"; then pkg_cv_BLUEZ_LIBS="$BLUEZ_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bluez >= 4.99\""; } >&5 ($PKG_CONFIG --exists --print-errors "bluez >= 4.99") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_BLUEZ_LIBS=`$PKG_CONFIG --libs "bluez >= 4.99" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then BLUEZ_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bluez >= 4.99" 2>&1` else BLUEZ_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bluez >= 4.99" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$BLUEZ_PKG_ERRORS" >&5 as_fn_error $? "BlueZ >= 4.99 is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "BlueZ >= 4.99 is required" "$LINENO" 5 else BLUEZ_CFLAGS=$pkg_cv_BLUEZ_CFLAGS BLUEZ_LIBS=$pkg_cv_BLUEZ_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi # Check whether --enable-optimization was given. if test "${enable_optimization+set}" = set; then : enableval=$enable_optimization; if (test "${enableval}" = "no"); then CFLAGS="$CFLAGS -O0" fi fi # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; if (test "${enableval}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then CFLAGS="$CFLAGS -g" fi fi messages_driver=dummy # Check whether --with-messages was given. if test "${with_messages+set}" = set; then : withval=$with_messages; if (test "${withval}" = "no"); then messages_driver=dummy; else messages_driver=${withval}; fi fi MESSAGES_DRIVER=messages-${messages_driver}.c phonebook_driver=dummy # Check whether --with-phonebook was given. if test "${with_phonebook+set}" = set; then : withval=$with_phonebook; if (test "${withval}" = "no"); then phonebook_driver=dummy; else phonebook_driver=${withval}; fi fi if (test "${phonebook_driver}" = "dummy"); then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBICAL" >&5 $as_echo_n "checking for LIBICAL... " >&6; } if test -n "$LIBICAL_CFLAGS"; then pkg_cv_LIBICAL_CFLAGS="$LIBICAL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libical\""; } >&5 ($PKG_CONFIG --exists --print-errors "libical") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBICAL_CFLAGS=`$PKG_CONFIG --cflags "libical" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBICAL_LIBS"; then pkg_cv_LIBICAL_LIBS="$LIBICAL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libical\""; } >&5 ($PKG_CONFIG --exists --print-errors "libical") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBICAL_LIBS=`$PKG_CONFIG --libs "libical" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBICAL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libical" 2>&1` else LIBICAL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libical" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBICAL_PKG_ERRORS" >&5 as_fn_error $? "libical is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libical is required" "$LINENO" 5 else LIBICAL_CFLAGS=$pkg_cv_LIBICAL_CFLAGS LIBICAL_LIBS=$pkg_cv_LIBICAL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi fi if (test "${phonebook_driver}" = "ebook"); then $as_echo "#define NEED_THREADS 1" >>confdefs.h pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EBOOK" >&5 $as_echo_n "checking for EBOOK... " >&6; } if test -n "$EBOOK_CFLAGS"; then pkg_cv_EBOOK_CFLAGS="$EBOOK_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libebook-1.2\""; } >&5 ($PKG_CONFIG --exists --print-errors "libebook-1.2") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_EBOOK_CFLAGS=`$PKG_CONFIG --cflags "libebook-1.2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$EBOOK_LIBS"; then pkg_cv_EBOOK_LIBS="$EBOOK_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libebook-1.2\""; } >&5 ($PKG_CONFIG --exists --print-errors "libebook-1.2") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_EBOOK_LIBS=`$PKG_CONFIG --libs "libebook-1.2" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then EBOOK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libebook-1.2" 2>&1` else EBOOK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libebook-1.2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$EBOOK_PKG_ERRORS" >&5 as_fn_error $? "libebook is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libebook is required" "$LINENO" 5 else EBOOK_CFLAGS=$pkg_cv_EBOOK_CFLAGS EBOOK_LIBS=$pkg_cv_EBOOK_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTHREAD" >&5 $as_echo_n "checking for GTHREAD... " >&6; } if test -n "$GTHREAD_CFLAGS"; then pkg_cv_GTHREAD_CFLAGS="$GTHREAD_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gthread-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gthread-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTHREAD_CFLAGS=`$PKG_CONFIG --cflags "gthread-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GTHREAD_LIBS"; then pkg_cv_GTHREAD_LIBS="$GTHREAD_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gthread-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gthread-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTHREAD_LIBS=`$PKG_CONFIG --libs "gthread-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GTHREAD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gthread-2.0" 2>&1` else GTHREAD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gthread-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GTHREAD_PKG_ERRORS" >&5 as_fn_error $? "libgthread is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libgthread is required" "$LINENO" 5 else GTHREAD_CFLAGS=$pkg_cv_GTHREAD_CFLAGS GTHREAD_LIBS=$pkg_cv_GTHREAD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } dummy=yes fi fi if (test "${phonebook_driver}" = "tracker"); then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TRACKER_09" >&5 $as_echo_n "checking for TRACKER_09... " >&6; } if test -n "$TRACKER_09_CFLAGS"; then pkg_cv_TRACKER_09_CFLAGS="$TRACKER_09_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.9\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.9") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_09_CFLAGS=`$PKG_CONFIG --cflags "tracker-sparql-0.9" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TRACKER_09_LIBS"; then pkg_cv_TRACKER_09_LIBS="$TRACKER_09_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.9\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.9") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_09_LIBS=`$PKG_CONFIG --libs "tracker-sparql-0.9" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TRACKER_09_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "tracker-sparql-0.9" 2>&1` else TRACKER_09_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "tracker-sparql-0.9" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TRACKER_09_PKG_ERRORS" >&5 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TRACKER_10" >&5 $as_echo_n "checking for TRACKER_10... " >&6; } if test -n "$TRACKER_10_CFLAGS"; then pkg_cv_TRACKER_10_CFLAGS="$TRACKER_10_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_10_CFLAGS=`$PKG_CONFIG --cflags "tracker-sparql-0.10" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TRACKER_10_LIBS"; then pkg_cv_TRACKER_10_LIBS="$TRACKER_10_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_10_LIBS=`$PKG_CONFIG --libs "tracker-sparql-0.10" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TRACKER_10_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "tracker-sparql-0.10" 2>&1` else TRACKER_10_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "tracker-sparql-0.10" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TRACKER_10_PKG_ERRORS" >&5 as_fn_error $? "libtracker-sparql is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libtracker-sparql is required" "$LINENO" 5 else TRACKER_10_CFLAGS=$pkg_cv_TRACKER_10_CFLAGS TRACKER_10_LIBS=$pkg_cv_TRACKER_10_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } TRACKER_CFLAGS=${TRACKER_10_CFLAGS} TRACKER_LIBS=${TRACKER_10_LIBS} fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TRACKER_10" >&5 $as_echo_n "checking for TRACKER_10... " >&6; } if test -n "$TRACKER_10_CFLAGS"; then pkg_cv_TRACKER_10_CFLAGS="$TRACKER_10_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_10_CFLAGS=`$PKG_CONFIG --cflags "tracker-sparql-0.10" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TRACKER_10_LIBS"; then pkg_cv_TRACKER_10_LIBS="$TRACKER_10_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tracker-sparql-0.10\""; } >&5 ($PKG_CONFIG --exists --print-errors "tracker-sparql-0.10") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRACKER_10_LIBS=`$PKG_CONFIG --libs "tracker-sparql-0.10" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TRACKER_10_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "tracker-sparql-0.10" 2>&1` else TRACKER_10_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "tracker-sparql-0.10" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TRACKER_10_PKG_ERRORS" >&5 as_fn_error $? "libtracker-sparql is required" "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libtracker-sparql is required" "$LINENO" 5 else TRACKER_10_CFLAGS=$pkg_cv_TRACKER_10_CFLAGS TRACKER_10_LIBS=$pkg_cv_TRACKER_10_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } TRACKER_CFLAGS=${TRACKER_10_CFLAGS} TRACKER_LIBS=${TRACKER_10_LIBS} fi else TRACKER_09_CFLAGS=$pkg_cv_TRACKER_09_CFLAGS TRACKER_09_LIBS=$pkg_cv_TRACKER_09_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } TRACKER_CFLAGS=${TRACKER_09_CFLAGS} TRACKER_LIBS=${TRACKER_09_LIBS} fi fi PHONEBOOK_DRIVER=phonebook-${phonebook_driver}.c # Check whether --enable-usb was given. if test "${enable_usb+set}" = set; then : enableval=$enable_usb; enable_usb=${enableval} fi if test "${enable_usb}" = "yes"; then USB_TRUE= USB_FALSE='#' else USB_TRUE='#' USB_FALSE= fi # Check whether --enable-pcsuite was given. if test "${enable_pcsuite+set}" = set; then : enableval=$enable_pcsuite; enable_pcsuite=${enableval} fi if test "${enable_pcsuite}" = "yes"; then NOKIA_PCSUITE_TRUE= NOKIA_PCSUITE_FALSE='#' else NOKIA_PCSUITE_TRUE='#' NOKIA_PCSUITE_FALSE= fi # Check whether --enable-server was given. if test "${enable_server+set}" = set; then : enableval=$enable_server; enable_server=${enableval} fi if test "${enable_server}" != "no"; then SERVER_TRUE= SERVER_FALSE='#' else SERVER_TRUE='#' SERVER_FALSE= fi # Check whether --enable-client was given. if test "${enable_client+set}" = set; then : enableval=$enable_client; enable_client=${enableval} fi if test "${enable_client}" != "no"; then CLIENT_TRUE= CLIENT_FALSE='#' else CLIENT_TRUE='#' CLIENT_FALSE= fi if test "${readline_found}" = "yes"; then READLINE_TRUE= READLINE_FALSE='#' else READLINE_TRUE='#' READLINE_FALSE= fi ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USB_TRUE}" && test -z "${USB_FALSE}"; then as_fn_error $? "conditional \"USB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${NOKIA_PCSUITE_TRUE}" && test -z "${NOKIA_PCSUITE_FALSE}"; then as_fn_error $? "conditional \"NOKIA_PCSUITE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${SERVER_TRUE}" && test -z "${SERVER_FALSE}"; then as_fn_error $? "conditional \"SERVER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CLIENT_TRUE}" && test -z "${CLIENT_FALSE}"; then as_fn_error $? "conditional \"CLIENT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${READLINE_TRUE}" && test -z "${READLINE_FALSE}"; then as_fn_error $? "conditional \"READLINE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by obexd $as_me 0.46, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ obexd config.status 0.46 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Whether or not to build static libraries. build_old_libs=$enable_static # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi obexd-0.46/COPYING0000644000000000000000000004312611177066076010507 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. obexd-0.46/Makefile.am0000644000000000000000000001334011755212521011471 00000000000000 AM_MAKEFLAGS = --no-print-directory servicedir = $(datarootdir)/dbus-1/services service_in_files = doc_files = doc/obexd-api.txt doc/agent-api.txt doc/client-api.txt test_files = test/simple-agent test/send-files \ test/pull-business-card test/exchange-business-cards \ test/list-folders test/pbap-client test/ftp-client \ test/map-client gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \ gdbus/object.c gdbus/polkit.c btio_sources = btio/btio.h btio/btio.c gobex_sources = gobex/gobex.h gobex/gobex.c \ gobex/gobex-defs.h gobex/gobex-defs.c \ gobex/gobex-packet.c gobex/gobex-packet.h \ gobex/gobex-header.c gobex/gobex-header.h \ gobex/gobex-transfer.c gobex/gobex-debug.h noinst_PROGRAMS = libexec_PROGRAMS = if SERVER confdir = $(sysconfdir)/obex service_in_files += src/obexd.service.in builtin_modules = builtin_sources = builtin_nodist = builtin_modules += bluetooth builtin_sources += plugins/bluetooth.c if USB builtin_modules += usb builtin_sources += plugins/usb.c endif builtin_modules += filesystem builtin_sources += plugins/filesystem.c plugins/filesystem.h if NOKIA_PCSUITE builtin_modules += pcsuite builtin_sources += plugins/pcsuite.c endif builtin_modules += opp builtin_sources += plugins/opp.c builtin_modules += ftp builtin_sources += plugins/ftp.c plugins/ftp.h builtin_modules += pbap builtin_sources += plugins/pbap.c plugins/phonebook.h \ plugins/vcard.h plugins/vcard.c builtin_modules += mas builtin_sources += plugins/mas.c plugins/messages.h \ src/map_ap.c src/map_ap.h builtin_modules += irmc builtin_sources += plugins/irmc.c builtin_modules += syncevolution builtin_sources += plugins/syncevolution.c builtin_nodist += plugins/phonebook.c builtin_nodist += plugins/messages.c libexec_PROGRAMS += src/obexd src_obexd_SOURCES = $(gdbus_sources) $(builtin_sources) $(btio_sources) \ $(gobex_sources) src/main.c src/obexd.h \ src/plugin.h src/plugin.c \ src/log.h src/log.c src/manager.h src/manager.c \ src/obex.h src/obex.c src/obex-priv.h \ src/mimetype.h src/mimetype.c \ src/service.h src/service.c \ src/transport.h src/transport.c \ src/server.h src/server.c src_obexd_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @GTHREAD_LIBS@ \ @EBOOK_LIBS@ @BLUEZ_LIBS@ \ @LIBICAL_LIBS@ @TRACKER_LIBS@ -ldl src_obexd_LDFLAGS = -Wl,--export-dynamic builtin_files = src/builtin.h $(builtin_nodist) nodist_src_obexd_SOURCES = $(builtin_files) plugindir = $(libdir)/obex/plugins plugin_LTLIBRARIES = src/plugin.$(OBJEXT): src/builtin.h src/builtin.h: src/genbuiltin $(builtin_sources) $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@ endif if CLIENT service_in_files += client/obex-client.service.in libexec_PROGRAMS += client/obex-client client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \ $(btio_sources) \ client/main.c src/log.h src/log.c \ client/manager.h client/manager.c \ client/session.h client/session.c \ client/bluetooth.h client/bluetooth.c \ client/sync.h client/sync.c \ client/pbap.h client/pbap.c \ client/ftp.h client/ftp.c \ client/opp.h client/opp.c \ client/map.h client/map.c \ client/transfer.h client/transfer.c \ client/agent.h client/agent.c \ client/transport.h client/transport.c \ client/driver.h client/driver.c \ src/map_ap.h src/map_ap.c client_obex_client_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ endif service_DATA = $(service_in_files:.service.in=.service) AM_CFLAGS = @BLUEZ_CFLAGS@ @EBOOK_CFLAGS@ @GTHREAD_CFLAGS@ @GLIB_CFLAGS@ \ @DBUS_CFLAGS@ @LIBICAL_CFLAGS@ @TRACKER_CFLAGS@ \ -DOBEX_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\" \ -D_FILE_OFFSET_BITS=64 INCLUDES = -I$(builddir)/src -I$(srcdir)/src -I$(srcdir)/plugins \ -I$(srcdir)/gdbus \ -I$(srcdir)/btio -I$(srcdir)/gobex CLEANFILES = $(service_DATA) $(builtin_files) EXTRA_DIST = src/genbuiltin $(doc_files) $(test_files) \ src/obexd.service.in client/obex-client.service.in \ plugins/phonebook-dummy.c plugins/phonebook-ebook.c \ plugins/phonebook-tracker.c \ plugins/messages-dummy.c plugins/messages-tracker.c DISTCHECK_CONFIGURE_FLAGS = --enable-client --enable-server MAINTAINERCLEANFILES = Makefile.in \ aclocal.m4 configure config.h.in config.sub config.guess \ ltmain.sh depcomp compile missing install-sh mkinstalldirs %.service: %.service.in config.log $(AM_V_GEN)$(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ plugins/phonebook.c: plugins/@PHONEBOOK_DRIVER@ $(AM_V_GEN)$(LN_S) @abs_top_srcdir@/$< $@ plugins/messages.c: plugins/@MESSAGES_DRIVER@ $(AM_V_GEN)$(LN_S) @abs_top_srcdir@/$< $@ TESTS = unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \ unit/test-gobex-transfer noinst_PROGRAMS += unit/test-gobex-header unit/test-gobex-packet \ unit/test-gobex unit/test-gobex-transfer unit_test_gobex_SOURCES = $(gobex_sources) unit/test-gobex.c \ unit/util.c unit/util.h unit_test_gobex_LDADD = @GLIB_LIBS@ unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/test-gobex-packet.c \ unit/util.c unit/util.h unit_test_gobex_packet_LDADD = @GLIB_LIBS@ unit_test_gobex_header_SOURCES = $(gobex_sources) unit/test-gobex-header.c \ unit/util.c unit/util.h unit_test_gobex_header_LDADD = @GLIB_LIBS@ unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ unit/test-gobex-transfer.c unit_test_gobex_transfer_LDADD = @GLIB_LIBS@ if READLINE noinst_PROGRAMS += tools/test-client tools_test_client_SOURCES = $(gobex_sources) $(btio_sources) \ tools/test-client.c tools_test_client_LDADD = @GLIB_LIBS@ @BLUEZ_LIBS@ @READLINE_LIBS@ endif noinst_PROGRAMS += tools/test-server tools_test_server_SOURCES = $(gobex_sources) $(btio_sources) \ tools/test-server.c tools_test_server_LDADD = @GLIB_LIBS@ @BLUEZ_LIBS@ obexd-0.46/doc/0000755000000000000000000000000011755212615010265 500000000000000obexd-0.46/doc/obexd-api.txt0000644000000000000000000000326511364341101012611 00000000000000obexd API description ********************************** Copyright (C) 2007-2010 Nokia Corporation Copyright (C) 2007-2010 Marcel Holtmann Manager hierarchy =============== Service org.openobex Interface org.openobex.Manager Object path / Methods void RegisterAgent(object agent) Register an agent to request authorization of the user to accept/reject objects. Object push service needs to authorize each received object. Possible errors: org.openobex.Error.AlreadyExists void UnregisterAgent(object agent) This unregisters the agent that has been previously registered. The object path parameter must match the same value that has been used on registration. Possible errors: org.openobex.Error.DoesNotExist Signals SessionCreated(object session) Signal sent when OBEX connection has been accepted. (FTP only) SessionRemoved(object session) Sent when the transport is disconnected (FTP only) TransferStarted(object transfer) Signal sent when an object push operation starts. (OPP only) TransferCompleted(object transfer, boolean success) Signal sent when the object has been received or an error happens. (OPP only) Transfer hierarchy =============== Service org.openobex Interface org.openobex.Transfer Object path /transfer{0, 1, 2, ...} Methods void Cancel() Stops the current transference. Signals Progress(int32 total, int32 transfered) Session hierarchy =============== Service org.openobex Interface org.openobex.Session Object path /session{0, 1, 2, ...} Methods dict GetProperties() Signals TBD Properties string Address [readonly] Bluetooth device address or USB obexd-0.46/doc/client-api.txt0000644000000000000000000002050311755212521012767 00000000000000OBEX client API description *************************** Copyright (C) 2007-2010 Marcel Holtmann Client hierarchy ================ Service org.openobex.client Interface org.openobex.Client Object path / Methods void SendFiles(dict device, array{string} files, object agent) Send one or multiple local files to the specified device. The device is configured via properties. At least the Destination property should be specified. void PullBusinessCard(dict device, string file) Request the business card from a remote device and store it in the local file. void ExchangeBusinessCards(dict device, string clientfile, string file) Push the client's business card to the remote device and then retrieve the remote business card and store it in a local file. object CreateSession(dict device) Create a new OBEX session. The device is configured via properties like in SendFiles. void RemoveSession(object session) Unregister session and abort pending transfers. string GetCapabilities(dict device) Get remote device capabilities. Properties string Target string Source string Destination byte Channel Session hierarchy ================= Service org.openobex.client Interface org.openobex.Session Object path [variable prefix]/{session0,session1,...} Methods dict GetProperties() Returns all properties for the session. void AssignAgent(object agent) Assign an OBEX agent to this session. This allows detailed progress reports about the transactions. void ReleaseAgent(object agent) Release a previously assigned OBEX agent. Properties string Source [readonly] string Destination [readonly] byte Channel [readonly] File Transfer hierarchy ======================= Service org.openobex.client Interface org.openobex.FileTransfer Object path [variable prefix]/{session0,session1,...} Methods void ChangeFolder(string folder) Change the current folder of the remote device. void CreateFolder(string folder) Create a new folder in the remote device. array{dict} ListFolder() Returns a dictionary containing information about the current folder content. The following keys are defined: string Name : Object name in UTF-8 format string Type : Either "folder" or "file" uint64 Size : Object size or number of items in folder string Permission : Group, owner and other permission uint64 Modified : Last change uint64 Accessed : Last access uint64 Created : Creation date void GetFile(string targetfile, string sourcefile) Copy the source file (from remote device) to the target file (on local filesystem). A new Transfer object is created to represent this transaction. void PutFile(string sourcefile, string targetfile) Copy the source file (from local filesystem) to the target file (on remote device). A new Transfer object is created to represent this transaction. void CopyFile(string sourcefile, string targetfile) Copy a file within the remote device from source file to target file. void MoveFile(string sourcefile, string targetfile) Move a file within the remote device from source file to the target file. void Delete(string file) Deletes the specified file/folder. Phonebook Access hierarchy ======================= Service org.openobex.client Interface org.openobex.PhonebookAccess Object path [variable prefix]/{session0,session1,...} Methods void Select(string location, string phonebook) Select the phonebook object for other operations. Should be call before all the other operations. location : Where the phonebook is stored, possible inputs : "INT" ( "INTERNAL" which is default ) "SIM" ( "SIM1" ) "SIM2" ... phonebook : Possible inputs : "pb" : phonebook for the saved contacts "ich": incoming call history "och": outgoing call history "mch": missing call history "cch": combination of ich och mch string PullAll() Return the entire phonebook object from the PSE server in plain string with vcard format. array{string vcard, string name} List() Return an array of vcard-listing data which contains the vcard : name paired string, for example "1.vcf" : "John". string Pull(string vcard) Retrieve the vcard in the current phonebook object for example : Pull("0.vcf") array{string vcard, string name} Search(string field, string value) Return an array of vcard-listing data which contains the vcard : name paired string match the search condition. field : the field in the vcard to search with { "name" (default) | "number" | "sound" } value : the string value to search for uint16 GetSize() Return the number of the non-null entries in the selected phonebook object. void SetFormat(string format) Indicate the format of the vcard that should be return by related methods. format : { "vcard21" (default) | "vcard30" } void SetOrder(string order) Indicate the sorting method of the vcard-listing data returned by List and Search methods. order : { "indexed" (default) | "alphanumeric" | "phonetic" } void SetFilter(array{string}) Indicate fields that should be contained in vcards return by related methods. Give an empty array will clear the filter and return all fields available in vcards. And this is the default behavior. Possible filter fields : "VERSION", "FN", ..., "ALL", "bit[0-63]" array{string} ListFilterFields() Return All Available fields that can be used in SefFilter method. array{string} GetFilter() Return the current filter setting Synchronization hierarchy ======================= Service org.openobex.client Interface org.openobex.Synchronization Object path [variable prefix]/{session0,session1,...} Methods void SetLocation(string location) Set the phonebook object store location for other operations. Should be called before all the other operations. location: Where the phonebook is stored, possible values: "INT" ( "INTERNAL" which is default ) "SIM1" "SIM2" ...... string GetPhonebook() Retrieve an entire Phonebook Object store from remote device void PutPhonebook(string obj) Send an entire Phonebook Object store to remote device Message Access hierarchy ========================= Service org.openobex.client Interface org.openobex.MessageAccess Object path [variable prefix]/{session0,session1,...} Methods void SetFolder(string name) Set working directory for current session, *name* may be the directory name or '..[/dir]'. Transfer hierarchy ================== Service org.openobex.client Interface org.openobex.Transfer Object path [variable prefix]/{transfer0,transfer1,...} Methods dict GetProperties() Returns all properties for the transfer. See the properties section for available properties. void Cancel() Cancels this transfer. Properties string Name [readonly] Name of the transferred object. uint64 Size [readonly] Size of the transferred object. If the size is unknown, then this property will not be present. string Filename [readonly] Complete name of the file being received or sent. Agent hierarchy =============== Service unique name Interface org.openobex.Agent Object path freely definable Methods void Release() This method gets called when the service daemon unregisters the agent. An agent can use it to do cleanup tasks. There is no need to unregister the agent, because when this method gets called it has already been unregistered. string Request(object transfer) Accept or reject a new transfer (client and server) and provide the filename for it. In case of incoming transfers it is the filename where to store the file and for outgoing transfers it is the filename to show the remote device. If left empty it will be calculated automatically. Possible errors: org.openobex.Error.Rejected org.openobex.Error.Canceled void Progress(object transfer, uint64 transferred) Progress within the transfer has been made. The number of transferred bytes is given as second argument for convenience. void Complete(object transfer) Informs that the transfer has completed successfully. void Error(object transfer, string message) Informs that the transfer has been terminated because of some error. obexd-0.46/doc/agent-api.txt0000644000000000000000000000152711364341101012605 00000000000000obexd Agent API description ********************************** Copyright (C) 2007-2010 Nokia Corporation Copyright (C) 2007-2010 Marcel Holtmann Agent hierarchy =============== Service unique name Interface org.openobex.Agent Object path freely definable Methods string Authorize(object transfer, string bt_address, string name, string type, int32 length, int32 time) This method gets called when the service daemon needs to accept/reject a Bluetooth object push request. Returns the full path (including the filename) where the object shall be stored. Possible errors: org.openobex.Error.Rejected org.openobex.Error.Canceled void Cancel() This method gets called to indicate that the agent request failed before a reply was returned. It cancels the previous request. obexd-0.46/src/0000755000000000000000000000000011755212615010307 500000000000000obexd-0.46/src/obex.c0000644000000000000000000006333711755212521011340 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "log.h" #include "obex.h" #include "obex-priv.h" #include "server.h" #include "manager.h" #include "mimetype.h" #include "service.h" #include "transport.h" #include "btio.h" /* Challenge request */ #define NONCE_TAG 0x00 #define OPTIONS_TAG 0x01 /* Optional */ #define REALM_TAG 0x02 /* Optional */ #define NONCE_LEN 16 /* Challenge response */ #define DIGEST_TAG 0x00 #define USER_ID_TAG 0x01 /* Optional */ #define DIGEST_NONCE_TAG 0x02 /* Optional */ static GSList *sessions = NULL; typedef struct { uint8_t version; uint8_t flags; uint16_t mtu; } __attribute__ ((packed)) obex_connect_hdr_t; struct auth_header { uint8_t tag; uint8_t len; uint8_t val[0]; } __attribute__ ((packed)); /* Possible commands */ static struct { int cmd; const char *name; } obex_command[] = { { G_OBEX_OP_CONNECT, "CONNECT" }, { G_OBEX_OP_DISCONNECT, "DISCONNECT" }, { G_OBEX_OP_PUT, "PUT" }, { G_OBEX_OP_GET, "GET" }, { G_OBEX_OP_SETPATH, "SETPATH" }, { G_OBEX_OP_SESSION, "SESSION" }, { G_OBEX_OP_ABORT, "ABORT" }, { G_OBEX_OP_ACTION, "ACTION" }, { 0xFF, NULL }, }; /* Possible Response */ static struct { int rsp; const char *name; } obex_response[] = { { G_OBEX_RSP_CONTINUE, "CONTINUE" }, { G_OBEX_RSP_SUCCESS, "SUCCESS" }, { G_OBEX_RSP_CREATED, "CREATED" }, { G_OBEX_RSP_ACCEPTED, "ACCEPTED" }, { G_OBEX_RSP_NON_AUTHORITATIVE, "NON_AUTHORITATIVE" }, { G_OBEX_RSP_NO_CONTENT, "NO_CONTENT" }, { G_OBEX_RSP_RESET_CONTENT, "RESET_CONTENT" }, { G_OBEX_RSP_PARTIAL_CONTENT, "PARTIAL_CONTENT" }, { G_OBEX_RSP_MULTIPLE_CHOICES, "MULTIPLE_CHOICES" }, { G_OBEX_RSP_MOVED_PERMANENTLY, "MOVED_PERMANENTLY" }, { G_OBEX_RSP_MOVED_TEMPORARILY, "MOVED_TEMPORARILY" }, { G_OBEX_RSP_SEE_OTHER, "SEE_OTHER" }, { G_OBEX_RSP_NOT_MODIFIED, "NOT_MODIFIED" }, { G_OBEX_RSP_USE_PROXY, "USE_PROXY" }, { G_OBEX_RSP_BAD_REQUEST, "BAD_REQUEST" }, { G_OBEX_RSP_UNAUTHORIZED, "UNAUTHORIZED" }, { G_OBEX_RSP_PAYMENT_REQUIRED, "PAYMENT_REQUIRED" }, { G_OBEX_RSP_FORBIDDEN, "FORBIDDEN" }, { G_OBEX_RSP_NOT_FOUND, "NOT_FOUND" }, { G_OBEX_RSP_METHOD_NOT_ALLOWED, "METHOD_NOT_ALLOWED" }, { G_OBEX_RSP_NOT_ACCEPTABLE, "NOT_ACCEPTABLE" }, { G_OBEX_RSP_PROXY_AUTH_REQUIRED, "PROXY_AUTH_REQUIRED" }, { G_OBEX_RSP_REQUEST_TIME_OUT, "REQUEST_TIME_OUT" }, { G_OBEX_RSP_CONFLICT, "CONFLICT" }, { G_OBEX_RSP_GONE, "GONE" }, { G_OBEX_RSP_LENGTH_REQUIRED, "LENGTH_REQUIRED" }, { G_OBEX_RSP_PRECONDITION_FAILED, "PRECONDITION_FAILED" }, { G_OBEX_RSP_REQ_ENTITY_TOO_LARGE, "REQ_ENTITY_TOO_LARGE" }, { G_OBEX_RSP_REQ_URL_TOO_LARGE, "REQ_URL_TOO_LARGE" }, { G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE, "UNSUPPORTED_MEDIA_TYPE"}, { G_OBEX_RSP_INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR" }, { G_OBEX_RSP_NOT_IMPLEMENTED, "NOT_IMPLEMENTED" }, { G_OBEX_RSP_BAD_GATEWAY, "BAD_GATEWAY" }, { G_OBEX_RSP_SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE" }, { G_OBEX_RSP_GATEWAY_TIMEOUT, "GATEWAY_TIMEOUT" }, { G_OBEX_RSP_VERSION_NOT_SUPPORTED, "VERSION_NOT_SUPPORTED" }, { G_OBEX_RSP_DATABASE_FULL, "DATABASE_FULL" }, { G_OBEX_RSP_DATABASE_LOCKED, "DATABASE_LOCKED" }, { 0xFF, NULL }, }; static gboolean handle_async_io(void *object, int flags, int err, void *user_data); static void print_event(int cmd, int rsp) { const char *cmdstr = NULL, *rspstr = NULL; int i; static int lastcmd; if (cmd < 0) cmd = lastcmd; else lastcmd = cmd; for (i = 0; obex_command[i].cmd != 0xFF; i++) { if (obex_command[i].cmd != cmd) continue; cmdstr = obex_command[i].name; } for (i = 0; obex_response[i].rsp != 0xFF; i++) { if (obex_response[i].rsp != rsp) continue; rspstr = obex_response[i].name; } obex_debug("%s(0x%x), %s(0x%x)", cmdstr, cmd, rspstr, rsp); } static void os_set_response(struct obex_session *os, int err) { uint8_t rsp; rsp = g_obex_errno_to_rsp(err); print_event(-1, rsp); g_obex_send_rsp(os->obex, rsp, NULL, G_OBEX_HDR_INVALID); } static void os_session_mark_aborted(struct obex_session *os) { /* the session was already cancelled/aborted or size in unknown */ if (os->aborted || os->size == OBJECT_SIZE_UNKNOWN) return; os->aborted = (os->size != os->offset); } static void os_reset_session(struct obex_session *os) { os_session_mark_aborted(os); if (os->object) { os->driver->set_io_watch(os->object, NULL, NULL); os->driver->close(os->object); if (os->aborted && os->cmd == G_OBEX_OP_PUT && os->path && os->driver->remove) os->driver->remove(os->path); } if (os->service && os->service->reset) os->service->reset(os, os->service_data); if (os->name) { g_free(os->name); os->name = NULL; } if (os->type) { g_free(os->type); os->type = NULL; } if (os->buf) { g_free(os->buf); os->buf = NULL; } if (os->path) { g_free(os->path); os->path = NULL; } if (os->apparam) { g_free(os->apparam); os->apparam = NULL; os->apparam_len = 0; } if (os->get_rsp > 0) { g_obex_remove_request_function(os->obex, os->get_rsp); os->get_rsp = 0; } os->object = NULL; os->driver = NULL; os->aborted = FALSE; os->pending = 0; os->offset = 0; os->size = OBJECT_SIZE_DELETE; os->headers_sent = FALSE; os->checked = FALSE; } static void obex_session_free(struct obex_session *os) { sessions = g_slist_remove(sessions, os); if (os->io) g_io_channel_unref(os->io); if (os->obex) g_obex_unref(os->obex); g_free(os); } /* From Imendio's GnomeVFS OBEX module (om-utils.c) */ static time_t parse_iso8610(const char *val, int size) { time_t time, tz_offset = 0; struct tm tm; char *date; char tz; int nr; memset(&tm, 0, sizeof(tm)); /* According to spec the time doesn't have to be null terminated */ date = g_strndup(val, size); nr = sscanf(date, "%04u%02u%02uT%02u%02u%02u%c", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tz); g_free(date); if (nr < 6) { /* Invalid time format */ return -1; } tm.tm_year -= 1900; /* Year since 1900 */ tm.tm_mon--; /* Months since January, values 0-11 */ tm.tm_isdst = -1; /* Daylight savings information not avail */ #if defined(HAVE_TM_GMTOFF) tz_offset = tm.tm_gmtoff; #elif defined(HAVE_TIMEZONE) tz_offset = -timezone; if (tm.tm_isdst > 0) tz_offset += 3600; #endif time = mktime(&tm); if (nr == 7) { /* * Date/Time was in localtime (to remote device) * already. Since we don't know anything about the * timezone on that one we won't try to apply UTC offset */ time += tz_offset; } return time; } static uint8_t *extract_nonce(const uint8_t *buffer, unsigned int hlen) { struct auth_header *hdr; uint8_t *nonce = NULL; uint32_t len = 0; while (len < hlen) { hdr = (void *) buffer + len; switch (hdr->tag) { case NONCE_TAG: if (hdr->len != NONCE_LEN) return NULL; nonce = hdr->val; break; } len += hdr->len + sizeof(struct auth_header); } return nonce; } static uint8_t *challenge_response(const uint8_t *nonce) { GChecksum *md5; uint8_t *result; size_t size; result = g_new0(uint8_t, NONCE_LEN); md5 = g_checksum_new(G_CHECKSUM_MD5); if (md5 == NULL) return result; g_checksum_update(md5, nonce, NONCE_LEN); g_checksum_update(md5, (uint8_t *) ":BlueZ", 6); size = NONCE_LEN; g_checksum_get_digest(md5, result, &size); g_checksum_free(md5); return result; } static void parse_service(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const guint8 *target = NULL, *who = NULL; gsize target_size = 0, who_size = 0; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_WHO); if (hdr == NULL) goto target; g_obex_header_get_bytes(hdr, &who, &who_size); target: hdr = g_obex_packet_get_header(req, G_OBEX_HDR_TARGET); if (hdr == NULL) goto probe; g_obex_header_get_bytes(hdr, &target, &target_size); probe: os->service = obex_service_driver_find(os->server->drivers, target, target_size, who, who_size); } static void parse_authchal(struct obex_session *session, GObexPacket *req, GObexPacket *rsp) { GObexHeader *hdr; const guint8 *data, *nonce = NULL; gsize len; uint8_t challenge[18]; struct auth_header *auth = (struct auth_header *) challenge; uint8_t *response; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_AUTHCHAL); if (hdr == NULL) return; if (!g_obex_header_get_bytes(hdr, &data, &len)) return; nonce = extract_nonce(data, len); DBG("AUTH CHALLENGE REQUEST"); response = challenge_response(nonce); auth->tag = DIGEST_TAG; auth->len = NONCE_LEN; memcpy(auth->val, response, NONCE_LEN); hdr = g_obex_header_new_bytes(G_OBEX_HDR_AUTHRESP, challenge, sizeof(challenge)); g_obex_packet_add_header(rsp, hdr); } static void cmd_connect(GObex *obex, GObexPacket *req, void *user_data) { struct obex_session *os = user_data; GObexPacket *rsp; GObexHeader *hdr; int err; DBG(""); print_event(G_OBEX_OP_CONNECT, -1); parse_service(os, req); if (os->service == NULL || os->service->connect == NULL) { error("Connect attempt to a non-supported target"); os_set_response(os, -EPERM); return; } DBG("Selected driver: %s", os->service->name); os->service_data = os->service->connect(os, &err); if (err < 0) { os_set_response(os, err); return; } os->cmd = G_OBEX_OP_CONNECT; rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID); parse_authchal(os, req, rsp); if (os->service->target) { hdr = g_obex_header_new_bytes(G_OBEX_HDR_WHO, os->service->target, os->service->target_size); g_obex_packet_add_header(rsp, hdr); } g_obex_send(obex, rsp, NULL); print_event(-1, 0); } static void cmd_disconnect(GObex *obex, GObexPacket *req, void *user_data) { struct obex_session *os = user_data; DBG("session %p", os); print_event(G_OBEX_OP_DISCONNECT, -1); os->cmd = G_OBEX_OP_DISCONNECT; os_set_response(os, 0); } static ssize_t driver_write(struct obex_session *os) { ssize_t len = 0; while (os->pending > 0) { ssize_t w; w = os->driver->write(os->object, os->buf + len, os->pending); if (w < 0) { error("write(): %s (%zd)", strerror(-w), -w); if (w == -EINTR) continue; else if (w == -EINVAL) memmove(os->buf, os->buf + len, os->pending); return w; } len += w; os->offset += w; os->pending -= w; } DBG("%zd written", len); if (os->service->progress != NULL) os->service->progress(os, os->service_data); return len; } static gssize driver_read(struct obex_session *os, void *buf, gsize size) { gssize len; if (os->object == NULL) return -EIO; if (os->service->progress != NULL) os->service->progress(os, os->service_data); len = os->driver->read(os->object, buf, size); if (len < 0) { error("read(): %s (%zd)", strerror(-len), -len); if (len == -ENOSTR) return 0; if (len == -EAGAIN) os->driver->set_io_watch(os->object, handle_async_io, os); } os->offset += len; DBG("%zd read", len); return len; } static gssize send_data(void *buf, gsize size, gpointer user_data) { struct obex_session *os = user_data; DBG("name=%s type=%s file=%p size=%zu", os->name, os->type, os->object, size); if (os->aborted) return os->err < 0 ? os->err : -EPERM; return driver_read(os, buf, size); } static void transfer_complete(GObex *obex, GError *err, gpointer user_data) { struct obex_session *os = user_data; DBG(""); if (err != NULL) { error("transfer failed: %s\n", err->message); goto reset; } if (os->object && os->driver && os->driver->flush) { if (os->driver->flush(os->object) == -EAGAIN) { g_obex_suspend(os->obex); os->driver->set_io_watch(os->object, handle_async_io, os); return; } } reset: os_reset_session(os); } static int driver_get_headers(struct obex_session *os) { GObexPacket *rsp; gssize len; guint8 data[255]; guint8 id; GObexHeader *hdr; DBG("name=%s type=%s object=%p", os->name, os->type, os->object); if (os->aborted) return os->err < 0 ? os->err : -EPERM; if (os->object == NULL) return -EIO; if (os->headers_sent) return 0; rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID); if (os->driver->get_next_header == NULL) goto done; while ((len = os->driver->get_next_header(os->object, &data, sizeof(data), &id))) { if (len < 0) { error("get_next_header(): %s (%zd)", strerror(-len), -len); g_obex_packet_free(rsp); if (len == -EAGAIN) return len; g_free(os->buf); os->buf = NULL; return len; } hdr = g_obex_header_new_bytes(id, data, len); g_obex_packet_add_header(rsp, hdr); } done: if (os->size != OBJECT_SIZE_UNKNOWN && os->size < UINT32_MAX) { hdr = g_obex_header_new_uint32(G_OBEX_HDR_LENGTH, os->size); g_obex_packet_add_header(rsp, hdr); } g_obex_get_rsp_pkt(os->obex, rsp, send_data, transfer_complete, os, NULL); os->headers_sent = TRUE; print_event(-1, G_OBEX_RSP_CONTINUE); return 0; } static gboolean handle_async_io(void *object, int flags, int err, void *user_data) { struct obex_session *os = user_data; if (err < 0) goto done; if (flags & G_IO_OUT) err = driver_write(os); if ((flags & G_IO_IN) && !os->headers_sent) err = driver_get_headers(os); if (err == -EAGAIN) return TRUE; done: if (err < 0) { os->err = err; os->aborted = TRUE; } g_obex_resume(os->obex); return FALSE; } static gboolean recv_data(const void *buf, gsize size, gpointer user_data) { struct obex_session *os = user_data; ssize_t ret; DBG("name=%s type=%s file=%p size=%zu", os->name, os->type, os->object, size); if (os->aborted) return FALSE; /* workaround: client didn't send the object lenght */ if (os->size == OBJECT_SIZE_DELETE) os->size = OBJECT_SIZE_UNKNOWN; os->buf = g_realloc(os->buf, os->pending + size); memcpy(os->buf + os->pending, buf, size); os->pending += size; /* only write if both object and driver are valid */ if (os->object == NULL || os->driver == NULL) { DBG("Stored %" PRIu64 " bytes into temporary buffer", os->pending); return TRUE; } ret = driver_write(os); if (ret >= 0) return TRUE; if (ret == -EAGAIN) { g_obex_suspend(os->obex); os->driver->set_io_watch(os->object, handle_async_io, os); return TRUE; } return FALSE; } static void parse_type(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const guint8 *type; gsize len; g_free(os->type); os->type = NULL; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_TYPE); if (hdr == NULL) goto probe; if (!g_obex_header_get_bytes(hdr, &type, &len)) goto probe; /* Ensure null termination */ if (type[len - 1] != '\0') goto probe; os->type = g_strndup((const char *) type, len); DBG("TYPE: %s", os->type); probe: os->driver = obex_mime_type_driver_find(os->service->target, os->service->target_size, os->type, os->service->who, os->service->who_size); } static void parse_name(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const char *name; g_free(os->name); os->name = NULL; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_NAME); if (hdr == NULL) return; if (!g_obex_header_get_unicode(hdr, &name)) return; os->name = g_strdup(name); DBG("NAME: %s", os->name); } static void parse_apparam(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const guint8 *apparam; gsize len; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_APPARAM); if (hdr == NULL) return; if (!g_obex_header_get_bytes(hdr, &apparam, &len)) return; os->apparam = g_memdup(apparam, len); os->apparam_len = len; DBG("APPARAM"); } static void cmd_get(GObex *obex, GObexPacket *req, gpointer user_data) { struct obex_session *os = user_data; int err; DBG("session %p", os); print_event(G_OBEX_OP_GET, -1); if (os->service == NULL) { os_set_response(os, -EPERM); return; } if (os->service->get == NULL) { os_set_response(os, -ENOSYS); return; } os->headers_sent = FALSE; if (os->type) { g_free(os->type); os->type = NULL; } parse_type(os, req); if (!os->driver) { error("No driver found"); os_set_response(os, -ENOSYS); return; } os->cmd = G_OBEX_OP_GET; parse_name(os, req); parse_apparam(os, req); err = os->service->get(os, os->service_data); if (err == 0) return; os_set_response(os, err); } static void cmd_setpath(GObex *obex, GObexPacket *req, gpointer user_data) { struct obex_session *os = user_data; int err; DBG(""); print_event(G_OBEX_OP_SETPATH, -1); if (os->service == NULL) { err = -EPERM; goto done; } if (os->service->setpath == NULL) { err = -ENOSYS; goto done; } os->cmd = G_OBEX_OP_SETPATH; parse_name(os, req); os->nonhdr = g_obex_packet_get_data(req, &os->nonhdr_len); err = os->service->setpath(os, os->service_data); done: os_set_response(os, err); } int obex_get_stream_start(struct obex_session *os, const char *filename) { int err; void *object; size_t size = OBJECT_SIZE_UNKNOWN; object = os->driver->open(filename, O_RDONLY, 0, os->service_data, &size, &err); if (object == NULL) { error("open(%s): %s (%d)", filename, strerror(-err), -err); return err; } os->object = object; os->offset = 0; os->size = size; err = driver_get_headers(os); if (err != -EAGAIN) return err; g_obex_suspend(os->obex); os->driver->set_io_watch(os->object, handle_async_io, os); return 0; } int obex_put_stream_start(struct obex_session *os, const char *filename) { int err; os->object = os->driver->open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600, os->service_data, os->size != OBJECT_SIZE_UNKNOWN ? (size_t *) &os->size : NULL, &err); if (os->object == NULL) { error("open(%s): %s (%d)", filename, strerror(-err), -err); return err; } os->path = g_strdup(filename); return 0; } static void parse_length(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; guint32 size; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_LENGTH); if (hdr == NULL) return; if (!g_obex_header_get_uint32(hdr, &size)) return; os->size = size; DBG("LENGTH: %" PRIu64, os->size); } static void parse_time(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const guint8 *time; gsize len; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_TIME); if (hdr == NULL) return; if (!g_obex_header_get_bytes(hdr, &time, &len)) return; os->time = parse_iso8610((const char *) time, len); DBG("TIME: %s", ctime(&os->time)); } static gboolean check_put(GObex *obex, GObexPacket *req, void *user_data) { struct obex_session *os = user_data; int ret; if (os->service->chkput == NULL) goto done; ret = os->service->chkput(os, os->service_data); switch (ret) { case 0: break; case -EAGAIN: g_obex_suspend(os->obex); os->driver->set_io_watch(os->object, handle_async_io, os); return TRUE; default: os_set_response(os, ret); return FALSE; } if (os->size == OBJECT_SIZE_DELETE || os->size == OBJECT_SIZE_UNKNOWN) DBG("Got a PUT without a Length"); done: os->checked = TRUE; return TRUE; } static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data) { struct obex_session *os = user_data; int err; DBG(""); print_event(G_OBEX_OP_PUT, -1); if (os->service == NULL) { os_set_response(os, -EPERM); return; } parse_type(os, req); if (os->driver == NULL) { error("No driver found"); os_set_response(os, -ENOSYS); return; } os->cmd = G_OBEX_OP_PUT; parse_name(os, req); parse_length(os, req); parse_time(os, req); parse_apparam(os, req); if (!os->checked) { if (!check_put(obex, req, user_data)) return; } if (os->service->put == NULL) { os_set_response(os, -ENOSYS); return; } err = os->service->put(os, os->service_data); if (err == 0) { g_obex_put_rsp(obex, req, recv_data, transfer_complete, os, NULL, G_OBEX_HDR_INVALID); print_event(G_OBEX_OP_PUT, G_OBEX_RSP_CONTINUE); return; } os_set_response(os, err); } static void parse_destname(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; const char *destname; g_free(os->destname); os->destname = NULL; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_DESTNAME); if (hdr == NULL) return; if (!g_obex_header_get_unicode(hdr, &destname)) return; os->destname = g_strdup(destname); DBG("DESTNAME: %s", os->destname); } static void parse_action(struct obex_session *os, GObexPacket *req) { GObexHeader *hdr; guint8 id; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_ACTION); if (hdr == NULL) return; if (!g_obex_header_get_uint8(hdr, &id)) return; os->action_id = id; DBG("ACTION: 0x%02x", os->action_id); } static void cmd_action(GObex *obex, GObexPacket *req, gpointer user_data) { struct obex_session *os = user_data; int err; DBG(""); print_event(G_OBEX_OP_ACTION, -1); if (os->service == NULL) { err = -EPERM; goto done; } if (os->service->action == NULL) { err = -ENOSYS; goto done; } os->cmd = G_OBEX_OP_ACTION; parse_name(os, req); parse_destname(os, req); parse_action(os, req); os->driver = obex_mime_type_driver_find(os->service->target, os->service->target_size, NULL, os->service->who, os->service->who_size); if (os->driver == NULL) { err = -ENOSYS; goto done; } err = os->service->action(os, os->service_data); done: os_set_response(os, err); } static void cmd_abort(GObex *obex, GObexPacket *req, gpointer user_data) { struct obex_session *os = user_data; DBG(""); print_event(G_OBEX_OP_ABORT, -1); os_reset_session(os); os_set_response(os, 0); } static void obex_session_destroy(struct obex_session *os) { DBG(""); os_reset_session(os); if (os->service && os->service->disconnect) os->service->disconnect(os, os->service_data); obex_session_free(os); } static void disconn_func(GObex *obex, GError *err, gpointer user_data) { struct obex_session *os = user_data; error("disconnected: %s\n", err ? err->message : ""); obex_session_destroy(os); } int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu, gboolean stream, struct obex_server *server) { struct obex_session *os; GObex *obex; GObexTransportType type; static uint32_t id = 0; DBG(""); os = g_new0(struct obex_session, 1); os->id = ++id; os->service = obex_service_driver_find(server->drivers, NULL, 0, NULL, 0); os->server = server; os->size = OBJECT_SIZE_DELETE; type = stream ? G_OBEX_TRANSPORT_STREAM : G_OBEX_TRANSPORT_PACKET; obex = g_obex_new(io, type, rx_mtu, tx_mtu); if (!obex) { obex_session_free(os); return -EIO; } g_obex_set_disconnect_function(obex, disconn_func, os); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, cmd_connect, os); g_obex_add_request_function(obex, G_OBEX_OP_DISCONNECT, cmd_disconnect, os); g_obex_add_request_function(obex, G_OBEX_OP_PUT, cmd_put, os); g_obex_add_request_function(obex, G_OBEX_OP_GET, cmd_get, os); g_obex_add_request_function(obex, G_OBEX_OP_SETPATH, cmd_setpath, os); g_obex_add_request_function(obex, G_OBEX_OP_ACTION, cmd_action, os); g_obex_add_request_function(obex, G_OBEX_OP_ABORT, cmd_abort, os); os->obex = obex; os->io = g_io_channel_ref(io); sessions = g_slist_prepend(sessions, os); return 0; } const char *obex_get_name(struct obex_session *os) { return os->name; } const char *obex_get_destname(struct obex_session *os) { return os->destname; } void obex_set_name(struct obex_session *os, const char *name) { g_free(os->name); os->name = g_strdup(name); DBG("Name changed: %s", os->name); } ssize_t obex_get_size(struct obex_session *os) { return os->size; } const char *obex_get_type(struct obex_session *os) { return os->type; } int obex_remove(struct obex_session *os, const char *path) { if (os->driver == NULL) return -ENOSYS; return os->driver->remove(path); } int obex_copy(struct obex_session *os, const char *source, const char *destination) { if (os->driver == NULL || os->driver->copy == NULL) return -ENOSYS; DBG("%s %s", source, destination); return os->driver->copy(source, destination); } int obex_move(struct obex_session *os, const char *source, const char *destination) { if (os->driver == NULL || os->driver->move == NULL) return -ENOSYS; DBG("%s %s", source, destination); return os->driver->move(source, destination); } uint8_t obex_get_action_id(struct obex_session *os) { return os->action_id; } ssize_t obex_get_apparam(struct obex_session *os, const uint8_t **buffer) { *buffer = os->apparam; return os->apparam_len; } ssize_t obex_get_non_header_data(struct obex_session *os, const uint8_t **data) { *data = os->nonhdr; return os->nonhdr_len; } int obex_getpeername(struct obex_session *os, char **name) { struct obex_transport_driver *transport = os->server->transport; if (transport == NULL || transport->getpeername == NULL) return -ENOTSUP; return transport->getpeername(os->io, name); } int memncmp0(const void *a, size_t na, const void *b, size_t nb) { if (na != nb) return na - nb; if (a == NULL) return -(a != b); if (b == NULL) return a != b; return memcmp(a, b, na); } obexd-0.46/src/transport.c0000644000000000000000000000417711755212521012434 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "obex.h" #include "server.h" #include "transport.h" #include "log.h" static GSList *drivers = NULL; static struct obex_transport_driver *obex_transport_driver_find( const char *name) { GSList *l; for (l = drivers; l; l = l->next) { struct obex_transport_driver *driver = l->data; if (g_strcmp0(name, driver->name) == 0) return driver; } return NULL; } GSList *obex_transport_driver_list(void) { return drivers; } int obex_transport_driver_register(struct obex_transport_driver *driver) { if (!driver) { error("Invalid driver"); return -EINVAL; } if (obex_transport_driver_find(driver->name) != NULL) { error("Permission denied: transport %s already registered", driver->name); return -EPERM; } DBG("driver %p transport %s registered", driver, driver->name); drivers = g_slist_prepend(drivers, driver); return 0; } void obex_transport_driver_unregister(struct obex_transport_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); return; } DBG("driver %p transport %s unregistered", driver, driver->name); drivers = g_slist_remove(drivers, driver); } obexd-0.46/src/mimetype.c0000644000000000000000000001116611755212521012225 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include "log.h" #include "obex.h" #include "mimetype.h" static GSList *drivers = NULL; static GSList *watches = NULL; struct io_watch { void *object; obex_object_io_func func; void *user_data; }; void obex_object_set_io_flags(void *object, int flags, int err) { GSList *l; for (l = watches; l;) { struct io_watch *watch = l->data; l = l->next; if (watch->object != object) continue; if (watch->func(object, flags, err, watch->user_data) == TRUE) continue; if (g_slist_find(watches, watch) == NULL) continue; watches = g_slist_remove(watches, watch); g_free(watch); } } static struct io_watch *find_io_watch(void *object) { GSList *l; for (l = watches; l; l = l->next) { struct io_watch *watch = l->data; if (watch->object == object) return watch; } return NULL; } static void reset_io_watch(void *object) { struct io_watch *watch; watch = find_io_watch(object); if (watch == NULL) return; watches = g_slist_remove(watches, watch); g_free(watch); } static int set_io_watch(void *object, obex_object_io_func func, void *user_data) { struct io_watch *watch; if (func == NULL) { reset_io_watch(object); return 0; } watch = find_io_watch(object); if (watch) return -EPERM; watch = g_new0(struct io_watch, 1); watch->object = object; watch->func = func; watch->user_data = user_data; watches = g_slist_append(watches, watch); return 0; } static struct obex_mime_type_driver *find_driver(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) { GSList *l; for (l = drivers; l; l = l->next) { struct obex_mime_type_driver *driver = l->data; if (memncmp0(target, target_size, driver->target, driver->target_size)) continue; if (memncmp0(who, who_size, driver->who, driver->who_size)) continue; if (mimetype == NULL || driver->mimetype == NULL) { if (mimetype == driver->mimetype) return driver; else continue; } if (g_ascii_strcasecmp(mimetype, driver->mimetype) == 0) return driver; } return NULL; } struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) { struct obex_mime_type_driver *driver; driver = find_driver(target, target_size, mimetype, who, who_size); if (driver == NULL) { if (who != NULL) { /* Fallback to non-who specific */ driver = find_driver(target, target_size, mimetype, NULL, 0); if (driver != NULL) return driver; } if (mimetype != NULL) /* Fallback to target default */ driver = find_driver(target, target_size, NULL, NULL, 0); if (driver == NULL) /* Fallback to general default */ driver = find_driver(NULL, 0, NULL, NULL, 0); } return driver; } int obex_mime_type_driver_register(struct obex_mime_type_driver *driver) { if (!driver) { error("Invalid driver"); return -EINVAL; } if (find_driver(driver->target, driver->target_size, driver->mimetype, driver->who, driver->who_size)) { error("Permission denied: %s could not be registered", driver->mimetype); return -EPERM; } if (driver->set_io_watch == NULL) driver->set_io_watch = set_io_watch; DBG("driver %p mimetype %s registered", driver, driver->mimetype); drivers = g_slist_append(drivers, driver); return 0; } void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); return; } DBG("driver %p mimetype %s unregistered", driver, driver->mimetype); drivers = g_slist_remove(drivers, driver); } obexd-0.46/src/service.h0000644000000000000000000000372311755212521012041 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define OBEX_PORT_RANDOM UINT16_MAX struct obex_service_driver { const char *name; uint16_t service; uint8_t channel; uint16_t port; gboolean secure; const uint8_t *target; unsigned int target_size; const uint8_t *who; unsigned int who_size; const char *record; void *(*connect) (struct obex_session *os, int *err); void (*progress) (struct obex_session *os, void *user_data); int (*get) (struct obex_session *os, void *user_data); int (*put) (struct obex_session *os, void *user_data); int (*chkput) (struct obex_session *os, void *user_data); int (*setpath) (struct obex_session *os, void *user_data); int (*action) (struct obex_session *os, void *user_data); void (*disconnect) (struct obex_session *os, void *user_data); void (*reset) (struct obex_session *os, void *user_data); }; int obex_service_driver_register(struct obex_service_driver *driver); void obex_service_driver_unregister(struct obex_service_driver *driver); GSList *obex_service_driver_list(uint16_t services); struct obex_service_driver *obex_service_driver_find(GSList *drivers, const uint8_t *target, unsigned int target_size, const uint8_t *who, unsigned int who_size); obexd-0.46/src/log.h0000644000000000000000000000354711503171163011163 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ void info(const char *format, ...) __attribute__((format(printf, 1, 2))); void error(const char *format, ...) __attribute__((format(printf, 1, 2))); void obex_debug(const char *format, ...) __attribute__((format(printf, 1, 2))); void __obex_log_init(const char *label, const char *debug, int detach); void __obex_log_cleanup(void); void __obex_log_enable_debug(void); struct obex_debug_desc { const char *name; const char *file; #define OBEX_DEBUG_FLAG_DEFAULT (0) #define OBEX_DEBUG_FLAG_PRINT (1 << 0) unsigned int flags; } __attribute__((aligned(8))); /** * DBG: * @fmt: format string * @arg...: list of arguments * * Simple macro around debug() which also include the function * name it is called in. */ #define DBG(fmt, arg...) do { \ static struct obex_debug_desc __obex_debug_desc \ __attribute__((used, section("__debug"), aligned(8))) = { \ .file = __FILE__, .flags = OBEX_DEBUG_FLAG_DEFAULT, \ }; \ if (__obex_debug_desc.flags & OBEX_DEBUG_FLAG_PRINT) \ obex_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \ } while (0) obexd-0.46/src/plugin.h0000644000000000000000000000244311503171163011672 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obex_plugin_desc { const char *name; int (*init) (void); void (*exit) (void); }; #ifdef OBEX_PLUGIN_BUILTIN #define OBEX_PLUGIN_DEFINE(name, init, exit) \ struct obex_plugin_desc __obex_builtin_ ## name = { \ #name, init, exit \ }; #else #define OBEX_PLUGIN_DEFINE(name,init,exit) \ extern struct obex_plugin_desc obex_plugin_desc \ __attribute__ ((visibility("default"))); \ struct obex_plugin_desc obex_plugin_desc = { \ #name, init, exit \ }; #endif obexd-0.46/src/map_ap.h0000644000000000000000000001114011755212521011626 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include /* List of OBEX application parameters tags as per MAP specification. */ enum map_ap_tag { MAP_AP_MAXLISTCOUNT = 0x01, /* uint16_t */ MAP_AP_STARTOFFSET = 0x02, /* uint16_t */ MAP_AP_FILTERMESSAGETYPE = 0x03, /* uint8_t */ MAP_AP_FILTERPERIODBEGIN = 0x04, /* char * */ MAP_AP_FILTERPERIODEND = 0x05, /* char * */ MAP_AP_FILTERREADSTATUS = 0x06, /* uint8_t */ MAP_AP_FILTERRECIPIENT = 0x07, /* char * */ MAP_AP_FILTERORIGINATOR = 0x08, /* char * */ MAP_AP_FILTERPRIORITY = 0x09, /* uint8_t */ MAP_AP_ATTACHMENT = 0x0A, /* uint8_t */ MAP_AP_TRANSPARENT = 0x0B, /* uint8_t */ MAP_AP_RETRY = 0x0C, /* uint8_t */ MAP_AP_NEWMESSAGE = 0x0D, /* uint8_t */ MAP_AP_NOTIFICATIONSTATUS = 0x0E, /* uint8_t */ MAP_AP_MASINSTANCEID = 0x0F, /* uint8_t */ MAP_AP_PARAMETERMASK = 0x10, /* uint32_t */ MAP_AP_FOLDERLISTINGSIZE = 0x11, /* uint16_t */ MAP_AP_MESSAGESLISTINGSIZE = 0x12, /* uint16_t */ MAP_AP_SUBJECTLENGTH = 0x13, /* uint8_t */ MAP_AP_CHARSET = 0x14, /* uint8_t */ MAP_AP_FRACTIONREQUEST = 0x15, /* uint8_t */ MAP_AP_FRACTIONDELIVER = 0x16, /* uint8_t */ MAP_AP_STATUSINDICATOR = 0x17, /* uint8_t */ MAP_AP_STATUSVALUE = 0x18, /* uint8_t */ MAP_AP_MSETIME = 0x19, /* char * */ }; /* Data type representing MAP application parameters. Consider opaque. */ typedef GHashTable map_ap_t; /* Creates a new empty MAP application parameters object. */ map_ap_t *map_ap_new(void); /* Frees all the memory used by MAP application parameters object. */ void map_ap_free(map_ap_t *ap); /* Parses given buffer that is a payload of OBEX application parameter header * with a given length. Returned value can be used in calls to map_ap_get_*() * and map_ap_set_*(). It has to be freed using map_ap_free(). It also takes * care of converting all the data to host byte order, so this is the byte * order used in map_ap_get_*()/map_ap_set_*(). * * Returns NULL in case of failure. */ map_ap_t *map_ap_decode(const uint8_t *buffer, size_t length); /* Takes all parameters currently set and packs them into a buffer with OBEX * application parameters header payload format. * * Returns newly allocated buffer of size 'length'. Free with g_free(). */ uint8_t *map_ap_encode(map_ap_t *ap, size_t *length); /* Following family of functions reads value of MAP parameter with given tag. * Use the one with appropriate type for a given tag, as noted above in * map_ap_tag declaration comments. * * Returns TRUE when value is present. FALSE if it is not or the function is * used get a parameter of a different type. When FALSE is returned, variable * pointed by 'val' is left intact. */ gboolean map_ap_get_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t *val); gboolean map_ap_get_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t *val); gboolean map_ap_get_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t *val); /* Reads value of MAP parameter with given tag that is of a string type. * * Returns NULL if parameter is not present in ap or given tag is not of a * string type. */ const char *map_ap_get_string(map_ap_t *ap, enum map_ap_tag tag); /* Following family of functions sets the value of MAP parameter with given * tag. Use the one with appropriate type for a given tag, as noted above in * map_ap_tag declaration comments. * * If there is already a parameter with given tag present, it will be * replaced. map_ap_set_string() makes its own copy of given string. * * Returns TRUE on success (the tag is known and the function chosen matches * the type of tag). */ gboolean map_ap_set_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t val); gboolean map_ap_set_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t val); gboolean map_ap_set_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t val); gboolean map_ap_set_string(map_ap_t *ap, enum map_ap_tag tag, const char *val); obexd-0.46/src/server.c0000644000000000000000000000621011755212521011674 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "obex.h" #include "obex-priv.h" #include "server.h" #include "service.h" #include "transport.h" static GSList *servers = NULL; static void init_server(uint16_t service, GSList *transports) { GSList *l; for (l = transports; l; l = l->next) { struct obex_transport_driver *transport = l->data; struct obex_server *server; int err; if (transport->service != 0 && (transport->service & service) == FALSE) continue; server = g_new0(struct obex_server, 1); server->transport = transport; server->drivers = obex_service_driver_list(service); server->transport_data = transport->start(server, &err); if (server->transport_data == NULL) { DBG("Unable to start %s transport: %s (%d)", transport->name, strerror(err), err); g_free(server); continue; } servers = g_slist_prepend(servers, server); } } int obex_server_init(void) { GSList *drivers; GSList *transports; GSList *l; drivers = obex_service_driver_list(0); if (drivers == NULL) { DBG("No service driver registered"); return -EINVAL; } transports = obex_transport_driver_list(); if (transports == NULL) { DBG("No transport driver registered"); return -EINVAL; } for (l = drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; init_server(driver->service, transports); } return 0; } void obex_server_exit(void) { GSList *l; for (l = servers; l; l = l->next) { struct obex_server *server = l->data; server->transport->stop(server->transport_data); g_free(server); } g_slist_free(servers); return; } struct obex_service_driver *obex_server_find_driver( struct obex_server *server, uint8_t channel) { GSList *l; for (l = server->drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; if (driver->channel == channel) return driver; } return NULL; } int obex_server_new_connection(struct obex_server *server, GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu, gboolean stream) { return obex_session_start(io, tx_mtu, rx_mtu, stream, server); } obexd-0.46/src/transport.h0000644000000000000000000000232011755212521012425 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obex_transport_driver { const char *name; uint16_t service; void *(*start) (struct obex_server *server, int *err); int (*getpeername) (GIOChannel *io, char **name); void (*stop) (void *data); }; int obex_transport_driver_register(struct obex_transport_driver *driver); void obex_transport_driver_unregister(struct obex_transport_driver *driver); GSList *obex_transport_driver_list(void); obexd-0.46/src/obex.h0000644000000000000000000000400711755212521011332 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define OBJECT_SIZE_UNKNOWN -1 #define OBJECT_SIZE_DELETE -2 #define TARGET_SIZE 16 struct obex_session; int obex_get_stream_start(struct obex_session *os, const char *filename); int obex_put_stream_start(struct obex_session *os, const char *filename); const char *obex_get_name(struct obex_session *os); const char *obex_get_destname(struct obex_session *os); void obex_set_name(struct obex_session *os, const char *name); ssize_t obex_get_size(struct obex_session *os); const char *obex_get_type(struct obex_session *os); int obex_remove(struct obex_session *os, const char *path); int obex_copy(struct obex_session *os, const char *source, const char *destination); int obex_move(struct obex_session *os, const char *source, const char *destination); uint8_t obex_get_action_id(struct obex_session *os); ssize_t obex_get_apparam(struct obex_session *os, const uint8_t **buffer); ssize_t obex_get_non_header_data(struct obex_session *os, const uint8_t **data); int obex_getpeername(struct obex_session *os, char **name); /* Just a thin wrapper around memcmp to deal with NULL values */ int memncmp0(const void *a, size_t na, const void *b, size_t nb); obexd-0.46/src/map_ap.c0000644000000000000000000002365111755212521011633 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include "log.h" #include "map_ap.h" enum ap_type { APT_UINT8, APT_UINT16, APT_UINT32, APT_STR }; /* NOTE: ap_defs array has to be kept in sync with map_ap_tag. */ static const struct ap_def { const char *name; enum ap_type type; } ap_defs[] = { { "MAXLISTCOUNT", APT_UINT16 }, { "STARTOFFSET", APT_UINT16 }, { "FILTERMESSAGETYPE", APT_UINT8 }, { "FILTERPERIODBEGIN", APT_STR }, { "FILTERPERIODEND", APT_STR }, { "FILTERREADSTATUS", APT_UINT8 }, { "FILTERRECIPIENT", APT_STR }, { "FILTERORIGINATOR", APT_STR }, { "FILTERPRIORITY", APT_UINT8 }, { "ATTACHMENT", APT_UINT8 }, { "TRANSPARENT", APT_UINT8 }, { "RETRY", APT_UINT8 }, { "NEWMESSAGE", APT_UINT8 }, { "NOTIFICATIONSTATUS", APT_UINT8 }, { "MASINSTANCEID", APT_UINT8 }, { "PARAMETERMASK", APT_UINT32 }, { "FOLDERLISTINGSIZE", APT_UINT16 }, { "MESSAGESLISTINGSIZE", APT_UINT16 }, { "SUBJECTLENGTH", APT_UINT8 }, { "CHARSET", APT_UINT8 }, { "FRACTIONREQUEST", APT_UINT8 }, { "FRACTIONDELIVER", APT_UINT8 }, { "STATUSINDICATOR", APT_UINT8 }, { "STATUSVALUE", APT_UINT8 }, { "MSETIME", APT_STR }, }; struct ap_entry { enum map_ap_tag tag; union { uint32_t u32; uint16_t u16; uint8_t u8; char *str; } val; }; /* This comes from OBEX specs */ struct obex_ap_header { uint8_t tag; uint8_t len; uint8_t val[0]; } __attribute__ ((packed)); static int find_ap_def_offset(uint8_t tag) { if (tag == 0 || tag > G_N_ELEMENTS(ap_defs)) return -1; return tag - 1; } static void ap_entry_dump(gpointer tag, gpointer val, gpointer user_data) { struct ap_entry *entry = val; int offset; offset = find_ap_def_offset(GPOINTER_TO_INT(tag)); switch (ap_defs[offset].type) { case APT_UINT8: DBG("%-30s %08x", ap_defs[offset].name, entry->val.u8); break; case APT_UINT16: DBG("%-30s %08x", ap_defs[offset].name, entry->val.u16); break; case APT_UINT32: DBG("%-30s %08x", ap_defs[offset].name, entry->val.u32); break; case APT_STR: DBG("%-30s %s", ap_defs[offset].name, entry->val.str); break; } } static void ap_entry_free(gpointer val) { struct ap_entry *entry = val; int offset; offset = find_ap_def_offset(entry->tag); if (offset >= 0 && ap_defs[offset].type == APT_STR) g_free(entry->val.str); g_free(entry); } map_ap_t *map_ap_new(void) { return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, ap_entry_free); } void map_ap_free(map_ap_t *ap) { if (!ap) return; g_hash_table_destroy(ap); } static void ap_decode_u8(map_ap_t *ap, const struct obex_ap_header *hdr) { if (hdr->len != 1) { DBG("Value of tag %u is %u byte(s) long instead of expected " "1 byte - skipped!", hdr->tag, hdr->len); return; } map_ap_set_u8(ap, hdr->tag, hdr->val[0]); } static void ap_decode_u16(map_ap_t *ap, const struct obex_ap_header *hdr) { uint16_t val; if (hdr->len != 2) { DBG("Value of tag %u is %u byte(s) long instead of expected " "2 bytes - skipped!", hdr->tag, hdr->len); return; } memcpy(&val, hdr->val, sizeof(val)); map_ap_set_u16(ap, hdr->tag, GUINT16_FROM_BE(val)); } static void ap_decode_u32(map_ap_t *ap, const struct obex_ap_header *hdr) { uint32_t val; if (hdr->len != 4) { DBG("Value of tag %u is %u byte(s) long instead of expected " "4 bytes - skipped!", hdr->tag, hdr->len); return; } memcpy(&val, hdr->val, sizeof(val)); map_ap_set_u32(ap, hdr->tag, GUINT32_FROM_BE(val)); } static void ap_decode_str(map_ap_t *ap, const struct obex_ap_header *hdr) { char *val = g_malloc0(hdr->len + 1); memcpy(val, hdr->val, hdr->len); map_ap_set_string(ap, hdr->tag, val); g_free(val); } map_ap_t *map_ap_decode(const uint8_t *buffer, size_t length) { map_ap_t *ap; struct obex_ap_header *hdr; uint32_t done; int offset; ap = map_ap_new(); if (!ap) return NULL; for (done = 0; done < length; done += hdr->len + sizeof(*hdr)) { hdr = (struct obex_ap_header *)(buffer + done); offset = find_ap_def_offset(hdr->tag); if (offset < 0) { DBG("Unknown tag %u (length %u) - skipped.", hdr->tag, hdr->len); continue; } switch (ap_defs[offset].type) { case APT_UINT8: ap_decode_u8(ap, hdr); break; case APT_UINT16: ap_decode_u16(ap, hdr); break; case APT_UINT32: ap_decode_u32(ap, hdr); break; case APT_STR: ap_decode_str(ap, hdr); break; } } g_hash_table_foreach(ap, ap_entry_dump, NULL); return ap; } static void ap_encode_u8(GByteArray *buf, struct ap_entry *entry) { struct obex_ap_header *hdr; hdr = (struct obex_ap_header *) buf->data + buf->len; g_byte_array_set_size(buf, buf->len + sizeof(*hdr) + 1); hdr->tag = entry->tag; hdr->len = 1; hdr->val[0] = entry->val.u8; } static void ap_encode_u16(GByteArray *buf, struct ap_entry *entry) { struct obex_ap_header *hdr; uint16_t val; hdr = (struct obex_ap_header *) buf->data + buf->len; g_byte_array_set_size(buf, buf->len + sizeof(*hdr) + 2); hdr->tag = entry->tag; hdr->len = 2; val = GUINT16_TO_BE(entry->val.u16); memcpy(hdr->val, &val, sizeof(val)); } static void ap_encode_u32(GByteArray *buf, struct ap_entry *entry) { uint32_t val; struct obex_ap_header *hdr; hdr = (struct obex_ap_header *) buf->data + buf->len; g_byte_array_set_size(buf, buf->len + sizeof(*hdr) + 4); hdr->tag = entry->tag; hdr->len = 4; val = GUINT32_TO_BE(entry->val.u16); memcpy(hdr->val, &val, sizeof(val)); } static void ap_encode_str(GByteArray *buf, struct ap_entry *entry) { size_t len; struct obex_ap_header *hdr; hdr = (struct obex_ap_header *) buf->data + buf->len; len = strlen(entry->val.str); g_byte_array_set_size(buf, buf->len + sizeof(*hdr) + len); hdr->tag = entry->tag; hdr->len = len; memcpy(hdr->val, entry->val.str, len); } uint8_t *map_ap_encode(map_ap_t *ap, size_t *length) { GByteArray *buf; GHashTableIter iter; gpointer key, value; struct ap_entry *entry; int offset; buf = g_byte_array_new(); g_hash_table_iter_init(&iter, ap); while (g_hash_table_iter_next(&iter, &key, &value)) { entry = (struct ap_entry *) value; offset = find_ap_def_offset(entry->tag); switch (ap_defs[offset].type) { case APT_UINT8: ap_encode_u8(buf, entry); break; case APT_UINT16: ap_encode_u16(buf, entry); break; case APT_UINT32: ap_encode_u32(buf, entry); break; case APT_STR: ap_encode_str(buf, entry); break; } } *length = buf->len; return g_byte_array_free(buf, FALSE); } gboolean map_ap_get_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t *val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT8) return FALSE; entry = g_hash_table_lookup(ap, GINT_TO_POINTER(tag)); if (entry == NULL) return FALSE; *val = entry->val.u8; return TRUE; } gboolean map_ap_get_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t *val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT16) return FALSE; entry = g_hash_table_lookup(ap, GINT_TO_POINTER(tag)); if (entry == NULL) return FALSE; *val = entry->val.u16; return TRUE; } gboolean map_ap_get_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t *val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT32) return FALSE; entry = g_hash_table_lookup(ap, GINT_TO_POINTER(tag)); if (entry == NULL) return FALSE; *val = entry->val.u32; return TRUE; } const char *map_ap_get_string(map_ap_t *ap, enum map_ap_tag tag) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_STR) return NULL; entry = g_hash_table_lookup(ap, GINT_TO_POINTER(tag)); if (entry == NULL) return NULL; return entry->val.str; } gboolean map_ap_set_u8(map_ap_t *ap, enum map_ap_tag tag, uint8_t val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT8) return FALSE; entry = g_new0(struct ap_entry, 1); entry->tag = tag; entry->val.u8 = val; g_hash_table_insert(ap, GINT_TO_POINTER(tag), entry); return TRUE; } gboolean map_ap_set_u16(map_ap_t *ap, enum map_ap_tag tag, uint16_t val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT16) return FALSE; entry = g_new0(struct ap_entry, 1); entry->tag = tag; entry->val.u16 = val; g_hash_table_insert(ap, GINT_TO_POINTER(tag), entry); return TRUE; } gboolean map_ap_set_u32(map_ap_t *ap, enum map_ap_tag tag, uint32_t val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_UINT32) return FALSE; entry = g_new0(struct ap_entry, 1); entry->tag = tag; entry->val.u32 = val; g_hash_table_insert(ap, GINT_TO_POINTER(tag), entry); return TRUE; } gboolean map_ap_set_string(map_ap_t *ap, enum map_ap_tag tag, const char *val) { struct ap_entry *entry; int offset = find_ap_def_offset(tag); if (offset < 0 || ap_defs[offset].type != APT_STR) return FALSE; entry = g_new0(struct ap_entry, 1); entry->tag = tag; entry->val.str = g_strdup(val); g_hash_table_insert(ap, GINT_TO_POINTER(tag), entry); return TRUE; } obexd-0.46/src/plugin.c0000644000000000000000000001031511755212521011665 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" /* * Plugins that are using libraries with threads and their own mainloop * will crash on exit. This is a bug inside these libraries, but there is * nothing much that can be done about it. One bad example is libebook. */ #ifdef NEED_THREADS #define PLUGINFLAG (RTLD_NOW | RTLD_NODELETE) #else #define PLUGINFLAG (RTLD_NOW) #endif static GSList *plugins = NULL; struct obex_plugin { void *handle; struct obex_plugin_desc *desc; }; static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc) { struct obex_plugin *plugin; if (desc->init == NULL) return FALSE; plugin = g_try_new0(struct obex_plugin, 1); if (plugin == NULL) return FALSE; plugin->handle = handle; plugin->desc = desc; if (desc->init() < 0) { g_free(plugin); return FALSE; } plugins = g_slist_append(plugins, plugin); DBG("Plugin %s loaded", desc->name); return TRUE; } static gboolean check_plugin(struct obex_plugin_desc *desc, char **patterns, char **excludes) { if (excludes) { for (; *excludes; excludes++) if (g_pattern_match_simple(*excludes, desc->name)) break; if (*excludes) { info("Excluding %s", desc->name); return FALSE; } } if (patterns) { for (; *patterns; patterns++) if (g_pattern_match_simple(*patterns, desc->name)) break; if (*patterns == NULL) { info("Ignoring %s", desc->name); return FALSE; } } return TRUE; } #include "builtin.h" gboolean plugin_init(const char *pattern, const char *exclude) { gchar **patterns = NULL; gchar **excludes = NULL; GDir *dir; const char *file; unsigned int i; if (strlen(PLUGINDIR) == 0) return FALSE; if (pattern) patterns = g_strsplit_set(pattern, ":, ", -1); if (exclude) excludes = g_strsplit_set(exclude, ":, ", -1); DBG("Loading builtin plugins"); for (i = 0; __obex_builtin[i]; i++) { if (check_plugin(__obex_builtin[i], patterns, excludes) == FALSE) continue; add_plugin(NULL, __obex_builtin[i]); } DBG("Loading plugins %s", PLUGINDIR); dir = g_dir_open(PLUGINDIR, 0, NULL); if (!dir) return FALSE; while ((file = g_dir_read_name(dir)) != NULL) { struct obex_plugin_desc *desc; void *handle; char *filename; if (g_str_has_prefix(file, "lib") == TRUE || g_str_has_suffix(file, ".so") == FALSE) continue; filename = g_build_filename(PLUGINDIR, file, NULL); handle = dlopen(filename, PLUGINFLAG); if (handle == NULL) { error("Can't load plugin %s: %s", filename, dlerror()); g_free(filename); continue; } g_free(filename); desc = dlsym(handle, "obex_plugin_desc"); if (desc == NULL) { error("Can't load plugin description: %s", dlerror()); dlclose(handle); continue; } if (check_plugin(desc, patterns, excludes) == FALSE) { dlclose(handle); continue; } if (add_plugin(handle, desc) == FALSE) dlclose(handle); } g_dir_close(dir); g_strfreev(patterns); g_strfreev(excludes); return TRUE; } void plugin_cleanup(void) { GSList *list; DBG("Cleanup plugins"); for (list = plugins; list; list = list->next) { struct obex_plugin *plugin = list->data; if (plugin->desc->exit) plugin->desc->exit(); if (plugin->handle != NULL) dlclose(plugin->handle); g_free(plugin); } g_slist_free(plugins); } obexd-0.46/src/obex-priv.h0000644000000000000000000000302011755212521012302 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obex_session { GIOChannel *io; uint32_t id; uint8_t cmd; uint8_t action_id; char *name; char *destname; char *type; char *path; time_t time; uint8_t *apparam; size_t apparam_len; const void *nonhdr; size_t nonhdr_len; guint get_rsp; uint8_t *buf; int64_t pending; int64_t offset; int64_t size; void *object; gboolean aborted; int err; struct obex_service_driver *service; void *service_data; struct obex_server *server; gboolean checked; GObex *obex; struct obex_mime_type_driver *driver; gboolean headers_sent; }; int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu, gboolean stream, struct obex_server *server); obexd-0.46/src/main.c0000644000000000000000000001670011755212521011317 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "obexd.h" #include "server.h" #define DEFAULT_ROOT_PATH "/tmp" #define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml" static GMainLoop *main_loop = NULL; static unsigned int __terminated = 0; static gboolean signal_handler(GIOChannel *channel, GIOCondition cond, gpointer user_data) { struct signalfd_siginfo si; ssize_t result; int fd; if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) return FALSE; fd = g_io_channel_unix_get_fd(channel); result = read(fd, &si, sizeof(si)); if (result != sizeof(si)) return FALSE; switch (si.ssi_signo) { case SIGINT: case SIGTERM: if (__terminated == 0) { info("Terminating"); g_main_loop_quit(main_loop); } __terminated = 1; break; case SIGUSR2: __obex_log_enable_debug(); break; case SIGPIPE: /* ignore */ break; } return TRUE; } static guint setup_signalfd(void) { GIOChannel *channel; guint source; sigset_t mask; int fd; sigemptyset(&mask); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGTERM); sigaddset(&mask, SIGUSR2); sigaddset(&mask, SIGPIPE); if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) { perror("Failed to set signal mask"); return 0; } fd = signalfd(-1, &mask, 0); if (fd < 0) { perror("Failed to create signal descriptor"); return 0; } channel = g_io_channel_unix_new(fd); g_io_channel_set_close_on_unref(channel, TRUE); g_io_channel_set_encoding(channel, NULL, NULL); g_io_channel_set_buffered(channel, FALSE); source = g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, signal_handler, NULL); g_io_channel_unref(channel); return source; } static gboolean option_detach = TRUE; static char *option_debug = NULL; static char *option_root = NULL; static char *option_root_setup = NULL; static char *option_capability = NULL; static char *option_plugin = NULL; static char *option_noplugin = NULL; static gboolean option_autoaccept = FALSE; static gboolean option_symlinks = FALSE; static gboolean parse_debug(const char *key, const char *value, gpointer user_data, GError **error) { if (value) option_debug = g_strdup(value); else option_debug = g_strdup("*"); return TRUE; } static GOptionEntry options[] = { { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_detach, "Don't run as daemon in background" }, { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug, "Enable debug information output", "DEBUG" }, { "root", 'r', 0, G_OPTION_ARG_STRING, &option_root, "Specify root folder location. Both absolute " "and relative can be used, but relative paths " "are assumed to be relative to user $HOME " "folder", "PATH" }, { "root-setup", 'S', 0, G_OPTION_ARG_STRING, &option_root_setup, "Root folder setup script", "SCRIPT" }, { "symlinks", 'l', 0, G_OPTION_ARG_NONE, &option_symlinks, "Allow symlinks leading outside of the root " "folder" }, { "capability", 'c', 0, G_OPTION_ARG_STRING, &option_capability, "Specify capability file, use '!' mark for " "scripts", "FILE" }, { "auto-accept", 'a', 0, G_OPTION_ARG_NONE, &option_autoaccept, "Automatically accept push requests" }, { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin, "Specify plugins to load", "NAME,..." }, { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin, "Specify plugins not to load", "NAME,..." }, { NULL }, }; gboolean obex_option_auto_accept(void) { return option_autoaccept; } const char *obex_option_root_folder(void) { return option_root; } gboolean obex_option_symlinks(void) { return option_symlinks; } const char *obex_option_capability(void) { return option_capability; } static gboolean is_dir(const char *dir) { struct stat st; if (stat(dir, &st) < 0) { error("stat(%s): %s (%d)", dir, strerror(errno), errno); return FALSE; } return S_ISDIR(st.st_mode); } static gboolean root_folder_setup(char *root, char *root_setup) { int status; char *argv[3] = { root_setup, root, NULL }; if (is_dir(root)) return TRUE; if (root_setup == NULL) return FALSE; DBG("Setting up %s using %s", root, root_setup); if (!g_spawn_sync(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &status, NULL)) { error("Unable to execute %s", root_setup); return FALSE; } if (WEXITSTATUS(status) != EXIT_SUCCESS) { error("%s exited with status %d", root_setup, WEXITSTATUS(status)); return FALSE; } return is_dir(root); } int main(int argc, char *argv[]) { GOptionContext *context; GError *err = NULL; guint signal; #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); #endif context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) { if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); } else g_printerr("An unknown error occurred\n"); exit(EXIT_FAILURE); } g_option_context_free(context); if (option_detach == TRUE) { if (daemon(0, 0)) { perror("Can't start daemon"); exit(1); } } __obex_log_init("obexd", option_debug, option_detach); DBG("Entering main loop"); main_loop = g_main_loop_new(NULL, FALSE); signal = setup_signalfd(); #ifdef NEED_THREADS if (dbus_threads_init_default() == FALSE) { fprintf(stderr, "Can't init usage of threads\n"); exit(EXIT_FAILURE); } #endif if (manager_init() == FALSE) { error("manager_init failed"); exit(EXIT_FAILURE); } if (option_root == NULL) option_root = g_strdup(DEFAULT_ROOT_PATH); if (option_root[0] != '/') { char *old_root = option_root, *home = getenv("HOME"); if (home) { option_root = g_strdup_printf("%s/%s", home, old_root); g_free(old_root); } } if (option_capability == NULL) option_capability = g_strdup(DEFAULT_CAP_FILE); plugin_init(option_plugin, option_noplugin); if (obex_server_init() < 0) { error("obex_server_init failed"); exit(EXIT_FAILURE); } if (!root_folder_setup(option_root, option_root_setup)) { error("Unable to setup root folder %s", option_root); exit(EXIT_FAILURE); } g_main_loop_run(main_loop); g_source_remove(signal); obex_server_exit(); plugin_cleanup(); manager_cleanup(); g_main_loop_unref(main_loop); g_free(option_capability); g_free(option_root); __obex_log_cleanup(); return 0; } obexd-0.46/src/obexd.h0000644000000000000000000000253011755212521011475 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define OBEX_OPP (1 << 1) #define OBEX_FTP (1 << 2) #define OBEX_BIP (1 << 3) #define OBEX_PBAP (1 << 4) #define OBEX_IRMC (1 << 5) #define OBEX_PCSUITE (1 << 6) #define OBEX_SYNCEVOLUTION (1 << 7) #define OBEX_MAS (1 << 8) gboolean plugin_init(const char *pattern, const char *exclude); void plugin_cleanup(void); gboolean manager_init(void); void manager_cleanup(void); gboolean obex_option_auto_accept(void); const char *obex_option_root_folder(void); gboolean obex_option_symlinks(void); const char *obex_option_capability(void); obexd-0.46/src/manager.h0000644000000000000000000000266111755212521012013 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #define OPENOBEX_SERVICE "org.openobex" void manager_register_session(struct obex_session *os); void manager_unregister_session(struct obex_session *os); void manager_register_transfer(struct obex_session *os); void manager_unregister_transfer(struct obex_session *os); void manager_emit_transfer_started(struct obex_session *os); void manager_emit_transfer_progress(struct obex_session *os); void manager_emit_transfer_completed(struct obex_session *os); int manager_request_authorization(struct obex_session *os, int32_t time, char **new_folder, char **new_name); DBusConnection *manager_dbus_get_connection(void); obexd-0.46/src/service.c0000644000000000000000000000540311755212521012031 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "obex.h" #include "service.h" #include "log.h" static GSList *drivers = NULL; struct obex_service_driver *obex_service_driver_find(GSList *drivers, const uint8_t *target, unsigned int target_size, const uint8_t *who, unsigned int who_size) { GSList *l; for (l = drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; /* who is optional, so only check for it if not NULL */ if (who != NULL && memncmp0(who, who_size, driver->who, driver->who_size)) continue; if (memncmp0(target, target_size, driver->target, driver->target_size) == 0) return driver; } return NULL; } GSList *obex_service_driver_list(uint16_t services) { GSList *l; GSList *list = NULL; if (services == 0) return drivers; for (l = drivers; l && services; l = l->next) { struct obex_service_driver *driver = l->data; if (driver->service & services) { list = g_slist_append(list, driver); services &= ~driver->service; } } return list; } int obex_service_driver_register(struct obex_service_driver *driver) { if (!driver) { error("Invalid driver"); return -EINVAL; } if (obex_service_driver_list(driver->service)) { error("Permission denied: service %s already registered", driver->name); return -EPERM; } DBG("driver %p service %s registered", driver, driver->name); /* Drivers that support who has priority */ if (driver->who) drivers = g_slist_prepend(drivers, driver); else drivers = g_slist_append(drivers, driver); return 0; } void obex_service_driver_unregister(struct obex_service_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); return; } DBG("driver %p service %s unregistered", driver, driver->name); drivers = g_slist_remove(drivers, driver); } obexd-0.46/src/mimetype.h0000644000000000000000000000405311755212521012227 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ typedef gboolean (*obex_object_io_func) (void *object, int flags, int err, void *user_data); struct obex_mime_type_driver { const uint8_t *target; unsigned int target_size; const char *mimetype; const uint8_t *who; unsigned int who_size; void *(*open) (const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err); int (*close) (void *object); ssize_t (*get_next_header)(void *object, void *buf, size_t mtu, uint8_t *hi); ssize_t (*read) (void *object, void *buf, size_t count); ssize_t (*write) (void *object, const void *buf, size_t count); int (*flush) (void *object); int (*copy) (const char *name, const char *destname); int (*move) (const char *name, const char *destname); int (*remove) (const char *name); int (*set_io_watch) (void *object, obex_object_io_func func, void *user_data); }; int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver); struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size); void obex_object_set_io_flags(void *object, int flags, int err); obexd-0.46/src/manager.c0000644000000000000000000003532311755212521012007 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include "obexd.h" #include "obex.h" #include "obex-priv.h" #include "server.h" #include "manager.h" #include "log.h" #include "btio.h" #include "service.h" #define OPENOBEX_MANAGER_PATH "/" #define OPENOBEX_MANAGER_INTERFACE OPENOBEX_SERVICE ".Manager" #define ERROR_INTERFACE OPENOBEX_SERVICE ".Error" #define TRANSFER_INTERFACE OPENOBEX_SERVICE ".Transfer" #define SESSION_INTERFACE OPENOBEX_SERVICE ".Session" #define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */ struct agent { char *bus_name; char *path; gboolean auth_pending; char *new_name; char *new_folder; unsigned int watch_id; }; static struct agent *agent = NULL; static DBusConnection *connection = NULL; static void agent_free(struct agent *agent) { if (!agent) return; g_free(agent->new_folder); g_free(agent->new_name); g_free(agent->bus_name); g_free(agent->path); g_free(agent); } static inline DBusMessage *invalid_args(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", "Invalid arguments in method call"); } static inline DBusMessage *agent_already_exists(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyExists", "Agent already exists"); } static inline DBusMessage *agent_does_not_exist(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist", "Agent does not exist"); } static inline DBusMessage *not_authorized(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAuthorized", "Not authorized"); } static void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val) { DBusMessageIter value; DBusMessageIter array; const char *sig; switch (type) { case DBUS_TYPE_STRING: sig = DBUS_TYPE_STRING_AS_STRING; break; case DBUS_TYPE_BYTE: sig = DBUS_TYPE_BYTE_AS_STRING; break; case DBUS_TYPE_INT16: sig = DBUS_TYPE_INT16_AS_STRING; break; case DBUS_TYPE_UINT16: sig = DBUS_TYPE_UINT16_AS_STRING; break; case DBUS_TYPE_INT32: sig = DBUS_TYPE_INT32_AS_STRING; break; case DBUS_TYPE_UINT32: sig = DBUS_TYPE_UINT32_AS_STRING; break; case DBUS_TYPE_BOOLEAN: sig = DBUS_TYPE_BOOLEAN_AS_STRING; break; case DBUS_TYPE_ARRAY: sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; break; case DBUS_TYPE_OBJECT_PATH: sig = DBUS_TYPE_OBJECT_PATH_AS_STRING; break; default: error("Could not append variant with type %d", type); return; } dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value); if (type == DBUS_TYPE_ARRAY) { int i; const char ***str_array = val; dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array); for (i = 0; (*str_array)[i]; i++) dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &((*str_array)[i])); dbus_message_iter_close_container(&value, &array); } else dbus_message_iter_append_basic(&value, type, val); dbus_message_iter_close_container(iter, &value); } static void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); dbus_message_iter_append_variant(&entry, type, val); dbus_message_iter_close_container(dict, &entry); } static void agent_disconnected(DBusConnection *conn, void *user_data) { DBG("Agent exited"); agent_free(agent); agent = NULL; } static DBusMessage *register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { const char *path, *sender; if (agent) return agent_already_exists(msg); if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) return invalid_args(msg); sender = dbus_message_get_sender(msg); agent = g_new0(struct agent, 1); agent->bus_name = g_strdup(sender); agent->path = g_strdup(path); agent->watch_id = g_dbus_add_disconnect_watch(conn, sender, agent_disconnected, NULL, NULL); DBG("Agent registered"); return dbus_message_new_method_return(msg); } static DBusMessage *unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { const char *path, *sender; if (!agent) return agent_does_not_exist(msg); if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) return invalid_args(msg); if (strcmp(agent->path, path) != 0) return agent_does_not_exist(msg); sender = dbus_message_get_sender(msg); if (strcmp(agent->bus_name, sender) != 0) return not_authorized(msg); g_dbus_remove_watch(conn, agent->watch_id); agent_free(agent); agent = NULL; DBG("Agent unregistered"); return dbus_message_new_method_return(msg); } static char *target2str(const uint8_t *t) { if (!t) return NULL; return g_strdup_printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-" "%02X%02X-%02X%02X%02X%02X%02X%02X", t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]); } static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct obex_session *os = data; DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; char *uuid; const char *root; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); /* Target */ uuid = target2str(os->service->target); dbus_message_iter_append_dict_entry(&dict, "Target", DBUS_TYPE_STRING, &uuid); g_free(uuid); /* Root folder */ root = obex_option_root_folder(); dbus_message_iter_append_dict_entry(&dict, "Root", DBUS_TYPE_STRING, &root); /* FIXME: Added Remote Address or USB */ dbus_message_iter_close_container(&iter, &dict); return reply; } static DBusMessage *transfer_cancel(DBusConnection *connection, DBusMessage *msg, void *user_data) { struct obex_session *os = user_data; const char *sender; if (!os) return invalid_args(msg); sender = dbus_message_get_sender(msg); if (strcmp(agent->bus_name, sender) != 0) return not_authorized(msg); os->aborted = TRUE; return dbus_message_new_method_return(msg); } static GDBusMethodTable manager_methods[] = { { "RegisterAgent", "o", "", register_agent }, { "UnregisterAgent", "o", "", unregister_agent }, { } }; static GDBusSignalTable manager_signals[] = { { "TransferStarted", "o" }, { "TransferCompleted", "ob" }, { "SessionCreated", "o" }, { "SessionRemoved", "o" }, { } }; static GDBusMethodTable transfer_methods[] = { { "Cancel", "", "", transfer_cancel }, { } }; static GDBusSignalTable transfer_signals[] = { { "Progress", "ii" }, { } }; static GDBusMethodTable session_methods[] = { { "GetProperties", "", "{sv}", get_properties }, { } }; gboolean manager_init(void) { DBusError err; DBG(""); dbus_error_init(&err); connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OPENOBEX_SERVICE, &err); if (connection == NULL) { if (dbus_error_is_set(&err) == TRUE) { fprintf(stderr, "%s\n", err.message); dbus_error_free(&err); } else fprintf(stderr, "Can't register with session bus\n"); return FALSE; } return g_dbus_register_interface(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, manager_methods, manager_signals, NULL, NULL, NULL); } void manager_cleanup(void) { DBG(""); g_dbus_unregister_interface(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE); /* FIXME: Release agent? */ if (agent) agent_free(agent); dbus_connection_unref(connection); } void manager_emit_transfer_started(struct obex_session *os) { char *path = g_strdup_printf("/transfer%u", os->id); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "TransferStarted", DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); g_free(path); } static void emit_transfer_completed(struct obex_session *os, gboolean success) { char *path = g_strdup_printf("/transfer%u", os->id); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "TransferCompleted", DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_BOOLEAN, &success, DBUS_TYPE_INVALID); g_free(path); } static void emit_transfer_progress(struct obex_session *os, uint32_t total, uint32_t transfered) { char *path = g_strdup_printf("/transfer%u", os->id); g_dbus_emit_signal(connection, path, TRANSFER_INTERFACE, "Progress", DBUS_TYPE_INT32, &total, DBUS_TYPE_INT32, &transfered, DBUS_TYPE_INVALID); g_free(path); } void manager_register_transfer(struct obex_session *os) { char *path = g_strdup_printf("/transfer%u", os->id); if (!g_dbus_register_interface(connection, path, TRANSFER_INTERFACE, transfer_methods, transfer_signals, NULL, os, NULL)) { error("Cannot register Transfer interface."); g_free(path); return; } g_free(path); } void manager_unregister_transfer(struct obex_session *os) { char *path = g_strdup_printf("/transfer%u", os->id); /* Got an error during a transfer. */ if (os->object) emit_transfer_completed(os, os->offset == os->size); g_dbus_unregister_interface(connection, path, TRANSFER_INTERFACE); g_free(path); } static void agent_cancel(void) { DBusMessage *msg; if (agent == NULL) return; msg = dbus_message_new_method_call(agent->bus_name, agent->path, "org.openobex.Agent", "Cancel"); g_dbus_send_message(connection, msg); } static void agent_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply = dbus_pending_call_steal_reply(call); const char *name; DBusError derr; gboolean *got_reply = user_data; *got_reply = TRUE; /* Received a reply after the agent exited */ if (!agent) return; agent->auth_pending = FALSE; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("Agent replied with an error: %s, %s", derr.name, derr.message); if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) agent_cancel(); dbus_error_free(&derr); dbus_message_unref(reply); return; } if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { /* Splits folder and name */ const char *slash = strrchr(name, '/'); DBG("Agent replied with %s", name); if (!slash) { agent->new_name = g_strdup(name); agent->new_folder = NULL; } else { agent->new_name = g_strdup(slash + 1); agent->new_folder = g_strndup(name, slash - name); } } dbus_message_unref(reply); } static gboolean auth_error(GIOChannel *io, GIOCondition cond, void *user_data) { agent->auth_pending = FALSE; return FALSE; } int manager_request_authorization(struct obex_session *os, int32_t time, char **new_folder, char **new_name) { DBusMessage *msg; DBusPendingCall *call; const char *filename = os->name ? os->name : ""; const char *type = os->type ? os->type : ""; char *path, *address; unsigned int watch; gboolean got_reply; int err; if (!agent) return -1; if (agent->auth_pending) return -EPERM; if (!new_folder || !new_name) return -EINVAL; err = obex_getpeername(os, &address); if (err < 0) return err; path = g_strdup_printf("/transfer%u", os->id); msg = dbus_message_new_method_call(agent->bus_name, agent->path, "org.openobex.Agent", "Authorize"); dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_STRING, &address, DBUS_TYPE_STRING, &filename, DBUS_TYPE_STRING, &type, DBUS_TYPE_INT32, &os->size, DBUS_TYPE_INT32, &time, DBUS_TYPE_INVALID); g_free(path); g_free(address); if (!dbus_connection_send_with_reply(connection, msg, &call, TIMEOUT)) { dbus_message_unref(msg); return -EPERM; } dbus_message_unref(msg); agent->auth_pending = TRUE; got_reply = FALSE; /* Catches errors before authorization response comes */ watch = g_io_add_watch_full(os->io, G_PRIORITY_DEFAULT, G_IO_HUP | G_IO_ERR | G_IO_NVAL, auth_error, NULL, NULL); dbus_pending_call_set_notify(call, agent_reply, &got_reply, NULL); /* Workaround: process events while agent doesn't reply */ while (agent && agent->auth_pending) g_main_context_iteration(NULL, TRUE); g_source_remove(watch); if (!got_reply) { dbus_pending_call_cancel(call); agent_cancel(); } dbus_pending_call_unref(call); if (!agent || !agent->new_name) return -EPERM; *new_folder = agent->new_folder; *new_name = agent->new_name; agent->new_folder = NULL; agent->new_name = NULL; return 0; } void manager_register_session(struct obex_session *os) { char *path = g_strdup_printf("/session%u", GPOINTER_TO_UINT(os)); if (!g_dbus_register_interface(connection, path, SESSION_INTERFACE, session_methods, NULL, NULL, os, NULL)) { error("Cannot register Session interface."); goto done; } g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "SessionCreated", DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); done: g_free(path); } void manager_unregister_session(struct obex_session *os) { char *path = g_strdup_printf("/session%u", GPOINTER_TO_UINT(os)); g_dbus_emit_signal(connection, OPENOBEX_MANAGER_PATH, OPENOBEX_MANAGER_INTERFACE, "SessionRemoved", DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); g_dbus_unregister_interface(connection, path, SESSION_INTERFACE); g_free(path); } void manager_emit_transfer_progress(struct obex_session *os) { emit_transfer_progress(os, os->size, os->offset); } void manager_emit_transfer_completed(struct obex_session *os) { if (os->object) emit_transfer_completed(os, !os->aborted); } DBusConnection *manager_dbus_get_connection(void) { if (connection == NULL) return NULL; return dbus_connection_ref(connection); } obexd-0.46/src/server.h0000644000000000000000000000240711755212521011705 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obex_server { struct obex_transport_driver *transport; void *transport_data; GSList *drivers; }; int obex_server_init(void); void obex_server_exit(void); struct obex_service_driver *obex_server_find_driver(struct obex_server *server, uint8_t channel); int obex_server_new_connection(struct obex_server *server, GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu, gboolean stream); obexd-0.46/src/obexd.service.in0000644000000000000000000000010511755212521013307 00000000000000[D-BUS Service] Name=org.openobex Exec=@libexecdir@/obexd --nodaemon obexd-0.46/src/genbuiltin0000755000000000000000000000034711364341101012306 00000000000000#!/bin/sh for i in $* do echo "extern struct obex_plugin_desc __obex_builtin_$i;" done echo echo "static struct obex_plugin_desc *__obex_builtin[] = {" for i in $* do echo " &__obex_builtin_$i," done echo " NULL" echo "};" obexd-0.46/src/log.c0000644000000000000000000000532511755212521011155 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "log.h" void info(const char *format, ...) { va_list ap; va_start(ap, format); vsyslog(LOG_INFO, format, ap); va_end(ap); } void error(const char *format, ...) { va_list ap; va_start(ap, format); vsyslog(LOG_ERR, format, ap); va_end(ap); } void obex_debug(const char *format, ...) { va_list ap; va_start(ap, format); vsyslog(LOG_DEBUG, format, ap); va_end(ap); } extern struct obex_debug_desc __start___debug[]; extern struct obex_debug_desc __stop___debug[]; static gchar **enabled = NULL; static gboolean is_enabled(struct obex_debug_desc *desc) { int i; if (enabled == NULL) return 0; for (i = 0; enabled[i] != NULL; i++) { if (desc->name != NULL && g_pattern_match_simple(enabled[i], desc->name) == TRUE) return 1; if (desc->file != NULL && g_pattern_match_simple(enabled[i], desc->file) == TRUE) return 1; } return 0; } void __obex_log_enable_debug(void) { struct obex_debug_desc *desc; for (desc = __start___debug; desc < __stop___debug; desc++) desc->flags |= OBEX_DEBUG_FLAG_PRINT; } void __obex_log_init(const char *label, const char *debug, int detach) { int option = LOG_NDELAY | LOG_PID; struct obex_debug_desc *desc; const char *name = NULL, *file = NULL; if (debug != NULL) enabled = g_strsplit_set(debug, ":, ", 0); for (desc = __start___debug; desc < __stop___debug; desc++) { if (file != NULL || name != NULL) { if (g_strcmp0(desc->file, file) == 0) { if (desc->name == NULL) desc->name = name; } else file = NULL; } if (is_enabled(desc)) desc->flags |= OBEX_DEBUG_FLAG_PRINT; } if (!detach) option |= LOG_PERROR; openlog(label, option, LOG_DAEMON); syslog(LOG_INFO, "%s daemon %s", label, VERSION); } void __obex_log_cleanup(void) { closelog(); g_strfreev(enabled); } obexd-0.46/config.guess0000755000000000000000000012743211755212544011772 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: obexd-0.46/ChangeLog0000644000000000000000000002760611755212521011221 00000000000000ver 0.46: Update client transfer API. Fix issue with using invalid PSM numbers. Add support for MAP message listing parameters. Add support for MAP folder listing retrieval. ver 0.45: Fix issue with SRM and GET requests. Fix issue with SRM headers and CONNECT. Fix issue with ABORT request not being not processed. Fix issue with file deletion when push gets aborted. Fix issue with missing parsing of PUT application parameter. Fix issue with parsing of PBAP client application parameter. Fix issue with byte-order conversion and L2CAP. Add support for OBEX over L2CAP transport. Add support for MAP AP core functions. ver 0.44: Fix issue with incorrect path during authorization. Fix issue with missing reset after transfer completion. Fix issue with invalid memory access and PBAP. Add support for OBEX Single Response Mode. ver 0.43: Remove OpenOBEX dependency. Fix multiple issues with PBAP and vCard encoding. Add initial support for handling Message Access Profile. Add support for internal and fully asynchronous OBEX library. ver 0.42: Fix issue with freeing buffer before transfer is complete. Fix issue with invalid memory read when pulling phonebook. Fix issue with test cases for empty phonebooks. Add support for multiple phonebooks when using EDS. Add support for handling OBEX Action command. ver 0.41: Fix issue with pulling phonebook entries without last name. Fix issue with handling owner data in phonebook pull. Add support for fetching call history in parts. Add support for selective plugin loading. Add support for Message Access Profile plugin. ver 0.40: Fix issue with plugin close & disconnect functions call order. Fix issue with history queries for contacts outside phonebook. Fix issue with crash after fetching single owner vCard. Add support for multiple URLs in phonebooks. ver 0.39: Fix for handling fax and cell phone numbers. Fix for handling emails in pull call history queries. Fix for handling addresses in pull call history queries. Fix for handling default card and empty phonebook. Add support for handling NewMissedCalls. ver 0.38: Fix regression causing crash in 3-way calling. Fix possible crash when processing session callback. Fix issue with fetching contact photo file name. Fix issue with fetching 0.vcf vCard entry. Add support for optimized PBAP tracker queries. Add support for files bigger than 2GB on 32-bit systems. ver 0.37: Fix queries for contact with only one affiliation. Fix pull phonebook with non-zero offset parameter. Fix pull phonebook reply if filter not set. Fix proper type handling for various queries. ver 0.36: Fix crash for empty listing and an invalid cache. Fix issue with process pending request if transfer canceled. Fix issue with error setting when canceling suspended requests. Fix issue with folder listing and name header for subfolders. Fix issue with status response after pulling empty call history. Fix issue with not handling nco affiliation fields correctly. Fix issue with history listing queries in phonebook-tracker. Fix regression when formatting timestamps from tracker. ver 0.35: Fix regression on suspend on opening. Fix suspend stream on opening if no data. Fix memory leaks in phonebook-tracker module. Fix not responding Not Found for filtered vcard-listing. Fix not responding Not Found when no entry is found. Fix issue with X-IRMC-CALL-DATETIME format. ver 0.34: Fix issue with error detection and last part of transfer buffer. Fix issue with not detecting errors on small files. Fix issue with emitting TransferCompleted twice. Fix issue with default call type from call log. Fix issue with websiteUrl query field not being generic. Add support for binding mch, ich, och and cch call logs. Add handling of TITLE contact's field in vCard. ver 0.33: Fix issue with handling of phonebook size during pull request. Add support for handling of UID contact field in vCard. Add support for handling more than one address in vCard. Add support for merging address fields into single field. ver 0.32: Fix issues caused by dependencies on phonebook source. Fix handling empty fields in vCards. Fix issues with emails category. ver 0.31: Fix aborting capability scripts creating zombies. Fix problem with multiple emails in same vcard. Fix multiple phone number problem in pull vcard. Fix multiple phone numbers problem in vcard-listing. Fix return value checking of e_book_async_get_contacts. Fix a memory leak when adding contacts to the result. Add support of single contact's fields in vcard. Add support for FAX number with tracker phonebook. Add simple IrMC sync server support. ver 0.30: Fix issue with empty error messages. Fix issue with query for vCarcd listing. Fix problem with incoming calls query. Fix handling of vCard filter settings. Fix potential buffer overflow with target sizes. Fix NULL checking within PBAP GET operation. Fix NULL checking for PBAP name parameter. Fix crash when processing OBEX_EV_PROGRESS event. Fix crash when resetting a session with no service. Fix not closing socket when connection attempt fails. Fix de-registering PBAP drivers on init failure scenarios. Add variable target size support to MIME type drivers. Add support for returning all eBook TEL attributes. Add PBAP client tests for ICH, OCH, MCH and CCH. ver 0.29: Fix security requirements for legacy devices. Fix empty 'N:' parameter handling for vCards. Fix order of contacts in the combined calls folder. Fix not replying error when transfer could not be started. Fix not unregistering transfer when completed. Fix memory leak when freeing transfer parameters. Fix issues with handling of driver reset. Add support for responding to Auth Challenge. Add support for dynamic debug feature. ver 0.28: Fix broken assumption about contacts. Fix issue with exporting empty contacts. Fix issue with not always including the TEL header. Fix wrong response code for PBAP PUT operation. Fix handling of Tracker optional parameters. Fix queries for incoming and outgoing folders. Fix ordering during folder listing. Fix complex logic discovering the type of call. Add support for the X-IRMC-CALL-DATETIME field. ver 0.27: Fix GET name handling with FTP service. Fix service driver matching when who is not specified. Fix object name not being updated when agent changes it. Fix inconsistency when using vCard version 2.1. Fix wrong response code to PUT requests for PBAP. Fix crash on PBAP SetPhoneBook function. Add support for transport drivers. Add support for Nokia backup plugin. ver 0.26: Fix the order of the calls handles. Fix crash when receiving small objects. Fix invalid memory access when removing a file. Fix inverting the list with wrong search attribute. Fix wrong response code for dummy PullvCardListing. Fix sending the Not Found response asynchronously. Fix not resetting buffered data count when resetting the session. Add support for multiple telephone numbers. Add support for the ADR filter. ver 0.25: Fix issue with missing phonebook-tracker.c file. ver 0.24: Fix bug when creating directories. Fix error code when removing non-empty directory. Fix PullBusinessCard not return transfer errors. Fix MaxListCount handling for PBAP PullPhoneBook function. Fix mimetype driver selection and default fallback. Add support to the WHO header in mimetype drivers. Add support for PBAP operations to the back-ends. Add support for PBAP Tracker backend. ver 0.23: Fix unneeded reset of session after a CONNECT. Fix folder and object names with enabled auto accept. Fix agent not being released after transfers complete. Fix sending full packets to achieve higher throughput. Add support for mimetype driver to phonebook access. Add support for mimetype driver to SyncEvolution. ver 0.22: Fix file corruption during PUT operation. Fix the response of PUT requests for PBAP. Fix blocking while waiting capability script to exit. Fix compilation issues with driver and plugin options. Fix service driver selection when WHO header is informed. Fix issue with PC-Suite WHO header. Fix issue when mime type exists but is unknown. Fix issue when opening file fails during SendFiles. Fix error code response when there is no default vCard. Fix a memory leak when opening a folder for listing. ver 0.21: Fix crash caused by D-Bus timeout handling. Fix issue when the object size is unknown. Fix issue with reporting no space left on disk. Fix read callback of various drivers. ver 0.20: Fix D-Bus error handling on SyncEvolution connect. Fix PC Suite service driver matching. ver 0.19: Fix crash with agent unregister handling. Add support for mimetype and filesystem plugins. Add support for phonebook and telephony drivers. Add initial OBEX server/SyncML binding for SyncEvolution. ver 0.18: Fix free space calculation on systems where fsfilcnt_t is 32-bit. Fix SendFiles to actually use the source argument. ver 0.17: Fix Bluetooth initialization handling. Add support for full non-recursive build. ver 0.16: Add support for mem-type attribute when in PC Suite mode. Make sure the ONLCR flag is cleared for the TTY. ver 0.15: Fix BtIO race condition in detecting a closed file descriptor. Fix handling of strict-aliasing rules. ver 0.14: Fix issue with symlinks on TTY based servers. Add proper error logs for os_prepare_get failures. Add proper error checks for finding adapter details. Add support for RFCOMM channel property. Add support for PBAP integration with EDS. ver 0.13: Fix issue when bluetoothd is restarted no record is registered. Fix registration of the Transfer interface for FTP sessions. Add FTP client test script. Add support for OBEX root folder setup script. Make root folder relative to $HOME if it doesn't start with '/'. ver 0.12: Fix various format string issues. Fix handling of authorizations with no reply. Add support for using BtIO helper library. Add signal handling for toggling debug messages. Add signal handling for USB TTY details. Add test script for folder listing. ver 0.11: Fix bug when canceling an authorization request. Fix broken handling of successful received D-Bus reply. Fix broken escape handling for filenames. Fix blocking issue with opened TTY. ver 0.10: Fix showing symlinks as files. Fix error codes on OBEX get operations. Fix "not found" error for delete operations. Fix NULL pointer usage of 'nonnull' parameter. Fix TTY handling with PC Suite mode. Fix D-Bus NameOwnerChanged watch handling. ver 0.9: Fix O_NOCTTY issue when opening TTY device. Add support for verbose compiler warnings. Add support for application parameters. Add support for generic GetCapabilities command. Add initial support for Synchronization profile. Add basic implementation of Phonebook Access profile. Add basic Phonebook Access client support. ver 0.8: Fix memory leaks with asynchronous operations. Fix issues with handling larger MTU sizes. Fix session and client disconnect handling. Add basic Nokia PC Suite support. Add support for reinitializing TTY server. ver 0.7: Fix issue with transfers larger than session buffer size. Fix various memory leaks within session handling. Add support for OBEX client session interface. Add support for File Transfer client interface. Add support for using the any adapter object path. ver 0.6: Use BlueZ service for FTP authorization. Use BlueZ service for service records. Never send an OBEX abort for a server. Set buffer to NULL after freeing it. Include the correct COPYING file. ver 0.5: Add initial obex-client support. Add missing API documenation. Rename D-Bus service files. ver 0.4: Add plugin infrastructure. Add support for TTY transport. Fix case when the client doesn't send length header. Use LM_AUTH and LM_ENCRYPT instead of LM_SECURE. ver 0.3: Add support for dynamic capability file. Removing incomplete files on error. Multiple bug fixes. ver 0.2: Add folder listing support. Add D-Bus session interface. Check for dbus_watch_get_unix_fd function. ver 0.1: Initial public release. obexd-0.46/gdbus/0000755000000000000000000000000011755212614010623 500000000000000obexd-0.46/gdbus/polkit.c0000644000000000000000000001262011755212521012207 00000000000000/* * * D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include int polkit_check_authorization(DBusConnection *conn, const char *action, gboolean interaction, void (*function) (dbus_bool_t authorized, void *user_data), void *user_data, int timeout); static void add_dict_with_string_value(DBusMessageIter *iter, const char *key, const char *str) { DBusMessageIter dict, entry, value; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value); dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &str); dbus_message_iter_close_container(&entry, &value); dbus_message_iter_close_container(&dict, &entry); dbus_message_iter_close_container(iter, &dict); } static void add_empty_string_dict(DBusMessageIter *iter) { DBusMessageIter dict; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); dbus_message_iter_close_container(iter, &dict); } static void add_arguments(DBusConnection *conn, DBusMessageIter *iter, const char *action, dbus_uint32_t flags) { const char *busname = dbus_bus_get_unique_name(conn); const char *kind = "system-bus-name"; const char *cancel = ""; DBusMessageIter subject; dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &subject); dbus_message_iter_append_basic(&subject, DBUS_TYPE_STRING, &kind); add_dict_with_string_value(&subject, "name", busname); dbus_message_iter_close_container(iter, &subject); dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &action); add_empty_string_dict(iter); dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &flags); dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &cancel); } static dbus_bool_t parse_result(DBusMessageIter *iter) { DBusMessageIter result; dbus_bool_t authorized, challenge; dbus_message_iter_recurse(iter, &result); dbus_message_iter_get_basic(&result, &authorized); dbus_message_iter_get_basic(&result, &challenge); return authorized; } struct authorization_data { void (*function) (dbus_bool_t authorized, void *user_data); void *user_data; }; static void authorization_reply(DBusPendingCall *call, void *user_data) { struct authorization_data *data = user_data; DBusMessage *reply; DBusMessageIter iter; dbus_bool_t authorized = FALSE; reply = dbus_pending_call_steal_reply(call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) goto done; if (dbus_message_has_signature(reply, "(bba{ss})") == FALSE) goto done; dbus_message_iter_init(reply, &iter); authorized = parse_result(&iter); done: if (data->function != NULL) data->function(authorized, data->user_data); dbus_message_unref(reply); dbus_pending_call_unref(call); } #define AUTHORITY_DBUS "org.freedesktop.PolicyKit1" #define AUTHORITY_INTF "org.freedesktop.PolicyKit1.Authority" #define AUTHORITY_PATH "/org/freedesktop/PolicyKit1/Authority" int polkit_check_authorization(DBusConnection *conn, const char *action, gboolean interaction, void (*function) (dbus_bool_t authorized, void *user_data), void *user_data, int timeout) { struct authorization_data *data; DBusMessage *msg; DBusMessageIter iter; DBusPendingCall *call; dbus_uint32_t flags = 0x00000000; if (conn == NULL) return -EINVAL; data = dbus_malloc0(sizeof(*data)); if (data == NULL) return -ENOMEM; msg = dbus_message_new_method_call(AUTHORITY_DBUS, AUTHORITY_PATH, AUTHORITY_INTF, "CheckAuthorization"); if (msg == NULL) { dbus_free(data); return -ENOMEM; } if (interaction == TRUE) flags |= 0x00000001; if (action == NULL) action = "org.freedesktop.policykit.exec"; dbus_message_iter_init_append(msg, &iter); add_arguments(conn, &iter, action, flags); if (dbus_connection_send_with_reply(conn, msg, &call, timeout) == FALSE) { dbus_message_unref(msg); dbus_free(data); return -EIO; } if (call == NULL) { dbus_message_unref(msg); dbus_free(data); return -EIO; } data->function = function; data->user_data = user_data; dbus_pending_call_set_notify(call, authorization_reply, data, dbus_free); dbus_message_unref(msg); return 0; } obexd-0.46/gdbus/gdbus.h0000644000000000000000000001323711755212521012023 00000000000000/* * * D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GDBUS_H #define __GDBUS_H #ifdef __cplusplus extern "C" { #endif #include #include typedef void (* GDBusWatchFunction) (DBusConnection *connection, void *user_data); typedef gboolean (* GDBusSignalFunction) (DBusConnection *connection, DBusMessage *message, void *user_data); DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, DBusError *error); DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, DBusError *error); gboolean g_dbus_request_name(DBusConnection *connection, const char *name, DBusError *error); gboolean g_dbus_set_disconnect_function(DBusConnection *connection, GDBusWatchFunction function, void *user_data, DBusFreeFunction destroy); typedef void (* GDBusDestroyFunction) (void *user_data); typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection, DBusMessage *message, void *user_data); typedef guint32 GDBusPendingReply; typedef void (* GDBusSecurityFunction) (DBusConnection *connection, const char *action, gboolean interaction, GDBusPendingReply pending); typedef enum { G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0), G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1), G_DBUS_METHOD_FLAG_ASYNC = (1 << 2), } GDBusMethodFlags; typedef enum { G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0), } GDBusSignalFlags; typedef enum { G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0), } GDBusPropertyFlags; typedef enum { G_DBUS_SECURITY_FLAG_DEPRECATED = (1 << 0), G_DBUS_SECURITY_FLAG_BUILTIN = (1 << 1), G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION = (1 << 2), } GDBusSecurityFlags; typedef struct { const char *name; const char *signature; const char *reply; GDBusMethodFunction function; GDBusMethodFlags flags; unsigned int privilege; } GDBusMethodTable; typedef struct { const char *name; const char *signature; GDBusSignalFlags flags; } GDBusSignalTable; typedef struct { const char *name; const char *type; GDBusPropertyFlags flags; } GDBusPropertyTable; typedef struct { unsigned int privilege; const char *action; GDBusSecurityFlags flags; GDBusSecurityFunction function; } GDBusSecurityTable; gboolean g_dbus_register_interface(DBusConnection *connection, const char *path, const char *name, const GDBusMethodTable *methods, const GDBusSignalTable *signals, const GDBusPropertyTable *properties, void *user_data, GDBusDestroyFunction destroy); gboolean g_dbus_unregister_interface(DBusConnection *connection, const char *path, const char *name); gboolean g_dbus_register_security(const GDBusSecurityTable *security); gboolean g_dbus_unregister_security(const GDBusSecurityTable *security); void g_dbus_pending_success(DBusConnection *connection, GDBusPendingReply pending); void g_dbus_pending_error(DBusConnection *connection, GDBusPendingReply pending, const char *name, const char *format, ...) __attribute__((format(printf, 4, 5))); void g_dbus_pending_error_valist(DBusConnection *connection, GDBusPendingReply pending, const char *name, const char *format, va_list args); DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, const char *format, ...) __attribute__((format(printf, 3, 4))); DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, const char *format, va_list args); DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...); DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, int type, va_list args); gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message); gboolean g_dbus_send_reply(DBusConnection *connection, DBusMessage *message, int type, ...); gboolean g_dbus_send_reply_valist(DBusConnection *connection, DBusMessage *message, int type, va_list args); gboolean g_dbus_emit_signal(DBusConnection *connection, const char *path, const char *interface, const char *name, int type, ...); gboolean g_dbus_emit_signal_valist(DBusConnection *connection, const char *path, const char *interface, const char *name, int type, va_list args); guint g_dbus_add_service_watch(DBusConnection *connection, const char *name, GDBusWatchFunction connect, GDBusWatchFunction disconnect, void *user_data, GDBusDestroyFunction destroy); guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, GDBusWatchFunction function, void *user_data, GDBusDestroyFunction destroy); guint g_dbus_add_signal_watch(DBusConnection *connection, const char *sender, const char *path, const char *interface, const char *member, GDBusSignalFunction function, void *user_data, GDBusDestroyFunction destroy); gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag); void g_dbus_remove_all_watches(DBusConnection *connection); #ifdef __cplusplus } #endif #endif /* __GDBUS_H */ obexd-0.46/gdbus/object.c0000644000000000000000000004672511755212521012170 00000000000000/* * * D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "gdbus.h" #define info(fmt...) #define error(fmt...) #define debug(fmt...) struct generic_data { unsigned int refcount; GSList *interfaces; char *introspect; }; struct interface_data { char *name; const GDBusMethodTable *methods; const GDBusSignalTable *signals; const GDBusPropertyTable *properties; void *user_data; GDBusDestroyFunction destroy; }; struct security_data { GDBusPendingReply pending; DBusMessage *message; const GDBusMethodTable *method; void *iface_user_data; }; static void print_arguments(GString *gstr, const char *sig, const char *direction) { int i; for (i = 0; sig[i]; i++) { char type[32]; int struct_level, dict_level; unsigned int len; gboolean complete; complete = FALSE; struct_level = dict_level = 0; memset(type, 0, sizeof(type)); /* Gather enough data to have a single complete type */ for (len = 0; len < (sizeof(type) - 1) && sig[i]; len++, i++) { switch (sig[i]) { case '(': struct_level++; break; case ')': struct_level--; if (struct_level <= 0 && dict_level <= 0) complete = TRUE; break; case '{': dict_level++; break; case '}': dict_level--; if (struct_level <= 0 && dict_level <= 0) complete = TRUE; break; case 'a': break; default: if (struct_level <= 0 && dict_level <= 0) complete = TRUE; break; } type[len] = sig[i]; if (complete) break; } if (direction) g_string_append_printf(gstr, "\t\t\t\n", type, direction); else g_string_append_printf(gstr, "\t\t\t\n", type); } } static void generate_interface_xml(GString *gstr, struct interface_data *iface) { const GDBusMethodTable *method; const GDBusSignalTable *signal; for (method = iface->methods; method && method->name; method++) { if (!strlen(method->signature) && !strlen(method->reply)) g_string_append_printf(gstr, "\t\t\n", method->name); else { g_string_append_printf(gstr, "\t\t\n", method->name); print_arguments(gstr, method->signature, "in"); print_arguments(gstr, method->reply, "out"); g_string_append_printf(gstr, "\t\t\n"); } } for (signal = iface->signals; signal && signal->name; signal++) { if (!strlen(signal->signature)) g_string_append_printf(gstr, "\t\t\n", signal->name); else { g_string_append_printf(gstr, "\t\t\n", signal->name); print_arguments(gstr, signal->signature, NULL); g_string_append_printf(gstr, "\t\t\n"); } } } static void generate_introspection_xml(DBusConnection *conn, struct generic_data *data, const char *path) { GSList *list; GString *gstr; char **children; int i; g_free(data->introspect); gstr = g_string_new(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); g_string_append_printf(gstr, "\n"); for (list = data->interfaces; list; list = list->next) { struct interface_data *iface = list->data; g_string_append_printf(gstr, "\t\n", iface->name); generate_interface_xml(gstr, iface); g_string_append_printf(gstr, "\t\n"); } if (!dbus_connection_list_registered(conn, path, &children)) goto done; for (i = 0; children[i]; i++) g_string_append_printf(gstr, "\t\n", children[i]); dbus_free_string_array(children); done: g_string_append_printf(gstr, "\n"); data->introspect = g_string_free(gstr, FALSE); } static DBusMessage *introspect(DBusConnection *connection, DBusMessage *message, void *user_data) { struct generic_data *data = user_data; DBusMessage *reply; if (!dbus_message_has_signature(message, DBUS_TYPE_INVALID_AS_STRING)) { error("Unexpected signature to introspect call"); return NULL; } if (data->introspect == NULL) generate_introspection_xml(connection, data, dbus_message_get_path(message)); reply = dbus_message_new_method_return(message); if (reply == NULL) return NULL; dbus_message_append_args(reply, DBUS_TYPE_STRING, &data->introspect, DBUS_TYPE_INVALID); return reply; } static DBusHandlerResult process_message(DBusConnection *connection, DBusMessage *message, const GDBusMethodTable *method, void *iface_user_data) { DBusMessage *reply; reply = method->function(connection, message, iface_user_data); if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY) { if (reply != NULL) dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } if (method->flags & G_DBUS_METHOD_FLAG_ASYNC) { if (reply == NULL) return DBUS_HANDLER_RESULT_HANDLED; } if (reply == NULL) return DBUS_HANDLER_RESULT_NEED_MEMORY; dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } static GDBusPendingReply next_pending = 1; static GSList *pending_security = NULL; static const GDBusSecurityTable *security_table = NULL; void g_dbus_pending_success(DBusConnection *connection, GDBusPendingReply pending) { GSList *list; for (list = pending_security; list; list = list->next) { struct security_data *secdata = list->data; if (secdata->pending != pending) continue; pending_security = g_slist_remove(pending_security, secdata); process_message(connection, secdata->message, secdata->method, secdata->iface_user_data); dbus_message_unref(secdata->message); g_free(secdata); return; } } void g_dbus_pending_error_valist(DBusConnection *connection, GDBusPendingReply pending, const char *name, const char *format, va_list args) { GSList *list; for (list = pending_security; list; list = list->next) { struct security_data *secdata = list->data; DBusMessage *reply; if (secdata->pending != pending) continue; pending_security = g_slist_remove(pending_security, secdata); reply = g_dbus_create_error_valist(secdata->message, name, format, args); if (reply != NULL) { dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); } dbus_message_unref(secdata->message); g_free(secdata); return; } } void g_dbus_pending_error(DBusConnection *connection, GDBusPendingReply pending, const char *name, const char *format, ...) { va_list args; va_start(args, format); g_dbus_pending_error_valist(connection, pending, name, format, args); va_end(args); } int polkit_check_authorization(DBusConnection *conn, const char *action, gboolean interaction, void (*function) (dbus_bool_t authorized, void *user_data), void *user_data, int timeout); struct builtin_security_data { DBusConnection *conn; GDBusPendingReply pending; }; static void builtin_security_result(dbus_bool_t authorized, void *user_data) { struct builtin_security_data *data = user_data; if (authorized == TRUE) g_dbus_pending_success(data->conn, data->pending); else g_dbus_pending_error(data->conn, data->pending, DBUS_ERROR_AUTH_FAILED, NULL); g_free(data); } static void builtin_security_function(DBusConnection *conn, const char *action, gboolean interaction, GDBusPendingReply pending) { struct builtin_security_data *data; data = g_new0(struct builtin_security_data, 1); data->conn = conn; data->pending = pending; if (polkit_check_authorization(conn, action, interaction, builtin_security_result, data, 30000) < 0) g_dbus_pending_error(conn, pending, NULL, NULL); } static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg, const GDBusMethodTable *method, void *iface_user_data) { const GDBusSecurityTable *security; for (security = security_table; security && security->privilege; security++) { struct security_data *secdata; gboolean interaction; if (security->privilege != method->privilege) continue; secdata = g_new(struct security_data, 1); secdata->pending = next_pending++; secdata->message = dbus_message_ref(msg); secdata->method = method; secdata->iface_user_data = iface_user_data; pending_security = g_slist_prepend(pending_security, secdata); if (security->flags & G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION) interaction = TRUE; else interaction = FALSE; if (!(security->flags & G_DBUS_SECURITY_FLAG_BUILTIN) && security->function) security->function(conn, security->action, interaction, secdata->pending); else builtin_security_function(conn, security->action, interaction, secdata->pending); return TRUE; } return FALSE; } static void generic_unregister(DBusConnection *connection, void *user_data) { struct generic_data *data = user_data; g_free(data->introspect); g_free(data); } static struct interface_data *find_interface(GSList *interfaces, const char *name) { GSList *list; if (name == NULL) return NULL; for (list = interfaces; list; list = list->next) { struct interface_data *iface = list->data; if (!strcmp(name, iface->name)) return iface; } return NULL; } static DBusHandlerResult generic_message(DBusConnection *connection, DBusMessage *message, void *user_data) { struct generic_data *data = user_data; struct interface_data *iface; const GDBusMethodTable *method; const char *interface; interface = dbus_message_get_interface(message); iface = find_interface(data->interfaces, interface); if (iface == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; for (method = iface->methods; method && method->name && method->function; method++) { if (dbus_message_is_method_call(message, iface->name, method->name) == FALSE) continue; if (dbus_message_has_signature(message, method->signature) == FALSE) continue; if (check_privilege(connection, message, method, iface->user_data) == TRUE) return DBUS_HANDLER_RESULT_HANDLED; return process_message(connection, message, method, iface->user_data); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static DBusObjectPathVTable generic_table = { .unregister_function = generic_unregister, .message_function = generic_message, }; static void invalidate_parent_data(DBusConnection *conn, const char *child_path) { struct generic_data *data = NULL; char *parent_path, *slash; parent_path = g_strdup(child_path); slash = strrchr(parent_path, '/'); if (slash == NULL) goto done; if (slash == parent_path && parent_path[1] != '\0') parent_path[1] = '\0'; else *slash = '\0'; if (!strlen(parent_path)) goto done; if (dbus_connection_get_object_path_data(conn, parent_path, (void *) &data) == FALSE) { goto done; } invalidate_parent_data(conn, parent_path); if (data == NULL) goto done; g_free(data->introspect); data->introspect = NULL; done: g_free(parent_path); } static GDBusMethodTable introspect_methods[] = { { "Introspect", "", "s", introspect }, { } }; static void add_interface(struct generic_data *data, const char *name, const GDBusMethodTable *methods, const GDBusSignalTable *signals, const GDBusPropertyTable *properties, void *user_data, GDBusDestroyFunction destroy) { struct interface_data *iface; iface = g_new0(struct interface_data, 1); iface->name = g_strdup(name); iface->methods = methods; iface->signals = signals; iface->properties = properties; iface->user_data = user_data; iface->destroy = destroy; data->interfaces = g_slist_append(data->interfaces, iface); } static struct generic_data *object_path_ref(DBusConnection *connection, const char *path) { struct generic_data *data; if (dbus_connection_get_object_path_data(connection, path, (void *) &data) == TRUE) { if (data != NULL) { data->refcount++; return data; } } data = g_new0(struct generic_data, 1); data->refcount = 1; data->introspect = g_strdup(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE ""); if (!dbus_connection_register_object_path(connection, path, &generic_table, data)) { g_free(data->introspect); g_free(data); return NULL; } invalidate_parent_data(connection, path); add_interface(data, DBUS_INTERFACE_INTROSPECTABLE, introspect_methods, NULL, NULL, data, NULL); return data; } static gboolean remove_interface(struct generic_data *data, const char *name) { struct interface_data *iface; iface = find_interface(data->interfaces, name); if (iface == NULL) return FALSE; data->interfaces = g_slist_remove(data->interfaces, iface); if (iface->destroy) iface->destroy(iface->user_data); g_free(iface->name); g_free(iface); return TRUE; } static void object_path_unref(DBusConnection *connection, const char *path) { struct generic_data *data = NULL; if (dbus_connection_get_object_path_data(connection, path, (void *) &data) == FALSE) return; if (data == NULL) return; data->refcount--; if (data->refcount > 0) return; remove_interface(data, DBUS_INTERFACE_INTROSPECTABLE); invalidate_parent_data(connection, path); dbus_connection_unregister_object_path(connection, path); } static gboolean check_signal(DBusConnection *conn, const char *path, const char *interface, const char *name, const char **args) { struct generic_data *data = NULL; struct interface_data *iface; const GDBusSignalTable *signal; *args = NULL; if (!dbus_connection_get_object_path_data(conn, path, (void *) &data) || data == NULL) { error("dbus_connection_emit_signal: path %s isn't registered", path); return FALSE; } iface = find_interface(data->interfaces, interface); if (iface == NULL) { error("dbus_connection_emit_signal: %s does not implement %s", path, interface); return FALSE; } for (signal = iface->signals; signal && signal->name; signal++) { if (!strcmp(signal->name, name)) { *args = signal->signature; break; } } if (*args == NULL) { error("No signal named %s on interface %s", name, interface); return FALSE; } return TRUE; } static dbus_bool_t emit_signal_valist(DBusConnection *conn, const char *path, const char *interface, const char *name, int first, va_list var_args) { DBusMessage *signal; dbus_bool_t ret; const char *signature, *args; if (!check_signal(conn, path, interface, name, &args)) return FALSE; signal = dbus_message_new_signal(path, interface, name); if (signal == NULL) { error("Unable to allocate new %s.%s signal", interface, name); return FALSE; } ret = dbus_message_append_args_valist(signal, first, var_args); if (!ret) goto fail; signature = dbus_message_get_signature(signal); if (strcmp(args, signature) != 0) { error("%s.%s: expected signature'%s' but got '%s'", interface, name, args, signature); ret = FALSE; goto fail; } ret = dbus_connection_send(conn, signal, NULL); fail: dbus_message_unref(signal); return ret; } gboolean g_dbus_register_interface(DBusConnection *connection, const char *path, const char *name, const GDBusMethodTable *methods, const GDBusSignalTable *signals, const GDBusPropertyTable *properties, void *user_data, GDBusDestroyFunction destroy) { struct generic_data *data; data = object_path_ref(connection, path); if (data == NULL) return FALSE; if (find_interface(data->interfaces, name)) { object_path_unref(connection, path); return FALSE; } add_interface(data, name, methods, signals, properties, user_data, destroy); g_free(data->introspect); data->introspect = NULL; return TRUE; } gboolean g_dbus_unregister_interface(DBusConnection *connection, const char *path, const char *name) { struct generic_data *data = NULL; if (path == NULL) return FALSE; if (dbus_connection_get_object_path_data(connection, path, (void *) &data) == FALSE) return FALSE; if (data == NULL) return FALSE; if (remove_interface(data, name) == FALSE) return FALSE; g_free(data->introspect); data->introspect = NULL; object_path_unref(connection, path); return TRUE; } gboolean g_dbus_register_security(const GDBusSecurityTable *security) { if (security_table != NULL) return FALSE; security_table = security; return TRUE; } gboolean g_dbus_unregister_security(const GDBusSecurityTable *security) { security_table = NULL; return TRUE; } DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, const char *format, va_list args) { char str[1024]; vsnprintf(str, sizeof(str), format, args); return dbus_message_new_error(message, name, str); } DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, const char *format, ...) { va_list args; DBusMessage *reply; va_start(args, format); reply = g_dbus_create_error_valist(message, name, format, args); va_end(args); return reply; } DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, int type, va_list args) { DBusMessage *reply; reply = dbus_message_new_method_return(message); if (reply == NULL) return NULL; if (dbus_message_append_args_valist(reply, type, args) == FALSE) { dbus_message_unref(reply); return NULL; } return reply; } DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...) { va_list args; DBusMessage *reply; va_start(args, type); reply = g_dbus_create_reply_valist(message, type, args); va_end(args); return reply; } gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message) { dbus_bool_t result; if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL) dbus_message_set_no_reply(message, TRUE); result = dbus_connection_send(connection, message, NULL); dbus_message_unref(message); return result; } gboolean g_dbus_send_reply_valist(DBusConnection *connection, DBusMessage *message, int type, va_list args) { DBusMessage *reply; reply = dbus_message_new_method_return(message); if (reply == NULL) return FALSE; if (dbus_message_append_args_valist(reply, type, args) == FALSE) { dbus_message_unref(reply); return FALSE; } return g_dbus_send_message(connection, reply); } gboolean g_dbus_send_reply(DBusConnection *connection, DBusMessage *message, int type, ...) { va_list args; gboolean result; va_start(args, type); result = g_dbus_send_reply_valist(connection, message, type, args); va_end(args); return result; } gboolean g_dbus_emit_signal(DBusConnection *connection, const char *path, const char *interface, const char *name, int type, ...) { va_list args; gboolean result; va_start(args, type); result = emit_signal_valist(connection, path, interface, name, type, args); va_end(args); return result; } gboolean g_dbus_emit_signal_valist(DBusConnection *connection, const char *path, const char *interface, const char *name, int type, va_list args) { return emit_signal_valist(connection, path, interface, name, type, args); } obexd-0.46/gdbus/mainloop.c0000644000000000000000000001773611755212521012540 00000000000000/* * * D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "gdbus.h" #define DISPATCH_TIMEOUT 0 #define info(fmt...) #define error(fmt...) #define debug(fmt...) struct timeout_handler { guint id; DBusTimeout *timeout; }; struct watch_info { guint id; DBusWatch *watch; DBusConnection *conn; }; struct disconnect_data { GDBusWatchFunction function; void *user_data; }; static gboolean disconnected_signal(DBusConnection *conn, DBusMessage *msg, void *data) { struct disconnect_data *dc_data = data; error("Got disconnected from the system message bus"); dc_data->function(conn, dc_data->user_data); dbus_connection_unref(conn); return TRUE; } static gboolean message_dispatch(void *data) { DBusConnection *conn = data; dbus_connection_ref(conn); /* Dispatch messages */ while (dbus_connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS); dbus_connection_unref(conn); return FALSE; } static inline void queue_dispatch(DBusConnection *conn, DBusDispatchStatus status) { if (status == DBUS_DISPATCH_DATA_REMAINS) g_timeout_add(DISPATCH_TIMEOUT, message_dispatch, conn); } static gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data) { struct watch_info *info = data; unsigned int flags = 0; DBusDispatchStatus status; dbus_connection_ref(info->conn); if (cond & G_IO_IN) flags |= DBUS_WATCH_READABLE; if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE; if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP; if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR; dbus_watch_handle(info->watch, flags); status = dbus_connection_get_dispatch_status(info->conn); queue_dispatch(info->conn, status); dbus_connection_unref(info->conn); return TRUE; } static void watch_info_free(void *data) { struct watch_info *info = data; if (info->id > 0) { g_source_remove(info->id); info->id = 0; } dbus_connection_unref(info->conn); g_free(info); } static dbus_bool_t add_watch(DBusWatch *watch, void *data) { DBusConnection *conn = data; GIOCondition cond = G_IO_HUP | G_IO_ERR; GIOChannel *chan; struct watch_info *info; unsigned int flags; int fd; if (!dbus_watch_get_enabled(watch)) return TRUE; info = g_new0(struct watch_info, 1); fd = dbus_watch_get_unix_fd(watch); chan = g_io_channel_unix_new(fd); info->watch = watch; info->conn = dbus_connection_ref(conn); dbus_watch_set_data(watch, info, watch_info_free); flags = dbus_watch_get_flags(watch); if (flags & DBUS_WATCH_READABLE) cond |= G_IO_IN; if (flags & DBUS_WATCH_WRITABLE) cond |= G_IO_OUT; info->id = g_io_add_watch(chan, cond, watch_func, info); g_io_channel_unref(chan); return TRUE; } static void remove_watch(DBusWatch *watch, void *data) { if (dbus_watch_get_enabled(watch)) return; /* will trigger watch_info_free() */ dbus_watch_set_data(watch, NULL, NULL); } static void watch_toggled(DBusWatch *watch, void *data) { /* Because we just exit on OOM, enable/disable is * no different from add/remove */ if (dbus_watch_get_enabled(watch)) add_watch(watch, data); else remove_watch(watch, data); } static gboolean timeout_handler_dispatch(gpointer data) { struct timeout_handler *handler = data; handler->id = 0; /* if not enabled should not be polled by the main loop */ if (!dbus_timeout_get_enabled(handler->timeout)) return FALSE; dbus_timeout_handle(handler->timeout); return FALSE; } static void timeout_handler_free(void *data) { struct timeout_handler *handler = data; if (handler->id > 0) { g_source_remove(handler->id); handler->id = 0; } g_free(handler); } static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) { int interval = dbus_timeout_get_interval(timeout); struct timeout_handler *handler; if (!dbus_timeout_get_enabled(timeout)) return TRUE; handler = g_new0(struct timeout_handler, 1); handler->timeout = timeout; dbus_timeout_set_data(timeout, handler, timeout_handler_free); handler->id = g_timeout_add(interval, timeout_handler_dispatch, handler); return TRUE; } static void remove_timeout(DBusTimeout *timeout, void *data) { /* will trigger timeout_handler_free() */ dbus_timeout_set_data(timeout, NULL, NULL); } static void timeout_toggled(DBusTimeout *timeout, void *data) { if (dbus_timeout_get_enabled(timeout)) add_timeout(timeout, data); else remove_timeout(timeout, data); } static void dispatch_status(DBusConnection *conn, DBusDispatchStatus status, void *data) { if (!dbus_connection_get_is_connected(conn)) return; queue_dispatch(conn, status); } static inline void setup_dbus_with_main_loop(DBusConnection *conn) { dbus_connection_set_watch_functions(conn, add_watch, remove_watch, watch_toggled, conn, NULL); dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout, timeout_toggled, NULL, NULL); dbus_connection_set_dispatch_status_function(conn, dispatch_status, NULL, NULL); } static gboolean setup_bus(DBusConnection *conn, const char *name, DBusError *error) { gboolean result; DBusDispatchStatus status; if (name != NULL) { result = g_dbus_request_name(conn, name, error); if (error != NULL) { if (dbus_error_is_set(error) == TRUE) return FALSE; } if (result == FALSE) return FALSE; } setup_dbus_with_main_loop(conn); status = dbus_connection_get_dispatch_status(conn); queue_dispatch(conn, status); return TRUE; } DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, DBusError *error) { DBusConnection *conn; conn = dbus_bus_get(type, error); if (error != NULL) { if (dbus_error_is_set(error) == TRUE) return NULL; } if (conn == NULL) return NULL; if (setup_bus(conn, name, error) == FALSE) { dbus_connection_unref(conn); return NULL; } return conn; } DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, DBusError *error) { DBusConnection *conn; conn = dbus_bus_get_private(type, error); if (error != NULL) { if (dbus_error_is_set(error) == TRUE) return NULL; } if (conn == NULL) return NULL; if (setup_bus(conn, name, error) == FALSE) { dbus_connection_unref(conn); return NULL; } return conn; } gboolean g_dbus_request_name(DBusConnection *connection, const char *name, DBusError *error) { int result; result = dbus_bus_request_name(connection, name, DBUS_NAME_FLAG_DO_NOT_QUEUE, error); if (error != NULL) { if (dbus_error_is_set(error) == TRUE) return FALSE; } if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { if (error != NULL) dbus_set_error(error, name, "Name already in use"); return FALSE; } return TRUE; } gboolean g_dbus_set_disconnect_function(DBusConnection *connection, GDBusWatchFunction function, void *user_data, DBusFreeFunction destroy) { struct disconnect_data *dc_data; dc_data = g_new0(struct disconnect_data, 1); dc_data->function = function; dc_data->user_data = user_data; dbus_connection_set_exit_on_disconnect(connection, FALSE); if (g_dbus_add_signal_watch(connection, NULL, NULL, DBUS_INTERFACE_LOCAL, "Disconnected", disconnected_signal, dc_data, g_free) == 0) { error("Failed to add watch for D-Bus Disconnected signal"); g_free(dc_data); return FALSE; } return TRUE; } obexd-0.46/gdbus/watch.c0000644000000000000000000004172311755212521012021 00000000000000/* * * D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "gdbus.h" #define info(fmt...) #define error(fmt...) #define debug(fmt...) static DBusHandlerResult message_filter(DBusConnection *connection, DBusMessage *message, void *user_data); static guint listener_id = 0; static GSList *listeners = NULL; struct service_data { DBusConnection *conn; DBusPendingCall *call; char *name; const char *owner; guint id; struct filter_callback *callback; }; struct filter_callback { GDBusWatchFunction conn_func; GDBusWatchFunction disc_func; GDBusSignalFunction signal_func; GDBusDestroyFunction destroy_func; struct service_data *data; void *user_data; guint id; }; struct filter_data { DBusConnection *connection; DBusHandleMessageFunction handle_func; char *name; char *owner; char *path; char *interface; char *member; char *argument; GSList *callbacks; GSList *processed; guint name_watch; gboolean lock; gboolean registered; }; static struct filter_data *filter_data_find(DBusConnection *connection, const char *name, const char *owner, const char *path, const char *interface, const char *member, const char *argument) { GSList *current; for (current = listeners; current != NULL; current = current->next) { struct filter_data *data = current->data; if (connection != data->connection) continue; if (name && data->name && g_str_equal(name, data->name) == FALSE) continue; if (owner && data->owner && g_str_equal(owner, data->owner) == FALSE) continue; if (path && data->path && g_str_equal(path, data->path) == FALSE) continue; if (interface && data->interface && g_str_equal(interface, data->interface) == FALSE) continue; if (member && data->member && g_str_equal(member, data->member) == FALSE) continue; if (argument && data->argument && g_str_equal(argument, data->argument) == FALSE) continue; return data; } return NULL; } static void format_rule(struct filter_data *data, char *rule, size_t size) { const char *sender; int offset; offset = snprintf(rule, size, "type='signal'"); sender = data->name ? : data->owner; if (sender) offset += snprintf(rule + offset, size - offset, ",sender='%s'", sender); if (data->path) offset += snprintf(rule + offset, size - offset, ",path='%s'", data->path); if (data->interface) offset += snprintf(rule + offset, size - offset, ",interface='%s'", data->interface); if (data->member) offset += snprintf(rule + offset, size - offset, ",member='%s'", data->member); if (data->argument) snprintf(rule + offset, size - offset, ",arg0='%s'", data->argument); } static gboolean add_match(struct filter_data *data, DBusHandleMessageFunction filter) { DBusError err; char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; format_rule(data, rule, sizeof(rule)); dbus_error_init(&err); dbus_bus_add_match(data->connection, rule, &err); if (dbus_error_is_set(&err)) { error("Adding match rule \"%s\" failed: %s", rule, err.message); dbus_error_free(&err); return FALSE; } data->handle_func = filter; data->registered = TRUE; return TRUE; } static gboolean remove_match(struct filter_data *data) { DBusError err; char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; format_rule(data, rule, sizeof(rule)); dbus_error_init(&err); dbus_bus_remove_match(data->connection, rule, &err); if (dbus_error_is_set(&err)) { error("Removing owner match rule for %s failed: %s", rule, err.message); dbus_error_free(&err); return FALSE; } return TRUE; } static struct filter_data *filter_data_get(DBusConnection *connection, DBusHandleMessageFunction filter, const char *sender, const char *path, const char *interface, const char *member, const char *argument) { struct filter_data *data; const char *name = NULL, *owner = NULL; if (filter_data_find(connection, NULL, NULL, NULL, NULL, NULL, NULL) == NULL) { if (!dbus_connection_add_filter(connection, message_filter, NULL, NULL)) { error("dbus_connection_add_filter() failed"); return NULL; } } if (sender == NULL) goto proceed; if (sender[0] == ':') owner = sender; else name = sender; proceed: data = filter_data_find(connection, name, owner, path, interface, member, argument); if (data) return data; data = g_new0(struct filter_data, 1); data->connection = dbus_connection_ref(connection); data->name = name ? g_strdup(name) : NULL; data->owner = owner ? g_strdup(owner) : NULL; data->path = g_strdup(path); data->interface = g_strdup(interface); data->member = g_strdup(member); data->argument = g_strdup(argument); if (!add_match(data, filter)) { g_free(data); return NULL; } listeners = g_slist_append(listeners, data); return data; } static struct filter_callback *filter_data_find_callback( struct filter_data *data, guint id) { GSList *l; for (l = data->callbacks; l; l = l->next) { struct filter_callback *cb = l->data; if (cb->id == id) return cb; } for (l = data->processed; l; l = l->next) { struct filter_callback *cb = l->data; if (cb->id == id) return cb; } return NULL; } static void filter_data_free(struct filter_data *data) { GSList *l; for (l = data->callbacks; l != NULL; l = l->next) g_free(l->data); g_slist_free(data->callbacks); g_dbus_remove_watch(data->connection, data->name_watch); g_free(data->name); g_free(data->owner); g_free(data->path); g_free(data->interface); g_free(data->member); g_free(data->argument); dbus_connection_unref(data->connection); g_free(data); } static void filter_data_call_and_free(struct filter_data *data) { GSList *l; for (l = data->callbacks; l != NULL; l = l->next) { struct filter_callback *cb = l->data; if (cb->disc_func) cb->disc_func(data->connection, cb->user_data); if (cb->destroy_func) cb->destroy_func(cb->user_data); g_free(cb); } filter_data_free(data); } static struct filter_callback *filter_data_add_callback( struct filter_data *data, GDBusWatchFunction connect, GDBusWatchFunction disconnect, GDBusSignalFunction signal, GDBusDestroyFunction destroy, void *user_data) { struct filter_callback *cb = NULL; cb = g_new0(struct filter_callback, 1); cb->conn_func = connect; cb->disc_func = disconnect; cb->signal_func = signal; cb->destroy_func = destroy; cb->user_data = user_data; cb->id = ++listener_id; if (data->lock) data->processed = g_slist_append(data->processed, cb); else data->callbacks = g_slist_append(data->callbacks, cb); return cb; } static void service_data_free(struct service_data *data) { struct filter_callback *callback = data->callback; dbus_connection_unref(data->conn); if (data->call) dbus_pending_call_unref(data->call); if (data->id) g_source_remove(data->id); g_free(data->name); g_free(data); callback->data = NULL; } static gboolean filter_data_remove_callback(struct filter_data *data, struct filter_callback *cb) { DBusConnection *connection; data->callbacks = g_slist_remove(data->callbacks, cb); data->processed = g_slist_remove(data->processed, cb); /* Cancel pending operations */ if (cb->data) { if (cb->data->call) dbus_pending_call_cancel(cb->data->call); service_data_free(cb->data); } if (cb->destroy_func) cb->destroy_func(cb->user_data); g_free(cb); /* Don't remove the filter if other callbacks exist or data is lock * processing callbacks */ if (data->callbacks || data->lock) return TRUE; if (data->registered && !remove_match(data)) return FALSE; connection = dbus_connection_ref(data->connection); listeners = g_slist_remove(listeners, data); filter_data_free(data); /* Remove filter if there are no listeners left for the connection */ data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL, NULL); if (data == NULL) dbus_connection_remove_filter(connection, message_filter, NULL); dbus_connection_unref(connection); return TRUE; } static DBusHandlerResult signal_filter(DBusConnection *connection, DBusMessage *message, void *user_data) { struct filter_data *data = user_data; struct filter_callback *cb; while (data->callbacks) { cb = data->callbacks->data; if (cb->signal_func && !cb->signal_func(connection, message, cb->user_data)) { filter_data_remove_callback(data, cb); continue; } /* Check if the watch was removed/freed by the callback * function */ if (!g_slist_find(data->callbacks, cb)) continue; data->callbacks = g_slist_remove(data->callbacks, cb); data->processed = g_slist_append(data->processed, cb); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static void update_name_cache(const char *name, const char *owner) { GSList *l; for (l = listeners; l != NULL; l = l->next) { struct filter_data *data = l->data; if (g_strcmp0(data->name, name) != 0) continue; g_free(data->owner); data->owner = g_strdup(owner); } } static const char *check_name_cache(const char *name) { GSList *l; for (l = listeners; l != NULL; l = l->next) { struct filter_data *data = l->data; if (g_strcmp0(data->name, name) != 0) continue; return data->owner; } return NULL; } static DBusHandlerResult service_filter(DBusConnection *connection, DBusMessage *message, void *user_data) { struct filter_data *data = user_data; struct filter_callback *cb; char *name, *old, *new; if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID)) { error("Invalid arguments for NameOwnerChanged signal"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } update_name_cache(name, new); while (data->callbacks) { cb = data->callbacks->data; if (*new == '\0') { if (cb->disc_func) cb->disc_func(connection, cb->user_data); } else { if (cb->conn_func) cb->conn_func(connection, cb->user_data); } /* Check if the watch was removed/freed by the callback * function */ if (!g_slist_find(data->callbacks, cb)) continue; /* Only auto remove if it is a bus name watch */ if (data->argument[0] == ':' && (cb->conn_func == NULL || cb->disc_func == NULL)) { filter_data_remove_callback(data, cb); continue; } data->callbacks = g_slist_remove(data->callbacks, cb); data->processed = g_slist_append(data->processed, cb); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static DBusHandlerResult message_filter(DBusConnection *connection, DBusMessage *message, void *user_data) { struct filter_data *data; const char *sender, *path, *iface, *member, *arg = NULL; /* Only filter signals */ if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; sender = dbus_message_get_sender(message); path = dbus_message_get_path(message); iface = dbus_message_get_interface(message); member = dbus_message_get_member(message); dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID); /* Sender is always bus name */ data = filter_data_find(connection, NULL, sender, path, iface, member, arg); if (data == NULL) { error("Got %s.%s signal which has no listeners", iface, member); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } if (data->handle_func) { data->lock = TRUE; data->handle_func(connection, message, data); data->callbacks = data->processed; data->processed = NULL; data->lock = FALSE; } if (data->callbacks) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; remove_match(data); listeners = g_slist_remove(listeners, data); filter_data_free(data); /* Remove filter if there no listener left for the connection */ data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL, NULL); if (data == NULL) dbus_connection_remove_filter(connection, message_filter, NULL); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static gboolean update_service(void *user_data) { struct service_data *data = user_data; struct filter_callback *cb = data->callback; update_name_cache(data->name, data->owner); if (cb->conn_func) cb->conn_func(data->conn, cb->user_data); service_data_free(data); return FALSE; } static void service_reply(DBusPendingCall *call, void *user_data) { struct service_data *data = user_data; DBusMessage *reply; DBusError err; reply = dbus_pending_call_steal_reply(call); if (reply == NULL) return; dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) goto fail; if (dbus_message_get_args(reply, &err, DBUS_TYPE_STRING, &data->owner, DBUS_TYPE_INVALID) == FALSE) goto fail; update_service(data); goto done; fail: error("%s", err.message); dbus_error_free(&err); service_data_free(data); done: dbus_message_unref(reply); } static void check_service(DBusConnection *connection, const char *name, struct filter_callback *callback) { DBusMessage *message; struct service_data *data; data = g_try_malloc0(sizeof(*data)); if (data == NULL) { error("Can't allocate data structure"); return; } data->conn = dbus_connection_ref(connection); data->name = g_strdup(name); data->callback = callback; callback->data = data; data->owner = check_name_cache(name); if (data->owner != NULL) { data->id = g_idle_add(update_service, data); return; } message = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetNameOwner"); if (message == NULL) { error("Can't allocate new message"); g_free(data); return; } dbus_message_append_args(message, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID); if (dbus_connection_send_with_reply(connection, message, &data->call, -1) == FALSE) { error("Failed to execute method call"); g_free(data); goto done; } if (data->call == NULL) { error("D-Bus connection not available"); g_free(data); goto done; } dbus_pending_call_set_notify(data->call, service_reply, data, NULL); done: dbus_message_unref(message); } guint g_dbus_add_service_watch(DBusConnection *connection, const char *name, GDBusWatchFunction connect, GDBusWatchFunction disconnect, void *user_data, GDBusDestroyFunction destroy) { struct filter_data *data; struct filter_callback *cb; if (name == NULL) return 0; data = filter_data_get(connection, service_filter, NULL, NULL, DBUS_INTERFACE_DBUS, "NameOwnerChanged", name); if (data == NULL) return 0; cb = filter_data_add_callback(data, connect, disconnect, NULL, destroy, user_data); if (cb == NULL) return 0; if (connect) check_service(connection, name, cb); return cb->id; } guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, GDBusWatchFunction func, void *user_data, GDBusDestroyFunction destroy) { return g_dbus_add_service_watch(connection, name, NULL, func, user_data, destroy); } guint g_dbus_add_signal_watch(DBusConnection *connection, const char *sender, const char *path, const char *interface, const char *member, GDBusSignalFunction function, void *user_data, GDBusDestroyFunction destroy) { struct filter_data *data; struct filter_callback *cb; data = filter_data_get(connection, signal_filter, sender, path, interface, member, NULL); if (data == NULL) return 0; cb = filter_data_add_callback(data, NULL, NULL, function, destroy, user_data); if (cb == NULL) return 0; if (data->name != NULL && data->name_watch == 0) data->name_watch = g_dbus_add_service_watch(connection, data->name, NULL, NULL, NULL, NULL); return cb->id; } gboolean g_dbus_remove_watch(DBusConnection *connection, guint id) { struct filter_data *data; struct filter_callback *cb; GSList *ldata; if (id == 0) return FALSE; for (ldata = listeners; ldata; ldata = ldata->next) { data = ldata->data; cb = filter_data_find_callback(data, id); if (cb) { filter_data_remove_callback(data, cb); return TRUE; } } return FALSE; } void g_dbus_remove_all_watches(DBusConnection *connection) { struct filter_data *data; while ((data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL, NULL))) { listeners = g_slist_remove(listeners, data); filter_data_call_and_free(data); } dbus_connection_remove_filter(connection, message_filter, NULL); } obexd-0.46/Makefile.in0000644000000000000000000016253311755212545011521 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = unit/test-gobex-header$(EXEEXT) \ unit/test-gobex-packet$(EXEEXT) unit/test-gobex$(EXEEXT) \ unit/test-gobex-transfer$(EXEEXT) $(am__EXEEXT_3) \ tools/test-server$(EXEEXT) libexec_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) @SERVER_TRUE@am__append_1 = src/obexd.service.in @SERVER_TRUE@@USB_TRUE@am__append_2 = usb @SERVER_TRUE@@USB_TRUE@am__append_3 = plugins/usb.c @NOKIA_PCSUITE_TRUE@@SERVER_TRUE@am__append_4 = pcsuite @NOKIA_PCSUITE_TRUE@@SERVER_TRUE@am__append_5 = plugins/pcsuite.c @SERVER_TRUE@am__append_6 = src/obexd @CLIENT_TRUE@am__append_7 = client/obex-client.service.in @CLIENT_TRUE@am__append_8 = client/obex-client TESTS = unit/test-gobex-header$(EXEEXT) \ unit/test-gobex-packet$(EXEEXT) unit/test-gobex$(EXEEXT) \ unit/test-gobex-transfer$(EXEEXT) @READLINE_TRUE@am__append_9 = tools/test-client subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ TODO compile config.guess config.sub depcomp install-sh \ ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(servicedir)" LTLIBRARIES = $(plugin_LTLIBRARIES) @SERVER_TRUE@am__EXEEXT_1 = src/obexd$(EXEEXT) @CLIENT_TRUE@am__EXEEXT_2 = client/obex-client$(EXEEXT) @READLINE_TRUE@am__EXEEXT_3 = tools/test-client$(EXEEXT) PROGRAMS = $(libexec_PROGRAMS) $(noinst_PROGRAMS) am__client_obex_client_SOURCES_DIST = gdbus/gdbus.h gdbus/mainloop.c \ gdbus/watch.c gdbus/object.c gdbus/polkit.c gobex/gobex.h \ gobex/gobex.c gobex/gobex-defs.h gobex/gobex-defs.c \ gobex/gobex-packet.c gobex/gobex-packet.h gobex/gobex-header.c \ gobex/gobex-header.h gobex/gobex-transfer.c \ gobex/gobex-debug.h btio/btio.h btio/btio.c client/main.c \ src/log.h src/log.c client/manager.h client/manager.c \ client/session.h client/session.c client/bluetooth.h \ client/bluetooth.c client/sync.h client/sync.c client/pbap.h \ client/pbap.c client/ftp.h client/ftp.c client/opp.h \ client/opp.c client/map.h client/map.c client/transfer.h \ client/transfer.c client/agent.h client/agent.c \ client/transport.h client/transport.c client/driver.h \ client/driver.c src/map_ap.h src/map_ap.c am__dirstamp = $(am__leading_dot)dirstamp am__objects_1 = gdbus/mainloop.$(OBJEXT) gdbus/watch.$(OBJEXT) \ gdbus/object.$(OBJEXT) gdbus/polkit.$(OBJEXT) am__objects_2 = gobex/gobex.$(OBJEXT) gobex/gobex-defs.$(OBJEXT) \ gobex/gobex-packet.$(OBJEXT) gobex/gobex-header.$(OBJEXT) \ gobex/gobex-transfer.$(OBJEXT) am__objects_3 = btio/btio.$(OBJEXT) @CLIENT_TRUE@am_client_obex_client_OBJECTS = $(am__objects_1) \ @CLIENT_TRUE@ $(am__objects_2) $(am__objects_3) \ @CLIENT_TRUE@ client/main.$(OBJEXT) src/log.$(OBJEXT) \ @CLIENT_TRUE@ client/manager.$(OBJEXT) client/session.$(OBJEXT) \ @CLIENT_TRUE@ client/bluetooth.$(OBJEXT) client/sync.$(OBJEXT) \ @CLIENT_TRUE@ client/pbap.$(OBJEXT) client/ftp.$(OBJEXT) \ @CLIENT_TRUE@ client/opp.$(OBJEXT) client/map.$(OBJEXT) \ @CLIENT_TRUE@ client/transfer.$(OBJEXT) client/agent.$(OBJEXT) \ @CLIENT_TRUE@ client/transport.$(OBJEXT) \ @CLIENT_TRUE@ client/driver.$(OBJEXT) src/map_ap.$(OBJEXT) client_obex_client_OBJECTS = $(am_client_obex_client_OBJECTS) client_obex_client_DEPENDENCIES = AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__src_obexd_SOURCES_DIST = gdbus/gdbus.h gdbus/mainloop.c \ gdbus/watch.c gdbus/object.c gdbus/polkit.c \ plugins/bluetooth.c plugins/usb.c plugins/filesystem.c \ plugins/filesystem.h plugins/pcsuite.c plugins/opp.c \ plugins/ftp.c plugins/ftp.h plugins/pbap.c plugins/phonebook.h \ plugins/vcard.h plugins/vcard.c plugins/mas.c \ plugins/messages.h src/map_ap.c src/map_ap.h plugins/irmc.c \ plugins/syncevolution.c btio/btio.h btio/btio.c gobex/gobex.h \ gobex/gobex.c gobex/gobex-defs.h gobex/gobex-defs.c \ gobex/gobex-packet.c gobex/gobex-packet.h gobex/gobex-header.c \ gobex/gobex-header.h gobex/gobex-transfer.c \ gobex/gobex-debug.h src/main.c src/obexd.h src/plugin.h \ src/plugin.c src/log.h src/log.c src/manager.h src/manager.c \ src/obex.h src/obex.c src/obex-priv.h src/mimetype.h \ src/mimetype.c src/service.h src/service.c src/transport.h \ src/transport.c src/server.h src/server.c @SERVER_TRUE@@USB_TRUE@am__objects_4 = plugins/usb.$(OBJEXT) @NOKIA_PCSUITE_TRUE@@SERVER_TRUE@am__objects_5 = \ @NOKIA_PCSUITE_TRUE@@SERVER_TRUE@ plugins/pcsuite.$(OBJEXT) @SERVER_TRUE@am__objects_6 = plugins/bluetooth.$(OBJEXT) \ @SERVER_TRUE@ $(am__objects_4) plugins/filesystem.$(OBJEXT) \ @SERVER_TRUE@ $(am__objects_5) plugins/opp.$(OBJEXT) \ @SERVER_TRUE@ plugins/ftp.$(OBJEXT) plugins/pbap.$(OBJEXT) \ @SERVER_TRUE@ plugins/vcard.$(OBJEXT) plugins/mas.$(OBJEXT) \ @SERVER_TRUE@ src/map_ap.$(OBJEXT) plugins/irmc.$(OBJEXT) \ @SERVER_TRUE@ plugins/syncevolution.$(OBJEXT) @SERVER_TRUE@am_src_obexd_OBJECTS = $(am__objects_1) $(am__objects_6) \ @SERVER_TRUE@ $(am__objects_3) $(am__objects_2) \ @SERVER_TRUE@ src/main.$(OBJEXT) src/plugin.$(OBJEXT) \ @SERVER_TRUE@ src/log.$(OBJEXT) src/manager.$(OBJEXT) \ @SERVER_TRUE@ src/obex.$(OBJEXT) src/mimetype.$(OBJEXT) \ @SERVER_TRUE@ src/service.$(OBJEXT) src/transport.$(OBJEXT) \ @SERVER_TRUE@ src/server.$(OBJEXT) @SERVER_TRUE@am__objects_7 = plugins/phonebook.$(OBJEXT) \ @SERVER_TRUE@ plugins/messages.$(OBJEXT) @SERVER_TRUE@am__objects_8 = $(am__objects_7) @SERVER_TRUE@nodist_src_obexd_OBJECTS = $(am__objects_8) src_obexd_OBJECTS = $(am_src_obexd_OBJECTS) \ $(nodist_src_obexd_OBJECTS) src_obexd_DEPENDENCIES = src_obexd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(src_obexd_LDFLAGS) $(LDFLAGS) -o $@ am__tools_test_client_SOURCES_DIST = gobex/gobex.h gobex/gobex.c \ gobex/gobex-defs.h gobex/gobex-defs.c gobex/gobex-packet.c \ gobex/gobex-packet.h gobex/gobex-header.c gobex/gobex-header.h \ gobex/gobex-transfer.c gobex/gobex-debug.h btio/btio.h \ btio/btio.c tools/test-client.c @READLINE_TRUE@am_tools_test_client_OBJECTS = $(am__objects_2) \ @READLINE_TRUE@ $(am__objects_3) tools/test-client.$(OBJEXT) tools_test_client_OBJECTS = $(am_tools_test_client_OBJECTS) tools_test_client_DEPENDENCIES = am_tools_test_server_OBJECTS = $(am__objects_2) $(am__objects_3) \ tools/test-server.$(OBJEXT) tools_test_server_OBJECTS = $(am_tools_test_server_OBJECTS) tools_test_server_DEPENDENCIES = am_unit_test_gobex_OBJECTS = $(am__objects_2) \ unit/test-gobex.$(OBJEXT) unit/util.$(OBJEXT) unit_test_gobex_OBJECTS = $(am_unit_test_gobex_OBJECTS) unit_test_gobex_DEPENDENCIES = am_unit_test_gobex_header_OBJECTS = $(am__objects_2) \ unit/test-gobex-header.$(OBJEXT) unit/util.$(OBJEXT) unit_test_gobex_header_OBJECTS = $(am_unit_test_gobex_header_OBJECTS) unit_test_gobex_header_DEPENDENCIES = am_unit_test_gobex_packet_OBJECTS = $(am__objects_2) \ unit/test-gobex-packet.$(OBJEXT) unit/util.$(OBJEXT) unit_test_gobex_packet_OBJECTS = $(am_unit_test_gobex_packet_OBJECTS) unit_test_gobex_packet_DEPENDENCIES = am_unit_test_gobex_transfer_OBJECTS = $(am__objects_2) \ unit/util.$(OBJEXT) unit/test-gobex-transfer.$(OBJEXT) unit_test_gobex_transfer_OBJECTS = \ $(am_unit_test_gobex_transfer_OBJECTS) unit_test_gobex_transfer_DEPENDENCIES = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(client_obex_client_SOURCES) $(src_obexd_SOURCES) \ $(nodist_src_obexd_SOURCES) $(tools_test_client_SOURCES) \ $(tools_test_server_SOURCES) $(unit_test_gobex_SOURCES) \ $(unit_test_gobex_header_SOURCES) \ $(unit_test_gobex_packet_SOURCES) \ $(unit_test_gobex_transfer_SOURCES) DIST_SOURCES = $(am__client_obex_client_SOURCES_DIST) \ $(am__src_obexd_SOURCES_DIST) \ $(am__tools_test_client_SOURCES_DIST) \ $(tools_test_server_SOURCES) $(unit_test_gobex_SOURCES) \ $(unit_test_gobex_header_SOURCES) \ $(unit_test_gobex_packet_SOURCES) \ $(unit_test_gobex_transfer_SOURCES) DATA = $(service_DATA) ETAGS = etags CTAGS = ctags # If stdout is a non-dumb tty, use colors. If test -t is not supported, # then this fails; a conservative approach. Of course do not redirect # stdout here, just stderr. am__tty_colors = \ red=; grn=; lgn=; blu=; std=; \ test "X$(AM_COLOR_TESTS)" != Xno \ && test "X$$TERM" != Xdumb \ && { test "X$(AM_COLOR_TESTS)" = Xalways || test -t 1 2>/dev/null; } \ && { \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ std=''; \ } DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BLUEZ_CFLAGS = @BLUEZ_CFLAGS@ BLUEZ_LIBS = @BLUEZ_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ DBUS_LIBS = @DBUS_LIBS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ EBOOK_CFLAGS = @EBOOK_CFLAGS@ EBOOK_LIBS = @EBOOK_LIBS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GREP = @GREP@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBICAL_CFLAGS = @LIBICAL_CFLAGS@ LIBICAL_LIBS = @LIBICAL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MESSAGES_DRIVER = @MESSAGES_DRIVER@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PHONEBOOK_DRIVER = @PHONEBOOK_DRIVER@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ TRACKER_09_CFLAGS = @TRACKER_09_CFLAGS@ TRACKER_09_LIBS = @TRACKER_09_LIBS@ TRACKER_10_CFLAGS = @TRACKER_10_CFLAGS@ TRACKER_10_LIBS = @TRACKER_10_LIBS@ TRACKER_CFLAGS = @TRACKER_CFLAGS@ TRACKER_LIBS = @TRACKER_LIBS@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_MAKEFLAGS = --no-print-directory servicedir = $(datarootdir)/dbus-1/services service_in_files = $(am__append_1) $(am__append_7) doc_files = doc/obexd-api.txt doc/agent-api.txt doc/client-api.txt test_files = test/simple-agent test/send-files \ test/pull-business-card test/exchange-business-cards \ test/list-folders test/pbap-client test/ftp-client \ test/map-client gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \ gdbus/object.c gdbus/polkit.c btio_sources = btio/btio.h btio/btio.c gobex_sources = gobex/gobex.h gobex/gobex.c \ gobex/gobex-defs.h gobex/gobex-defs.c \ gobex/gobex-packet.c gobex/gobex-packet.h \ gobex/gobex-header.c gobex/gobex-header.h \ gobex/gobex-transfer.c gobex/gobex-debug.h @SERVER_TRUE@confdir = $(sysconfdir)/obex @SERVER_TRUE@builtin_modules = bluetooth $(am__append_2) filesystem \ @SERVER_TRUE@ $(am__append_4) opp ftp pbap mas irmc \ @SERVER_TRUE@ syncevolution @SERVER_TRUE@builtin_sources = plugins/bluetooth.c $(am__append_3) \ @SERVER_TRUE@ plugins/filesystem.c plugins/filesystem.h \ @SERVER_TRUE@ $(am__append_5) plugins/opp.c plugins/ftp.c \ @SERVER_TRUE@ plugins/ftp.h plugins/pbap.c plugins/phonebook.h \ @SERVER_TRUE@ plugins/vcard.h plugins/vcard.c plugins/mas.c \ @SERVER_TRUE@ plugins/messages.h src/map_ap.c src/map_ap.h \ @SERVER_TRUE@ plugins/irmc.c plugins/syncevolution.c @SERVER_TRUE@builtin_nodist = plugins/phonebook.c plugins/messages.c @SERVER_TRUE@src_obexd_SOURCES = $(gdbus_sources) $(builtin_sources) $(btio_sources) \ @SERVER_TRUE@ $(gobex_sources) src/main.c src/obexd.h \ @SERVER_TRUE@ src/plugin.h src/plugin.c \ @SERVER_TRUE@ src/log.h src/log.c src/manager.h src/manager.c \ @SERVER_TRUE@ src/obex.h src/obex.c src/obex-priv.h \ @SERVER_TRUE@ src/mimetype.h src/mimetype.c \ @SERVER_TRUE@ src/service.h src/service.c \ @SERVER_TRUE@ src/transport.h src/transport.c \ @SERVER_TRUE@ src/server.h src/server.c @SERVER_TRUE@src_obexd_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @GTHREAD_LIBS@ \ @SERVER_TRUE@ @EBOOK_LIBS@ @BLUEZ_LIBS@ \ @SERVER_TRUE@ @LIBICAL_LIBS@ @TRACKER_LIBS@ -ldl @SERVER_TRUE@src_obexd_LDFLAGS = -Wl,--export-dynamic @SERVER_TRUE@builtin_files = src/builtin.h $(builtin_nodist) @SERVER_TRUE@nodist_src_obexd_SOURCES = $(builtin_files) @SERVER_TRUE@plugindir = $(libdir)/obex/plugins @SERVER_TRUE@plugin_LTLIBRARIES = @CLIENT_TRUE@client_obex_client_SOURCES = $(gdbus_sources) $(gobex_sources) \ @CLIENT_TRUE@ $(btio_sources) \ @CLIENT_TRUE@ client/main.c src/log.h src/log.c \ @CLIENT_TRUE@ client/manager.h client/manager.c \ @CLIENT_TRUE@ client/session.h client/session.c \ @CLIENT_TRUE@ client/bluetooth.h client/bluetooth.c \ @CLIENT_TRUE@ client/sync.h client/sync.c \ @CLIENT_TRUE@ client/pbap.h client/pbap.c \ @CLIENT_TRUE@ client/ftp.h client/ftp.c \ @CLIENT_TRUE@ client/opp.h client/opp.c \ @CLIENT_TRUE@ client/map.h client/map.c \ @CLIENT_TRUE@ client/transfer.h client/transfer.c \ @CLIENT_TRUE@ client/agent.h client/agent.c \ @CLIENT_TRUE@ client/transport.h client/transport.c \ @CLIENT_TRUE@ client/driver.h client/driver.c \ @CLIENT_TRUE@ src/map_ap.h src/map_ap.c @CLIENT_TRUE@client_obex_client_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ service_DATA = $(service_in_files:.service.in=.service) AM_CFLAGS = @BLUEZ_CFLAGS@ @EBOOK_CFLAGS@ @GTHREAD_CFLAGS@ @GLIB_CFLAGS@ \ @DBUS_CFLAGS@ @LIBICAL_CFLAGS@ @TRACKER_CFLAGS@ \ -DOBEX_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\" \ -D_FILE_OFFSET_BITS=64 INCLUDES = -I$(builddir)/src -I$(srcdir)/src -I$(srcdir)/plugins \ -I$(srcdir)/gdbus \ -I$(srcdir)/btio -I$(srcdir)/gobex CLEANFILES = $(service_DATA) $(builtin_files) EXTRA_DIST = src/genbuiltin $(doc_files) $(test_files) \ src/obexd.service.in client/obex-client.service.in \ plugins/phonebook-dummy.c plugins/phonebook-ebook.c \ plugins/phonebook-tracker.c \ plugins/messages-dummy.c plugins/messages-tracker.c DISTCHECK_CONFIGURE_FLAGS = --enable-client --enable-server MAINTAINERCLEANFILES = Makefile.in \ aclocal.m4 configure config.h.in config.sub config.guess \ ltmain.sh depcomp compile missing install-sh mkinstalldirs unit_test_gobex_SOURCES = $(gobex_sources) unit/test-gobex.c \ unit/util.c unit/util.h unit_test_gobex_LDADD = @GLIB_LIBS@ unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/test-gobex-packet.c \ unit/util.c unit/util.h unit_test_gobex_packet_LDADD = @GLIB_LIBS@ unit_test_gobex_header_SOURCES = $(gobex_sources) unit/test-gobex-header.c \ unit/util.c unit/util.h unit_test_gobex_header_LDADD = @GLIB_LIBS@ unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \ unit/test-gobex-transfer.c unit_test_gobex_transfer_LDADD = @GLIB_LIBS@ @READLINE_TRUE@tools_test_client_SOURCES = $(gobex_sources) $(btio_sources) \ @READLINE_TRUE@ tools/test-client.c @READLINE_TRUE@tools_test_client_LDADD = @GLIB_LIBS@ @BLUEZ_LIBS@ @READLINE_LIBS@ tools_test_server_SOURCES = $(gobex_sources) $(btio_sources) \ tools/test-server.c tools_test_server_LDADD = @GLIB_LIBS@ @BLUEZ_LIBS@ all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ } uninstall-pluginLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ done clean-pluginLTLIBRARIES: -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done install-libexecPROGRAMS: $(libexec_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)" @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ } \ ; done uninstall-libexecPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(libexecdir)" && rm -f $$files clean-libexecPROGRAMS: @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list gdbus/$(am__dirstamp): @$(MKDIR_P) gdbus @: > gdbus/$(am__dirstamp) gdbus/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) gdbus/$(DEPDIR) @: > gdbus/$(DEPDIR)/$(am__dirstamp) gdbus/mainloop.$(OBJEXT): gdbus/$(am__dirstamp) \ gdbus/$(DEPDIR)/$(am__dirstamp) gdbus/watch.$(OBJEXT): gdbus/$(am__dirstamp) \ gdbus/$(DEPDIR)/$(am__dirstamp) gdbus/object.$(OBJEXT): gdbus/$(am__dirstamp) \ gdbus/$(DEPDIR)/$(am__dirstamp) gdbus/polkit.$(OBJEXT): gdbus/$(am__dirstamp) \ gdbus/$(DEPDIR)/$(am__dirstamp) gobex/$(am__dirstamp): @$(MKDIR_P) gobex @: > gobex/$(am__dirstamp) gobex/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) gobex/$(DEPDIR) @: > gobex/$(DEPDIR)/$(am__dirstamp) gobex/gobex.$(OBJEXT): gobex/$(am__dirstamp) \ gobex/$(DEPDIR)/$(am__dirstamp) gobex/gobex-defs.$(OBJEXT): gobex/$(am__dirstamp) \ gobex/$(DEPDIR)/$(am__dirstamp) gobex/gobex-packet.$(OBJEXT): gobex/$(am__dirstamp) \ gobex/$(DEPDIR)/$(am__dirstamp) gobex/gobex-header.$(OBJEXT): gobex/$(am__dirstamp) \ gobex/$(DEPDIR)/$(am__dirstamp) gobex/gobex-transfer.$(OBJEXT): gobex/$(am__dirstamp) \ gobex/$(DEPDIR)/$(am__dirstamp) btio/$(am__dirstamp): @$(MKDIR_P) btio @: > btio/$(am__dirstamp) btio/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) btio/$(DEPDIR) @: > btio/$(DEPDIR)/$(am__dirstamp) btio/btio.$(OBJEXT): btio/$(am__dirstamp) \ btio/$(DEPDIR)/$(am__dirstamp) client/$(am__dirstamp): @$(MKDIR_P) client @: > client/$(am__dirstamp) client/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) client/$(DEPDIR) @: > client/$(DEPDIR)/$(am__dirstamp) client/main.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) src/$(am__dirstamp): @$(MKDIR_P) src @: > src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/$(DEPDIR) @: > src/$(DEPDIR)/$(am__dirstamp) src/log.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) client/manager.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/session.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/bluetooth.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/sync.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/pbap.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/ftp.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/opp.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/map.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/transfer.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/agent.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/transport.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) client/driver.$(OBJEXT): client/$(am__dirstamp) \ client/$(DEPDIR)/$(am__dirstamp) src/map_ap.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) client/obex-client$(EXEEXT): $(client_obex_client_OBJECTS) $(client_obex_client_DEPENDENCIES) $(EXTRA_client_obex_client_DEPENDENCIES) client/$(am__dirstamp) @rm -f client/obex-client$(EXEEXT) $(AM_V_CCLD)$(LINK) $(client_obex_client_OBJECTS) $(client_obex_client_LDADD) $(LIBS) plugins/$(am__dirstamp): @$(MKDIR_P) plugins @: > plugins/$(am__dirstamp) plugins/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) plugins/$(DEPDIR) @: > plugins/$(DEPDIR)/$(am__dirstamp) plugins/bluetooth.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/usb.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/filesystem.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/pcsuite.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/opp.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/ftp.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/pbap.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/vcard.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/mas.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/irmc.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/syncevolution.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) src/main.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/plugin.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/manager.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/obex.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/mimetype.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/service.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/transport.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/server.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) plugins/phonebook.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) plugins/messages.$(OBJEXT): plugins/$(am__dirstamp) \ plugins/$(DEPDIR)/$(am__dirstamp) src/obexd$(EXEEXT): $(src_obexd_OBJECTS) $(src_obexd_DEPENDENCIES) $(EXTRA_src_obexd_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/obexd$(EXEEXT) $(AM_V_CCLD)$(src_obexd_LINK) $(src_obexd_OBJECTS) $(src_obexd_LDADD) $(LIBS) tools/$(am__dirstamp): @$(MKDIR_P) tools @: > tools/$(am__dirstamp) tools/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) tools/$(DEPDIR) @: > tools/$(DEPDIR)/$(am__dirstamp) tools/test-client.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) tools/test-client$(EXEEXT): $(tools_test_client_OBJECTS) $(tools_test_client_DEPENDENCIES) $(EXTRA_tools_test_client_DEPENDENCIES) tools/$(am__dirstamp) @rm -f tools/test-client$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tools_test_client_OBJECTS) $(tools_test_client_LDADD) $(LIBS) tools/test-server.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) tools/test-server$(EXEEXT): $(tools_test_server_OBJECTS) $(tools_test_server_DEPENDENCIES) $(EXTRA_tools_test_server_DEPENDENCIES) tools/$(am__dirstamp) @rm -f tools/test-server$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tools_test_server_OBJECTS) $(tools_test_server_LDADD) $(LIBS) unit/$(am__dirstamp): @$(MKDIR_P) unit @: > unit/$(am__dirstamp) unit/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) unit/$(DEPDIR) @: > unit/$(DEPDIR)/$(am__dirstamp) unit/test-gobex.$(OBJEXT): unit/$(am__dirstamp) \ unit/$(DEPDIR)/$(am__dirstamp) unit/util.$(OBJEXT): unit/$(am__dirstamp) \ unit/$(DEPDIR)/$(am__dirstamp) unit/test-gobex$(EXEEXT): $(unit_test_gobex_OBJECTS) $(unit_test_gobex_DEPENDENCIES) $(EXTRA_unit_test_gobex_DEPENDENCIES) unit/$(am__dirstamp) @rm -f unit/test-gobex$(EXEEXT) $(AM_V_CCLD)$(LINK) $(unit_test_gobex_OBJECTS) $(unit_test_gobex_LDADD) $(LIBS) unit/test-gobex-header.$(OBJEXT): unit/$(am__dirstamp) \ unit/$(DEPDIR)/$(am__dirstamp) unit/test-gobex-header$(EXEEXT): $(unit_test_gobex_header_OBJECTS) $(unit_test_gobex_header_DEPENDENCIES) $(EXTRA_unit_test_gobex_header_DEPENDENCIES) unit/$(am__dirstamp) @rm -f unit/test-gobex-header$(EXEEXT) $(AM_V_CCLD)$(LINK) $(unit_test_gobex_header_OBJECTS) $(unit_test_gobex_header_LDADD) $(LIBS) unit/test-gobex-packet.$(OBJEXT): unit/$(am__dirstamp) \ unit/$(DEPDIR)/$(am__dirstamp) unit/test-gobex-packet$(EXEEXT): $(unit_test_gobex_packet_OBJECTS) $(unit_test_gobex_packet_DEPENDENCIES) $(EXTRA_unit_test_gobex_packet_DEPENDENCIES) unit/$(am__dirstamp) @rm -f unit/test-gobex-packet$(EXEEXT) $(AM_V_CCLD)$(LINK) $(unit_test_gobex_packet_OBJECTS) $(unit_test_gobex_packet_LDADD) $(LIBS) unit/test-gobex-transfer.$(OBJEXT): unit/$(am__dirstamp) \ unit/$(DEPDIR)/$(am__dirstamp) unit/test-gobex-transfer$(EXEEXT): $(unit_test_gobex_transfer_OBJECTS) $(unit_test_gobex_transfer_DEPENDENCIES) $(EXTRA_unit_test_gobex_transfer_DEPENDENCIES) unit/$(am__dirstamp) @rm -f unit/test-gobex-transfer$(EXEEXT) $(AM_V_CCLD)$(LINK) $(unit_test_gobex_transfer_OBJECTS) $(unit_test_gobex_transfer_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f btio/btio.$(OBJEXT) -rm -f client/agent.$(OBJEXT) -rm -f client/bluetooth.$(OBJEXT) -rm -f client/driver.$(OBJEXT) -rm -f client/ftp.$(OBJEXT) -rm -f client/main.$(OBJEXT) -rm -f client/manager.$(OBJEXT) -rm -f client/map.$(OBJEXT) -rm -f client/opp.$(OBJEXT) -rm -f client/pbap.$(OBJEXT) -rm -f client/session.$(OBJEXT) -rm -f client/sync.$(OBJEXT) -rm -f client/transfer.$(OBJEXT) -rm -f client/transport.$(OBJEXT) -rm -f gdbus/mainloop.$(OBJEXT) -rm -f gdbus/object.$(OBJEXT) -rm -f gdbus/polkit.$(OBJEXT) -rm -f gdbus/watch.$(OBJEXT) -rm -f gobex/gobex-defs.$(OBJEXT) -rm -f gobex/gobex-header.$(OBJEXT) -rm -f gobex/gobex-packet.$(OBJEXT) -rm -f gobex/gobex-transfer.$(OBJEXT) -rm -f gobex/gobex.$(OBJEXT) -rm -f plugins/bluetooth.$(OBJEXT) -rm -f plugins/filesystem.$(OBJEXT) -rm -f plugins/ftp.$(OBJEXT) -rm -f plugins/irmc.$(OBJEXT) -rm -f plugins/mas.$(OBJEXT) -rm -f plugins/messages.$(OBJEXT) -rm -f plugins/opp.$(OBJEXT) -rm -f plugins/pbap.$(OBJEXT) -rm -f plugins/pcsuite.$(OBJEXT) -rm -f plugins/phonebook.$(OBJEXT) -rm -f plugins/syncevolution.$(OBJEXT) -rm -f plugins/usb.$(OBJEXT) -rm -f plugins/vcard.$(OBJEXT) -rm -f src/log.$(OBJEXT) -rm -f src/main.$(OBJEXT) -rm -f src/manager.$(OBJEXT) -rm -f src/map_ap.$(OBJEXT) -rm -f src/mimetype.$(OBJEXT) -rm -f src/obex.$(OBJEXT) -rm -f src/plugin.$(OBJEXT) -rm -f src/server.$(OBJEXT) -rm -f src/service.$(OBJEXT) -rm -f src/transport.$(OBJEXT) -rm -f tools/test-client.$(OBJEXT) -rm -f tools/test-server.$(OBJEXT) -rm -f unit/test-gobex-header.$(OBJEXT) -rm -f unit/test-gobex-packet.$(OBJEXT) -rm -f unit/test-gobex-transfer.$(OBJEXT) -rm -f unit/test-gobex.$(OBJEXT) -rm -f unit/util.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@btio/$(DEPDIR)/btio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/agent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/bluetooth.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/driver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/ftp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/opp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/pbap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/session.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/sync.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/transfer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@client/$(DEPDIR)/transport.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/mainloop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/object.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/polkit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/watch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gobex/$(DEPDIR)/gobex-defs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gobex/$(DEPDIR)/gobex-header.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gobex/$(DEPDIR)/gobex-packet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gobex/$(DEPDIR)/gobex-transfer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gobex/$(DEPDIR)/gobex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/bluetooth.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/filesystem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/ftp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/irmc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/mas.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/messages.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/opp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/pbap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/pcsuite.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/phonebook.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/syncevolution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/usb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/vcard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/map_ap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mimetype.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/obex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/plugin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/transport.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/test-client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/test-server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-gobex-header.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-gobex-packet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-gobex-transfer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-gobex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/util.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf client/.libs client/_libs -rm -rf src/.libs src/_libs -rm -rf tools/.libs tools/_libs -rm -rf unit/.libs unit/_libs distclean-libtool: -rm -f libtool config.lt install-serviceDATA: $(service_DATA) @$(NORMAL_INSTALL) test -z "$(servicedir)" || $(MKDIR_P) "$(DESTDIR)$(servicedir)" @list='$(service_DATA)'; test -n "$(servicedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(servicedir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(servicedir)" || exit $$?; \ done uninstall-serviceDATA: @$(NORMAL_UNINSTALL) @list='$(service_DATA)'; test -n "$(servicedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(servicedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ srcdir=$(srcdir); export srcdir; \ list=' $(TESTS) '; \ $(am__tty_colors); \ if test -n "$$list"; then \ for tst in $$list; do \ if test -f ./$$tst; then dir=./; \ elif test -f $$tst; then dir=; \ else dir="$(srcdir)/"; fi; \ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xpass=`expr $$xpass + 1`; \ failed=`expr $$failed + 1`; \ col=$$red; res=XPASS; \ ;; \ *) \ col=$$grn; res=PASS; \ ;; \ esac; \ elif test $$? -ne 77; then \ all=`expr $$all + 1`; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$tst[\ \ ]*) \ xfail=`expr $$xfail + 1`; \ col=$$lgn; res=XFAIL; \ ;; \ *) \ failed=`expr $$failed + 1`; \ col=$$red; res=FAIL; \ ;; \ esac; \ else \ skip=`expr $$skip + 1`; \ col=$$blu; res=SKIP; \ fi; \ echo "$${col}$$res$${std}: $$tst"; \ done; \ if test "$$all" -eq 1; then \ tests="test"; \ All=""; \ else \ tests="tests"; \ All="All "; \ fi; \ if test "$$failed" -eq 0; then \ if test "$$xfail" -eq 0; then \ banner="$$All$$all $$tests passed"; \ else \ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ else \ if test "$$xpass" -eq 0; then \ banner="$$failed of $$all $$tests failed"; \ else \ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ fi; \ dashes="$$banner"; \ skipped=""; \ if test "$$skip" -ne 0; then \ if test "$$skip" -eq 1; then \ skipped="($$skip test was not run)"; \ else \ skipped="($$skip tests were not run)"; \ fi; \ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$skipped"; \ fi; \ report=""; \ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ report="Please report to $(PACKAGE_BUGREPORT)"; \ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ dashes="$$report"; \ fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ col="$$grn"; \ else \ col="$$red"; \ fi; \ echo "$${col}$$dashes$${std}"; \ echo "$${col}$$banner$${std}"; \ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ test -z "$$report" || echo "$${col}$$report$${std}"; \ echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) config.h installdirs: for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(servicedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f btio/$(DEPDIR)/$(am__dirstamp) -rm -f btio/$(am__dirstamp) -rm -f client/$(DEPDIR)/$(am__dirstamp) -rm -f client/$(am__dirstamp) -rm -f gdbus/$(DEPDIR)/$(am__dirstamp) -rm -f gdbus/$(am__dirstamp) -rm -f gobex/$(DEPDIR)/$(am__dirstamp) -rm -f gobex/$(am__dirstamp) -rm -f plugins/$(DEPDIR)/$(am__dirstamp) -rm -f plugins/$(am__dirstamp) -rm -f src/$(DEPDIR)/$(am__dirstamp) -rm -f src/$(am__dirstamp) -rm -f tools/$(DEPDIR)/$(am__dirstamp) -rm -f tools/$(am__dirstamp) -rm -f unit/$(DEPDIR)/$(am__dirstamp) -rm -f unit/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ clean-noinstPROGRAMS clean-pluginLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf btio/$(DEPDIR) client/$(DEPDIR) gdbus/$(DEPDIR) gobex/$(DEPDIR) plugins/$(DEPDIR) src/$(DEPDIR) tools/$(DEPDIR) unit/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pluginLTLIBRARIES install-serviceDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libexecPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf btio/$(DEPDIR) client/$(DEPDIR) gdbus/$(DEPDIR) gobex/$(DEPDIR) plugins/$(DEPDIR) src/$(DEPDIR) tools/$(DEPDIR) unit/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libexecPROGRAMS uninstall-pluginLTLIBRARIES \ uninstall-serviceDATA .MAKE: all check-am install-am install-strip .PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ clean clean-generic clean-libexecPROGRAMS clean-libtool \ clean-noinstPROGRAMS clean-pluginLTLIBRARIES ctags dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-lzma dist-shar \ dist-tarZ dist-xz dist-zip distcheck distclean \ distclean-compile distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libexecPROGRAMS install-man install-pdf install-pdf-am \ install-pluginLTLIBRARIES install-ps install-ps-am \ install-serviceDATA install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-libexecPROGRAMS \ uninstall-pluginLTLIBRARIES uninstall-serviceDATA @SERVER_TRUE@src/plugin.$(OBJEXT): src/builtin.h @SERVER_TRUE@src/builtin.h: src/genbuiltin $(builtin_sources) @SERVER_TRUE@ $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@ %.service: %.service.in config.log $(AM_V_GEN)$(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ plugins/phonebook.c: plugins/@PHONEBOOK_DRIVER@ $(AM_V_GEN)$(LN_S) @abs_top_srcdir@/$< $@ plugins/messages.c: plugins/@MESSAGES_DRIVER@ $(AM_V_GEN)$(LN_S) @abs_top_srcdir@/$< $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: obexd-0.46/plugins/0000755000000000000000000000000011755212615011201 500000000000000obexd-0.46/plugins/messages-dummy.c0000644000000000000000000001645111755212521014230 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "log.h" #include "messages.h" static char *root_folder = NULL; struct session { char *cwd; char *cwd_absolute; void *request; }; struct folder_listing_data { struct session *session; const char *name; uint16_t max; uint16_t offset; messages_folder_listing_cb callback; void *user_data; }; /* NOTE: Neither IrOBEX nor MAP specs says that folder listing needs to * be sorted (in IrOBEX examples it is not). However existing implementations * seem to follow the fig. 3-2 from MAP specification v1.0, and I've seen a * test suite requiring folder listing to be in that order. */ static gint folder_names_cmp(gconstpointer a, gconstpointer b, gpointer user_data) { static const char *order[] = { "inbox", "outbox", "sent", "deleted", "draft", NULL }; struct session *session = user_data; int ia, ib; if (g_strcmp0(session->cwd, "telecom/msg") == 0) { for (ia = 0; order[ia]; ia++) { if (g_strcmp0(a, order[ia]) == 0) break; } for (ib = 0; order[ib]; ib++) { if (g_strcmp0(b, order[ib]) == 0) break; } if (ia != ib) return ia - ib; } return g_strcmp0(a, b); } static char *get_next_subdir(DIR *dp, char *path) { struct dirent *ep; char *abs, *name; for (;;) { if ((ep = readdir(dp)) == NULL) return NULL; if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; abs = g_build_filename(path, ep->d_name, NULL); if (g_file_test(abs, G_FILE_TEST_IS_DIR)) { g_free(abs); break; } g_free(abs); } name = g_filename_to_utf8(ep->d_name, -1, NULL, NULL, NULL); if (name == NULL) { DBG("g_filename_to_utf8(): invalid filename"); return NULL; } return name; } static ssize_t get_subdirs(struct folder_listing_data *fld, GSList **list) { DIR *dp; char *path, *name; size_t n; path = g_build_filename(fld->session->cwd_absolute, fld->name, NULL); dp = opendir(path); if (dp == NULL) { int err = -errno; DBG("opendir(): %d, %s", -err, strerror(-err)); g_free(path); return err; } n = 0; while ((name = get_next_subdir(dp, path)) != NULL) { n++; if (fld->max > 0) *list = g_slist_prepend(*list, name); } closedir(dp); g_free(path); *list = g_slist_sort_with_data(*list, folder_names_cmp, fld->session); return n; } static void return_folder_listing(struct folder_listing_data *fld, GSList *list) { struct session *session = fld->session; GSList *cur; uint16_t num = 0; uint16_t offs = 0; /* XXX: This isn't really documented for MAP. I need to take a look how * other implementations choose to deal with parent folder. */ if (session->cwd[0] != 0 && fld->offset == 0) { num++; fld->callback(session, -EAGAIN, 0, "..", fld->user_data); } else { offs++; } for (cur = list; offs < fld->offset; offs++) { cur = cur->next; if (cur == NULL) break; } for (; cur != NULL && num < fld->max; cur = cur->next, num++) fld->callback(session, -EAGAIN, 0, cur->data, fld->user_data); fld->callback(session, 0, 0, NULL, fld->user_data); } static gboolean get_folder_listing(void *d) { struct folder_listing_data *fld = d; ssize_t n; GSList *list = NULL; n = get_subdirs(fld, &list); if (n < 0) { fld->callback(fld->session, n, 0, NULL, fld->user_data); return FALSE; } if (fld->max == 0) { fld->callback(fld->session, 0, n, NULL, fld->user_data); return FALSE; } return_folder_listing(fld, list); g_slist_free_full(list, g_free); return FALSE; } int messages_init(void) { char *tmp; if (root_folder) return 0; tmp = getenv("MAP_ROOT"); if (tmp) { root_folder = g_strdup(tmp); return 0; } tmp = getenv("HOME"); if (!tmp) return -ENOENT; root_folder = g_build_filename(tmp, "map-messages", NULL); return 0; } void messages_exit(void) { g_free(root_folder); root_folder = NULL; } int messages_connect(void **s) { struct session *session; session = g_new0(struct session, 1); session->cwd = g_strdup(""); session->cwd_absolute = g_strdup(root_folder); *s = session; return 0; } void messages_disconnect(void *s) { struct session *session = s; g_free(session->cwd); g_free(session->cwd_absolute); g_free(session); } int messages_set_notification_registration(void *session, void (*send_event)(void *session, const struct messages_event *event, void *user_data), void *user_data) { return -ENOSYS; } int messages_set_folder(void *s, const char *name, gboolean cdup) { struct session *session = s; char *newrel = NULL; char *newabs; char *tmp; if (name && (strchr(name, '/') || strcmp(name, "..") == 0)) return -EBADR; if (cdup) { if (session->cwd[0] == 0) return -ENOENT; newrel = g_path_get_dirname(session->cwd); /* We use empty string for indication of the root directory */ if (newrel[0] == '.' && newrel[1] == 0) newrel[0] = 0; } tmp = newrel; if (!cdup && (!name || name[0] == 0)) newrel = g_strdup(""); else newrel = g_build_filename(newrel ? newrel : session->cwd, name, NULL); g_free(tmp); newabs = g_build_filename(root_folder, newrel, NULL); if (!g_file_test(newabs, G_FILE_TEST_IS_DIR)) { g_free(newrel); g_free(newabs); return -ENOENT; } g_free(session->cwd); session->cwd = newrel; g_free(session->cwd_absolute); session->cwd_absolute = newabs; return 0; } int messages_get_folder_listing(void *s, const char *name, uint16_t max, uint16_t offset, messages_folder_listing_cb callback, void *user_data) { struct session *session = s; struct folder_listing_data *fld; fld = g_new0(struct folder_listing_data, 1); fld->session = session; fld->name = name; fld->max = max; fld->offset = offset; fld->callback = callback; fld->user_data = user_data; session->request = fld; g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, get_folder_listing, fld, g_free); return 0; } int messages_get_messages_listing(void *session, const char *name, uint16_t max, uint16_t offset, const struct messages_filter *filter, messages_get_messages_listing_cb callback, void *user_data) { return -ENOSYS; } int messages_get_message(void *session, const char *handle, unsigned long flags, messages_get_message_cb callback, void *user_data) { return -ENOSYS; } int messages_update_inbox(void *session, messages_update_inbox_cb callback, void *user_data) { return -ENOSYS; } void messages_abort(void *s) { struct session *session = s; if (session->request) { g_idle_remove_by_data(session->request); session->request = NULL; } } obexd-0.46/plugins/bluetooth.c0000644000000000000000000003774711755212521013310 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "server.h" #include "obex.h" #include "transport.h" #include "service.h" #include "log.h" #include "btio.h" #define BT_RX_MTU 32767 #define BT_TX_MTU 32767 #define TIMEOUT 60*1000 /* Timeout for user response (miliseconds) */ struct pending_request { DBusPendingCall *call; struct bluetooth_service *service; char *adapter_path; char address[18]; unsigned int watch; GIOChannel *io; }; struct bluetooth_service { struct obex_server *server; struct obex_service_driver *driver; uint32_t handle; }; struct adapter_any { char *path; /* Adapter ANY path */ GSList *services; /* List of services to register records */ }; static DBusConnection *connection = NULL; static struct adapter_any *any = NULL; static void add_record_reply(DBusPendingCall *call, void *user_data) { struct bluetooth_service *service = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; uint32_t handle; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("bluetooth: Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); handle = 0; } else { dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &handle, DBUS_TYPE_INVALID); service->handle = handle; DBG("Registered: %s, handle: 0x%x", service->driver->name, service->handle); } dbus_message_unref(reply); } static int add_record(const char *path, const char *xml, struct bluetooth_service *service) { DBusMessage *msg; DBusPendingCall *call; int ret = 0; msg = dbus_message_new_method_call("org.bluez", path, "org.bluez.Service", "AddRecord"); dbus_message_append_args(msg, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID); if (dbus_connection_send_with_reply(connection, msg, &call, -1) == FALSE) { ret = -1; goto failed; } dbus_pending_call_set_notify(call, add_record_reply, service, NULL); dbus_pending_call_unref(call); failed: dbus_message_unref(msg); return ret; } static struct bluetooth_service *find_service( struct obex_service_driver *driver) { GSList *l; for (l = any->services; l; l = l->next) { struct bluetooth_service *service = l->data; if (service->driver == driver) return service; } return NULL; } static void register_record(struct obex_server *server) { const GSList *l; if (connection == NULL) return; for (l = server->drivers; l; l = l->next) { struct obex_service_driver *driver = l->data; struct bluetooth_service *service; char *xml; service = find_service(driver); if (service == NULL) { service = g_new0(struct bluetooth_service, 1); service->driver = driver; service->server = server; any->services = g_slist_append(any->services, service); } /* Service already has a record registered */ if (service->handle != 0) continue; /* Adapter ANY is not available yet: Add record later */ if (any->path == NULL) continue; if (driver->port != 0) xml = g_markup_printf_escaped(driver->record, driver->channel, driver->name, driver->port); else xml = g_markup_printf_escaped(driver->record, driver->channel, driver->name); add_record(any->path, xml, service); g_free(xml); } } static void find_adapter_any_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply = dbus_pending_call_steal_reply(call); const char *path; GSList *l; DBusError derr; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("bluetooth: Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); goto done; } dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); any->path = g_strdup(path); for (l = any->services; l; l = l->next) { struct bluetooth_service *service = l->data; struct obex_service_driver *driver = service->driver; char *xml; if (driver->port != 0) xml = g_markup_printf_escaped(driver->record, driver->channel, driver->name, driver->port); else xml = g_markup_printf_escaped(driver->record, driver->channel, driver->name); add_record(any->path, xml, service); g_free(xml); } done: dbus_message_unref(reply); } static DBusPendingCall *find_adapter(const char *pattern, DBusPendingCallNotifyFunction function, void *user_data) { DBusMessage *msg; DBusPendingCall *call; DBG("FindAdapter(%s)", pattern); msg = dbus_message_new_method_call("org.bluez", "/", "org.bluez.Manager", "FindAdapter"); if (!msg) return NULL; dbus_message_append_args(msg, DBUS_TYPE_STRING, &pattern, DBUS_TYPE_INVALID); if (!dbus_connection_send_with_reply(connection, msg, &call, -1)) { dbus_message_unref(msg); return NULL; } dbus_pending_call_set_notify(call, function, user_data, NULL); dbus_message_unref(msg); return call; } static void name_acquired(DBusConnection *conn, void *user_data) { DBusPendingCall *call; call = find_adapter("any", find_adapter_any_reply, NULL); if (call) dbus_pending_call_unref(call); } static void name_released(DBusConnection *conn, void *user_data) { GSList *l; /* reset handles so the services got register next time */ for (l = any->services; l; l = l->next) { struct bluetooth_service *service = l->data; service->handle = 0; } g_free(any->path); any->path = NULL; } static void service_cancel(struct pending_request *pending) { DBusMessage *msg; msg = dbus_message_new_method_call("org.bluez", pending->adapter_path, "org.bluez.Service", "CancelAuthorization"); g_dbus_send_message(connection, msg); } static void pending_request_free(struct pending_request *pending) { if (pending->call) dbus_pending_call_unref(pending->call); g_io_channel_unref(pending->io); g_free(pending->adapter_path); g_free(pending); } static void connect_event(GIOChannel *io, GError *err, void *user_data) { int sk = g_io_channel_unix_get_fd(io); struct bluetooth_service *service = user_data; struct obex_server *server = service->server; int type; int omtu = BT_TX_MTU; int imtu = BT_RX_MTU; gboolean stream = TRUE; socklen_t len = sizeof(int); if (err) goto drop; if (getsockopt(sk, SOL_SOCKET, SO_TYPE, &type, &len) < 0) goto done; if (type != SOCK_SEQPACKET) goto done; stream = FALSE; /* Read MTU if io is an L2CAP socket */ bt_io_get(io, BT_IO_L2CAP, NULL, BT_IO_OPT_OMTU, &omtu, BT_IO_OPT_IMTU, &imtu, BT_IO_OPT_INVALID); done: if (obex_server_new_connection(server, io, omtu, imtu, stream) < 0) g_io_channel_shutdown(io, TRUE, NULL); return; drop: error("%s", err->message); g_io_channel_shutdown(io, TRUE, NULL); return; } static void service_reply(DBusPendingCall *call, void *user_data) { struct pending_request *pending = user_data; GIOChannel *io = pending->io; struct bluetooth_service *service = pending->service; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; GError *err = NULL; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("bluetooth: RequestAuthorization error: %s, %s", derr.name, derr.message); if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) service_cancel(pending); dbus_error_free(&derr); g_io_channel_shutdown(io, TRUE, NULL); goto done; } DBG("RequestAuthorization succeeded"); if (!bt_io_accept(io, connect_event, service, NULL, &err)) { error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); } done: g_source_remove(pending->watch); pending_request_free(pending); dbus_message_unref(reply); } static gboolean service_error(GIOChannel *io, GIOCondition cond, void *user_data) { struct pending_request *pending = user_data; service_cancel(pending); dbus_pending_call_cancel(pending->call); pending_request_free(pending); return FALSE; } static void find_adapter_reply(DBusPendingCall *call, void *user_data) { struct pending_request *pending = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusMessage *msg; DBusPendingCall *pcall; const char *path, *paddr = pending->address; DBusError derr; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); goto failed; } dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); DBG("FindAdapter -> %s", path); pending->adapter_path = g_strdup(path); dbus_message_unref(reply); msg = dbus_message_new_method_call("org.bluez", path, "org.bluez.Service", "RequestAuthorization"); dbus_message_append_args(msg, DBUS_TYPE_STRING, &paddr, DBUS_TYPE_UINT32, &pending->service->handle, DBUS_TYPE_INVALID); if (!dbus_connection_send_with_reply(connection, msg, &pcall, TIMEOUT)) { dbus_message_unref(msg); goto failed; } dbus_message_unref(msg); DBG("RequestAuthorization(%s, %x)", paddr, pending->service->handle); if (!dbus_pending_call_set_notify(pcall, service_reply, pending, NULL)) { dbus_pending_call_unref(pcall); goto failed; } dbus_pending_call_unref(pending->call); pending->call = pcall; /* Catches errors before authorization response comes */ pending->watch = g_io_add_watch(pending->io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, service_error, pending); return; failed: g_io_channel_shutdown(pending->io, TRUE, NULL); pending_request_free(pending); } static int request_service_authorization(struct bluetooth_service *service, GIOChannel *io, const char *source, const char *address) { struct pending_request *pending; if (connection == NULL || any->path == NULL) return -1; pending = g_new0(struct pending_request, 1); pending->call = find_adapter(source, find_adapter_reply, pending); if (!pending->call) { g_free(pending); return -ENOMEM; } pending->service = service; pending->io = g_io_channel_ref(io); memcpy(pending->address, address, sizeof(pending->address)); return 0; } static void confirm_connection(GIOChannel *io, const char *source, const char *address, void *user_data) { struct obex_service_driver *driver = user_data; struct bluetooth_service *service; GError *err = NULL; service = find_service(driver); if (service == NULL) { error("bluetooth: Unable to find service"); goto drop; } if (driver->secure) { if (request_service_authorization(service, io, source, address) < 0) goto drop; return; } if (!bt_io_accept(io, connect_event, service, NULL, &err)) { error("%s", err->message); g_error_free(err); goto drop; } return; drop: g_io_channel_shutdown(io, TRUE, NULL); } static void confirm_rfcomm(GIOChannel *io, void *user_data) { GError *err = NULL; char source[18]; char address[18]; uint8_t channel; bt_io_get(io, BT_IO_RFCOMM, &err, BT_IO_OPT_SOURCE, source, BT_IO_OPT_DEST, address, BT_IO_OPT_CHANNEL, &channel, BT_IO_OPT_INVALID); if (err) { error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); return; } info("bluetooth: New connection from: %s, channel %u", address, channel); confirm_connection(io, source, address, user_data); } static void confirm_l2cap(GIOChannel *io, void *user_data) { GError *err = NULL; char source[18]; char address[18]; uint16_t psm; bt_io_get(io, BT_IO_L2CAP, &err, BT_IO_OPT_SOURCE, source, BT_IO_OPT_DEST, address, BT_IO_OPT_PSM, &psm, BT_IO_OPT_INVALID); if (err) { error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); return; } info("bluetooth: New connection from: %s, psm %u", address, psm); confirm_connection(io, source, address, user_data); } static GSList *start(struct obex_server *server, struct obex_service_driver *service) { BtIOSecLevel sec_level; GSList *l = NULL; GIOChannel *io; GError *err = NULL; uint16_t psm; if (service->secure == TRUE) sec_level = BT_IO_SEC_MEDIUM; else sec_level = BT_IO_SEC_LOW; io = bt_io_listen(BT_IO_RFCOMM, NULL, confirm_rfcomm, service, NULL, &err, BT_IO_OPT_CHANNEL, service->channel, BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); if (io == NULL) { error("bluetooth: unable to listen in channel %d: %s", service->channel, err->message); g_error_free(err); } else { l = g_slist_prepend(l, io); DBG("listening on channel %d", service->channel); } if (service->port == 0) return l; psm = service->port == OBEX_PORT_RANDOM ? 0 : service->port; io = bt_io_listen(BT_IO_L2CAP, NULL, confirm_l2cap, service, NULL, &err, BT_IO_OPT_PSM, psm, BT_IO_OPT_MODE, BT_IO_MODE_ERTM, BT_IO_OPT_OMTU, BT_TX_MTU, BT_IO_OPT_IMTU, BT_RX_MTU, BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); if (io == NULL) { error("bluetooth: unable to listen in psm %d: %s", service->port, err->message); g_error_free(err); service->port = 0; } else { l = g_slist_prepend(l, io); bt_io_get(io, BT_IO_L2CAP, &err, BT_IO_OPT_PSM, &service->port, BT_IO_OPT_INVALID); DBG("listening on psm %d", service->port); } return l; } static void *bluetooth_start(struct obex_server *server, int *err) { GSList *ios = NULL; const GSList *l; for (l = server->drivers; l; l = l->next) { struct obex_service_driver *service = l->data; GSList *l; l = start(server, service); if (l == NULL) continue; ios = g_slist_concat(ios, l); } register_record(server); return ios; } static void stop(gpointer data) { GIOChannel *io = data; g_io_channel_shutdown(io, TRUE, NULL); g_io_channel_unref(io); } static void bluetooth_stop(void *data) { GSList *ios = data; g_slist_free_full(ios, stop); } static int bluetooth_getpeername(GIOChannel *io, char **name) { int sk = g_io_channel_unix_get_fd(io); GError *gerr = NULL; char address[18]; int type; socklen_t len = sizeof(int); if (getsockopt(sk, SOL_SOCKET, SO_TYPE, &type, &len) < 0) return -errno; if (type == SOCK_STREAM) bt_io_get(io, BT_IO_RFCOMM, &gerr, BT_IO_OPT_DEST, address, BT_IO_OPT_INVALID); else bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_DEST, address, BT_IO_OPT_INVALID); if (gerr) { error("%s", gerr->message); g_error_free(gerr); return -EINVAL; } *name = g_strdup(address); return 0; } static struct obex_transport_driver driver = { .name = "bluetooth", .start = bluetooth_start, .getpeername = bluetooth_getpeername, .stop = bluetooth_stop }; static unsigned int listener_id = 0; static int bluetooth_init(void) { any = g_new0(struct adapter_any, 1); connection = g_dbus_setup_private(DBUS_BUS_SYSTEM, NULL, NULL); if (connection == NULL) return -EPERM; listener_id = g_dbus_add_service_watch(connection, "org.bluez", name_acquired, name_released, NULL, NULL); return obex_transport_driver_register(&driver); } static void bluetooth_exit(void) { g_dbus_remove_watch(connection, listener_id); if (any) { g_slist_free_full(any->services, g_free); g_free(any->path); g_free(any); } if (connection) dbus_connection_unref(connection); obex_transport_driver_unregister(&driver); } OBEX_PLUGIN_DEFINE(bluetooth, bluetooth_init, bluetooth_exit) obexd-0.46/plugins/ftp.h0000644000000000000000000000232111755212521012055 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ void *ftp_connect(struct obex_session *os, int *err); int ftp_get(struct obex_session *os, void *user_data); int ftp_chkput(struct obex_session *os, void *user_data); int ftp_put(struct obex_session *os, void *user_data); int ftp_setpath(struct obex_session *os, void *user_data); void ftp_disconnect(struct obex_session *os, void *user_data); int ftp_action(struct obex_session *os, void *user_data); obexd-0.46/plugins/phonebook-dummy.c0000644000000000000000000003030511755212521014377 00000000000000/* * * OBEX Server * * Copyright (C) 2009-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "phonebook.h" typedef void (*vcard_func_t) (const char *file, VObject *vo, void *user_data); struct dummy_data { phonebook_cb cb; void *user_data; const struct apparam_field *apparams; char *folder; int fd; guint id; }; struct cache_query { phonebook_entry_cb entry_cb; phonebook_cache_ready_cb ready_cb; void *user_data; DIR *dp; }; static char *root_folder = NULL; static void dummy_free(void *user_data) { struct dummy_data *dummy = user_data; if (dummy->fd >= 0) close(dummy->fd); g_free(dummy->folder); g_free(dummy); } static void query_free(void *user_data) { struct cache_query *query = user_data; if (query->dp) closedir(query->dp); g_free(query); } int phonebook_init(void) { if (root_folder) return 0; /* FIXME: It should NOT be hard-coded */ root_folder = g_build_filename(getenv("HOME"), "phonebook", NULL); return 0; } void phonebook_exit(void) { g_free(root_folder); root_folder = NULL; } static int handle_cmp(gconstpointer a, gconstpointer b) { const char *f1 = a; const char *f2 = b; unsigned int i1, i2; if (sscanf(f1, "%u.vcf", &i1) != 1) return -1; if (sscanf(f2, "%u.vcf", &i2) != 1) return -1; return (i1 - i2); } static int foreach_vcard(DIR *dp, vcard_func_t func, uint16_t offset, uint16_t maxlistcount, void *user_data, uint16_t *count) { struct dirent *ep; GSList *sorted = NULL, *l; VObject *v; FILE *fp; int err, fd, folderfd; uint16_t n = 0; folderfd = dirfd(dp); if (folderfd < 0) { err = errno; error("dirfd(): %s(%d)", strerror(err), err); return -err; } /* * Sorting vcards by file name. versionsort is a GNU extension. * The simple sorting function implemented on handle_cmp address * vcards handle only(handle is always a number). This sort function * doesn't address filename started by "0". */ while ((ep = readdir(dp))) { char *filename; if (ep->d_name[0] == '.') continue; filename = g_filename_to_utf8(ep->d_name, -1, NULL, NULL, NULL); if (filename == NULL) { error("g_filename_to_utf8: invalid filename"); continue; } if (!g_str_has_suffix(filename, ".vcf")) { g_free(filename); continue; } sorted = g_slist_insert_sorted(sorted, filename, handle_cmp); } /* * Filtering only the requested vCards attributes. Offset * shall be based on the first entry of the phonebook. */ for (l = g_slist_nth(sorted, offset); l && n < maxlistcount; l = l->next) { const char *filename = l->data; fd = openat(folderfd, filename, O_RDONLY); if (fd < 0) { err = errno; error("openat(%s): %s(%d)", filename, strerror(err), err); continue; } fp = fdopen(fd, "r"); v = Parse_MIME_FromFile(fp); if (v != NULL) { func(filename, v, user_data); deleteVObject(v); n++; } close(fd); } g_slist_free_full(sorted, g_free); if (count) *count = n; return 0; } static void entry_concat(const char *filename, VObject *v, void *user_data) { GString *buffer = user_data; char tmp[1024]; int len; /* * VObject API uses len for IN and OUT * Written bytes is also returned in the len variable */ len = sizeof(tmp); memset(tmp, 0, len); writeMemVObject(tmp, &len, v); /* FIXME: only the requested fields must be added */ g_string_append_len(buffer, tmp, len); } static gboolean read_dir(void *user_data) { struct dummy_data *dummy = user_data; GString *buffer; DIR *dp; uint16_t count, max, offset; buffer = g_string_new(""); dp = opendir(dummy->folder); if (dp == NULL) { int err = errno; DBG("opendir(): %s(%d)", strerror(err), err); goto done; } /* * For PullPhoneBook function, the decision of returning the size * or contacts is made in the PBAP core. When MaxListCount is ZERO, * PCE wants to know the size of a given folder, PSE shall ignore all * other applicattion parameters that may be present in the request. */ if (dummy->apparams->maxlistcount == 0) { max = 0xffff; offset = 0; } else { max = dummy->apparams->maxlistcount; offset = dummy->apparams->liststartoffset; } foreach_vcard(dp, entry_concat, offset, max, buffer, &count); closedir(dp); done: /* FIXME: Missing vCards fields filtering */ dummy->cb(buffer->str, buffer->len, count, 0, TRUE, dummy->user_data); g_string_free(buffer, TRUE); return FALSE; } static void entry_notify(const char *filename, VObject *v, void *user_data) { struct cache_query *query = user_data; VObject *property, *subproperty; GString *name; const char *tel; long unsigned int handle; property = isAPropertyOf(v, VCNameProp); if (!property) return; if (sscanf(filename, "%lu.vcf", &handle) != 1) return; if (handle > UINT32_MAX) return; /* LastName; FirstName; MiddleName; Prefix; Suffix */ name = g_string_new(""); subproperty = isAPropertyOf(property, VCFamilyNameProp); if (subproperty) { g_string_append(name, fakeCString(vObjectUStringZValue(subproperty))); } subproperty = isAPropertyOf(property, VCGivenNameProp); if (subproperty) g_string_append_printf(name, ";%s", fakeCString(vObjectUStringZValue(subproperty))); subproperty = isAPropertyOf(property, VCAdditionalNamesProp); if (subproperty) g_string_append_printf(name, ";%s", fakeCString(vObjectUStringZValue(subproperty))); subproperty = isAPropertyOf(property, VCNamePrefixesProp); if (subproperty) g_string_append_printf(name, ";%s", fakeCString(vObjectUStringZValue(subproperty))); subproperty = isAPropertyOf(property, VCNameSuffixesProp); if (subproperty) g_string_append_printf(name, ";%s", fakeCString(vObjectUStringZValue(subproperty))); property = isAPropertyOf(v, VCTelephoneProp); tel = property ? fakeCString(vObjectUStringZValue(property)) : NULL; query->entry_cb(filename, handle, name->str, NULL, tel, query->user_data); g_string_free(name, TRUE); } static gboolean create_cache(void *user_data) { struct cache_query *query = user_data; /* * MaxListCount and ListStartOffset shall not be used * when creating the cache. All entries shall be fetched. * PBAP core is responsible for consider these application * parameters before reply the entries. */ foreach_vcard(query->dp, entry_notify, 0, 0xffff, query, NULL); query->ready_cb(query->user_data); return FALSE; } static gboolean read_entry(void *user_data) { struct dummy_data *dummy = user_data; char buffer[1024]; ssize_t count; memset(buffer, 0, sizeof(buffer)); count = read(dummy->fd, buffer, sizeof(buffer)); if (count < 0) { int err = errno; error("read(): %s(%d)", strerror(err), err); count = 0; } /* FIXME: Missing vCards fields filtering */ dummy->cb(buffer, count, 1, 0, TRUE, dummy->user_data); return FALSE; } static gboolean is_dir(const char *dir) { struct stat st; if (stat(dir, &st) < 0) { int err = errno; error("stat(%s): %s (%d)", dir, strerror(err), err); return FALSE; } return S_ISDIR(st.st_mode); } char *phonebook_set_folder(const char *current_folder, const char *new_folder, uint8_t flags, int *err) { gboolean root, child; char *tmp1, *tmp2, *base, *absolute, *relative = NULL; int len, ret = 0; root = (g_strcmp0("/", current_folder) == 0); child = (new_folder && strlen(new_folder) != 0); switch (flags) { case 0x02: /* Go back to root */ if (!child) { relative = g_strdup("/"); goto done; } relative = g_build_filename(current_folder, new_folder, NULL); break; case 0x03: /* Go up 1 level */ if (root) { /* Already root */ ret = -EBADR; goto done; } /* * Removing one level of the current folder. Current folder * contains AT LEAST one level since it is not at root folder. * Use glib utility functions to handle invalid chars in the * folder path properly. */ tmp1 = g_path_get_basename(current_folder); tmp2 = g_strrstr(current_folder, tmp1); len = tmp2 - (current_folder + 1); g_free(tmp1); if (len == 0) base = g_strdup("/"); else base = g_strndup(current_folder, len); /* Return: one level only */ if (!child) { relative = base; goto done; } relative = g_build_filename(base, new_folder, NULL); g_free(base); break; default: ret = -EBADR; break; } done: if (!relative) { if (err) *err = ret; return NULL; } absolute = g_build_filename(root_folder, relative, NULL); if (!is_dir(absolute)) { g_free(relative); relative = NULL; ret = -ENOENT; } g_free(absolute); if (err) *err = ret; return relative; } void phonebook_req_finalize(void *request) { struct dummy_data *dummy = request; /* dummy_data will be cleaned when request will be finished via * g_source_remove */ if (dummy && dummy->id) g_source_remove(dummy->id); } void *phonebook_pull(const char *name, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct dummy_data *dummy; char *filename, *folder; /* * Main phonebook objects will be created dinamically based on the * folder content. All vcards inside the given folder will be appended * in the "virtual" main phonebook object. */ filename = g_build_filename(root_folder, name, NULL); if (!g_str_has_suffix(filename, ".vcf")) { g_free(filename); if (err) *err = -EBADR; return NULL; } folder = g_strndup(filename, strlen(filename) - 4); g_free(filename); if (!is_dir(folder)) { g_free(folder); if (err) *err = -ENOENT; return NULL; } dummy = g_new0(struct dummy_data, 1); dummy->cb = cb; dummy->user_data = user_data; dummy->apparams = params; dummy->folder = folder; dummy->fd = -1; if (err) *err = 0; return dummy; } int phonebook_pull_read(void *request) { struct dummy_data *dummy = request; if (!dummy) return -ENOENT; dummy->id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_dir, dummy, dummy_free); return 0; } void *phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct dummy_data *dummy; char *filename; int fd; guint ret; filename = g_build_filename(root_folder, folder, id, NULL); fd = open(filename, O_RDONLY); if (fd < 0) { DBG("open(): %s(%d)", strerror(errno), errno); if (err) *err = -ENOENT; return NULL; } dummy = g_new0(struct dummy_data, 1); dummy->cb = cb; dummy->user_data = user_data; dummy->apparams = params; dummy->fd = fd; ret = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_entry, dummy, dummy_free); if (err) *err = 0; return GINT_TO_POINTER(ret); } void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, phonebook_cache_ready_cb ready_cb, void *user_data, int *err) { struct cache_query *query; char *foldername; DIR *dp; guint ret; foldername = g_build_filename(root_folder, name, NULL); dp = opendir(foldername); g_free(foldername); if (dp == NULL) { DBG("opendir(): %s(%d)", strerror(errno), errno); if (err) *err = -ENOENT; return NULL; } query = g_new0(struct cache_query, 1); query->entry_cb = entry_cb; query->ready_cb = ready_cb; query->user_data = user_data; query->dp = dp; ret = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, create_cache, query, query_free); if (err) *err = 0; return GINT_TO_POINTER(ret); } obexd-0.46/plugins/syncevolution.c0000644000000000000000000002734411755212521014214 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include "plugin.h" #include "obex.h" #include "service.h" #include "mimetype.h" #include "log.h" #include "manager.h" #include "btio.h" #include "obexd.h" #include "gdbus.h" #include "filesystem.h" #define SYNCML_TARGET_SIZE 11 static const uint8_t SYNCML_TARGET[SYNCML_TARGET_SIZE] = { 0x53, 0x59, 0x4E, 0x43, 0x4D, 0x4C, 0x2D, 0x53, 0x59, 0x4E, 0x43 }; #define SYNCEVOLUTION_CHANNEL 19 #define SYNCEVOLUTION_RECORD "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " #define SYNCE_BUS_NAME "org.syncevolution" #define SYNCE_PATH "/org/syncevolution/Server" #define SYNCE_SERVER_INTERFACE "org.syncevolution.Server" #define SYNCE_CONN_INTERFACE "org.syncevolution.Connection" struct synce_context { struct obex_session *os; DBusConnection *dbus_conn; char *conn_obj; unsigned int reply_watch; unsigned int abort_watch; GString *buffer; int lasterr; char *id; }; static void append_dict_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &val); dbus_message_iter_close_container(dict, &entry); } static gboolean reply_signal(DBusConnection *conn, DBusMessage *msg, void *data) { struct synce_context *context = data; const char *path = dbus_message_get_path(msg); DBusMessageIter iter, array_iter; char *value; int length; if (strcmp(context->conn_obj, path) != 0) { obex_object_set_io_flags(context, G_IO_ERR, -EPERM); context->lasterr = -EPERM; return FALSE; } dbus_message_iter_init(msg, &iter); dbus_message_iter_recurse(&iter, &array_iter); dbus_message_iter_get_fixed_array(&array_iter, &value, &length); context->buffer = g_string_new_len(value, length); obex_object_set_io_flags(context, G_IO_IN, 0); context->lasterr = 0; return TRUE; } static gboolean abort_signal(DBusConnection *conn, DBusMessage *msg, void *data) { struct synce_context *context = data; obex_object_set_io_flags(context, G_IO_ERR, -EPERM); context->lasterr = -EPERM; return TRUE; } static void connect_cb(DBusPendingCall *call, void *user_data) { struct synce_context *context = user_data; DBusConnection *conn; DBusMessage *reply; DBusError err; char *path; conn = context->dbus_conn; reply = dbus_pending_call_steal_reply(call); dbus_error_init(&err); if (dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) { error("%s", err.message); dbus_error_free(&err); goto failed; } DBG("Got conn object %s from syncevolution", path); context->conn_obj = g_strdup(path); context->reply_watch = g_dbus_add_signal_watch(conn, NULL, path, SYNCE_CONN_INTERFACE, "Reply", reply_signal, context, NULL); context->abort_watch = g_dbus_add_signal_watch(conn, NULL, path, SYNCE_CONN_INTERFACE, "Abort", abort_signal, context, NULL); dbus_message_unref(reply); return; failed: obex_object_set_io_flags(context, G_IO_ERR, -EPERM); context->lasterr = -EPERM; } static void process_cb(DBusPendingCall *call, void *user_data) { struct synce_context *context = user_data; DBusMessage *reply; DBusError derr; reply = dbus_pending_call_steal_reply(call); dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("process_cb(): syncevolution replied with an error:" " %s, %s", derr.name, derr.message); dbus_error_free(&derr); obex_object_set_io_flags(context, G_IO_ERR, -EPERM); context->lasterr = -EPERM; goto done; } obex_object_set_io_flags(context, G_IO_OUT, 0); context->lasterr = 0; done: dbus_message_unref(reply); } static void *synce_connect(struct obex_session *os, int *err) { DBusConnection *conn; struct synce_context *context; char *address; manager_register_session(os); conn = manager_dbus_get_connection(); if (!conn) goto failed; context = g_new0(struct synce_context, 1); context->dbus_conn = conn; context->lasterr = -EAGAIN; context->os = os; if (obex_getpeername(os, &address) == 0) { context->id = g_strdup_printf("%s+%d", address, SYNCEVOLUTION_CHANNEL); g_free(address); } if (err) *err = 0; return context; failed: if (err) *err = -EPERM; return NULL; } static int synce_put(struct obex_session *os, void *user_data) { return 0; } static int synce_get(struct obex_session *os, void *user_data) { return obex_get_stream_start(os, NULL); } static void close_cb(DBusPendingCall *call, void *user_data) { DBusMessage *reply; DBusError derr; reply = dbus_pending_call_steal_reply(call); dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("close_cb(): syncevolution replied with an error:" " %s, %s", derr.name, derr.message); dbus_error_free(&derr); } dbus_message_unref(reply); } static void synce_disconnect(struct obex_session *os, void *user_data) { struct synce_context *context = user_data; g_free(context); } static void *synce_open(const char *name, int oflag, mode_t mode, void *user_data, size_t *size, int *err) { struct synce_context *context = user_data; if (err) *err = context ? 0 : -EFAULT; return user_data; } static int synce_close(void *object) { struct synce_context *context = object; DBusMessage *msg; const char *error; gboolean normal; DBusPendingCall *call; if (!context->conn_obj) goto done; msg = dbus_message_new_method_call(SYNCE_BUS_NAME, context->conn_obj, SYNCE_CONN_INTERFACE, "Close"); if (!msg) goto failed; normal = TRUE; error = "none"; dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &normal, DBUS_TYPE_STRING, &error, DBUS_TYPE_INVALID); dbus_connection_send_with_reply(context->dbus_conn, msg, &call, -1); dbus_pending_call_set_notify(call, close_cb, NULL, NULL); dbus_message_unref(msg); dbus_pending_call_unref(call); failed: g_dbus_remove_watch(context->dbus_conn, context->reply_watch); context->reply_watch = 0; g_dbus_remove_watch(context->dbus_conn, context->abort_watch); context->abort_watch = 0; g_free(context->conn_obj); context->conn_obj = NULL; done: dbus_connection_unref(context->dbus_conn); g_free(context); return 0; } static ssize_t synce_read(void *object, void *buf, size_t count) { struct synce_context *context = object; DBusConnection *conn; char transport[36], transport_description[24]; const char *session; DBusMessage *msg; DBusMessageIter iter, dict; gboolean authenticate; DBusPendingCall *call; if (context->buffer) return string_read(context->buffer, buf, count); conn = manager_dbus_get_connection(); if (conn == NULL) return -EPERM; msg = dbus_message_new_method_call(SYNCE_BUS_NAME, SYNCE_PATH, SYNCE_SERVER_INTERFACE, "Connect"); if (!msg) return -EPERM; dbus_message_iter_init_append(msg, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); append_dict_entry(&dict, "id", DBUS_TYPE_STRING, context->id); snprintf(transport, sizeof(transport), "%s.obexd", OPENOBEX_SERVICE); append_dict_entry(&dict, "transport", DBUS_TYPE_STRING, transport); snprintf(transport_description, sizeof(transport_description), "version %s", VERSION); append_dict_entry(&dict, "transport_description", DBUS_TYPE_STRING, transport_description); dbus_message_iter_close_container(&iter, &dict); authenticate = FALSE; session = ""; dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &authenticate, DBUS_TYPE_STRING, &session, DBUS_TYPE_INVALID); if (!dbus_connection_send_with_reply(conn, msg, &call, -1)) { error("D-Bus call to %s failed.", SYNCE_SERVER_INTERFACE); dbus_message_unref(msg); return -EPERM; } dbus_pending_call_set_notify(call, connect_cb, context, NULL); dbus_pending_call_unref(call); dbus_message_unref(msg); return -EAGAIN; } static ssize_t synce_write(void *object, const void *buf, size_t count) { struct synce_context *context = object; DBusMessage *msg; DBusMessageIter iter, array_iter; DBusPendingCall *call; const char *type = obex_get_type(context->os); if (context->lasterr == 0) return count; if (!context->conn_obj) return -EFAULT; msg = dbus_message_new_method_call(SYNCE_BUS_NAME, context->conn_obj, SYNCE_CONN_INTERFACE, "Process"); if (!msg) return -EFAULT; dbus_message_iter_init_append(msg, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING, &array_iter); dbus_message_iter_append_fixed_array(&array_iter, DBUS_TYPE_BYTE, &buf, count); dbus_message_iter_close_container(&iter, &array_iter); dbus_message_append_args(msg, DBUS_TYPE_STRING, &type, DBUS_TYPE_INVALID); if (!dbus_connection_send_with_reply(context->dbus_conn, msg, &call, -1)) { error("D-Bus call to %s failed.", SYNCE_CONN_INTERFACE); dbus_message_unref(msg); return -EPERM; } dbus_pending_call_set_notify(call, process_cb, context, NULL); dbus_message_unref(msg); dbus_pending_call_unref(call); return -EAGAIN; } static struct obex_mime_type_driver synce_driver = { .target = SYNCML_TARGET, .target_size = SYNCML_TARGET_SIZE, .open = synce_open, .close = synce_close, .read = synce_read, .write = synce_write, }; static struct obex_service_driver synce = { .name = "OBEX server for SyncML, using SyncEvolution", .service = OBEX_SYNCEVOLUTION, .channel = SYNCEVOLUTION_CHANNEL, .secure = TRUE, .record = SYNCEVOLUTION_RECORD, .target = SYNCML_TARGET, .target_size = SYNCML_TARGET_SIZE, .get = synce_get, .put = synce_put, .connect = synce_connect, .disconnect = synce_disconnect, }; static int synce_init(void) { int err; err = obex_mime_type_driver_register(&synce_driver); if (err < 0) return err; return obex_service_driver_register(&synce); } static void synce_exit(void) { obex_service_driver_unregister(&synce); obex_mime_type_driver_unregister(&synce_driver); } OBEX_PLUGIN_DEFINE(syncevolution, synce_init, synce_exit) obexd-0.46/plugins/filesystem.c0000644000000000000000000003503611755212521013454 00000000000000/* * * OBEX Server * * Copyright (C) 2009-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" #include "mimetype.h" #include "filesystem.h" #define EOL_CHARS "\n" #define FL_VERSION "" EOL_CHARS #define FL_TYPE "" EOL_CHARS #define FL_TYPE_PCSUITE " ]>" EOL_CHARS #define FL_BODY_BEGIN "" EOL_CHARS #define FL_BODY_END "" EOL_CHARS #define FL_PARENT_FOLDER_ELEMENT "" EOL_CHARS #define FL_FILE_ELEMENT "" EOL_CHARS #define FL_FOLDER_ELEMENT "" EOL_CHARS #define FL_FOLDER_ELEMENT_PCSUITE "" EOL_CHARS #define FTP_TARGET_SIZE 16 static const uint8_t FTP_TARGET[FTP_TARGET_SIZE] = { 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; #define PCSUITE_WHO_SIZE 8 static const uint8_t PCSUITE_WHO[PCSUITE_WHO_SIZE] = { 'P', 'C', ' ', 'S', 'u', 'i', 't', 'e' }; gboolean is_filename(const char *name) { if (strchr(name, '/')) return FALSE; if (strcmp(name, ".") == 0) return FALSE; if (strcmp(name, "..") == 0) return FALSE; return TRUE; } int verify_path(const char *path) { char *t; int ret = 0; if (obex_option_symlinks()) return 0; t = realpath(path, NULL); if (t == NULL) return -errno; if (!g_str_has_prefix(t, obex_option_root_folder())) ret = -EPERM; free(t); return ret; } static char *file_stat_line(char *filename, struct stat *fstat, struct stat *dstat, gboolean root, gboolean pcsuite) { char perm[51], atime[18], ctime[18], mtime[18]; char *escaped, *ret = NULL; snprintf(perm, 50, "user-perm=\"%s%s%s\" group-perm=\"%s%s%s\" " "other-perm=\"%s%s%s\"", (fstat->st_mode & S_IRUSR ? "R" : ""), (fstat->st_mode & S_IWUSR ? "W" : ""), (dstat->st_mode & S_IWUSR ? "D" : ""), (fstat->st_mode & S_IRGRP ? "R" : ""), (fstat->st_mode & S_IWGRP ? "W" : ""), (dstat->st_mode & S_IWGRP ? "D" : ""), (fstat->st_mode & S_IROTH ? "R" : ""), (fstat->st_mode & S_IWOTH ? "W" : ""), (dstat->st_mode & S_IWOTH ? "D" : "")); strftime(atime, 17, "%Y%m%dT%H%M%SZ", gmtime(&fstat->st_atime)); strftime(ctime, 17, "%Y%m%dT%H%M%SZ", gmtime(&fstat->st_ctime)); strftime(mtime, 17, "%Y%m%dT%H%M%SZ", gmtime(&fstat->st_mtime)); escaped = g_markup_escape_text(filename, -1); if (S_ISDIR(fstat->st_mode)) { if (pcsuite && root && g_str_equal(filename, "Data")) ret = g_strdup_printf(FL_FOLDER_ELEMENT_PCSUITE, escaped, perm, atime, mtime, ctime); else ret = g_strdup_printf(FL_FOLDER_ELEMENT, escaped, perm, atime, mtime, ctime); } else if (S_ISREG(fstat->st_mode)) ret = g_strdup_printf(FL_FILE_ELEMENT, escaped, (uint64_t) fstat->st_size, perm, atime, mtime, ctime); g_free(escaped); return ret; } static void *filesystem_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct stat stats; struct statvfs buf; int fd, ret; uint64_t avail; fd = open(name, oflag, mode); if (fd < 0) { if (err) *err = -errno; return NULL; } if (fstat(fd, &stats) < 0) { if (err) *err = -errno; goto failed; } ret = verify_path(name); if (ret < 0) { if (err) *err = ret; goto failed; } if (oflag == O_RDONLY) { if (size) *size = stats.st_size; goto done; } if (fstatvfs(fd, &buf) < 0) { if (err) *err = -errno; goto failed; } if (size == NULL) goto done; avail = (uint64_t) buf.f_bsize * buf.f_bavail; if (avail < *size) { if (err) *err = -ENOSPC; goto failed; } done: if (err) *err = 0; return GINT_TO_POINTER(fd); failed: close(fd); return NULL; } static int filesystem_close(void *object) { if (close(GPOINTER_TO_INT(object)) < 0) return -errno; return 0; } static ssize_t filesystem_read(void *object, void *buf, size_t count) { ssize_t ret; ret = read(GPOINTER_TO_INT(object), buf, count); if (ret < 0) return -errno; return ret; } static ssize_t filesystem_write(void *object, const void *buf, size_t count) { ssize_t ret; ret = write(GPOINTER_TO_INT(object), buf, count); if (ret < 0) return -errno; return ret; } static int filesystem_rename(const char *name, const char *destname) { int ret; ret = rename(name, destname); if (ret < 0) { error("rename(%s, %s): %s (%d)", name, destname, strerror(errno), errno); return -errno; } return ret; } static int sendfile_async(int out_fd, int in_fd, off_t *offset, size_t count) { int pid; /* Run sendfile on child process */ pid = fork(); switch (pid) { case 0: break; case -1: error("fork() %s (%d)", strerror(errno), errno); return -errno; default: DBG("child %d forked", pid); return pid; } /* At child */ if (sendfile(out_fd, in_fd, offset, count) < 0) error("sendfile(): %s (%d)", strerror(errno), errno); close(in_fd); close(out_fd); exit(errno); } static int filesystem_copy(const char *name, const char *destname) { void *in, *out; ssize_t ret; size_t size; struct stat st; int in_fd, out_fd, err; in = filesystem_open(name, O_RDONLY, 0, NULL, &size, &err); if (in == NULL) { error("open(%s): %s (%d)", name, strerror(-err), -err); return -err; } in_fd = GPOINTER_TO_INT(in); ret = fstat(in_fd, &st); if (ret < 0) { error("stat(%s): %s (%d)", name, strerror(errno), errno); return -errno; } out = filesystem_open(destname, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode, NULL, &size, &err); if (out == NULL) { error("open(%s): %s (%d)", destname, strerror(-err), -err); filesystem_close(in); return -errno; } out_fd = GPOINTER_TO_INT(out); /* Check if sendfile is supported */ ret = sendfile(out_fd, in_fd, NULL, 0); if (ret < 0) { ret = -errno; error("sendfile: %s (%zd)", strerror(-ret), -ret); goto done; } ret = sendfile_async(out_fd, in_fd, NULL, st.st_size); if (ret < 0) goto done; return 0; done: filesystem_close(in); filesystem_close(out); return ret; } struct capability_object { int pid; int output; int err; gboolean aborted; GString *buffer; }; static void script_exited(GPid pid, int status, void *data) { struct capability_object *object = data; char buf[128]; object->pid = -1; DBG("pid: %d status: %d", pid, status); g_spawn_close_pid(pid); /* free the object if aborted */ if (object->aborted) { if (object->buffer != NULL) g_string_free(object->buffer, TRUE); g_free(object); return; } if (WEXITSTATUS(status) != EXIT_SUCCESS) { memset(buf, 0, sizeof(buf)); if (read(object->err, buf, sizeof(buf)) > 0) error("%s", buf); obex_object_set_io_flags(data, G_IO_ERR, -EPERM); } else obex_object_set_io_flags(data, G_IO_IN, 0); } static int capability_exec(const char **argv, int *output, int *err) { GError *gerr = NULL; int pid; GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH; if (!g_spawn_async_with_pipes(NULL, (char **) argv, NULL, flags, NULL, NULL, &pid, NULL, output, err, &gerr)) { error("%s", gerr->message); g_error_free(gerr); return -EPERM; } DBG("executing %s pid %d", argv[0], pid); return pid; } static void *capability_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct capability_object *object = NULL; char *buf; const char *argv[2]; if (oflag != O_RDONLY) goto fail; object = g_new0(struct capability_object, 1); object->pid = -1; object->output = -1; object->err = -1; if (name[0] != '!') { GError *gerr = NULL; gboolean ret; ret = g_file_get_contents(name, &buf, NULL, &gerr); if (ret == FALSE) { error("%s", gerr->message); g_error_free(gerr); goto fail; } object->buffer = g_string_new(buf); if (size) *size = object->buffer->len; goto done; } argv[0] = &name[1]; argv[1] = NULL; object->pid = capability_exec(argv, &object->output, &object->err); if (object->pid < 0) goto fail; /* Watch cannot be removed while the process is still running */ g_child_watch_add(object->pid, script_exited, object); done: if (err) *err = 0; return object; fail: if (err) *err = -EPERM; g_free(object); return NULL; } static GString *append_pcsuite_preamble(GString *object) { return g_string_append(object, FL_TYPE_PCSUITE); } static GString *append_folder_preamble(GString *object) { return g_string_append(object, FL_TYPE); } static GString *append_listing(GString *object, const char *name, gboolean pcsuite, size_t *size, int *err) { struct stat fstat, dstat; struct dirent *ep; DIR *dp; gboolean root; int ret; root = g_str_equal(name, obex_option_root_folder()); dp = opendir(name); if (dp == NULL) { if (err) *err = -ENOENT; goto failed; } if (!root) object = g_string_append(object, FL_PARENT_FOLDER_ELEMENT); ret = verify_path(name); if (ret < 0) { *err = ret; goto failed; } ret = stat(name, &dstat); if (ret < 0) { if (err) *err = -errno; goto failed; } while ((ep = readdir(dp))) { char *filename; char *fullname; char *line; if (ep->d_name[0] == '.') continue; filename = g_filename_to_utf8(ep->d_name, -1, NULL, NULL, NULL); if (filename == NULL) { error("g_filename_to_utf8: invalid filename"); continue; } fullname = g_build_filename(name, ep->d_name, NULL); ret = stat(fullname, &fstat); if (ret < 0) { DBG("stat: %s(%d)", strerror(errno), errno); g_free(filename); g_free(fullname); continue; } g_free(fullname); line = file_stat_line(filename, &fstat, &dstat, root, FALSE); if (line == NULL) { g_free(filename); continue; } g_free(filename); object = g_string_append(object, line); g_free(line); } closedir(dp); object = g_string_append(object, FL_BODY_END); if (size) *size = object->len; if (err) *err = 0; return object; failed: if (dp) closedir(dp); g_string_free(object, TRUE); return NULL; } static void *folder_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { GString *object; object = g_string_new(FL_VERSION); object = append_folder_preamble(object); object = g_string_append(object, FL_BODY_BEGIN); return append_listing(object, name, FALSE, size, err); } static void *pcsuite_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { GString *object; object = g_string_new(FL_VERSION); object = append_pcsuite_preamble(object); object = g_string_append(object, FL_BODY_BEGIN); return append_listing(object, name, TRUE, size, err); } static int string_free(void *object) { GString *string = object; g_string_free(string, TRUE); return 0; } ssize_t string_read(void *object, void *buf, size_t count) { GString *string = object; ssize_t len; if (string->len == 0) return 0; len = MIN(string->len, count); memcpy(buf, string->str, len); string = g_string_erase(string, 0, len); return len; } static ssize_t folder_read(void *object, void *buf, size_t count) { return string_read(object, buf, count); } static ssize_t capability_read(void *object, void *buf, size_t count) { struct capability_object *obj = object; if (obj->buffer) return string_read(obj->buffer, buf, count); if (obj->pid >= 0) return -EAGAIN; return read(obj->output, buf, count); } static int capability_close(void *object) { struct capability_object *obj = object; int err = 0; if (obj->pid < 0) goto done; DBG("kill: pid %d", obj->pid); err = kill(obj->pid, SIGTERM); if (err < 0) { err = -errno; error("kill: %s (%d)", strerror(-err), -err); goto done; } obj->aborted = TRUE; return 0; done: if (obj->buffer != NULL) g_string_free(obj->buffer, TRUE); g_free(obj); return err; } static struct obex_mime_type_driver file = { .open = filesystem_open, .close = filesystem_close, .read = filesystem_read, .write = filesystem_write, .remove = remove, .move = filesystem_rename, .copy = filesystem_copy, }; static struct obex_mime_type_driver capability = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .mimetype = "x-obex/capability", .open = capability_open, .close = capability_close, .read = capability_read, }; static struct obex_mime_type_driver folder = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .mimetype = "x-obex/folder-listing", .open = folder_open, .close = string_free, .read = folder_read, }; static struct obex_mime_type_driver pcsuite = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .who = PCSUITE_WHO, .who_size = PCSUITE_WHO_SIZE, .mimetype = "x-obex/folder-listing", .open = pcsuite_open, .close = string_free, .read = folder_read, }; static int filesystem_init(void) { int err; err = obex_mime_type_driver_register(&folder); if (err < 0) return err; err = obex_mime_type_driver_register(&capability); if (err < 0) return err; err = obex_mime_type_driver_register(&pcsuite); if (err < 0) return err; return obex_mime_type_driver_register(&file); } static void filesystem_exit(void) { obex_mime_type_driver_unregister(&folder); obex_mime_type_driver_unregister(&capability); obex_mime_type_driver_unregister(&file); } OBEX_PLUGIN_DEFINE(filesystem, filesystem_init, filesystem_exit) obexd-0.46/plugins/mas.c0000644000000000000000000004436611755212521012056 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" #include "obex.h" #include "service.h" #include "mimetype.h" #include "filesystem.h" #include "manager.h" #include "map_ap.h" #include "messages.h" /* Channel number according to bluez doc/assigned-numbers.txt */ #define MAS_CHANNEL 16 #define MAS_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " #define XML_DECL "" /* Building blocks for x-obex/folder-listing */ #define FL_DTD "" #define FL_BODY_BEGIN "" #define FL_BODY_EMPTY "" #define FL_PARENT_FOLDER_ELEMENT "" #define FL_FOLDER_ELEMENT "" #define FL_BODY_END "" #define ML_BODY_BEGIN "" #define ML_BODY_END "" struct mas_session { struct mas_request *request; void *backend_data; gboolean finished; gboolean nth_call; GString *buffer; map_ap_t *inparams; map_ap_t *outparams; gboolean ap_sent; }; static const uint8_t MAS_TARGET[TARGET_SIZE] = { 0xbb, 0x58, 0x2b, 0x40, 0x42, 0x0c, 0x11, 0xdb, 0xb0, 0xde, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 }; static int get_params(struct obex_session *os, struct mas_session *mas) { const uint8_t *buffer; ssize_t size; size = obex_get_apparam(os, &buffer); if (size < 0) size = 0; mas->inparams = map_ap_decode(buffer, size); if (mas->inparams == NULL) { DBG("Error when parsing parameters!"); return -EBADR; } mas->outparams = map_ap_new(); return 0; } static void reset_request(struct mas_session *mas) { if (mas->buffer) { g_string_free(mas->buffer, TRUE); mas->buffer = NULL; } map_ap_free(mas->inparams); mas->inparams = NULL; map_ap_free(mas->outparams); mas->outparams = NULL; mas->nth_call = FALSE; mas->finished = FALSE; } static void mas_clean(struct mas_session *mas) { reset_request(mas); g_free(mas); } static void *mas_connect(struct obex_session *os, int *err) { struct mas_session *mas; DBG(""); mas = g_new0(struct mas_session, 1); *err = messages_connect(&mas->backend_data); if (*err < 0) goto failed; manager_register_session(os); return mas; failed: g_free(mas); return NULL; } static void mas_disconnect(struct obex_session *os, void *user_data) { struct mas_session *mas = user_data; DBG(""); manager_unregister_session(os); messages_disconnect(mas->backend_data); mas_clean(mas); } static int mas_get(struct obex_session *os, void *user_data) { struct mas_session *mas = user_data; const char *type = obex_get_type(os); const char *name = obex_get_name(os); int ret; DBG("GET: name %s type %s mas %p", name, type, mas); if (type == NULL) return -EBADR; ret = get_params(os, mas); if (ret < 0) goto failed; ret = obex_get_stream_start(os, name); if (ret < 0) goto failed; return 0; failed: reset_request(mas); return ret; } static int mas_put(struct obex_session *os, void *user_data) { struct mas_session *mas = user_data; const char *type = obex_get_type(os); const char *name = obex_get_name(os); int ret; DBG("PUT: name %s type %s mas %p", name, type, mas); if (type == NULL) return -EBADR; ret = get_params(os, mas); if (ret < 0) goto failed; ret = obex_put_stream_start(os, name); if (ret < 0) goto failed; return 0; failed: reset_request(mas); return ret; } /* FIXME: Preserve whitespaces */ static void g_string_append_escaped_printf(GString *string, const gchar *format, ...) { va_list ap; char *escaped; va_start(ap, format); escaped = g_markup_vprintf_escaped(format, ap); g_string_append(string, escaped); g_free(escaped); va_end(ap); } static const char *yesorno(gboolean a) { if (a) return "yes"; return "no"; } static void get_messages_listing_cb(void *session, int err, uint16_t size, gboolean newmsg, const struct messages_message *entry, void *user_data) { struct mas_session *mas = user_data; uint16_t max = 1024; if (err < 0 && err != -EAGAIN) { obex_object_set_io_flags(mas, G_IO_ERR, err); return; } map_ap_get_u16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); if (max == 0) { if (!entry) mas->finished = TRUE; goto proceed; } if (!mas->nth_call) { g_string_append(mas->buffer, ML_BODY_BEGIN); mas->nth_call = TRUE; } if (!entry) { g_string_append(mas->buffer, ML_BODY_END); mas->finished = TRUE; goto proceed; } g_string_append(mas->buffer, "buffer, " handle=\"%s\"", entry->handle); if (entry->mask & PMASK_SUBJECT) g_string_append_escaped_printf(mas->buffer, " subject=\"%s\"", entry->subject); if (entry->mask & PMASK_DATETIME) g_string_append_escaped_printf(mas->buffer, " datetime=\"%s\"", entry->datetime); if (entry->mask & PMASK_SENDER_NAME) g_string_append_escaped_printf(mas->buffer, " sender_name=\"%s\"", entry->sender_name); if (entry->mask & PMASK_SENDER_ADDRESSING) g_string_append_escaped_printf(mas->buffer, " sender_addressing=\"%s\"", entry->sender_addressing); if (entry->mask & PMASK_REPLYTO_ADDRESSING) g_string_append_escaped_printf(mas->buffer, " replyto_addressing=\"%s\"", entry->replyto_addressing); if (entry->mask & PMASK_RECIPIENT_NAME) g_string_append_escaped_printf(mas->buffer, " recipient_name=\"%s\"", entry->recipient_name); if (entry->mask & PMASK_RECIPIENT_ADDRESSING) g_string_append_escaped_printf(mas->buffer, " recipient_addressing=\"%s\"", entry->recipient_addressing); if (entry->mask & PMASK_TYPE) g_string_append_escaped_printf(mas->buffer, " type=\"%s\"", entry->type); if (entry->mask & PMASK_RECEPTION_STATUS) g_string_append_escaped_printf(mas->buffer, " reception_status=\"%s\"", entry->reception_status); if (entry->mask & PMASK_SIZE) g_string_append_escaped_printf(mas->buffer, " size=\"%s\"", entry->size); if (entry->mask & PMASK_ATTACHMENT_SIZE) g_string_append_escaped_printf(mas->buffer, " attachment_size=\"%s\"", entry->attachment_size); if (entry->mask & PMASK_TEXT) g_string_append_escaped_printf(mas->buffer, " text=\"%s\"", yesorno(entry->text)); if (entry->mask & PMASK_READ) g_string_append_escaped_printf(mas->buffer, " read=\"%s\"", yesorno(entry->read)); if (entry->mask & PMASK_SENT) g_string_append_escaped_printf(mas->buffer, " sent=\"%s\"", yesorno(entry->sent)); if (entry->mask & PMASK_PROTECTED) g_string_append_escaped_printf(mas->buffer, " protected=\"%s\"", yesorno(entry->protect)); if (entry->mask & PMASK_PRIORITY) g_string_append_escaped_printf(mas->buffer, " priority=\"%s\"", yesorno(entry->priority)); g_string_append(mas->buffer, "/>\n"); proceed: if (!entry) { map_ap_set_u16(mas->outparams, MAP_AP_MESSAGESLISTINGSIZE, size); map_ap_set_u8(mas->outparams, MAP_AP_NEWMESSAGE, newmsg ? 1 : 0); } if (err != -EAGAIN) obex_object_set_io_flags(mas, G_IO_IN, 0); } static void get_message_cb(void *session, int err, gboolean fmore, const char *chunk, void *user_data) { struct mas_session *mas = user_data; DBG(""); if (err < 0 && err != -EAGAIN) { obex_object_set_io_flags(mas, G_IO_ERR, err); return; } if (!chunk) { mas->finished = TRUE; goto proceed; } g_string_append(mas->buffer, chunk); proceed: if (err != -EAGAIN) obex_object_set_io_flags(mas, G_IO_IN, 0); } static void get_folder_listing_cb(void *session, int err, uint16_t size, const char *name, void *user_data) { struct mas_session *mas = user_data; uint16_t max = 1024; if (err < 0 && err != -EAGAIN) { obex_object_set_io_flags(mas, G_IO_ERR, err); return; } map_ap_get_u16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); if (max == 0) { if (err != -EAGAIN) map_ap_set_u16(mas->outparams, MAP_AP_FOLDERLISTINGSIZE, size); if (!name) mas->finished = TRUE; goto proceed; } if (!mas->nth_call) { g_string_append(mas->buffer, XML_DECL); g_string_append(mas->buffer, FL_DTD); if (!name) { g_string_append(mas->buffer, FL_BODY_EMPTY); mas->finished = TRUE; goto proceed; } g_string_append(mas->buffer, FL_BODY_BEGIN); mas->nth_call = TRUE; } if (!name) { g_string_append(mas->buffer, FL_BODY_END); mas->finished = TRUE; goto proceed; } if (g_strcmp0(name, "..") == 0) g_string_append(mas->buffer, FL_PARENT_FOLDER_ELEMENT); else g_string_append_escaped_printf(mas->buffer, FL_FOLDER_ELEMENT, name); proceed: if (err != -EAGAIN) obex_object_set_io_flags(mas, G_IO_IN, err); } static void update_inbox_cb(void *session, int err, void *user_data) { struct mas_session *mas = user_data; DBG(""); mas->finished = TRUE; if (err < 0) obex_object_set_io_flags(mas, G_IO_ERR, err); else obex_object_set_io_flags(mas, G_IO_OUT, 0); } static int mas_setpath(struct obex_session *os, void *user_data) { const char *name; const uint8_t *nonhdr; struct mas_session *mas = user_data; if (obex_get_non_header_data(os, &nonhdr) != 2) { error("Set path failed: flag and constants not found!"); return -EBADR; } name = obex_get_name(os); DBG("SETPATH: name %s nonhdr 0x%x%x", name, nonhdr[0], nonhdr[1]); if ((nonhdr[0] & 0x02) != 0x02) { DBG("Error: requested directory creation"); return -EBADR; } return messages_set_folder(mas->backend_data, name, nonhdr[0] & 0x01); } static void *folder_listing_open(const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err) { struct mas_session *mas = driver_data; /* 1024 is the default when there was no MaxListCount sent */ uint16_t max = 1024; uint16_t offset = 0; if (oflag != O_RDONLY) { *err = -EBADR; return NULL; } DBG("name = %s", name); map_ap_get_u16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); map_ap_get_u16(mas->inparams, MAP_AP_STARTOFFSET, &offset); *err = messages_get_folder_listing(mas->backend_data, name, max, offset, get_folder_listing_cb, mas); mas->buffer = g_string_new(""); if (*err < 0) return NULL; else return mas; } static void *msg_listing_open(const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err) { struct mas_session *mas = driver_data; struct messages_filter filter = { 0, }; /* 1024 is the default when there was no MaxListCount sent */ uint16_t max = 1024; uint16_t offset = 0; DBG(""); if (oflag != O_RDONLY) { *err = -EBADR; return NULL; } map_ap_get_u16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max); map_ap_get_u16(mas->inparams, MAP_AP_STARTOFFSET, &offset); map_ap_get_u32(mas->inparams, MAP_AP_PARAMETERMASK, &filter.parameter_mask); map_ap_get_u8(mas->inparams, MAP_AP_FILTERMESSAGETYPE, &filter.type); filter.period_begin = map_ap_get_string(mas->inparams, MAP_AP_FILTERPERIODBEGIN); filter.period_end = map_ap_get_string(mas->inparams, MAP_AP_FILTERPERIODEND); map_ap_get_u8(mas->inparams, MAP_AP_FILTERREADSTATUS, &filter.read_status); filter.recipient = map_ap_get_string(mas->inparams, MAP_AP_FILTERRECIPIENT); filter.originator = map_ap_get_string(mas->inparams, MAP_AP_FILTERORIGINATOR); map_ap_get_u8(mas->inparams, MAP_AP_FILTERPRIORITY, &filter.priority); *err = messages_get_messages_listing(mas->backend_data, name, max, offset, &filter, get_messages_listing_cb, mas); mas->buffer = g_string_new(""); if (*err < 0) return NULL; else return mas; } static void *message_open(const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err) { struct mas_session *mas = driver_data; DBG(""); if (oflag != O_RDONLY) { DBG("Message pushing unsupported"); *err = -ENOSYS; return NULL; } *err = messages_get_message(mas->backend_data, name, 0, get_message_cb, mas); mas->buffer = g_string_new(""); if (*err < 0) return NULL; else return mas; } static void *message_update_open(const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err) { struct mas_session *mas = driver_data; DBG(""); if (oflag != O_WRONLY) { *err = -EBADR; return NULL; } *err = messages_update_inbox(mas->backend_data, update_inbox_cb, mas); if (*err < 0) return NULL; else return mas; } static ssize_t any_get_next_header(void *object, void *buf, size_t mtu, uint8_t *hi) { struct mas_session *mas = object; size_t len; uint8_t *apbuf; DBG(""); if (mas->buffer->len == 0 && !mas->finished) return -EAGAIN; *hi = G_OBEX_HDR_APPARAM; if (mas->ap_sent) return 0; mas->ap_sent = TRUE; apbuf = map_ap_encode(mas->outparams, &len); if (len > mtu) { DBG("MTU is to small to fit application parameters header!"); g_free(apbuf); return -EIO; } memcpy(buf, apbuf, len); return len; } static void *any_open(const char *name, int oflag, mode_t mode, void *driver_data, size_t *size, int *err) { DBG(""); *err = -ENOSYS; return NULL; } static ssize_t any_write(void *object, const void *buf, size_t count) { DBG(""); return count; } static ssize_t any_read(void *obj, void *buf, size_t count) { struct mas_session *mas = obj; ssize_t len; DBG(""); len = string_read(mas->buffer, buf, count); if (len == 0 && !mas->finished) return -EAGAIN; return len; } static int any_close(void *obj) { struct mas_session *mas = obj; DBG(""); if (!mas->finished) messages_abort(mas->backend_data); reset_request(mas); return 0; } static struct obex_service_driver mas = { .name = "Message Access server", .service = OBEX_MAS, .channel = MAS_CHANNEL, .secure = TRUE, .record = MAS_RECORD, .target = MAS_TARGET, .target_size = TARGET_SIZE, .connect = mas_connect, .get = mas_get, .put = mas_put, .setpath = mas_setpath, .disconnect = mas_disconnect, }; static struct obex_mime_type_driver mime_map = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = NULL, .open = any_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_message = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/message", .open = message_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_folder_listing = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-obex/folder-listing", .get_next_header = any_get_next_header, .open = folder_listing_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_msg_listing = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-msg-listing", .open = msg_listing_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_notification_registration = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-NotificationRegistration", .open = any_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_message_status = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/messageStatus", .open = any_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver mime_message_update = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-messageUpdate", .open = message_update_open, .close = any_close, .read = any_read, .write = any_write, }; static struct obex_mime_type_driver *map_drivers[] = { &mime_map, &mime_message, &mime_folder_listing, &mime_msg_listing, &mime_notification_registration, &mime_message_status, &mime_message_update, NULL }; static int mas_init(void) { int err; int i; err = messages_init(); if (err < 0) return err; for (i = 0; map_drivers[i] != NULL; ++i) { err = obex_mime_type_driver_register(map_drivers[i]); if (err < 0) goto failed; } err = obex_service_driver_register(&mas); if (err < 0) goto failed; return 0; failed: for (--i; i >= 0; --i) obex_mime_type_driver_unregister(map_drivers[i]); messages_exit(); return err; } static void mas_exit(void) { int i; obex_service_driver_unregister(&mas); for (i = 0; map_drivers[i] != NULL; ++i) obex_mime_type_driver_unregister(map_drivers[i]); messages_exit(); } OBEX_PLUGIN_DEFINE(mas, mas_init, mas_exit) obexd-0.46/plugins/opp.c0000644000000000000000000001242211755212521012060 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "obex.h" #include "service.h" #include "log.h" #include "manager.h" #include "filesystem.h" #define VCARD_TYPE "text/x-vcard" #define VCARD_FILE CONFIGDIR "/vcard.vcf" #define OPP_CHANNEL 9 #define OPP_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " static void *opp_connect(struct obex_session *os, int *err) { manager_register_transfer(os); if (err) *err = 0; return NULL; } static void opp_progress(struct obex_session *os, void *user_data) { manager_emit_transfer_progress(os); } static int opp_chkput(struct obex_session *os, void *user_data) { char *folder, *name, *path; int32_t time; const char *t; int err; if (obex_get_size(os) == OBJECT_SIZE_DELETE) return -ENOSYS; t = obex_get_name(os); if (t != NULL && !is_filename(t)) return -EBADR; if (obex_option_auto_accept()) { folder = g_strdup(obex_option_root_folder()); name = g_strdup(obex_get_name(os)); goto skip_auth; } time = 0; err = manager_request_authorization(os, time, &folder, &name); if (err < 0) return -EPERM; if (folder == NULL) folder = g_strdup(obex_option_root_folder()); if (name == NULL) name = g_strdup(obex_get_name(os)); skip_auth: if (name == NULL || strlen(name) == 0) { err = -EBADR; goto failed; } if (g_strcmp0(name, obex_get_name(os)) != 0) obex_set_name(os, name); path = g_build_filename(folder, name, NULL); err = obex_put_stream_start(os, path); g_free(path); if (err < 0) goto failed; manager_emit_transfer_started(os); failed: g_free(folder); g_free(name); return err; } static int opp_put(struct obex_session *os, void *user_data) { const char *name = obex_get_name(os); const char *folder = obex_option_root_folder(); if (folder == NULL) return -EPERM; if (name == NULL) return -EBADR; return 0; } static int opp_get(struct obex_session *os, void *user_data) { const char *type; if (obex_get_name(os)) return -EPERM; type = obex_get_type(os); if (type == NULL) return -EPERM; if (g_ascii_strcasecmp(type, VCARD_TYPE) == 0) { if (obex_get_stream_start(os, VCARD_FILE) < 0) return -ENOENT; } else return -EPERM; return 0; } static void opp_disconnect(struct obex_session *os, void *user_data) { manager_unregister_transfer(os); } static void opp_reset(struct obex_session *os, void *user_data) { manager_emit_transfer_completed(os); } static struct obex_service_driver driver = { .name = "Object Push server", .service = OBEX_OPP, .channel = OPP_CHANNEL, .port = OBEX_PORT_RANDOM, .record = OPP_RECORD, .connect = opp_connect, .progress = opp_progress, .disconnect = opp_disconnect, .get = opp_get, .put = opp_put, .chkput = opp_chkput, .reset = opp_reset }; static int opp_init(void) { return obex_service_driver_register(&driver); } static void opp_exit(void) { obex_service_driver_unregister(&driver); } OBEX_PLUGIN_DEFINE(opp, opp_init, opp_exit) obexd-0.46/plugins/messages.h0000644000000000000000000002165611755212521013107 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include /* Those are used by backend to notify transport plugin which properties did it * send. */ #define PMASK_SUBJECT 0x0001 #define PMASK_DATETIME 0x0002 #define PMASK_SENDER_NAME 0x0004 #define PMASK_SENDER_ADDRESSING 0x0008 #define PMASK_RECIPIENT_NAME 0x0010 #define PMASK_RECIPIENT_ADDRESSING 0x0020 #define PMASK_TYPE 0x0040 #define PMASK_SIZE 0x0080 #define PMASK_RECEPTION_STATUS 0x0100 #define PMASK_TEXT 0x0200 #define PMASK_ATTACHMENT_SIZE 0x0400 #define PMASK_PRIORITY 0x0800 #define PMASK_READ 0x1000 #define PMASK_SENT 0x2000 #define PMASK_PROTECTED 0x4000 #define PMASK_REPLYTO_ADDRESSING 0x8000 /* This one is used in a response to GetMessagesListing. Use PMASK_* values to * notify the plugin which members are actually set. Backend shall not omit * properties required by MAP specification (subject, datetime, * recipient_addressing, type, size, reception_status, attachment_size) unless * ordered by PARAMETERMASK. Boolean values should be probably * always sent (need checking). Handle is mandatory. Plugin will filter out any * properties that were not wanted by MCE. * * Handle shall be set to hexadecimal representation with upper-case letters. No * prefix shall be appended and without no zeros. This corresponds to PTS * behaviour described in comments to the MAP specification. * * The rest of char * fields shall be set according to the MAP specification * rules. */ struct messages_message { uint32_t mask; char *handle; char *subject; char *datetime; char *sender_name; char *sender_addressing; char *replyto_addressing; char *recipient_name; char *recipient_addressing; char *type; char *reception_status; char *size; char *attachment_size; gboolean text; gboolean read; gboolean sent; gboolean protect; gboolean priority; }; /* Type of message event to be delivered to MNS server */ enum messages_event_type { MET_NEW_MESSAGE, MET_DELIVERY_SUCCESS, MET_SENDING_SUCCESS, MET_DELIVERY_FAILURE, MET_SENDING_FAILURE, MET_MEMORY_FULL, MET_MEMORY_AVAILABLE, MET_MESSAGE_DELETED, MET_MESSAGE_SHIFT }; /* Data for sending MNS notification. Handle shall be formatted as described in * messages_message. */ struct messages_event { enum messages_event_type type; uint8_t instance_id; char *handle; char *folder; char *old_folder; char *msg_type; }; /* parameter_mask: |-ed PMASK_* values * See MAP specification for the rest. */ struct messages_filter { uint32_t parameter_mask; uint8_t type; const char *period_begin; const char *period_end; uint8_t read_status; const char *recipient; const char *originator; uint8_t priority; }; /* This is called once after server starts. * * Returns value less than zero if error. This will prevent MAP plugin from * starting. */ int messages_init(void); /* This gets called right before server finishes */ void messages_exit(void); /* Starts a new MAP session. * * session: variable to store pointer to backend session data. This one shall be * passed to all in-session calls. * * If session start succeeded, backend shall return 0. Otherwise the error value * will be sent as a response to OBEX connect. */ int messages_connect(void **session); /* Closes a MAP session. * * This call should free buffer reserved by messages_connect. */ void messages_disconnect(void *session); /****************************************************************************** * NOTE on callbacks. * * All functions requiring callbacks have to call them asynchronously. * 'user_data' is for passing arbitrary user data. * * Functions for GetMessagesListing, GetFolder listing and GetMessage call their * callbacks multiple times - one for each listing entry or message body chunk. * To indicate the end of operation backend must call callback with the data * pointer parameter set to NULL. * * If err == -EAGAIN the transport * plugin does not wake IO. * * Keep in mind that application parameters has to be send first. Therefore the * first time err == 0 and thus sending is started, callback will use provided * parameters (e.g. size in case of folder listing) to build applications * parameters header used in response. In any other case those parameters will * be ignored. * * If err != 0 && err != -EAGAIN, the operation is finished immediately and err * value is used to set the error code in OBEX response. ******************************************************************************/ /* Registers for messaging events notifications. * * session: Backend session. * send_event: Function that will be called to indicate a new event. * * To unregister currently registered notifications, call this with send_event * set to NULL. */ int messages_set_notification_registration(void *session, void (*send_event)(void *session, const struct messages_event *event, void *user_data), void *user_data); /* Changes current directory. * * session: Backend session. * name: Subdirectory to go to. If empty or null and cdup is false, go to the * root directory. * cdup: If true, go up one level first. */ int messages_set_folder(void *session, const char *name, gboolean cdup); /* Retrieves subdirectories listing from a current directory. * * session: Backend session. * name: Optional subdirectory name (not strictly required by MAP). * max: Maximum number of entries to retrieve. * offset: Offset of the first entry. * size: Total size of listing to be returned. * * Callback shall be called for every entry of the listing. 'name' is the * subdirectory name. */ typedef void (*messages_folder_listing_cb)(void *session, int err, uint16_t size, const char *name, void *user_data); int messages_get_folder_listing(void *session, const char *name, uint16_t max, uint16_t offset, messages_folder_listing_cb callback, void *user_data); /* Retrieves messages listing from a current directory. * * session: Backend session. * name: Optional subdirectory name. * max: Maximum number of entries to retrieve. * filter: Filter to apply on returned message listing. * size: Total size of listing to be returned. * newmsg: Indicates presence of unread messages. * * Callback shall be called for every entry of the listing, giving message data * in 'message'. */ typedef void (*messages_get_messages_listing_cb)(void *session, int err, uint16_t size, gboolean newmsg, const struct messages_message *message, void *user_data); int messages_get_messages_listing(void *session, const char *name, uint16_t max, uint16_t offset, const struct messages_filter *filter, messages_get_messages_listing_cb callback, void *user_data); #define MESSAGES_ATTACHMENT (1 << 0) #define MESSAGES_UTF8 (1 << 1) #define MESSAGES_FRACTION (1 << 2) #define MESSAGES_NEXT (1 << 3) /* Retrieves bMessage object (see MAP specification, ch. 3.1.3) of a given * message. * * session: Backend session. * handle: Handle of the message to retrieve. * flags: or-ed mask of following: * MESSAGES_ATTACHMENT: Selects whether or not attachments (if any) are to * be included. * MESSAGES_UTF8: If true, convert message to utf-8. Otherwise use native * encoding. * MESSAGES_FRACTION: If true, deliver fractioned message. * MESSAGES_NEXT: If fraction is true this indicates whether to retrieve * first fraction * or the next one. * fmore: Indicates whether next fraction is available. * chunk: chunk of bMessage body * * Callback allows for returning bMessage in chunks. */ typedef void (*messages_get_message_cb)(void *session, int err, gboolean fmore, const char *chunk, void *user_data); int messages_get_message(void *session, const char *handle, unsigned long flags, messages_get_message_cb callback, void *user_data); /* Informs Message Server to Update Inbox via network. * * session: Backend session. * user_data: User data if any to be sent. * Callback shall be called for every update inbox request recieved from MCE. */ typedef void (*messages_update_inbox_cb)(void *session, int err, void *user_data); int messages_update_inbox(void *session, messages_update_inbox_cb callback, void *user_data); /* Aborts currently pending request. * * session: Backend session. */ void messages_abort(void *session); obexd-0.46/plugins/phonebook.h0000644000000000000000000001216411755212521013256 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #define EOL "\r\n" #define VCARD_LISTING_BEGIN \ "" EOL\ "" EOL\ "" EOL #define VCARD_LISTING_ELEMENT "" EOL #define VCARD_LISTING_END "" struct apparam_field { /* list and pull attributes */ uint16_t maxlistcount; uint16_t liststartoffset; /* pull and vcard attributes */ uint64_t filter; uint8_t format; /* list attributes only */ uint8_t order; uint8_t searchattrib; uint8_t *searchval; }; /* * Interface between the PBAP core and backends to retrieve * all contacts that match the application parameters rules. * Contacts will be returned in the vcard format. */ typedef void (*phonebook_cb) (const char *buffer, size_t bufsize, int vcards, int missed, gboolean lastpart, void *user_data); /* * Interface between the PBAP core and backends to * append a new entry in the PBAP folder cache. */ #define PHONEBOOK_INVALID_HANDLE 0xffffffff typedef void (*phonebook_entry_cb) (const char *id, uint32_t handle, const char *name, const char *sound, const char *tel, void *user_data); /* * After notify all entries to PBAP core, the backend * needs to notify that the operation has finished. */ typedef void (*phonebook_cache_ready_cb) (void *user_data); int phonebook_init(void); void phonebook_exit(void); /* * Changes the current folder in the phonebook back-end. The PBAP core * doesn't validate or restrict the possible values for the folders, * allowing non-standard backends implementation which doesn't follow * the PBAP virtual folder architecture. Validate the folder's name * is responsibility of the back-ends. */ char *phonebook_set_folder(const char *current_folder, const char *new_folder, uint8_t flags, int *err); /* * phonebook_pull should be used only to prepare pull request - prepared * request data is returned by this function. Start of fetching data from * back-end will be done only after calling phonebook_pull_read with this * returned request given as a parameter. * * phonebook_req_finalize MUST always be used to free associated resources. */ void *phonebook_pull(const char *name, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err); /* * phonebook_pull_read should be used to start getting results from back-end. * The back-end can return data as one response or can return it many parts. * After obtaining one part, PBAP core need to call phonebook_pull_read with * the same request again to get more results from back-end. * The back-end MUST return only the content based on the application * parameters requested by the client. * * Returns error code or 0 in case of success */ int phonebook_pull_read(void *request); /* * Function used to retrieve a contact from the backend. Only contacts * found in the cache are requested to the back-ends. The back-end MUST * return only the content based on the application parameters requested * by the client. * * Return value is a pointer to asynchronous request to phonebook back-end. * phonebook_req_finalize MUST always be used to free associated resources. */ void *phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err); /* * PBAP core will keep the contacts cache per folder. SetPhoneBook or * PullvCardListing can invalidate the cache if the current folder changes. * Cache will store only the necessary information required to reply to * PullvCardListing request and verify if a given contact belongs to the * source. * * Return value is a pointer to asynchronous request to phonebook back-end. * phonebook_req_finalize MUST always be used to free associated resources. */ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, phonebook_cache_ready_cb ready_cb, void *user_data, int *err); /* * Finalizes request to phonebook back-end and deallocates associated * resources. Operation is canceled if not completed. This function MUST * always be used after any of phonebook_pull, phonebook_get_entry, and * phonebook_create_cache invoked. * * request is a pointer to asynchronous operation returned by phonebook_pull, * phonebook_get_entry, and phonebook_create_cache. */ void phonebook_req_finalize(void *request); obexd-0.46/plugins/messages-tracker.c0000644000000000000000000001575011755212521014531 00000000000000/* * * OBEX Server * * Copyright (C) 2010-2011 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "messages.h" struct message_folder { char *name; GSList *subfolders; char *query; }; struct session { char *cwd; struct message_folder *folder; char *name; uint16_t max; uint16_t offset; void *user_data; void (*folder_list_cb)(void *session, int err, uint16_t size, const char *name, void *user_data); }; static struct message_folder *folder_tree = NULL; static struct message_folder *get_folder(const char *folder) { GSList *folders = folder_tree->subfolders; struct message_folder *last = NULL; char **path; int i; if (g_strcmp0(folder, "/") == 0) return folder_tree; path = g_strsplit(folder, "/", 0); for (i = 1; path[i] != NULL; i++) { gboolean match_found = FALSE; GSList *l; for (l = folders; l != NULL; l = g_slist_next(l)) { struct message_folder *folder = l->data; if (g_strcmp0(folder->name, path[i]) == 0) { match_found = TRUE; last = l->data; folders = folder->subfolders; break; } } if (!match_found) { g_strfreev(path); return NULL; } } g_strfreev(path); return last; } static struct message_folder *create_folder(const char *name, const char *query) { struct message_folder *folder = g_new0(struct message_folder, 1); folder->name = g_strdup(name); folder->query = g_strdup(query); return folder; } static void destroy_folder_tree(void *root) { struct message_folder *folder = root; GSList *tmp, *next; if (folder == NULL) return; g_free(folder->name); g_free(folder->query); tmp = folder->subfolders; while (tmp != NULL) { next = g_slist_next(tmp); destroy_folder_tree(tmp->data); tmp = next; } g_slist_free(folder->subfolders); g_free(folder); } static void create_folder_tree(void) { struct message_folder *parent, *child; folder_tree = create_folder("/", "FILTER (!BOUND(?msg))"); parent = create_folder("telecom", "FILTER (!BOUND(?msg))"); folder_tree->subfolders = g_slist_append(folder_tree->subfolders, parent); child = create_folder("msg", "FILTER (!BOUND(?msg))"); parent->subfolders = g_slist_append(parent->subfolders, child); parent = child; child = create_folder("inbox", "?msg nmo:isSent \"false\" ; " "nmo:isDeleted \"false\" ; " "nmo:isDraft \"false\". "); parent->subfolders = g_slist_append(parent->subfolders, child); child = create_folder("sent", "?msg nmo:isDeleted \"false\" ; " "nmo:isSent \"true\" . "); parent->subfolders = g_slist_append(parent->subfolders, child); child = create_folder("deleted", "?msg nmo:isDeleted \"true\" . "); parent->subfolders = g_slist_append(parent->subfolders, child); } int messages_init(void) { create_folder_tree(); return 0; } void messages_exit(void) { destroy_folder_tree(folder_tree); } int messages_connect(void **s) { struct session *session = g_new0(struct session, 1); session->cwd = g_strdup("/"); session->folder = folder_tree; *s = session; return 0; } void messages_disconnect(void *s) { struct session *session = s; g_free(session->cwd); g_free(session); } int messages_set_notification_registration(void *session, void (*send_event)(void *session, const struct messages_event *event, void *user_data), void *user_data) { return -ENOSYS; } int messages_set_folder(void *s, const char *name, gboolean cdup) { struct session *session = s; char *newrel = NULL; char *newabs; char *tmp; if (name && (strchr(name, '/') || strcmp(name, "..") == 0)) return -EBADR; if (cdup) { if (session->cwd[0] == 0) return -ENOENT; newrel = g_path_get_dirname(session->cwd); /* We use empty string for indication of the root directory */ if (newrel[0] == '.' && newrel[1] == 0) newrel[0] = 0; } tmp = newrel; if (!cdup && (!name || name[0] == 0)) newrel = g_strdup(""); else newrel = g_build_filename(newrel ? newrel : session->cwd, name, NULL); g_free(tmp); if (newrel[0] != '/') newabs = g_build_filename("/", newrel, NULL); else newabs = g_strdup(newrel); session->folder = get_folder(newabs); if (session->folder == NULL) { g_free(newrel); g_free(newabs); return -ENOENT; } g_free(newrel); g_free(session->cwd); session->cwd = newabs; return 0; } static gboolean async_get_folder_listing(void *s) { struct session *session = s; gboolean count = FALSE; int folder_count = 0; char *path = NULL; struct message_folder *folder; GSList *dir; if (session->name && strchr(session->name, '/') != NULL) goto done; path = g_build_filename(session->cwd, session->name, NULL); if (path == NULL || strlen(path) == 0) goto done; folder = get_folder(path); if (folder == NULL) goto done; if (session->max == 0) { session->max = 0xffff; session->offset = 0; count = TRUE; } for (dir = folder->subfolders; dir && (folder_count - session->offset) < session->max; folder_count++, dir = g_slist_next(dir)) { struct message_folder *dir_data = dir->data; if (count == FALSE && session->offset <= folder_count) session->folder_list_cb(session, -EAGAIN, 0, dir_data->name, session->user_data); } done: session->folder_list_cb(session, 0, folder_count, NULL, session->user_data); g_free(path); g_free(session->name); return FALSE; } int messages_get_folder_listing(void *s, const char *name, uint16_t max, uint16_t offset, messages_folder_listing_cb callback, void *user_data) { struct session *session = s; session->name = g_strdup(name); session->max = max; session->offset = offset; session->folder_list_cb = callback; session->user_data = user_data; g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, async_get_folder_listing, session, NULL); return 0; } int messages_get_messages_listing(void *session, const char *name, uint16_t max, uint16_t offset, const struct messages_filter *filter, messages_get_messages_listing_cb callback, void *user_data) { return -ENOSYS; } int messages_get_message(void *session, const char *handle, unsigned long flags, messages_get_message_cb callback, void *user_data) { return -ENOSYS; } int messages_update_inbox(void *session, messages_update_inbox_cb callback, void *user_data) { return -ENOSYS; } void messages_abort(void *session) { } obexd-0.46/plugins/vcard.c0000644000000000000000000005407411755212521012372 00000000000000/* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include "vcard.h" #define ADDR_FIELD_AMOUNT 7 #define LEN_MAX 128 #define TYPE_INTERNATIONAL 145 #define PHONEBOOK_FLAG_CACHED 0x1 #define FILTER_VERSION (1 << 0) #define FILTER_FN (1 << 1) #define FILTER_N (1 << 2) #define FILTER_PHOTO (1 << 3) #define FILTER_BDAY (1 << 4) #define FILTER_ADR (1 << 5) #define FILTER_LABEL (1 << 6) #define FILTER_TEL (1 << 7) #define FILTER_EMAIL (1 << 8) #define FILTER_MAILER (1 << 9) #define FILTER_TZ (1 << 10) #define FILTER_GEO (1 << 11) #define FILTER_TITLE (1 << 12) #define FILTER_ROLE (1 << 13) #define FILTER_LOGO (1 << 14) #define FILTER_AGENT (1 << 15) #define FILTER_ORG (1 << 16) #define FILTER_NOTE (1 << 17) #define FILTER_REV (1 << 18) #define FILTER_SOUND (1 << 19) #define FILTER_URL (1 << 20) #define FILTER_UID (1 << 21) #define FILTER_KEY (1 << 22) #define FILTER_NICKNAME (1 << 23) #define FILTER_CATEGORIES (1 << 24) #define FILTER_PROID (1 << 25) #define FILTER_CLASS (1 << 26) #define FILTER_SORT_STRING (1 << 27) #define FILTER_X_IRMC_CALL_DATETIME (1 << 28) #define FORMAT_VCARD21 0x00 #define FORMAT_VCARD30 0x01 #define QP_LINE_LEN 75 #define QP_CHAR_LEN 3 #define QP_CR 0x0D #define QP_LF 0x0A #define QP_ESC 0x5C #define QP_SOFT_LINE_BREAK "=" #define QP_SELECT "\n!\"#$=@[\\]^`{|}~" #define ASCII_LIMIT 0x7F /* according to RFC 2425, the output string may need folding */ static void vcard_printf(GString *str, const char *fmt, ...) { char buf[1024]; va_list ap; int len_temp, line_number, i; unsigned int line_delimit = 75; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); line_number = strlen(buf) / line_delimit + 1; for (i = 0; i < line_number; i++) { len_temp = MIN(line_delimit, strlen(buf) - line_delimit * i); g_string_append_len(str, buf + line_delimit * i, len_temp); if (i != line_number - 1) g_string_append(str, "\r\n "); } g_string_append(str, "\r\n"); } /* According to RFC 2426, we need escape following characters: * '\n', '\r', ';', ',', '\'. */ static void add_slash(char *dest, const char *src, int len_max, int len) { int i, j; for (i = 0, j = 0; i < len && j + 1 < len_max; i++, j++) { /* filling dest buffer - last field need to be reserved * for '\0'*/ switch (src[i]) { case '\n': if (j + 2 >= len_max) /* not enough space in the buffer to put char * preceded with escaping sequence (and '\0' in * the end) */ goto done; dest[j++] = '\\'; dest[j] = 'n'; break; case '\r': if (j + 2 >= len_max) goto done; dest[j++] = '\\'; dest[j] = 'r'; break; case '\\': case ';': case ',': if (j + 2 >= len_max) goto done; dest[j++] = '\\'; default: dest[j] = src[i]; break; } } done: dest[j] = 0; } static void escape_semicolon(char *dest, const char *src, int len_max, int len) { int i, j; for (i = 0, j = 0; i < len && j + 1 < len_max; i++, j++) { if (src[i] == ';') { if (j + 2 >= len_max) break; dest[j++] = '\\'; } dest[j] = src[i]; } dest[j] = 0; } static void set_escape(uint8_t format, char *dest, const char *src, int len_max, int len) { if (format == FORMAT_VCARD30) add_slash(dest, src, len_max, len); else if (format == FORMAT_VCARD21) escape_semicolon(dest, src, len_max, len); } static void get_escaped_fields(uint8_t format, char **fields, ...) { va_list ap; GString *line; char *field; char escaped[LEN_MAX]; va_start(ap, fields); line = g_string_new(""); for (field = va_arg(ap, char *); field; ) { set_escape(format, escaped, field, LEN_MAX, strlen(field)); g_string_append(line, escaped); field = va_arg(ap, char *); if (field) g_string_append(line, ";"); } va_end(ap); *fields = g_string_free(line, FALSE); } static gboolean set_qp_encoding(char c) { unsigned char q = c; if (strchr(QP_SELECT, q) != NULL) return TRUE; if (q < '!' || q > '~') return TRUE; return FALSE; } static void append_qp_break_line(GString *vcards, size_t *limit) { /* Quoted Printable lines of text must be limited to less than 76 * characters and terminated by Quoted Printable softline break * sequence of "=" (if some more characters left) */ g_string_append(vcards, QP_SOFT_LINE_BREAK); g_string_append(vcards, "\r\n "); *limit = QP_LINE_LEN - 1; } static void append_qp_ascii(GString *vcards, size_t *limit, char c) { if (*limit == 0) append_qp_break_line(vcards, limit); g_string_append_c(vcards, c); --*limit; } static void append_qp_hex(GString *vcards, size_t *limit, char c) { if (*limit < QP_CHAR_LEN) append_qp_break_line(vcards, limit); g_string_append_printf(vcards, "=%2.2X", (unsigned char) c); *limit -= QP_CHAR_LEN; } static void append_qp_new_line(GString *vcards, size_t *limit) { /* Multiple lines of text are separated with a Quoted Printable CRLF * sequence of "=0D" followed by "=0A" followed by a Quoted Printable * softline break sequence of "=" */ append_qp_hex(vcards, limit, QP_CR); append_qp_hex(vcards, limit, QP_LF); append_qp_break_line(vcards, limit); } static gboolean utf8_select(const char *field) { const char *pos; if (g_utf8_validate(field, -1, NULL) == FALSE) return FALSE; for (pos = field; *pos != '\0'; pos = g_utf8_next_char(pos)) { /* Test for non-standard UTF-8 character (out of range * standard ASCII set), composed of more than single byte * and represented by 32-bit value greater than 0x7F */ if (g_utf8_get_char(pos) > ASCII_LIMIT) return TRUE; } return FALSE; } static void vcard_qp_print_encoded(GString *vcards, const char *desc, ...) { const char *field, *charset = ""; const char *encoding = ";ENCODING=QUOTED-PRINTABLE"; size_t limit, param_len; va_list ap; va_start(ap, desc); for (field = va_arg(ap, char *); field; field = va_arg(ap, char *)) { if (utf8_select(field) == TRUE) { charset = ";CHARSET=UTF-8"; break; } } va_end(ap); vcard_printf(vcards, "%s%s%s:", desc, encoding, charset); g_string_truncate(vcards, vcards->len - 2); param_len = strlen(desc) + strlen(encoding) + strlen(charset) + 1; limit = QP_LINE_LEN - param_len; va_start(ap, desc); for (field = va_arg(ap, char *); field != NULL; ) { size_t i, size = strlen(field); for (i = 0; i < size; ++i) { if (set_qp_encoding(field[i])) { if (field[i] == '\n') { append_qp_new_line(vcards, &limit); continue; } append_qp_hex(vcards, &limit, field[i]); } else { /* According to vCard 2.1 spec. semicolons in * property parameter value must be escaped */ if (field[i] == ';') append_qp_hex(vcards, &limit, QP_ESC); append_qp_ascii(vcards, &limit, field[i]); } } field = va_arg(ap, char *); if (field) append_qp_ascii(vcards, &limit, ';'); } va_end(ap); g_string_append(vcards, "\r\n"); } static gboolean select_qp_encoding(uint8_t format, ...) { char *field; va_list ap; if (format != FORMAT_VCARD21) return FALSE; va_start(ap, format); for (field = va_arg(ap, char *); field; field = va_arg(ap, char *)) { int i; unsigned char c; if (strpbrk(field, QP_SELECT)) { va_end(ap); return TRUE; } /* Quoted Printable encoding is selected if there is * a character, which value is out of range standard * ASCII set, since it may be a part of some * non-standard character such as specified by UTF-8 */ for (i = 0; (c = field[i]) != '\0'; ++i) { if (c > ASCII_LIMIT) { va_end(ap); return TRUE; } } } va_end(ap); return FALSE; } static void vcard_printf_begin(GString *vcards, uint8_t format) { vcard_printf(vcards, "BEGIN:VCARD"); if (format == FORMAT_VCARD30) vcard_printf(vcards, "VERSION:3.0"); else if (format == FORMAT_VCARD21) vcard_printf(vcards, "VERSION:2.1"); } /* check if there is at least one contact field with personal data present */ static gboolean contact_fields_present(struct phonebook_contact * contact) { if (contact->family && strlen(contact->family) > 0) return TRUE; if (contact->given && strlen(contact->given) > 0) return TRUE; if (contact->additional && strlen(contact->additional) > 0) return TRUE; if (contact->prefix && strlen(contact->prefix) > 0) return TRUE; if (contact->suffix && strlen(contact->suffix) > 0) return TRUE; /* none of the personal data fields are present*/ return FALSE; } static void vcard_printf_name(GString *vcards, uint8_t format, struct phonebook_contact *contact) { char *fields; if (contact_fields_present(contact) == FALSE) { /* If fields are empty, add only 'N:' as parameter. * This is crucial for some devices (Nokia BH-903) which * have problems with history listings and can't determine * that a parameter is really empty if there are unnecessary * characters after 'N:' (e.g. 'N:;;;;'). * We need to add only'N:' param - without semicolons. */ vcard_printf(vcards, "N:"); return; } if (select_qp_encoding(format, contact->family, contact->given, contact->additional, contact->prefix, contact->suffix, NULL)) { vcard_qp_print_encoded(vcards, "N", contact->family, contact->given, contact->additional, contact->prefix, contact->suffix, NULL); return; } get_escaped_fields(format, &fields, contact->family, contact->given, contact->additional, contact->prefix, contact->suffix, NULL); vcard_printf(vcards, "N:%s", fields); g_free(fields); } static void vcard_printf_fullname(GString *vcards, uint8_t format, const char *text) { char field[LEN_MAX]; if (!text || strlen(text) == 0) { vcard_printf(vcards, "FN:"); return; } if (select_qp_encoding(format, text, NULL)) { vcard_qp_print_encoded(vcards, "FN", text, NULL); return; } set_escape(format, field, text, LEN_MAX, strlen(text)); vcard_printf(vcards, "FN:%s", field); } static void vcard_printf_number(GString *vcards, uint8_t format, const char *number, int type, enum phonebook_number_type category) { const char *intl = "", *category_string = ""; char buf[LEN_MAX], field[LEN_MAX]; /* TEL is a mandatory field, include even if empty */ if (!number || !strlen(number) || !type) { vcard_printf(vcards, "TEL:"); return; } switch (category) { case TEL_TYPE_HOME: if (format == FORMAT_VCARD21) category_string = "HOME;VOICE"; else if (format == FORMAT_VCARD30) category_string = "TYPE=HOME;TYPE=VOICE"; break; case TEL_TYPE_MOBILE: if (format == FORMAT_VCARD21) category_string = "CELL;VOICE"; else if (format == FORMAT_VCARD30) category_string = "TYPE=CELL;TYPE=VOICE"; break; case TEL_TYPE_FAX: if (format == FORMAT_VCARD21) category_string = "FAX"; else if (format == FORMAT_VCARD30) category_string = "TYPE=FAX"; break; case TEL_TYPE_WORK: if (format == FORMAT_VCARD21) category_string = "WORK;VOICE"; else if (format == FORMAT_VCARD30) category_string = "TYPE=WORK;TYPE=VOICE"; break; case TEL_TYPE_OTHER: if (format == FORMAT_VCARD21) category_string = "OTHER;VOICE"; else if (format == FORMAT_VCARD30) category_string = "TYPE=OTHER;TYPE=VOICE"; break; } if ((type == TYPE_INTERNATIONAL) && (number[0] != '+')) intl = "+"; snprintf(field, sizeof(field), "%s%s", intl, number); if (select_qp_encoding(format, number, NULL)) { snprintf(buf, sizeof(buf), "TEL;%s", category_string); vcard_qp_print_encoded(vcards, buf, field, NULL); return; } vcard_printf(vcards, "TEL;%s:%s", category_string, field); } static void vcard_printf_tag(GString *vcards, uint8_t format, const char *tag, const char *category, const char *fld) { int len; char *separator = "", *type = ""; char buf[LEN_MAX], field[LEN_MAX]; if (tag == NULL || strlen(tag) == 0) return; if (fld == NULL || (len = strlen(fld)) == 0) { vcard_printf(vcards, "%s:", tag); return; } if (category && strlen(category)) { separator = ";"; if (format == FORMAT_VCARD30) type = "TYPE="; } else { category = ""; } snprintf(buf, LEN_MAX, "%s%s%s%s", tag, separator, type, category); if (select_qp_encoding(format, fld, NULL)) { vcard_qp_print_encoded(vcards, buf, fld, NULL); return; } set_escape(format, field, fld, LEN_MAX, len); vcard_printf(vcards, "%s:%s", buf, field); } static void vcard_printf_email(GString *vcards, uint8_t format, const char *address, enum phonebook_field_type category) { const char *category_string = ""; char buf[LEN_MAX], field[LEN_MAX]; int len = 0; if (!address || !(len = strlen(address))) { vcard_printf(vcards, "EMAIL:"); return; } switch (category) { case FIELD_TYPE_HOME: if (format == FORMAT_VCARD21) category_string = "INTERNET;HOME"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET;TYPE=HOME"; break; case FIELD_TYPE_WORK: if (format == FORMAT_VCARD21) category_string = "INTERNET;WORK"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET;TYPE=WORK"; break; default: if (format == FORMAT_VCARD21) category_string = "INTERNET"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET;TYPE=OTHER"; } if (select_qp_encoding(format, address, NULL)) { snprintf(buf, sizeof(buf), "EMAIL;%s", category_string); vcard_qp_print_encoded(vcards, buf, address, NULL); return; } set_escape(format, field, address, LEN_MAX, len); vcard_printf(vcards, "EMAIL;%s:%s", category_string, field); } static void vcard_printf_url(GString *vcards, uint8_t format, const char *url, enum phonebook_field_type category) { const char *category_string = ""; char buf[LEN_MAX], field[LEN_MAX]; if (!url || strlen(url) == 0) { vcard_printf(vcards, "URL:"); return; } switch (category) { case FIELD_TYPE_HOME: if (format == FORMAT_VCARD21) category_string = "INTERNET;HOME"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET;TYPE=HOME"; break; case FIELD_TYPE_WORK: if (format == FORMAT_VCARD21) category_string = "INTERNET;WORK"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET;TYPE=WORK"; break; default: if (format == FORMAT_VCARD21) category_string = "INTERNET"; else if (format == FORMAT_VCARD30) category_string = "TYPE=INTERNET"; break; } if (select_qp_encoding(format, url, NULL)) { snprintf(buf, sizeof(buf), "URL;%s", category_string); vcard_qp_print_encoded(vcards, buf, url, NULL); return; } set_escape(format, field, url, LEN_MAX, strlen(url)); vcard_printf(vcards, "URL;%s:%s", category_string, field); } static gboolean org_fields_present(struct phonebook_contact *contact) { if (contact->company && strlen(contact->company)) return TRUE; if (contact->department && strlen(contact->department)) return TRUE; return FALSE; } static void vcard_printf_org(GString *vcards, uint8_t format, struct phonebook_contact *contact) { char *fields; if (org_fields_present(contact) == FALSE) return; if (select_qp_encoding(format, contact->company, contact->department, NULL)) { vcard_qp_print_encoded(vcards, "ORG", contact->company, contact->department, NULL); return; } get_escaped_fields(format, &fields, contact->company, contact->department, NULL); vcard_printf(vcards, "ORG:%s", fields); g_free(fields); } static void vcard_printf_address(GString *vcards, uint8_t format, struct phonebook_addr *address) { char *fields, field_esc[LEN_MAX]; const char *category_string = ""; char buf[LEN_MAX], *address_fields[ADDR_FIELD_AMOUNT]; int i; size_t len; GSList *l; if (!address) { vcard_printf(vcards, "ADR:"); return; } switch (address->type) { case FIELD_TYPE_HOME: if (format == FORMAT_VCARD21) category_string = "HOME"; else if (format == FORMAT_VCARD30) category_string = "TYPE=HOME"; break; case FIELD_TYPE_WORK: if (format == FORMAT_VCARD21) category_string = "WORK"; else if (format == FORMAT_VCARD30) category_string = "TYPE=WORK"; break; default: if (format == FORMAT_VCARD21) category_string = "OTHER"; else if (format == FORMAT_VCARD30) category_string = "TYPE=OTHER"; break; } for (i = 0, l = address->fields; l; l = l->next) address_fields[i++] = l->data; if (select_qp_encoding(format, address_fields[0], address_fields[1], address_fields[2], address_fields[3], address_fields[4], address_fields[5], address_fields[6], NULL)) { snprintf(buf, sizeof(buf), "ADR;%s", category_string); vcard_qp_print_encoded(vcards, buf, address_fields[0], address_fields[1], address_fields[2], address_fields[3], address_fields[4], address_fields[5], address_fields[6], NULL); return; } /* allocate enough memory to insert address fields separated by ';' * and terminated by '\0' */ len = ADDR_FIELD_AMOUNT * LEN_MAX; fields = g_malloc0(len); for (l = address->fields; l; l = l->next) { char *field = l->data; if (field) { set_escape(format, field_esc, field, LEN_MAX, strlen(field)); g_strlcat(fields, field_esc, len); } if (l->next) /* not adding ';' after last addr field */ g_strlcat(fields, ";", len); } vcard_printf(vcards,"ADR;%s:%s", category_string, fields); g_free(fields); } static void vcard_printf_datetime(GString *vcards, uint8_t format, struct phonebook_contact *contact) { const char *type; char buf[LEN_MAX]; switch (contact->calltype) { case CALL_TYPE_MISSED: type = "MISSED"; break; case CALL_TYPE_INCOMING: type = "RECEIVED"; break; case CALL_TYPE_OUTGOING: type = "DIALED"; break; case CALL_TYPE_NOT_A_CALL: default: return; } if (select_qp_encoding(format, contact->datetime, NULL)) { snprintf(buf, sizeof(buf), "X-IRMC-CALL-DATETIME;%s", type); vcard_qp_print_encoded(vcards, buf, contact->datetime, NULL); return; } vcard_printf(vcards, "X-IRMC-CALL-DATETIME;%s:%s", type, contact->datetime); } static void vcard_printf_end(GString *vcards) { vcard_printf(vcards, "END:VCARD"); } void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact, uint64_t filter, uint8_t format) { if (format == FORMAT_VCARD30 && filter) filter |= (FILTER_VERSION | FILTER_FN | FILTER_N | FILTER_TEL); else if (format == FORMAT_VCARD21 && filter) filter |= (FILTER_VERSION | FILTER_N | FILTER_TEL); else filter = (FILTER_VERSION | FILTER_UID | FILTER_N | FILTER_FN | FILTER_TEL | FILTER_EMAIL | FILTER_ADR | FILTER_BDAY | FILTER_NICKNAME | FILTER_URL | FILTER_PHOTO | FILTER_ORG | FILTER_ROLE | FILTER_TITLE | FILTER_X_IRMC_CALL_DATETIME); vcard_printf_begin(vcards, format); if (filter & FILTER_UID && *contact->uid) vcard_printf_tag(vcards, format, "UID", NULL, contact->uid); if (filter & FILTER_N) vcard_printf_name(vcards, format, contact); if (filter & FILTER_FN && (*contact->fullname || format == FORMAT_VCARD30)) vcard_printf_fullname(vcards, format, contact->fullname); if (filter & FILTER_TEL) { GSList *l = contact->numbers; if (g_slist_length(l) == 0) vcard_printf_number(vcards, format, NULL, 1, TEL_TYPE_OTHER); for (; l; l = l->next) { struct phonebook_field *number = l->data; vcard_printf_number(vcards, format, number->text, 1, number->type); } } if (filter & FILTER_EMAIL) { GSList *l = contact->emails; for (; l; l = l->next) { struct phonebook_field *email = l->data; vcard_printf_email(vcards, format, email->text, email->type); } } if (filter & FILTER_ADR) { GSList *l = contact->addresses; for (; l; l = l->next) { struct phonebook_addr *addr = l->data; vcard_printf_address(vcards, format, addr); } } if (filter & FILTER_BDAY && *contact->birthday) vcard_printf_tag(vcards, format, "BDAY", NULL, contact->birthday); if (filter & FILTER_NICKNAME && *contact->nickname) vcard_printf_tag(vcards, format, "NICKNAME", NULL, contact->nickname); if (filter & FILTER_URL) { GSList *l = contact->urls; for (; l; l = l->next) { struct phonebook_field *url = l->data; vcard_printf_url(vcards, format, url->text, url->type); } } if (filter & FILTER_PHOTO && *contact->photo) vcard_printf_tag(vcards, format, "PHOTO", NULL, contact->photo); if (filter & FILTER_ORG) vcard_printf_org(vcards, format, contact); if (filter & FILTER_ROLE && *contact->role) vcard_printf_tag(vcards, format, "ROLE", NULL, contact->role); if (filter & FILTER_TITLE && *contact->title) vcard_printf_tag(vcards, format, "TITLE", NULL, contact->title); if (filter & FILTER_X_IRMC_CALL_DATETIME) vcard_printf_datetime(vcards, format, contact); vcard_printf_end(vcards); } static void field_free(gpointer data) { struct phonebook_field *field = data; g_free(field->text); g_free(field); } void phonebook_addr_free(gpointer addr) { struct phonebook_addr *address = addr; g_slist_free_full(address->fields, g_free); g_free(address); } void phonebook_contact_free(struct phonebook_contact *contact) { if (contact == NULL) return; g_slist_free_full(contact->numbers, field_free); g_slist_free_full(contact->emails, field_free); g_slist_free_full(contact->addresses, phonebook_addr_free); g_slist_free_full(contact->urls, field_free); g_free(contact->uid); g_free(contact->fullname); g_free(contact->given); g_free(contact->family); g_free(contact->additional); g_free(contact->prefix); g_free(contact->suffix); g_free(contact->birthday); g_free(contact->nickname); g_free(contact->photo); g_free(contact->company); g_free(contact->department); g_free(contact->role); g_free(contact->title); g_free(contact->datetime); g_free(contact); } obexd-0.46/plugins/vcard.h0000644000000000000000000000342711755212521012373 00000000000000/* * OBEX Server * * Copyright (C) 2008-2010 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ enum phonebook_number_type { TEL_TYPE_HOME, TEL_TYPE_MOBILE, TEL_TYPE_FAX, TEL_TYPE_WORK, TEL_TYPE_OTHER, }; enum phonebook_field_type { FIELD_TYPE_HOME, FIELD_TYPE_WORK, FIELD_TYPE_OTHER, }; enum phonebook_call_type { CALL_TYPE_NOT_A_CALL, CALL_TYPE_MISSED, CALL_TYPE_INCOMING, CALL_TYPE_OUTGOING, }; struct phonebook_field { char *text; int type; }; struct phonebook_addr { GSList *fields; int type; }; struct phonebook_contact { char *uid; char *fullname; char *given; char *family; char *additional; GSList *numbers; GSList *emails; char *prefix; char *suffix; GSList *addresses; char *birthday; char *nickname; GSList *urls; char *photo; char *company; char *department; char *role; char *title; char *datetime; int calltype; }; void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact, uint64_t filter, uint8_t format); void phonebook_contact_free(struct phonebook_contact *contact); void phonebook_addr_free(gpointer addr); obexd-0.46/plugins/pcsuite.c0000644000000000000000000002627011755212521012744 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "gdbus.h" #include "obexd.h" #include "plugin.h" #include "log.h" #include "obex.h" #include "mimetype.h" #include "service.h" #include "ftp.h" #define PCSUITE_CHANNEL 24 #define PCSUITE_WHO_SIZE 8 #define PCSUITE_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " #define BACKUP_BUS_NAME "com.nokia.backup.plugin" #define BACKUP_PATH "/com/nokia/backup" #define BACKUP_PLUGIN_INTERFACE "com.nokia.backup.plugin" #define BACKUP_DBUS_TIMEOUT (1000 * 60 * 15) static const uint8_t FTP_TARGET[TARGET_SIZE] = { 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; static const uint8_t PCSUITE_WHO[PCSUITE_WHO_SIZE] = { 'P', 'C', ' ', 'S', 'u', 'i', 't', 'e' }; struct pcsuite_session { struct ftp_session *ftp; char *lock_file; int fd; }; static void *pcsuite_connect(struct obex_session *os, int *err) { struct pcsuite_session *pcsuite; struct ftp_session *ftp; int fd; char *filename; DBG(""); ftp = ftp_connect(os, err); if (ftp == NULL) return NULL; filename = g_build_filename(g_get_home_dir(), ".pcsuite", NULL); fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644); if (fd < 0 && errno != EEXIST) { error("open(%s): %s(%d)", filename, strerror(errno), errno); goto fail; } /* Try to remove the file before retrying since it could be that some process left/crash without removing it */ if (fd < 0) { if (remove(filename) < 0) { error("remove(%s): %s(%d)", filename, strerror(errno), errno); goto fail; } fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644); if (fd < 0) { error("open(%s): %s(%d)", filename, strerror(errno), errno); goto fail; } } DBG("%s created", filename); pcsuite = g_new0(struct pcsuite_session, 1); pcsuite->ftp = ftp; pcsuite->lock_file = filename; pcsuite->fd = fd; DBG("session %p created", pcsuite); if (err) *err = 0; return pcsuite; fail: if (ftp) ftp_disconnect(os, ftp); if (err) *err = -errno; g_free(filename); return NULL; } static int pcsuite_get(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); return ftp_get(os, pcsuite->ftp); } static int pcsuite_chkput(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); return ftp_chkput(os, pcsuite->ftp); } static int pcsuite_put(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); return ftp_put(os, pcsuite->ftp); } static int pcsuite_setpath(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); return ftp_setpath(os, pcsuite->ftp); } static int pcsuite_action(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); return ftp_action(os, pcsuite->ftp); } static void pcsuite_disconnect(struct obex_session *os, void *user_data) { struct pcsuite_session *pcsuite = user_data; DBG("%p", pcsuite); if (pcsuite->fd >= 0) close(pcsuite->fd); if (pcsuite->lock_file) { remove(pcsuite->lock_file); g_free(pcsuite->lock_file); } if (pcsuite->ftp) ftp_disconnect(os, pcsuite->ftp); g_free(pcsuite); } static struct obex_service_driver pcsuite = { .name = "Nokia OBEX PC Suite Services", .service = OBEX_PCSUITE, .channel = PCSUITE_CHANNEL, .secure = TRUE, .record = PCSUITE_RECORD, .target = FTP_TARGET, .target_size = TARGET_SIZE, .who = PCSUITE_WHO, .who_size = PCSUITE_WHO_SIZE, .connect = pcsuite_connect, .get = pcsuite_get, .put = pcsuite_put, .chkput = pcsuite_chkput, .setpath = pcsuite_setpath, .action = pcsuite_action, .disconnect = pcsuite_disconnect }; struct backup_object { gchar *cmd; int fd; int oflag; int error_code; mode_t mode; DBusPendingCall *pending_call; DBusConnection *conn; }; static void on_backup_dbus_notify(DBusPendingCall *pending_call, void *user_data) { struct backup_object *obj = user_data; DBusMessage *reply; const char *filename; int error_code; DBG("Notification received for pending call - %s", obj->cmd); reply = dbus_pending_call_steal_reply(pending_call); if (reply && dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32, &error_code, DBUS_TYPE_STRING, &filename, DBUS_TYPE_INVALID)) { obj->error_code = error_code; if (filename) { DBG("Notification - file path = %s, error_code = %d", filename, error_code); if (error_code == 0) obj->fd = open(filename,obj->oflag,obj->mode); } } else DBG("Notification timed out or connection got closed"); if (reply) dbus_message_unref(reply); dbus_pending_call_unref(pending_call); obj->pending_call = NULL; dbus_connection_unref(obj->conn); obj->conn = NULL; if (obj->fd >= 0) { DBG("File opened, setting io flags, cmd = %s", obj->cmd); if (obj->oflag == O_RDONLY) obex_object_set_io_flags(user_data, G_IO_IN, 0); else obex_object_set_io_flags(user_data, G_IO_OUT, 0); } else { DBG("File open error, setting io error, cmd = %s", obj->cmd); obex_object_set_io_flags(user_data, G_IO_ERR, -EPERM); } } static gboolean send_backup_dbus_message(const char *oper, struct backup_object *obj, size_t *size) { DBusConnection *conn; DBusMessage *msg; DBusPendingCall *pending_call; gboolean ret = FALSE; dbus_uint32_t file_size; file_size = size ? *size : 0; conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL); if (conn == NULL) return FALSE; msg = dbus_message_new_method_call(BACKUP_BUS_NAME, BACKUP_PATH, BACKUP_PLUGIN_INTERFACE, "request"); if (msg == NULL) { dbus_connection_unref(conn); return FALSE; } dbus_message_append_args(msg, DBUS_TYPE_STRING, &oper, DBUS_TYPE_STRING, &obj->cmd, DBUS_TYPE_INT32, &file_size, DBUS_TYPE_INVALID); if (strcmp(oper, "open") == 0) { ret = dbus_connection_send_with_reply(conn, msg, &pending_call, BACKUP_DBUS_TIMEOUT); dbus_message_unref(msg); if (ret) { obj->conn = conn; obj->pending_call = pending_call; ret = dbus_pending_call_set_notify(pending_call, on_backup_dbus_notify, obj, NULL); } else dbus_connection_unref(conn); } else { ret = dbus_connection_send(conn, msg, NULL); dbus_message_unref(msg); dbus_connection_unref(conn); } return ret; } static void *backup_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct backup_object *obj = g_new0(struct backup_object, 1); DBG("cmd = %s", name); obj->cmd = g_path_get_basename(name); obj->oflag = oflag; obj->mode = mode; obj->fd = -1; obj->pending_call = NULL; obj->conn = NULL; obj->error_code = 0; if (send_backup_dbus_message("open", obj, size) == FALSE) { g_free(obj); obj = NULL; } if (err) *err = 0; return obj; } static int backup_close(void *object) { struct backup_object *obj = object; size_t size = 0; DBG("cmd = %s", obj->cmd); if (obj->fd != -1) close(obj->fd); if (obj->pending_call) { dbus_pending_call_cancel(obj->pending_call); dbus_pending_call_unref(obj->pending_call); dbus_connection_unref(obj->conn); } send_backup_dbus_message("close", obj, &size); g_free(obj->cmd); g_free(obj); return 0; } static ssize_t backup_read(void *object, void *buf, size_t count) { struct backup_object *obj = object; ssize_t ret = 0; if (obj->pending_call) { DBG("cmd = %s, IN WAITING STAGE", obj->cmd); return -EAGAIN; } if (obj->fd != -1) { DBG("cmd = %s, READING DATA", obj->cmd); ret = read(obj->fd, buf, count); if (ret < 0) ret = -errno; } else { DBG("cmd = %s, PERMANENT FAILURE", obj->cmd); ret = obj->error_code ? -obj->error_code : -ENOENT; } return ret; } static ssize_t backup_write(void *object, const void *buf, size_t count) { struct backup_object *obj = object; ssize_t ret = 0; if (obj->pending_call) { DBG("cmd = %s, IN WAITING STAGE", obj->cmd); return -EAGAIN; } if (obj->fd != -1) { ret = write(obj->fd, buf, count); DBG("cmd = %s, WRITTING", obj->cmd); if (ret < 0) { error("backup: cmd = %s", obj->cmd); ret = -errno; } } else { error("backup: cmd = %s", obj->cmd); ret = obj->error_code ? -obj->error_code : -ENOENT; } return ret; } static int backup_flush(void *object) { DBG("%p", object); return 0; } static struct obex_mime_type_driver backup = { .target = FTP_TARGET, .target_size = TARGET_SIZE, .mimetype = "application/vnd.nokia-backup", .open = backup_open, .close = backup_close, .read = backup_read, .write = backup_write, .flush = backup_flush, }; static int pcsuite_init(void) { int err; err = obex_service_driver_register(&pcsuite); if (err < 0) return err; err = obex_mime_type_driver_register(&backup); if (err < 0) obex_service_driver_unregister(&pcsuite); return err; } static void pcsuite_exit(void) { obex_mime_type_driver_unregister(&backup); obex_service_driver_unregister(&pcsuite); } OBEX_PLUGIN_DEFINE(pcsuite, pcsuite_init, pcsuite_exit) obexd-0.46/plugins/ftp.c0000644000000000000000000002536611755212521012066 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" #include "obex.h" #include "manager.h" #include "mimetype.h" #include "service.h" #include "ftp.h" #include "filesystem.h" #define LST_TYPE "x-obex/folder-listing" #define CAP_TYPE "x-obex/capability" #define FTP_CHANNEL 10 #define FTP_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " static const uint8_t FTP_TARGET[TARGET_SIZE] = { 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; struct ftp_session { struct obex_session *os; char *folder; }; static void set_folder(struct ftp_session *ftp, const char *new_folder) { DBG("%p folder %s", ftp, new_folder); g_free(ftp->folder); ftp->folder = new_folder ? g_strdup(new_folder) : NULL; } static int get_by_type(struct ftp_session *ftp, const char *type) { struct obex_session *os = ftp->os; const char *capability = obex_option_capability(); const char *name = obex_get_name(os); char *path; int err; DBG("%p name %s type %s", ftp, name, type); if (type == NULL && name == NULL) return -EBADR; if (type != NULL && g_ascii_strcasecmp(type, CAP_TYPE) == 0) return obex_get_stream_start(os, capability); if (name != NULL && !is_filename(name)) return -EBADR; path = g_build_filename(ftp->folder, name, NULL); err = obex_get_stream_start(os, path); g_free(path); return err; } void *ftp_connect(struct obex_session *os, int *err) { struct ftp_session *ftp; const char *root_folder; DBG(""); root_folder = obex_option_root_folder(); manager_register_session(os); ftp = g_new0(struct ftp_session, 1); set_folder(ftp, root_folder); ftp->os = os; if (err) *err = 0; DBG("session %p created", ftp); return ftp; } int ftp_get(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *type = obex_get_type(os); int ret; DBG("%p", ftp); if (ftp->folder == NULL) return -ENOENT; ret = get_by_type(ftp, type); if (ret < 0) return ret; return 0; } static int ftp_delete(struct ftp_session *ftp, const char *name) { char *path; int ret = 0; DBG("%p name %s", ftp, name); if (!(ftp->folder && name)) return -EINVAL; path = g_build_filename(ftp->folder, name, NULL); if (obex_remove(ftp->os, path) < 0) ret = -errno; g_free(path); return ret; } int ftp_chkput(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *name = obex_get_name(os); char *path; int ret; DBG("%p name %s", ftp, name); if (name == NULL) return -EBADR; if (!is_filename(name)) return -EBADR; if (obex_get_size(os) == OBJECT_SIZE_DELETE) return 0; path = g_build_filename(ftp->folder, name, NULL); ret = obex_put_stream_start(os, path); g_free(path); return ret; } int ftp_put(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *name = obex_get_name(os); ssize_t size = obex_get_size(os); DBG("%p name %s size %zd", ftp, name, size); if (ftp->folder == NULL) return -EPERM; if (name == NULL) return -EBADR; if (!is_filename(name)) return -EBADR; if (size == OBJECT_SIZE_DELETE) return ftp_delete(ftp, name); return 0; } int ftp_setpath(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *root_folder, *name; const uint8_t *nonhdr; char *fullname; struct stat dstat; gboolean root; int err; if (obex_get_non_header_data(os, &nonhdr) != 2) { error("Set path failed: flag and constants not found!"); return -EBADMSG; } name = obex_get_name(os); root_folder = obex_option_root_folder(); root = g_str_equal(root_folder, ftp->folder); DBG("%p name %s", ftp, name); /* Check flag "Backup" */ if ((nonhdr[0] & 0x01) == 0x01) { DBG("Set to parent path"); if (root) return -EPERM; fullname = g_path_get_dirname(ftp->folder); set_folder(ftp, fullname); g_free(fullname); DBG("Set to parent path: %s", ftp->folder); return 0; } if (!name) { DBG("Set path failed: name missing!"); return -EINVAL; } if (strlen(name) == 0) { DBG("Set to root"); set_folder(ftp, root_folder); return 0; } /* Check and set to name path */ if (!is_filename(name)) { error("Set path failed: name incorrect!"); return -EPERM; } fullname = g_build_filename(ftp->folder, name, NULL); DBG("Fullname: %s", fullname); err = verify_path(fullname); if (err < 0) goto done; err = stat(fullname, &dstat); if (err < 0) { err = -errno; if (err == -ENOENT) goto not_found; DBG("stat: %s(%d)", strerror(-err), -err); goto done; } if (S_ISDIR(dstat.st_mode) && (dstat.st_mode & S_IRUSR) && (dstat.st_mode & S_IXUSR)) { set_folder(ftp, fullname); goto done; } err = -EPERM; goto done; not_found: if (nonhdr[0] != 0) { err = -ENOENT; goto done; } if (mkdir(fullname, 0755) < 0) { err = -errno; DBG("mkdir: %s(%d)", strerror(-err), -err); goto done; } err = 0; set_folder(ftp, fullname); done: g_free(fullname); return err; } static gboolean is_valid_path(const char *path) { gchar **elements, **cur; int depth = 0; elements = g_strsplit(path, "/", 0); for (cur = elements; *cur != NULL; cur++) { if (**cur == '\0' || strcmp(*cur, ".") == 0) continue; if (strcmp(*cur, "..") == 0) { depth--; if (depth < 0) break; continue; } depth++; } g_strfreev(elements); if (depth < 0) return FALSE; return TRUE; } static char *ftp_build_filename(struct ftp_session *ftp, const char *destname) { char *filename; /* DestName can either be relative or absolute (FTP style) */ if (destname[0] == '/') filename = g_build_filename(obex_option_root_folder(), destname, NULL); else filename = g_build_filename(ftp->folder, destname, NULL); if (is_valid_path(filename + strlen(obex_option_root_folder()))) return filename; g_free(filename); return NULL; } static int ftp_copy(struct ftp_session *ftp, const char *name, const char *destname) { char *source, *destination, *destdir; int ret; DBG("%p name %s destination %s", ftp, name, destname); if (ftp->folder == NULL) { error("No folder set"); return -ENOENT; } if (name == NULL || destname == NULL) return -EINVAL; destination = ftp_build_filename(ftp, destname); if (destination == NULL) return -EBADR; destdir = g_path_get_dirname(destination); ret = verify_path(destdir); g_free(destdir); if (ret < 0) return ret; source = g_build_filename(ftp->folder, name, NULL); ret = obex_copy(ftp->os, source, destination); g_free(source); g_free(destination); return ret; } static int ftp_move(struct ftp_session *ftp, const char *name, const char *destname) { char *source, *destination, *destdir; int ret; DBG("%p name %s destname %s", ftp, name, destname); if (ftp->folder == NULL) { error("No folder set"); return -ENOENT; } if (name == NULL || destname == NULL) return -EINVAL; destination = ftp_build_filename(ftp, destname); if (destination == NULL) return -EBADR; destdir = g_path_get_dirname(destination); ret = verify_path(destdir); g_free(destdir); if (ret < 0) return ret; source = g_build_filename(ftp->folder, name, NULL); ret = obex_move(ftp->os, source, destination); g_free(source); g_free(destination); return ret; } int ftp_action(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; const char *name, *destname; uint8_t action_id; name = obex_get_name(os); if (name == NULL || !is_filename(name)) return -EBADR; destname = obex_get_destname(os); action_id = obex_get_action_id(os); DBG("%p action 0x%x", ftp, action_id); switch (action_id) { case 0x00: /* Copy Object */ return ftp_copy(ftp, name, destname); case 0x01: /* Move/Rename Object */ return ftp_move(ftp, name, destname); default: return -ENOSYS; } } void ftp_disconnect(struct obex_session *os, void *user_data) { struct ftp_session *ftp = user_data; DBG("%p", ftp); manager_unregister_session(os); g_free(ftp->folder); g_free(ftp); } static struct obex_service_driver ftp = { .name = "File Transfer server", .service = OBEX_FTP, .channel = FTP_CHANNEL, .port = OBEX_PORT_RANDOM, .secure = TRUE, .record = FTP_RECORD, .target = FTP_TARGET, .target_size = TARGET_SIZE, .connect = ftp_connect, .get = ftp_get, .put = ftp_put, .chkput = ftp_chkput, .setpath = ftp_setpath, .action = ftp_action, .disconnect = ftp_disconnect }; static int ftp_init(void) { return obex_service_driver_register(&ftp); } static void ftp_exit(void) { obex_service_driver_unregister(&ftp); } OBEX_PLUGIN_DEFINE(ftp, ftp_init, ftp_exit) obexd-0.46/plugins/filesystem.h0000644000000000000000000000170611755212521013456 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ ssize_t string_read(void *object, void *buf, size_t count); gboolean is_filename(const char *name); int verify_path(const char *path); obexd-0.46/plugins/usb.c0000644000000000000000000001423511755212521012057 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Nokia Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "server.h" #include "obex.h" #include "transport.h" #include "service.h" #include "log.h" static GIOChannel *usb_io = NULL; static guint usb_reconnecting = 0; static guint usb_watch = 0; static DBusConnection *connection = NULL; #define USB_RX_MTU 65535 #define USB_TX_MTU 65535 #define USB_DEVNODE "/dev/ttyGS0" static int usb_connect(struct obex_server *server); static void usb_disconnect(struct obex_server *server) { if (usb_reconnecting > 0) { g_source_remove(usb_reconnecting); usb_reconnecting = 0; } if (usb_watch > 0) { g_source_remove(usb_watch); usb_watch = 0; } /* already disconnected */ if (usb_io == NULL) return; g_io_channel_shutdown(usb_io, TRUE, NULL); g_io_channel_unref(usb_io); usb_io = NULL; DBG("disconnected"); } static gboolean usb_reconnect(void *data) { struct obex_server *server = data; DBG("reconnecting"); usb_reconnecting = 0; usb_connect(server); return FALSE; } static gboolean usb_watchdog(GIOChannel *io, GIOCondition cond, void *user_data) { struct obex_server *server = user_data; usb_watch = 0; usb_disconnect(server); if ((cond & G_IO_NVAL) == FALSE) usb_reconnecting = g_idle_add(usb_reconnect, server); return FALSE; } static int usb_connect(struct obex_server *server) { struct termios options; int fd, err, arg; glong flags; if (usb_reconnecting > 0) { g_source_remove(usb_reconnecting); usb_reconnecting = 0; } /* already connected */ if (usb_io != NULL) return 0; fd = open(USB_DEVNODE, O_RDWR | O_NOCTTY); if (fd < 0) return fd; flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); tcgetattr(fd, &options); cfmakeraw(&options); options.c_oflag &= ~ONLCR; tcsetattr(fd, TCSANOW, &options); arg = fcntl(fd, F_GETFL); if (arg < 0) { err = -errno; goto failed; } arg |= O_NONBLOCK; if (fcntl(fd, F_SETFL, arg) < 0) { err = -errno; goto failed; } usb_io = g_io_channel_unix_new(fd); g_io_channel_set_close_on_unref(usb_io, TRUE); err = obex_server_new_connection(server, usb_io, USB_TX_MTU, USB_RX_MTU, TRUE); if (err < 0) goto failed; usb_watch = g_io_add_watch(usb_io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, usb_watchdog, server); DBG("Successfully opened %s", USB_DEVNODE); return 0; failed: error("usb: %s (%d)", strerror(-err), -err); if (usb_io == NULL) close(fd); else usb_disconnect(server); return err; } static void sig_usb(int sig) { } static void usb_set_mode(struct obex_server *server, const char *mode) { DBG("%s", mode); if (g_str_equal(mode, "ovi_suite") == TRUE) usb_connect(server); else if (g_str_equal(mode, "USB disconnected") == TRUE) usb_disconnect(server); } static gboolean handle_signal(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obex_server *server = user_data; const char *mode; dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &mode, DBUS_TYPE_INVALID); usb_set_mode(server, mode); return TRUE; } static void usb_stop(void *data) { guint id = GPOINTER_TO_UINT(data); g_dbus_remove_watch(connection, id); } static void mode_request_reply(DBusPendingCall *call, void *user_data) { struct obex_server *server = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("usb: Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); } else { const char *mode; dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &mode, DBUS_TYPE_INVALID); usb_set_mode(server, mode); } dbus_message_unref(reply); } static void *usb_start(struct obex_server *server, int *err) { guint id; DBusMessage *msg; DBusPendingCall *call; msg = dbus_message_new_method_call("com.meego.usb_moded", "/com/meego/usb_moded", "com.meego.usb_moded", "mode_request"); if (dbus_connection_send_with_reply(connection, msg, &call, -1) == FALSE) { error("usb: unable to send mode_request"); dbus_message_unref(msg); goto fail; } dbus_pending_call_set_notify(call, mode_request_reply, server, NULL); dbus_pending_call_unref(call); dbus_message_unref(msg); id = g_dbus_add_signal_watch(connection, NULL, NULL, "com.meego.usb_moded", "sig_usb_state_ind", handle_signal, server, NULL); if (err != NULL) *err = 0; return GUINT_TO_POINTER(id); fail: if (err != NULL) *err = -1; return NULL; } static struct obex_transport_driver driver = { .name = "usb", .service = OBEX_PCSUITE, .start = usb_start, .stop = usb_stop }; static int usb_init(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_usb; sigaction(SIGUSR1, &sa, NULL); sigaction(SIGHUP, &sa, NULL); connection = g_dbus_setup_private(DBUS_BUS_SYSTEM, NULL, NULL); if (connection == NULL) return -EPERM; return obex_transport_driver_register(&driver); } static void usb_exit(void) { if (connection) dbus_connection_unref(connection); obex_transport_driver_unregister(&driver); } OBEX_PLUGIN_DEFINE(usb, usb_init, usb_exit) obexd-0.46/plugins/pbap.c0000644000000000000000000006017311755212521012212 00000000000000/* * * OBEX Server * * Copyright (C) 2009-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" #include "obex.h" #include "service.h" #include "phonebook.h" #include "mimetype.h" #include "filesystem.h" #include "manager.h" #define PHONEBOOK_TYPE "x-bt/phonebook" #define VCARDLISTING_TYPE "x-bt/vcard-listing" #define VCARDENTRY_TYPE "x-bt/vcard" #define ORDER_TAG 0x01 #define SEARCHVALUE_TAG 0x02 #define SEARCHATTRIB_TAG 0x03 #define MAXLISTCOUNT_TAG 0x04 #define LISTSTARTOFFSET_TAG 0x05 #define FILTER_TAG 0x06 #define FORMAT_TAG 0X07 #define PHONEBOOKSIZE_TAG 0X08 #define NEWMISSEDCALLS_TAG 0X09 /* The following length is in the unit of byte */ #define ORDER_LEN 1 #define SEARCHATTRIB_LEN 1 #define MAXLISTCOUNT_LEN 2 #define LISTSTARTOFFSET_LEN 2 #define FILTER_LEN 8 #define FORMAT_LEN 1 #define PHONEBOOKSIZE_LEN 2 #define NEWMISSEDCALLS_LEN 1 #define PBAP_CHANNEL 15 #define PBAP_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " struct aparam_header { uint8_t tag; uint8_t len; uint8_t val[0]; } __attribute__ ((packed)); struct cache { gboolean valid; uint32_t index; GSList *entries; }; struct cache_entry { uint32_t handle; char *id; char *name; char *sound; char *tel; }; struct pbap_session { struct apparam_field *params; char *folder; uint32_t find_handle; struct cache cache; struct pbap_object *obj; }; struct pbap_object { GString *buffer; GByteArray *aparams; gboolean firstpacket; gboolean lastpart; struct pbap_session *session; void *request; }; static const uint8_t PBAP_TARGET[TARGET_SIZE] = { 0x79, 0x61, 0x35, 0xF0, 0xF0, 0xC5, 0x11, 0xD8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0C, 0x9A, 0x66 }; typedef int (*cache_entry_find_f) (const struct cache_entry *entry, const char *value); static void cache_entry_free(void *data) { struct cache_entry *entry = data; g_free(entry->id); g_free(entry->name); g_free(entry->sound); g_free(entry->tel); g_free(entry); } static gboolean entry_name_find(const struct cache_entry *entry, const char *value) { char *name; gboolean ret; if (!entry->name) return FALSE; if (strlen(value) == 0) return TRUE; name = g_utf8_strdown(entry->name, -1); ret = (g_strstr_len(name, -1, value) ? TRUE : FALSE); g_free(name); return ret; } static gboolean entry_sound_find(const struct cache_entry *entry, const char *value) { if (!entry->sound) return FALSE; return (g_strstr_len(entry->sound, -1, value) ? TRUE : FALSE); } static gboolean entry_tel_find(const struct cache_entry *entry, const char *value) { if (!entry->tel) return FALSE; return (g_strstr_len(entry->tel, -1, value) ? TRUE : FALSE); } static const char *cache_find(struct cache *cache, uint32_t handle) { GSList *l; for (l = cache->entries; l; l = l->next) { struct cache_entry *entry = l->data; if (entry->handle == handle) return entry->id; } return NULL; } static void cache_clear(struct cache *cache) { g_slist_free_full(cache->entries, cache_entry_free); cache->entries = NULL; } static GByteArray *append_aparam_header(GByteArray *buf, uint8_t tag, const void *val) { /* largest aparam is for phonebooksize (4 bytes) */ uint8_t aparam[sizeof(struct aparam_header) + PHONEBOOKSIZE_LEN]; struct aparam_header *hdr = (struct aparam_header *) aparam; switch (tag) { case PHONEBOOKSIZE_TAG: hdr->tag = PHONEBOOKSIZE_TAG; hdr->len = PHONEBOOKSIZE_LEN; memcpy(hdr->val, val, PHONEBOOKSIZE_LEN); return g_byte_array_append(buf, aparam, sizeof(struct aparam_header) + PHONEBOOKSIZE_LEN); case NEWMISSEDCALLS_TAG: hdr->tag = NEWMISSEDCALLS_TAG; hdr->len = NEWMISSEDCALLS_LEN; memcpy(hdr->val, val, NEWMISSEDCALLS_LEN); return g_byte_array_append(buf, aparam, sizeof(struct aparam_header) + NEWMISSEDCALLS_LEN); default: return buf; } } static void phonebook_size_result(const char *buffer, size_t bufsize, int vcards, int missed, gboolean lastpart, void *user_data) { struct pbap_session *pbap = user_data; uint16_t phonebooksize; if (pbap->obj->request) { phonebook_req_finalize(pbap->obj->request); pbap->obj->request = NULL; } if (vcards < 0) vcards = 0; DBG("vcards %d", vcards); phonebooksize = htons(vcards); pbap->obj->aparams = g_byte_array_new(); pbap->obj->aparams = append_aparam_header(pbap->obj->aparams, PHONEBOOKSIZE_TAG, &phonebooksize); if (missed > 0) { DBG("missed %d", missed); pbap->obj->aparams = append_aparam_header(pbap->obj->aparams, NEWMISSEDCALLS_TAG, &missed); } obex_object_set_io_flags(pbap->obj, G_IO_IN, 0); } static void query_result(const char *buffer, size_t bufsize, int vcards, int missed, gboolean lastpart, void *user_data) { struct pbap_session *pbap = user_data; DBG(""); if (pbap->obj->request && lastpart) { phonebook_req_finalize(pbap->obj->request); pbap->obj->request = NULL; } pbap->obj->lastpart = lastpart; if (vcards < 0) { obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT); return; } if (!pbap->obj->buffer) pbap->obj->buffer = g_string_new_len(buffer, bufsize); else pbap->obj->buffer = g_string_append_len(pbap->obj->buffer, buffer, bufsize); if (missed > 0) { DBG("missed %d", missed); pbap->obj->firstpacket = TRUE; pbap->obj->aparams = g_byte_array_new(); pbap->obj->aparams = append_aparam_header(pbap->obj->aparams, NEWMISSEDCALLS_TAG, &missed); } obex_object_set_io_flags(pbap->obj, G_IO_IN, 0); } static void cache_entry_notify(const char *id, uint32_t handle, const char *name, const char *sound, const char *tel, void *user_data) { struct pbap_session *pbap = user_data; struct cache_entry *entry = g_new0(struct cache_entry, 1); struct cache *cache = &pbap->cache; if (handle != PHONEBOOK_INVALID_HANDLE) entry->handle = handle; else entry->handle = ++pbap->cache.index; entry->id = g_strdup(id); entry->name = g_strdup(name); entry->sound = g_strdup(sound); entry->tel = g_strdup(tel); cache->entries = g_slist_append(cache->entries, entry); } static int alpha_sort(gconstpointer a, gconstpointer b) { const struct cache_entry *e1 = a; const struct cache_entry *e2 = b; return g_strcmp0(e1->name, e2->name); } static int indexed_sort(gconstpointer a, gconstpointer b) { const struct cache_entry *e1 = a; const struct cache_entry *e2 = b; return (e1->handle - e2->handle); } static int phonetical_sort(gconstpointer a, gconstpointer b) { const struct cache_entry *e1 = a; const struct cache_entry *e2 = b; /* SOUND attribute is optional. Use Indexed sort if not present. */ if (!e1->sound || !e2->sound) return indexed_sort(a, b); return g_strcmp0(e1->sound, e2->sound); } static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib, const char *value) { GSList *sorted = NULL; cache_entry_find_f find; GCompareFunc sort; char *searchval; /* * Default sorter is "Indexed". Some backends doesn't inform the index, * for this case a sequential internal index is assigned. * 0x00 = indexed * 0x01 = alphanumeric * 0x02 = phonetic */ switch (order) { case 0x01: sort = alpha_sort; break; case 0x02: sort = phonetical_sort; break; default: sort = indexed_sort; break; } /* * This implementation checks if the given field CONTAINS the * search value(case insensitive). Name is the default field * when the attribute is not provided. */ switch (search_attrib) { /* Number */ case 1: find = entry_tel_find; break; /* Sound */ case 2: find = entry_sound_find; break; default: find = entry_name_find; break; } searchval = value ? g_utf8_strdown(value, -1) : NULL; for (; l; l = l->next) { struct cache_entry *entry = l->data; if (searchval && !find(entry, (const char *) searchval)) continue; sorted = g_slist_insert_sorted(sorted, entry, sort); } g_free(searchval); return sorted; } static int generate_response(void *user_data) { struct pbap_session *pbap = user_data; GSList *sorted; GSList *l; uint16_t max = pbap->params->maxlistcount; DBG(""); if (max == 0) { /* Ignore all other parameter and return PhoneBookSize */ uint16_t size = htons(g_slist_length(pbap->cache.entries)); pbap->obj->aparams = g_byte_array_new(); pbap->obj->aparams = append_aparam_header(pbap->obj->aparams, PHONEBOOKSIZE_TAG, &size); return 0; } /* * Don't free the sorted list content: this list contains * only the reference for the "real" cache entry. */ sorted = sort_entries(pbap->cache.entries, pbap->params->order, pbap->params->searchattrib, (const char *) pbap->params->searchval); /* Computing offset considering first entry of the phonebook */ l = g_slist_nth(sorted, pbap->params->liststartoffset); pbap->obj->buffer = g_string_new(VCARD_LISTING_BEGIN); for (; l && max; l = l->next, max--) { const struct cache_entry *entry = l->data; char *escaped_name = g_markup_escape_text(entry->name, -1); g_string_append_printf(pbap->obj->buffer, VCARD_LISTING_ELEMENT, entry->handle, escaped_name); g_free(escaped_name); } pbap->obj->buffer = g_string_append(pbap->obj->buffer, VCARD_LISTING_END); g_slist_free(sorted); return 0; } static void cache_ready_notify(void *user_data) { struct pbap_session *pbap = user_data; DBG(""); phonebook_req_finalize(pbap->obj->request); pbap->obj->request = NULL; pbap->cache.valid = TRUE; generate_response(pbap); obex_object_set_io_flags(pbap->obj, G_IO_IN, 0); } static void cache_entry_done(void *user_data) { struct pbap_session *pbap = user_data; const char *id; int ret; DBG(""); pbap->cache.valid = TRUE; id = cache_find(&pbap->cache, pbap->find_handle); if (id == NULL) { DBG("Entry %d not found on cache", pbap->find_handle); obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT); return; } phonebook_req_finalize(pbap->obj->request); pbap->obj->request = phonebook_get_entry(pbap->folder, id, pbap->params, query_result, pbap, &ret); if (ret < 0) obex_object_set_io_flags(pbap->obj, G_IO_ERR, ret); } static struct apparam_field *parse_aparam(const uint8_t *buffer, uint32_t hlen) { struct apparam_field *param; struct aparam_header *hdr; uint64_t val64; uint32_t len = 0; uint16_t val16; param = g_new0(struct apparam_field, 1); while (len < hlen) { hdr = (void *) buffer + len; switch (hdr->tag) { case ORDER_TAG: if (hdr->len != ORDER_LEN) goto failed; param->order = hdr->val[0]; break; case SEARCHATTRIB_TAG: if (hdr->len != SEARCHATTRIB_LEN) goto failed; param->searchattrib = hdr->val[0]; break; case SEARCHVALUE_TAG: if (hdr->len == 0) goto failed; param->searchval = g_try_malloc0(hdr->len + 1); if (param->searchval) memcpy(param->searchval, hdr->val, hdr->len); break; case FILTER_TAG: if (hdr->len != FILTER_LEN) goto failed; memcpy(&val64, hdr->val, sizeof(val64)); param->filter = GUINT64_FROM_BE(val64); break; case FORMAT_TAG: if (hdr->len != FORMAT_LEN) goto failed; param->format = hdr->val[0]; break; case MAXLISTCOUNT_TAG: if (hdr->len != MAXLISTCOUNT_LEN) goto failed; memcpy(&val16, hdr->val, sizeof(val16)); param->maxlistcount = GUINT16_FROM_BE(val16); break; case LISTSTARTOFFSET_TAG: if (hdr->len != LISTSTARTOFFSET_LEN) goto failed; memcpy(&val16, hdr->val, sizeof(val16)); param->liststartoffset = GUINT16_FROM_BE(val16); break; default: goto failed; } len += hdr->len + sizeof(struct aparam_header); } DBG("o %x sa %x sv %s fil %" G_GINT64_MODIFIER "x for %x max %x off %x", param->order, param->searchattrib, param->searchval, param->filter, param->format, param->maxlistcount, param->liststartoffset); return param; failed: g_free(param); return NULL; } static void *pbap_connect(struct obex_session *os, int *err) { struct pbap_session *pbap; manager_register_session(os); pbap = g_new0(struct pbap_session, 1); pbap->folder = g_strdup("/"); pbap->find_handle = PHONEBOOK_INVALID_HANDLE; if (err) *err = 0; return pbap; } static int pbap_get(struct obex_session *os, void *user_data) { struct pbap_session *pbap = user_data; const char *type = obex_get_type(os); const char *name = obex_get_name(os); struct apparam_field *params; const uint8_t *buffer; char *path; ssize_t rsize; int ret; DBG("name %s type %s pbap %p", name, type, pbap); if (type == NULL) return -EBADR; rsize = obex_get_apparam(os, &buffer); if (rsize < 0) { if (g_ascii_strcasecmp(type, VCARDENTRY_TYPE) != 0) return -EBADR; rsize = 0; } params = parse_aparam(buffer, rsize); if (params == NULL) return -EBADR; if (pbap->params) { g_free(pbap->params->searchval); g_free(pbap->params); } pbap->params = params; if (g_ascii_strcasecmp(type, PHONEBOOK_TYPE) == 0) { /* Always contains the absolute path */ if (g_path_is_absolute(name)) path = g_strdup(name); else path = g_build_filename("/", name, NULL); } else if (g_ascii_strcasecmp(type, VCARDLISTING_TYPE) == 0) { /* Always relative */ if (!name || strlen(name) == 0) /* Current folder */ path = g_strdup(pbap->folder); else /* Current folder + relative path */ path = g_build_filename(pbap->folder, name, NULL); } else if (g_ascii_strcasecmp(type, VCARDENTRY_TYPE) == 0) { /* File name only */ path = g_strdup(name); } else return -EBADR; if (path == NULL) return -EBADR; ret = obex_get_stream_start(os, path); g_free(path); return ret; } static int pbap_setpath(struct obex_session *os, void *user_data) { struct pbap_session *pbap = user_data; const char *name; const uint8_t *nonhdr; char *fullname; int err; if (obex_get_non_header_data(os, &nonhdr) != 2) { error("Set path failed: flag and constants not found!"); return -EBADMSG; } name = obex_get_name(os); DBG("name %s folder %s nonhdr 0x%x%x", name, pbap->folder, nonhdr[0], nonhdr[1]); fullname = phonebook_set_folder(pbap->folder, name, nonhdr[0], &err); if (err < 0) return err; g_free(pbap->folder); pbap->folder = fullname; /* * FIXME: Define a criteria to mark the cache as invalid */ pbap->cache.valid = FALSE; pbap->cache.index = 0; cache_clear(&pbap->cache); return 0; } static void pbap_disconnect(struct obex_session *os, void *user_data) { struct pbap_session *pbap = user_data; manager_unregister_session(os); if (pbap->obj) pbap->obj->session = NULL; if (pbap->params) { g_free(pbap->params->searchval); g_free(pbap->params); } cache_clear(&pbap->cache); g_free(pbap->folder); g_free(pbap); } static int pbap_chkput(struct obex_session *os, void *user_data) { /* Rejects all PUTs */ return -EBADR; } static struct obex_service_driver pbap = { .name = "Phonebook Access server", .service = OBEX_PBAP, .channel = PBAP_CHANNEL, .secure = TRUE, .record = PBAP_RECORD, .target = PBAP_TARGET, .target_size = TARGET_SIZE, .connect = pbap_connect, .get = pbap_get, .setpath = pbap_setpath, .disconnect = pbap_disconnect, .chkput = pbap_chkput }; static struct pbap_object *vobject_create(struct pbap_session *pbap, void *request) { struct pbap_object *obj; obj = g_new0(struct pbap_object, 1); obj->session = pbap; pbap->obj = obj; obj->request = request; return obj; } static void *vobject_pull_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct pbap_session *pbap = context; phonebook_cb cb; int ret; void *request; DBG("name %s context %p maxlistcount %d", name, context, pbap->params->maxlistcount); if (oflag != O_RDONLY) { ret = -EPERM; goto fail; } if (name == NULL) { ret = -EBADR; goto fail; } if (pbap->params->maxlistcount == 0) cb = phonebook_size_result; else cb = query_result; request = phonebook_pull(name, pbap->params, cb, pbap, &ret); if (ret < 0) goto fail; /* reading first part of results from backend */ ret = phonebook_pull_read(request); if (ret < 0) goto fail; if (err) *err = 0; return vobject_create(pbap, request); fail: if (err) *err = ret; return NULL; } static int vobject_close(void *object) { struct pbap_object *obj = object; DBG(""); if (obj->session) obj->session->obj = NULL; if (obj->buffer) g_string_free(obj->buffer, TRUE); if (obj->aparams) g_byte_array_free(obj->aparams, TRUE); if (obj->request) phonebook_req_finalize(obj->request); g_free(obj); return 0; } static void *vobject_list_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct pbap_session *pbap = context; struct pbap_object *obj = NULL; int ret; void *request; DBG("name %s context %p valid %d", name, context, pbap->cache.valid); if (oflag != O_RDONLY) { ret = -EPERM; goto fail; } if (name == NULL) { ret = -EBADR; goto fail; } /* PullvCardListing always get the contacts from the cache */ if (pbap->cache.valid) { obj = vobject_create(pbap, NULL); ret = generate_response(pbap); } else { request = phonebook_create_cache(name, cache_entry_notify, cache_ready_notify, pbap, &ret); if (ret == 0) obj = vobject_create(pbap, request); } if (ret < 0) goto fail; if (err) *err = 0; return obj; fail: if (obj) vobject_close(obj); if (err) *err = ret; return NULL; } static void *vobject_vcard_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct pbap_session *pbap = context; const char *id; uint32_t handle; int ret; void *request; DBG("name %s context %p valid %d", name, context, pbap->cache.valid); if (oflag != O_RDONLY) { ret = -EPERM; goto fail; } if (name == NULL || sscanf(name, "%u.vcf", &handle) != 1) { ret = -EBADR; goto fail; } if (pbap->cache.valid == FALSE) { pbap->find_handle = handle; request = phonebook_create_cache(pbap->folder, cache_entry_notify, cache_entry_done, pbap, &ret); goto done; } id = cache_find(&pbap->cache, handle); if (!id) { ret = -ENOENT; goto fail; } request = phonebook_get_entry(pbap->folder, id, pbap->params, query_result, pbap, &ret); done: if (ret < 0) goto fail; if (err) *err = 0; return vobject_create(pbap, request); fail: if (err) *err = ret; return NULL; } static ssize_t array_read(GByteArray *array, void *buf, size_t count) { ssize_t len; if (array->len == 0) return 0; len = MIN(array->len, count); memcpy(buf, array->data, len); array = g_byte_array_remove_range(array, 0, len); return len; } static ssize_t vobject_pull_get_next_header(void *object, void *buf, size_t mtu, uint8_t *hi) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; if (!obj->buffer && !obj->aparams) return -EAGAIN; *hi = G_OBEX_HDR_APPARAM; if (pbap->params->maxlistcount == 0 || obj->firstpacket) { obj->firstpacket = FALSE; return array_read(obj->aparams, buf, mtu); } return 0; } static ssize_t vobject_pull_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; int len, ret; DBG("buffer %p maxlistcount %d", obj->buffer, pbap->params->maxlistcount); if (!obj->buffer) { if (pbap->params->maxlistcount == 0) return -ENOSTR; return -EAGAIN; } len = string_read(obj->buffer, buf, count); if (len == 0 && !obj->lastpart) { /* in case when buffer is empty and we know that more * data is still available in backend, requesting new * data part via phonebook_pull_read and returning * -EAGAIN to suspend request for now */ ret = phonebook_pull_read(obj->request); if (ret) return -EPERM; return -EAGAIN; } return len; } static ssize_t vobject_list_get_next_header(void *object, void *buf, size_t mtu, uint8_t *hi) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; /* Backend still busy reading contacts */ if (!pbap->cache.valid) return -EAGAIN; *hi = G_OBEX_HDR_APPARAM; if (pbap->params->maxlistcount == 0) return array_read(obj->aparams, buf, mtu); return 0; } static ssize_t vobject_list_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; DBG("valid %d maxlistcount %d", pbap->cache.valid, pbap->params->maxlistcount); if (pbap->params->maxlistcount == 0) return -ENOSTR; return string_read(obj->buffer, buf, count); } static ssize_t vobject_vcard_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; DBG("buffer %p", obj->buffer); if (!obj->buffer) return -EAGAIN; return string_read(obj->buffer, buf, count); } static struct obex_mime_type_driver mime_pull = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/phonebook", .open = vobject_pull_open, .close = vobject_close, .read = vobject_pull_read, .get_next_header = vobject_pull_get_next_header, }; static struct obex_mime_type_driver mime_list = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/vcard-listing", .open = vobject_list_open, .close = vobject_close, .read = vobject_list_read, .get_next_header = vobject_list_get_next_header, }; static struct obex_mime_type_driver mime_vcard = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/vcard", .open = vobject_vcard_open, .close = vobject_close, .read = vobject_vcard_read, }; static int pbap_init(void) { int err; err = phonebook_init(); if (err < 0) return err; err = obex_mime_type_driver_register(&mime_pull); if (err < 0) goto fail_mime_pull; err = obex_mime_type_driver_register(&mime_list); if (err < 0) goto fail_mime_list; err = obex_mime_type_driver_register(&mime_vcard); if (err < 0) goto fail_mime_vcard; err = obex_service_driver_register(&pbap); if (err < 0) goto fail_pbap_reg; return 0; fail_pbap_reg: obex_mime_type_driver_unregister(&mime_vcard); fail_mime_vcard: obex_mime_type_driver_unregister(&mime_list); fail_mime_list: obex_mime_type_driver_unregister(&mime_pull); fail_mime_pull: phonebook_exit(); return err; } static void pbap_exit(void) { obex_service_driver_unregister(&pbap); obex_mime_type_driver_unregister(&mime_pull); obex_mime_type_driver_unregister(&mime_list); obex_mime_type_driver_unregister(&mime_vcard); phonebook_exit(); } OBEX_PLUGIN_DEFINE(pbap, pbap_init, pbap_exit) obexd-0.46/plugins/phonebook-ebook.c0000644000000000000000000003400011755212521014337 00000000000000/* * * OBEX Server * * Copyright (C) 2009-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "log.h" #include "obex.h" #include "service.h" #include "phonebook.h" #include "glib-helper.h" #define QUERY_FN "(contains \"family_name\" \"%s\")" #define QUERY_NAME "(contains \"given_name\" \"%s\")" #define QUERY_PHONE "(contains \"phone\" \"%s\")" struct query_context { const struct apparam_field *params; phonebook_cb contacts_cb; phonebook_entry_cb entry_cb; phonebook_cache_ready_cb ready_cb; EBookQuery *query; unsigned int count; GString *buf; char *id; unsigned queued_calls; void *user_data; GSList *ebooks; gboolean canceled; }; static char *attribute_mask[] = { /* 0 */ "VERSION", "FN", "N", "PHOTO", "BDAY", "ADR", "LABEL", "TEL", /* 8 */ "EMAIL", "MAILER", "TZ", "GEO", "TITLE", "ROLE", "LOGO", "AGENT", /* 16 */ "ORG", "NOTE", "REV", "SOUND", "URL", "UID", "KEY", "NICKNAME", /* 24 */ "CATEGORIES", "PROID", "CLASS", "SORT-STRING", /* 28 */ "X-IRMC-CALL-DATETIME", NULL }; static void close_ebooks(GSList *ebooks) { g_slist_free_full(ebooks, g_object_unref); } static void free_query_context(struct query_context *data) { g_free(data->id); if (data->buf != NULL) g_string_free(data->buf, TRUE); if (data->query != NULL) e_book_query_unref(data->query); close_ebooks(data->ebooks); g_free(data); } static char *evcard_to_string(EVCard *evcard, unsigned int format, uint64_t filter) { EVCard *evcard2; GList *l; char *vcard; if (!filter) return e_vcard_to_string(evcard, EVC_FORMAT_VCARD_30); /* XXX There is no support for VCARD 2.1 at this time */ /* * Mandatory attributes for vCard 2.1 are VERSION ,N and TEL. * Mandatory attributes for vCard 3.0 are VERSION, N, FN and TEL */ filter = format == EVC_FORMAT_VCARD_30 ? filter | 0x87: filter | 0x85; l = e_vcard_get_attributes(evcard); evcard2 = e_vcard_new(); for (; l; l = g_list_next(l)) { EVCardAttribute *attrib = l->data; const char *name; int i; if (!attrib) continue; name = e_vcard_attribute_get_name(attrib); for (i = 0; attribute_mask[i] != NULL; i++) { if (!(filter & (1 << i))) continue; if (g_strcmp0(name, attribute_mask[i]) != 0) continue; e_vcard_add_attribute(evcard2, e_vcard_attribute_copy(attrib)); } } vcard = e_vcard_to_string(evcard2, format); g_object_unref(evcard2); return vcard; } static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts, void *user_data) { struct query_context *data = user_data; GList *l; unsigned int count, maxcount; data->queued_calls--; if (data->canceled) goto canceled; if (gerr != NULL) { error("E-Book query failed: %s", gerr->message); goto done; } DBG(""); /* * When MaxListCount is zero, PCE wants to know the number of used * indexes in the phonebook of interest. All other parameters that * may be present in the request shall be ignored. */ maxcount = data->params->maxlistcount; if (maxcount == 0) { data->count += g_list_length(contacts); goto done; } l = g_list_nth(contacts, data->params->liststartoffset); for (count = 0; l && count + data->count < maxcount; l = g_list_next(l), count++) { EContact *contact = E_CONTACT(l->data); EVCard *evcard = E_VCARD(contact); char *vcard; vcard = evcard_to_string(evcard, EVC_FORMAT_VCARD_30, data->params->filter); data->buf = g_string_append(data->buf, vcard); data->buf = g_string_append(data->buf, "\r\n"); g_free(vcard); } DBG("collected %d vcards", count); data->count += count; g_list_free_full(contacts, g_object_unref); done: if (data->queued_calls == 0) { GString *buf = data->buf; data->buf = NULL; data->contacts_cb(buf->str, buf->len, data->count, 0, TRUE, data->user_data); g_string_free(buf, TRUE); } return; canceled: if (data->queued_calls == 0) free_query_context(data); } static void ebook_entry_cb(EBook *book, const GError *gerr, EContact *contact, void *user_data) { struct query_context *data = user_data; EVCard *evcard; char *vcard; size_t len; data->queued_calls--; if (data->canceled) goto done; if (gerr != NULL) { error("E-Book query failed: %s", gerr->message); goto done; } DBG(""); evcard = E_VCARD(contact); vcard = evcard_to_string(evcard, EVC_FORMAT_VCARD_30, data->params->filter); len = vcard ? strlen(vcard) : 0; data->count++; data->contacts_cb(vcard, len, 1, 0, TRUE, data->user_data); g_free(vcard); g_object_unref(contact); return; done: if (data->queued_calls == 0) { if (data->count == 0) data->contacts_cb(NULL, 0, 1, 0, TRUE, data->user_data); else if (data->canceled) free_query_context(data); } } static char *evcard_name_attribute_to_string(EVCard *evcard) { EVCardAttribute *attrib; GList *l; GString *name = NULL; attrib = e_vcard_get_attribute(evcard, EVC_N); if (!attrib) return NULL; for (l = e_vcard_attribute_get_values(attrib); l; l = l->next) { const char *value = l->data; if (!strlen(value)) continue; if (!name) name = g_string_new(value); else { name = g_string_append(name, ";"); name = g_string_append(name, l->data); } } if (!name) return NULL; return g_string_free(name, FALSE); } static void cache_cb(EBook *book, const GError *gerr, GList *contacts, void *user_data) { struct query_context *data = user_data; GList *l; data->queued_calls--; if (data->canceled) goto canceled; if (gerr != NULL) { error("E-Book operation failed: %s", gerr->message); goto done; } DBG(""); for (l = contacts; l; l = g_list_next(l)) { EContact *contact = E_CONTACT(l->data); EVCard *evcard = E_VCARD(contact); EVCardAttribute *attrib; char *uid, *tel, *name; name = evcard_name_attribute_to_string(evcard); if (!name) continue; attrib = e_vcard_get_attribute(evcard, EVC_UID); if (!attrib) continue; uid = e_vcard_attribute_get_value(attrib); if (!uid) continue; attrib = e_vcard_get_attribute(evcard, EVC_TEL); if (attrib) tel = e_vcard_attribute_get_value(attrib); else tel = g_strdup(""); data->entry_cb(uid, PHONEBOOK_INVALID_HANDLE, name, NULL, tel, data->user_data); g_free(name); g_free(uid); g_free(tel); } g_list_free_full(contacts, g_object_unref); done: if (data->queued_calls == 0) data->ready_cb(data->user_data); return; canceled: if (data->queued_calls == 0) free_query_context(data); } static GSList *traverse_sources(GSList *ebooks, GSList *sources, char **default_src) { GError *gerr = NULL; for (; sources != NULL; sources = g_slist_next(sources)) { char *uri; ESource *source = E_SOURCE(sources->data); EBook *ebook = e_book_new(source, &gerr); if (ebook == NULL) { error("Can't create user's address book: %s", gerr->message); g_clear_error(&gerr); continue; } uri = e_source_get_uri(source); if (g_strcmp0(*default_src, uri) == 0) { g_free(uri); continue; } g_free(uri); if (e_book_open(ebook, FALSE, &gerr) == FALSE) { error("Can't open e-book address book: %s", gerr->message); g_object_unref(ebook); g_clear_error(&gerr); continue; } if (*default_src == NULL) *default_src = e_source_get_uri(source); DBG("%s address book opened", e_source_peek_name(source)); ebooks = g_slist_append(ebooks, ebook); } return ebooks; } int phonebook_init(void) { g_type_init(); return 0; } static GSList *open_ebooks(void) { GError *gerr = NULL; ESourceList *src_list; GSList *list; gchar *default_src = NULL; GSList *ebooks = NULL; if (e_book_get_addressbooks(&src_list, &gerr) == FALSE) { error("Can't list user's address books: %s", gerr->message); g_error_free(gerr); return NULL; } list = e_source_list_peek_groups(src_list); while (list != NULL) { ESourceGroup *group = E_SOURCE_GROUP(list->data); GSList *sources = e_source_group_peek_sources(group); ebooks = traverse_sources(ebooks, sources, &default_src); list = list->next; } g_free(default_src); g_object_unref(src_list); return ebooks; } void phonebook_exit(void) { } char *phonebook_set_folder(const char *current_folder, const char *new_folder, uint8_t flags, int *err) { gboolean root, child; char *fullname = NULL, *tmp1, *tmp2, *base; int ret = 0, len; root = (g_strcmp0("/", current_folder) == 0); child = (new_folder && strlen(new_folder) != 0); /* Evolution back-end will support telecom/pb folder only */ switch (flags) { case 0x02: /* Go back to root */ if (!child) { fullname = g_strdup("/"); goto done; } /* Go down 1 level */ fullname = g_build_filename(current_folder, new_folder, NULL); if (strcmp("/telecom", fullname) != 0 && strcmp("/telecom/pb", fullname) != 0) { g_free(fullname); fullname = NULL; ret = -ENOENT; } break; case 0x03: /* Go up 1 level */ if (root) { /* Already root */ ret = -EBADR; goto done; } /* * Removing one level of the current folder. Current folder * contains AT LEAST one level since it is not at root folder. * Use glib utility functions to handle invalid chars in the * folder path properly. */ tmp1 = g_path_get_basename(current_folder); tmp2 = g_strrstr(current_folder, tmp1); len = tmp2 - (current_folder + 1); g_free(tmp1); if (len == 0) base = g_strdup("/"); else base = g_strndup(current_folder, len); /* Return one level only */ if (!child) { fullname = base; goto done; } fullname = g_build_filename(base, new_folder, NULL); if (strcmp(fullname, "/telecom") != 0 && strcmp(fullname, "/telecom/pb") != 0) { g_free(fullname); fullname = NULL; ret = -ENOENT; } g_free(base); break; default: ret = -EBADR; break; } done: if (err) *err = ret; return fullname; } void phonebook_req_finalize(void *request) { struct query_context *data = request; if (data->queued_calls == 0) free_query_context(data); else data->canceled = TRUE; } void *phonebook_pull(const char *name, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct query_context *data; if (g_strcmp0("/telecom/pb.vcf", name) != 0) { if (err) *err = -ENOENT; return NULL; } data = g_new0(struct query_context, 1); data->contacts_cb = cb; data->params = params; data->user_data = user_data; data->buf = g_string_new(""); data->query = e_book_query_any_field_contains(""); data->ebooks = open_ebooks(); if (err) *err = data->ebooks == NULL ? -EIO : 0; return data; } int phonebook_pull_read(void *request) { struct query_context *data = request; GSList *l; if (!data) return -ENOENT; for (l = data->ebooks; l != NULL; l = g_slist_next(l)) { EBook *ebook = l->data; if (e_book_is_opened(ebook) == FALSE) continue; if (e_book_get_contacts_async(ebook, data->query, ebookpull_cb, data) == TRUE) data->queued_calls++; } if (data->queued_calls == 0) return -ENOENT; return 0; } void *phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct query_context *data; GSList *l; data = g_new0(struct query_context, 1); data->contacts_cb = cb; data->params = params; data->user_data = user_data; data->id = g_strdup(id); data->ebooks = open_ebooks(); for (l = data->ebooks; l != NULL; l = g_slist_next(l)) { EBook *ebook = l->data; if (e_book_is_opened(ebook) == FALSE) continue; if (e_book_get_contact_async(ebook, data->id, ebook_entry_cb, data) == TRUE) data->queued_calls++; } if (err) *err = (data->queued_calls == 0 ? -ENOENT : 0); return data; } void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, phonebook_cache_ready_cb ready_cb, void *user_data, int *err) { struct query_context *data; EBookQuery *query; GSList *l; EContact *me; EVCard *evcard; GError *gerr = NULL; EBook *eb; EVCardAttribute *attrib; char *uid, *tel, *cname; if (g_strcmp0("/telecom/pb", name) != 0) { if (err) *err = -ENOENT; return NULL; } DBG(""); query = e_book_query_any_field_contains(""); data = g_new0(struct query_context, 1); data->entry_cb = entry_cb; data->ready_cb = ready_cb; data->user_data = user_data; data->query = query; data->ebooks = open_ebooks(); /* Add 0.vcf */ if (e_book_get_self(&me, &eb, &gerr) == FALSE) { g_error_free(gerr); goto next; } evcard = E_VCARD(me); cname = evcard_name_attribute_to_string(evcard); if (!cname) cname = g_strdup(""); attrib = e_vcard_get_attribute(evcard, EVC_UID); uid = e_vcard_attribute_get_value(attrib); if (!uid) uid = g_strdup(""); attrib = e_vcard_get_attribute(evcard, EVC_TEL); if (attrib) tel = e_vcard_attribute_get_value(attrib); else tel = g_strdup(""); data->entry_cb(uid, 0, cname, NULL, tel, data->user_data); data->count++; g_free(cname); g_free(uid); g_free(tel); g_object_unref(eb); next: for (l = data->ebooks; l != NULL; l = g_slist_next(l)) { EBook *ebook = l->data; if (e_book_is_opened(ebook) == FALSE) continue; if (e_book_get_contacts_async(ebook, query, cache_cb, data) == TRUE) data->queued_calls++; } if (err) *err = (data->queued_calls == 0 ? -ENOENT : 0); return data; } obexd-0.46/plugins/irmc.c0000644000000000000000000002767111755212521012230 00000000000000/* * * OBEX IrMC Sync Server * * Copyright (C) 2010 Marcel Mol * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "obexd.h" #include "plugin.h" #include "log.h" #include "obex.h" #include "service.h" #include "phonebook.h" #include "mimetype.h" #include "filesystem.h" #include "manager.h" #define IRMC_CHANNEL 14 #define IRMC_RECORD " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ " struct aparam_header { uint8_t tag; uint8_t len; uint8_t val[0]; } __attribute__ ((packed)); #define DID_LEN 18 struct irmc_session { struct obex_session *os; struct apparam_field *params; uint16_t entries; GString *buffer; char sn[DID_LEN]; char did[DID_LEN]; char manu[DID_LEN]; char model[DID_LEN]; void *request; }; #define IRMC_TARGET_SIZE 9 static const guint8 IRMC_TARGET[IRMC_TARGET_SIZE] = { 0x49, 0x52, 0x4d, 0x43, 0x2d, 0x53, 0x59, 0x4e, 0x43 }; /* FIXME: * the IrMC specs state the first vcard should be the owner * vcard. As there is no simple way to collect ownerdetails * just create an empty vcard (which is allowed according to the * specs). */ static const char *owner_vcard = "BEGIN:VCARD\r\n" "VERSION:2.1\r\n" "N:\r\n" "TEL:\r\n" "X-IRMX-LUID:0\r\n" "END:VCARD\r\n"; static void phonebook_size_result(const char *buffer, size_t bufsize, int vcards, int missed, gboolean lastpart, void *user_data) { struct irmc_session *irmc = user_data; DBG("vcards %d", vcards); irmc->params->maxlistcount = vcards; if (irmc->request) { phonebook_req_finalize(irmc->request); irmc->request = NULL; } } static void query_result(const char *buffer, size_t bufsize, int vcards, int missed, gboolean lastpart, void *user_data) { struct irmc_session *irmc = user_data; const char *s, *t; DBG("bufsize %zu vcards %d missed %d", bufsize, vcards, missed); if (irmc->request) { phonebook_req_finalize(irmc->request); irmc->request = NULL; } /* first add a 'owner' vcard */ if (!irmc->buffer) irmc->buffer = g_string_new(owner_vcard); else irmc->buffer = g_string_append(irmc->buffer, owner_vcard); if (buffer == NULL) goto done; /* loop around buffer and add X-IRMC-LUID attribs */ s = buffer; while ((t = strstr(s, "UID:")) != NULL) { /* add upto UID: into buffer */ irmc->buffer = g_string_append_len(irmc->buffer, s, t-s); /* * add UID: line into buffer * Not sure if UID is still needed if X-IRMC-LUID is there */ s = t; t = strstr(s, "\r\n"); t += 2; irmc->buffer = g_string_append_len(irmc->buffer, s, t-s); /* add X-IRMC-LUID with same number as UID */ irmc->buffer = g_string_append_len(irmc->buffer, "X-IRMC-LUID:", 12); s += 4; /* point to uid number */ irmc->buffer = g_string_append_len(irmc->buffer, s, t-s); s = t; } /* add remaining bit of buffer */ irmc->buffer = g_string_append(irmc->buffer, s); done: obex_object_set_io_flags(irmc, G_IO_IN, 0); } static void *irmc_connect(struct obex_session *os, int *err) { struct irmc_session *irmc; struct apparam_field *param; int ret; DBG(""); manager_register_session(os); irmc = g_new0(struct irmc_session, 1); irmc->os = os; /* FIXME: * Ideally get capabilities info here and use that to define * IrMC DID and SN etc parameters. * For now lets used hostname and some 'random' value */ gethostname(irmc->did, DID_LEN); strncpy(irmc->sn, "12345", sizeof(irmc->sn) - 1); strncpy(irmc->manu, "obex", sizeof(irmc->manu) - 1); strncpy(irmc->model, "mymodel", sizeof(irmc->model) - 1); /* We need to know the number of contact/cal/nt entries * somewhere so why not do it now. */ param = g_new0(struct apparam_field, 1); param->maxlistcount = 0; /* to count the number of vcards... */ param->filter = 0x200085; /* UID TEL N VERSION */ irmc->params = param; irmc->request = phonebook_pull("telecom/pb.vcf", irmc->params, phonebook_size_result, irmc, err); ret = phonebook_pull_read(irmc->request); if (err) *err = ret; return irmc; } static int irmc_get(struct obex_session *os, void *user_data) { struct irmc_session *irmc = user_data; const char *type = obex_get_type(os); const char *name = obex_get_name(os); char *path; int ret; DBG("name %s type %s irmc %p", name, type ? type : "NA", irmc); path = g_strdup(name); ret = obex_get_stream_start(os, path); g_free(path); return ret; } static void irmc_disconnect(struct obex_session *os, void *user_data) { struct irmc_session *irmc = user_data; DBG(""); manager_unregister_session(os); if (irmc->params) { if (irmc->params->searchval) g_free(irmc->params->searchval); g_free(irmc->params); } if (irmc->buffer) g_string_free(irmc->buffer, TRUE); g_free(irmc); } static int irmc_chkput(struct obex_session *os, void *user_data) { DBG(""); /* Reject all PUTs */ return -EBADR; } static void *irmc_open_devinfo(struct irmc_session *irmc, int *err) { if (!irmc->buffer) irmc->buffer = g_string_new(""); g_string_append_printf(irmc->buffer, "MANU:%s\r\n" "MOD:%s\r\n" "SN:%s\r\n" "IRMC-VERSION:1.1\r\n" "PB-TYPE-TX:VCARD2.1\r\n" "PB-TYPE-RX:NONE\r\n" "CAL-TYPE-TX:NONE\r\n" "CAL-TYPE-RX:NONE\r\n" "MSG-TYPE-TX:NONE\r\n" "MSG-TYPE-RX:NONE\r\n" "NOTE-TYPE-TX:NONE\r\n" "NOTE-TYPE-RX:NONE\r\n", irmc->manu, irmc->model, irmc->sn); return irmc; } static void *irmc_open_pb(const char *name, struct irmc_session *irmc, int *err) { GString *mybuf; int ret; if (!g_strcmp0(name, ".vcf")) { /* how can we tell if the vcard count call already finished? */ irmc->request = phonebook_pull("telecom/pb.vcf", irmc->params, query_result, irmc, &ret); if (ret < 0) { DBG("phonebook_pull failed..."); goto fail; } ret = phonebook_pull_read(irmc->request); if (ret < 0) { DBG("phonebook_pull_read failed..."); goto fail; } return irmc; } if (!g_strcmp0(name, "/info.log")) { mybuf = g_string_new(""); g_string_printf(mybuf, "Total-Records:%d\r\n" "Maximum-Records:%d\r\n" "IEL:2\r\n" "DID:%s\r\n", irmc->params->maxlistcount, irmc->params->maxlistcount, irmc->did); } else if (!strncmp(name, "/luid/", 6)) { name += 6; if (!g_strcmp0(name, "cc.log")) { mybuf = g_string_new(""); g_string_printf(mybuf, "%d\r\n", irmc->params->maxlistcount); } else { int l = strlen(name); /* FIXME: * Reply the same to any *.log so we hopefully force a * full phonebook dump. * Is IEL:2 ok? */ if (l > 4 && !g_strcmp0(name + l - 4, ".log")) { DBG("changelog request, force whole book"); mybuf = g_string_new(""); g_string_printf(mybuf, "SN:%s\r\n" "DID:%s\r\n" "Total-Records:%d\r\n" "Maximum-Records:%d\r\n" "*\r\n", irmc->sn, irmc->did, irmc->params->maxlistcount, irmc->params->maxlistcount); } else { ret = -EBADR; goto fail; } } } else { ret = -EBADR; goto fail; } if (!irmc->buffer) irmc->buffer = mybuf; else { irmc->buffer = g_string_append(irmc->buffer, mybuf->str); g_string_free(mybuf, TRUE); } return irmc; fail: if (err) *err = ret; return NULL; } static void *irmc_open_cal(const char *name, struct irmc_session *irmc, int *err) { /* no suport yet. Just return an empty buffer. cal.vcs */ DBG("unsupported, returning empty buffer"); if (!irmc->buffer) irmc->buffer = g_string_new(""); return irmc; } static void *irmc_open_nt(const char *name, struct irmc_session *irmc, int *err) { /* no suport yet. Just return an empty buffer. nt.vnt */ DBG("unsupported, returning empty buffer"); if (!irmc->buffer) irmc->buffer = g_string_new(""); return irmc; } static void *irmc_open(const char *name, int oflag, mode_t mode, void *context, size_t *size, int *err) { struct irmc_session *irmc = context; int ret = 0; const char *p; DBG("name %s context %p", name, context); if (oflag != O_RDONLY) { ret = -EPERM; goto fail; } if (name == NULL || strncmp(name, "telecom/", 8) != 0) { ret = -EBADR; goto fail; } p = name + 8; if (!g_strcmp0(p, "devinfo.txt")) return irmc_open_devinfo(irmc, err); else if (!strncmp(p, "pb", 2)) return irmc_open_pb(p+2, irmc, err); else if (!strncmp(p, "cal", 3)) return irmc_open_cal(p+3, irmc, err); else if (!strncmp(p, "nt", 2)) return irmc_open_nt(p+2, irmc, err); fail: if (err) *err = ret; return NULL; } static int irmc_close(void *object) { struct irmc_session *irmc = object; DBG(""); if (irmc->buffer) { g_string_free(irmc->buffer, TRUE); irmc->buffer = NULL; } if (irmc->request) { phonebook_req_finalize(irmc->request); irmc->request = NULL; } return 0; } static ssize_t irmc_read(void *object, void *buf, size_t count) { struct irmc_session *irmc = object; int len; DBG("buffer %p count %zu", irmc->buffer, count); if (!irmc->buffer) return -EAGAIN; len = string_read(irmc->buffer, buf, count); DBG("returning %d bytes", len); return len; } static struct obex_mime_type_driver irmc_driver = { .target = IRMC_TARGET, .target_size = IRMC_TARGET_SIZE, .open = irmc_open, .close = irmc_close, .read = irmc_read, }; static struct obex_service_driver irmc = { .name = "IRMC Sync server", .service = OBEX_IRMC, .channel = IRMC_CHANNEL, .secure = TRUE, .record = IRMC_RECORD, .target = IRMC_TARGET, .target_size = IRMC_TARGET_SIZE, .connect = irmc_connect, .get = irmc_get, .disconnect = irmc_disconnect, .chkput = irmc_chkput }; static int irmc_init(void) { int err; DBG(""); err = phonebook_init(); if (err < 0) return err; err = obex_mime_type_driver_register(&irmc_driver); if (err < 0) goto fail_mime_irmc; err = obex_service_driver_register(&irmc); if (err < 0) goto fail_irmc_reg; return 0; fail_irmc_reg: obex_mime_type_driver_unregister(&irmc_driver); fail_mime_irmc: phonebook_exit(); return err; } static void irmc_exit(void) { DBG(""); obex_service_driver_unregister(&irmc); obex_mime_type_driver_unregister(&irmc_driver); phonebook_exit(); } OBEX_PLUGIN_DEFINE(irmc, irmc_init, irmc_exit) obexd-0.46/plugins/phonebook-tracker.c0000644000000000000000000013151611755212521014705 00000000000000/* * Phonebook access through D-Bus vCard and call history service * * Copyright (C) 2010 Nokia Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include "log.h" #include "obex.h" #include "service.h" #include "mimetype.h" #include "phonebook.h" #include "vcard.h" #include "glib-helper.h" #define TRACKER_SERVICE "org.freedesktop.Tracker1" #define TRACKER_RESOURCES_PATH "/org/freedesktop/Tracker1/Resources" #define TRACKER_RESOURCES_INTERFACE "org.freedesktop.Tracker1.Resources" #define TRACKER_DEFAULT_CONTACT_ME "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#default-contact-me" #define AFFILATION_HOME "Home" #define AFFILATION_WORK "Work" #define ADDR_FIELD_AMOUNT 7 #define PULL_QUERY_COL_AMOUNT 23 #define COUNT_QUERY_COL_AMOUNT 1 #define COL_PHONE_AFF 0 /* work/home phone numbers */ #define COL_FULL_NAME 1 #define COL_FAMILY_NAME 2 #define COL_GIVEN_NAME 3 #define COL_ADDITIONAL_NAME 4 #define COL_NAME_PREFIX 5 #define COL_NAME_SUFFIX 6 #define COL_ADDR_AFF 7 /* addresses from affilation */ #define COL_BIRTH_DATE 8 #define COL_NICKNAME 9 #define COL_URL 10 #define COL_PHOTO 11 #define COL_ORG_ROLE 12 #define COL_UID 13 #define COL_TITLE 14 #define COL_AFF_TYPE 15 #define COL_ORG_NAME 16 #define COL_ORG_DEPARTMENT 17 #define COL_EMAIL_AFF 18 /* email's from affilation (work/home) */ #define COL_DATE 19 #define COL_SENT 20 #define COL_ANSWERED 21 #define CONTACTS_ID_COL 22 #define CONTACT_ID_PREFIX "urn:uuid:" #define CALL_ID_PREFIX "message:" #define FAX_NUM_TYPE "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#FaxNumber" #define MOBILE_NUM_TYPE "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#CellPhoneNumber" #define MAIN_DELIM "\30" /* Main delimiter between phones, addresses, emails*/ #define SUB_DELIM "\31" /* Delimiter used in telephone number strings*/ #define ADDR_DELIM "\37" /* Delimiter used for address data fields */ #define MAX_FIELDS 100 /* Max amount of fields to be concatenated at once*/ #define VCARDS_PART_COUNT 50 /* amount of vcards sent at once to PBAP core */ #define QUERY_OFFSET_FORMAT "%s OFFSET %d" #define CONTACTS_QUERY_ALL \ "SELECT " \ "(SELECT GROUP_CONCAT(fn:concat(rdf:type(?aff_number)," \ "\"\31\", nco:phoneNumber(?aff_number)), \"\30\")" \ "WHERE {" \ " ?_role nco:hasPhoneNumber ?aff_number" \ "}) " \ "nco:fullname(?_contact) " \ "nco:nameFamily(?_contact) " \ "nco:nameGiven(?_contact) " \ "nco:nameAdditional(?_contact) " \ "nco:nameHonorificPrefix(?_contact) " \ "nco:nameHonorificSuffix(?_contact) " \ "(SELECT GROUP_CONCAT(fn:concat(" \ "tracker:coalesce(nco:pobox(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:locality(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:region(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:country(?aff_addr), \"\"), " \ "\"\31\", rdfs:label(?_role) ), " \ "\"\30\") " \ "WHERE {" \ "?_role nco:hasPostalAddress ?aff_addr" \ "}) " \ "nco:birthDate(?_contact) " \ "(SELECT " \ " ?nick " \ " WHERE { " \ " { " \ " ?_contact nco:nickname ?nick " \ " } UNION { " \ " ?_contact nco:hasAffiliation ?role . " \ " ?role nco:hasIMAddress ?im . " \ " ?im nco:imNickname ?nick " \ " } " \ " } " \ ") " \ "(SELECT GROUP_CONCAT(fn:concat( " \ "?url_val, \"\31\", tracker:coalesce(rdfs:label(?_role), \"\") "\ "), \"\30\") " \ "WHERE {" \ "?_role nco:url ?url_val . " \ "})" \ "nie:url(nco:photo(?_contact)) " \ "nco:role(?_role) " \ "nco:contactUID(?_contact) " \ "nco:title(?_role) " \ "rdfs:label(?_role) " \ "nco:fullname(nco:org(?_role))" \ "nco:department(?_role) " \ "(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\"," \ "tracker:coalesce(rdfs:label(?_role), \"\"))," \ "\"\30\") " \ "WHERE { " \ "?_role nco:hasEmailAddress " \ " [ nco:emailAddress ?emailaddress ] " \ "}) " \ "\"NOTACALL\" \"false\" \"false\" " \ "?_contact " \ "WHERE {" \ " ?_contact a nco:PersonContact ." \ " OPTIONAL {?_contact nco:hasAffiliation ?_role .}" \ "}" \ "ORDER BY tracker:id(?_contact)" #define CONTACTS_QUERY_ALL_LIST \ "SELECT ?c nco:nameFamily(?c) " \ "nco:nameGiven(?c) nco:nameAdditional(?c) " \ "nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \ "(SELECT " \ "?nick " \ "WHERE { " \ "{ " \ "?c nco:nickname ?nick " \ "} UNION { " \ "?c nco:hasAffiliation ?role . " \ "?role nco:hasIMAddress ?im . " \ "?im nco:imNickname ?nick " \ "} " \ "} " \ ") " \ "nco:phoneNumber(?h) " \ "WHERE { " \ "?c a nco:PersonContact . " \ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \ "OPTIONAL { " \ "?c nco:hasAffiliation ?a . " \ "?a nco:hasPhoneNumber ?h . " \ "} " \ "} GROUP BY ?c" #define CALLS_CONSTRAINTS(CONSTRAINT) \ " WHERE { " \ "?_call a nmo:Call . " \ "?_unb_contact a nco:Contact . " \ "?_unb_contact nco:hasPhoneNumber ?_cpn . " \ CONSTRAINT \ "OPTIONAL { " \ "{ SELECT ?_contact ?_no ?_role ?_number " \ "count(?_contact) as ?cnt " \ "WHERE { " \ "?_contact a nco:PersonContact . " \ "{ " \ "?_contact nco:hasAffiliation ?_role . "\ "?_role nco:hasPhoneNumber ?_number . " \ "} UNION { " \ "?_contact nco:hasPhoneNumber ?_number" \ "} " \ "?_number maemo:localPhoneNumber ?_no . " \ "} GROUP BY ?_no } " \ "FILTER(?cnt = 1) " \ "?_cpn maemo:localPhoneNumber ?_no . " \ "} " \ "} " #define CALLS_LIST(CONSTRAINT) \ "SELECT ?_call nco:nameFamily(?_contact) " \ "nco:nameGiven(?_contact) nco:nameAdditional(?_contact) " \ "nco:nameHonorificPrefix(?_contact) " \ "nco:nameHonorificSuffix(?_contact) " \ "(SELECT " \ "?nick " \ "WHERE { " \ "{ " \ "?_contact nco:nickname ?nick " \ "} UNION { " \ "?_contact nco:hasAffiliation ?role . " \ "?role nco:hasIMAddress ?im . " \ "?im nco:imNickname ?nick " \ "} " \ "} " \ ") " \ "nco:phoneNumber(?_cpn) " \ CALLS_CONSTRAINTS(CONSTRAINT) \ "ORDER BY DESC(nmo:sentDate(?_call)) " #define CALLS_QUERY(CONSTRAINT) \ "SELECT " \ "(SELECT fn:concat(rdf:type(?role_number)," \ "\"\31\", nco:phoneNumber(?role_number))" \ "WHERE {" \ "{" \ " ?_role nco:hasPhoneNumber ?role_number " \ " FILTER (?role_number = ?_number)" \ "} UNION { " \ "?_unb_contact nco:hasPhoneNumber ?role_number . " \ " FILTER (!bound(?_role)) " \ "}" \ "} GROUP BY nco:phoneNumber(?role_number) ) " \ "nco:fullname(?_contact) " \ "nco:nameFamily(?_contact) " \ "nco:nameGiven(?_contact) " \ "nco:nameAdditional(?_contact) " \ "nco:nameHonorificPrefix(?_contact) " \ "nco:nameHonorificSuffix(?_contact) " \ "(SELECT GROUP_CONCAT(fn:concat(" \ "tracker:coalesce(nco:pobox(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \"\37\","\ "tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \"\37\","\ "tracker:coalesce(nco:locality(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:region(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:country(?aff_addr), \"\"), " \ "\"\31\", rdfs:label(?c_role) ), " \ "\"\30\") " \ "WHERE {" \ "?_contact nco:hasAffiliation ?c_role . " \ "?c_role nco:hasPostalAddress ?aff_addr" \ "}) " \ "nco:birthDate(?_contact) " \ "(SELECT " \ "?nick " \ "WHERE { " \ " { " \ " ?_contact nco:nickname ?nick " \ " } UNION { " \ " ?_contact nco:hasAffiliation ?role . " \ " ?role nco:hasIMAddress ?im . " \ " ?im nco:imNickname ?nick " \ " } " \ " } " \ ") " \ "(SELECT GROUP_CONCAT(fn:concat(?url_value, \"\31\", " \ "tracker:coalesce(rdfs:label(?c_role), \"\")), \"\30\") " \ "WHERE {" \ "?_contact nco:hasAffiliation ?c_role . " \ "?c_role nco:url ?url_value . " \ "})" \ "nie:url(nco:photo(?_contact)) " \ "nco:role(?_role) " \ "nco:contactUID(?_contact) " \ "nco:title(?_role) " \ "rdfs:label(?_role) " \ "nco:fullname(nco:org(?_role)) " \ "nco:department(?_role) " \ "(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\"," \ "tracker:coalesce(rdfs:label(?c_role), \"\"))," \ "\"\30\") " \ "WHERE { " \ "?_contact nco:hasAffiliation ?c_role . " \ "?c_role nco:hasEmailAddress " \ " [ nco:emailAddress ?emailaddress ] " \ "}) " \ "nmo:receivedDate(?_call) " \ "nmo:isSent(?_call) " \ "nmo:isAnswered(?_call) " \ "?_call " \ CALLS_CONSTRAINTS(CONSTRAINT) \ "ORDER BY DESC(nmo:sentDate(?_call)) " #define MISSED_CONSTRAINT \ "?_call nmo:from ?_unb_contact . " \ "?_call nmo:isSent false . " \ "?_call nmo:isAnswered false . " #define INCOMING_CONSTRAINT \ "?_call nmo:from ?_unb_contact . " \ "?_call nmo:isSent false . " \ "?_call nmo:isAnswered true . " #define OUTGOING_CONSTRAINT \ "?_call nmo:to ?_unb_contact . " \ "?_call nmo:isSent true . " #define COMBINED_CONSTRAINT \ "{ " \ " ?_call nmo:from ?_unb_contact . " \ " ?_call nmo:isSent false " \ "} UNION { " \ " ?_call nmo:to ?_unb_contact . " \ " ?_call nmo:isSent true " \ "} " #define CALL_URI_CONSTRAINT \ COMBINED_CONSTRAINT \ "FILTER (?_call = <%s>) " #define MISSED_CALLS_QUERY CALLS_QUERY(MISSED_CONSTRAINT) #define MISSED_CALLS_LIST CALLS_LIST(MISSED_CONSTRAINT) #define INCOMING_CALLS_QUERY CALLS_QUERY(INCOMING_CONSTRAINT) #define INCOMING_CALLS_LIST CALLS_LIST(INCOMING_CONSTRAINT) #define OUTGOING_CALLS_QUERY CALLS_QUERY(OUTGOING_CONSTRAINT) #define OUTGOING_CALLS_LIST CALLS_LIST(OUTGOING_CONSTRAINT) #define COMBINED_CALLS_QUERY CALLS_QUERY(COMBINED_CONSTRAINT) #define COMBINED_CALLS_LIST CALLS_LIST(COMBINED_CONSTRAINT) #define CONTACT_FROM_CALL_QUERY CALLS_QUERY(CALL_URI_CONSTRAINT) #define CONTACTS_QUERY_FROM_URI \ "SELECT " \ "(SELECT GROUP_CONCAT(fn:concat(rdf:type(?aff_number)," \ "\"\31\", nco:phoneNumber(?aff_number)), \"\30\")" \ "WHERE {" \ " ?_role nco:hasPhoneNumber ?aff_number" \ "}) " \ "nco:fullname(<%s>) " \ "nco:nameFamily(<%s>) " \ "nco:nameGiven(<%s>) " \ "nco:nameAdditional(<%s>) " \ "nco:nameHonorificPrefix(<%s>) " \ "nco:nameHonorificSuffix(<%s>) " \ "(SELECT GROUP_CONCAT(fn:concat(" \ "tracker:coalesce(nco:pobox(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:locality(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:region(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \"\37\"," \ "tracker:coalesce(nco:country(?aff_addr), \"\"), " \ "\"\31\", rdfs:label(?_role) ), " \ "\"\30\") " \ "WHERE {" \ "?_role nco:hasPostalAddress ?aff_addr" \ "}) " \ "nco:birthDate(<%s>) " \ "(SELECT " \ " ?nick " \ " WHERE { " \ " { " \ " ?_contact nco:nickname ?nick " \ " } UNION { " \ " ?_contact nco:hasAffiliation ?role . " \ " ?role nco:hasIMAddress ?im . " \ " ?im nco:imNickname ?nick " \ " } " \ " FILTER (?_contact = <%s>)" \ " } " \ ") " \ "(SELECT GROUP_CONCAT(fn:concat( " \ "?url_val, \"\31\", tracker:coalesce(rdfs:label(?_role), \"\") "\ "), \"\30\") " \ "WHERE {" \ "?_role nco:url ?url_val . " \ "})" \ "nie:url(nco:photo(<%s>)) " \ "nco:role(?_role) " \ "nco:contactUID(<%s>) " \ "nco:title(?_role) " \ "rdfs:label(?_role) " \ "nco:fullname(nco:org(?_role))" \ "nco:department(?_role) " \ "(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\"," \ "tracker:coalesce(rdfs:label(?_role), \"\"))," \ "\"\30\") " \ "WHERE { " \ "?_role nco:hasEmailAddress " \ " [ nco:emailAddress ?emailaddress ] " \ "}) " \ "\"NOTACALL\" \"false\" \"false\" " \ "<%s> " \ "WHERE {" \ " <%s> a nco:PersonContact ." \ " OPTIONAL {<%s> nco:hasAffiliation ?_role .}" \ "}" #define CONTACTS_OTHER_QUERY_FROM_URI \ "SELECT fn:concat(\"TYPE_OTHER\", \"\31\", nco:phoneNumber(?t))"\ "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \ "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \ " \"NOTACALL\" \"false\" \"false\" <%s> " \ "WHERE { " \ "<%s> a nco:Contact . " \ "OPTIONAL { <%s> nco:hasPhoneNumber ?t . } " \ "} " #define CONTACTS_COUNT_QUERY \ "SELECT COUNT(?c) " \ "WHERE {" \ "?c a nco:PersonContact ." \ "}" #define MISSED_CALLS_COUNT_QUERY \ "SELECT COUNT(?call) WHERE {" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:isSent false ;" \ "nmo:from ?c ;" \ "nmo:isAnswered false ." \ "}" #define INCOMING_CALLS_COUNT_QUERY \ "SELECT COUNT(?call) WHERE {" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:isSent false ;" \ "nmo:from ?c ;" \ "nmo:isAnswered true ." \ "}" #define OUTGOING_CALLS_COUNT_QUERY \ "SELECT COUNT(?call) WHERE {" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:isSent true ;" \ "nmo:to ?c ." \ "}" #define COMBINED_CALLS_COUNT_QUERY \ "SELECT COUNT(?call) WHERE {" \ "{" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:isSent true ;" \ "nmo:to ?c ." \ "}UNION {" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:from ?c ." \ "}" \ "}" #define NEW_MISSED_CALLS_COUNT_QUERY \ "SELECT COUNT(?call) WHERE {" \ "?c a nco:Contact ;" \ "nco:hasPhoneNumber ?h ." \ "?call a nmo:Call ;" \ "nmo:isSent false ;" \ "nmo:from ?c ;" \ "nmo:isAnswered false ;" \ "nmo:isRead false ." \ "}" typedef int (*reply_list_foreach_t) (const char **reply, int num_fields, void *user_data); typedef void (*add_field_t) (struct phonebook_contact *contact, const char *value, int type); struct pending_reply { reply_list_foreach_t callback; void *user_data; int num_fields; }; struct contact_data { char *id; struct phonebook_contact *contact; }; struct phonebook_data { phonebook_cb cb; void *user_data; int index; gboolean vcardentry; const struct apparam_field *params; GSList *contacts; phonebook_cache_ready_cb ready_cb; phonebook_entry_cb entry_cb; int newmissedcalls; GCancellable *query_canc; char *req_name; int vcard_part_count; int tracker_index; }; struct phonebook_index { GArray *phonebook; int index; }; static TrackerSparqlConnection *connection = NULL; static const char *name2query(const char *name) { if (g_str_equal(name, "/telecom/pb.vcf")) return CONTACTS_QUERY_ALL; else if (g_str_equal(name, "/telecom/ich.vcf")) return INCOMING_CALLS_QUERY; else if (g_str_equal(name, "/telecom/och.vcf")) return OUTGOING_CALLS_QUERY; else if (g_str_equal(name, "/telecom/mch.vcf")) return MISSED_CALLS_QUERY; else if (g_str_equal(name, "/telecom/cch.vcf")) return COMBINED_CALLS_QUERY; return NULL; } static const char *name2count_query(const char *name) { if (g_str_equal(name, "/telecom/pb.vcf")) return CONTACTS_COUNT_QUERY; else if (g_str_equal(name, "/telecom/ich.vcf")) return INCOMING_CALLS_COUNT_QUERY; else if (g_str_equal(name, "/telecom/och.vcf")) return OUTGOING_CALLS_COUNT_QUERY; else if (g_str_equal(name, "/telecom/mch.vcf")) return MISSED_CALLS_COUNT_QUERY; else if (g_str_equal(name, "/telecom/cch.vcf")) return COMBINED_CALLS_COUNT_QUERY; return NULL; } static gboolean folder_is_valid(const char *folder) { if (folder == NULL) return FALSE; if (g_str_equal(folder, "/")) return TRUE; else if (g_str_equal(folder, "/telecom")) return TRUE; else if (g_str_equal(folder, "/telecom/pb")) return TRUE; else if (g_str_equal(folder, "/telecom/ich")) return TRUE; else if (g_str_equal(folder, "/telecom/och")) return TRUE; else if (g_str_equal(folder, "/telecom/mch")) return TRUE; else if (g_str_equal(folder, "/telecom/cch")) return TRUE; return FALSE; } static const char *folder2query(const char *folder) { if (g_str_equal(folder, "/telecom/pb")) return CONTACTS_QUERY_ALL_LIST; else if (g_str_equal(folder, "/telecom/ich")) return INCOMING_CALLS_LIST; else if (g_str_equal(folder, "/telecom/och")) return OUTGOING_CALLS_LIST; else if (g_str_equal(folder, "/telecom/mch")) return MISSED_CALLS_LIST; else if (g_str_equal(folder, "/telecom/cch")) return COMBINED_CALLS_LIST; return NULL; } static const char **string_array_from_cursor(TrackerSparqlCursor *cursor, int array_len) { const char **result; int i; result = g_new0(const char *, array_len); for (i = 0; i < array_len; ++i) { TrackerSparqlValueType type; type = tracker_sparql_cursor_get_value_type(cursor, i); if (type == TRACKER_SPARQL_VALUE_TYPE_BLANK_NODE || type == TRACKER_SPARQL_VALUE_TYPE_UNBOUND) /* For null/unbound type filling result part with ""*/ result[i] = ""; else /* Filling with string representation of content*/ result[i] = tracker_sparql_cursor_get_string(cursor, i, NULL); } return result; } static void update_cancellable(struct phonebook_data *pdata, GCancellable *canc) { if (pdata->query_canc) g_object_unref(pdata->query_canc); pdata->query_canc = canc; } static void async_query_cursor_next_cb(GObject *source, GAsyncResult *result, gpointer user_data) { struct pending_reply *pending = user_data; TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR(source); GCancellable *cancellable; GError *error = NULL; gboolean success; const char **node; int err; success = tracker_sparql_cursor_next_finish( TRACKER_SPARQL_CURSOR(source), result, &error); if (!success) { if (error) { DBG("cursor_next error: %s", error->message); g_error_free(error); } else /* When tracker_sparql_cursor_next_finish ends with * failure and no error is set, that means end of * results returned by query */ pending->callback(NULL, 0, pending->user_data); goto failed; } node = string_array_from_cursor(cursor, pending->num_fields); err = pending->callback(node, pending->num_fields, pending->user_data); g_free(node); /* Fetch next result only if processing current chunk ended with * success. Sometimes during processing data, we are able to determine * if there is no need to get more data from tracker - by example * stored amount of data parts is big enough for sending and we might * want to suspend processing or just some error occurred. */ if (!err) { cancellable = g_cancellable_new(); update_cancellable(pending->user_data, cancellable); tracker_sparql_cursor_next_async(cursor, cancellable, async_query_cursor_next_cb, pending); return; } failed: g_object_unref(cursor); g_free(pending); } static int query_tracker(const char *query, int num_fields, reply_list_foreach_t callback, void *user_data) { struct pending_reply *pending; GCancellable *cancellable; TrackerSparqlCursor *cursor; GError *error = NULL; DBG(""); if (connection == NULL) connection = tracker_sparql_connection_get_direct( NULL, &error); if (!connection) { if (error) { DBG("direct-connection error: %s", error->message); g_error_free(error); } return -EINTR; } cancellable = g_cancellable_new(); update_cancellable(user_data, cancellable); cursor = tracker_sparql_connection_query(connection, query, cancellable, &error); if (cursor == NULL) { if (error) { DBG("connection_query error: %s", error->message); g_error_free(error); } g_object_unref(cancellable); return -EINTR; } pending = g_new0(struct pending_reply, 1); pending->callback = callback; pending->user_data = user_data; pending->num_fields = num_fields; /* Now asynchronously going through each row of results - callback * async_query_cursor_next_cb will be called ALWAYS, even if async * request was canceled */ tracker_sparql_cursor_next_async(cursor, cancellable, async_query_cursor_next_cb, pending); return 0; } static char *iso8601_utc_to_localtime(const char *datetime) { time_t time; struct tm tm, *local; char localdate[32]; int nr; memset(&tm, 0, sizeof(tm)); nr = sscanf(datetime, "%04u-%02u-%02uT%02u:%02u:%02u", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); if (nr < 6) { /* Invalid time format */ error("sscanf(): %s (%d)", strerror(errno), errno); return g_strdup(""); } /* Time already in localtime */ if (!g_str_has_suffix(datetime, "Z")) { strftime(localdate, sizeof(localdate), "%Y%m%dT%H%M%S", &tm); return g_strdup(localdate); } tm.tm_year -= 1900; /* Year since 1900 */ tm.tm_mon--; /* Months since January, values 0-11 */ time = mktime(&tm); time -= timezone; local = localtime(&time); strftime(localdate, sizeof(localdate), "%Y%m%dT%H%M%S", local); return g_strdup(localdate); } static void set_call_type(struct phonebook_contact *contact, const char *datetime, const char *is_sent, const char *is_answered) { gboolean sent, answered; if (g_strcmp0(datetime, "NOTACALL") == 0) { contact->calltype = CALL_TYPE_NOT_A_CALL; return; } sent = g_str_equal(is_sent, "true"); answered = g_str_equal(is_answered, "true"); if (sent == FALSE) { if (answered == FALSE) contact->calltype = CALL_TYPE_MISSED; else contact->calltype = CALL_TYPE_INCOMING; } else contact->calltype = CALL_TYPE_OUTGOING; /* Tracker gives time in the ISO 8601 format, UTC time */ contact->datetime = iso8601_utc_to_localtime(datetime); } static gboolean contact_matches(struct contact_data *c_data, const char *id, const char *datetime) { char *localtime; int cmp_ret; if (g_strcmp0(c_data->id, id) != 0) return FALSE; /* id is equal and not call history entry => contact matches */ if (c_data->contact->calltype == CALL_TYPE_NOT_A_CALL) return TRUE; /* for call history entries have to compare also timestamps of calls */ localtime = iso8601_utc_to_localtime(datetime); cmp_ret = g_strcmp0(c_data->contact->datetime, localtime); g_free(localtime); return (cmp_ret == 0) ? TRUE : FALSE; } static struct phonebook_contact *find_contact(GSList *contacts, const char *id, const char *datetime) { GSList *l; for (l = contacts; l; l = l->next) { struct contact_data *c_data = l->data; if (contact_matches(c_data, id, datetime)) return c_data->contact; } return NULL; } static struct phonebook_field *find_field(GSList *fields, const char *value, int type) { GSList *l; for (l = fields; l; l = l->next) { struct phonebook_field *field = l->data; /* Returning phonebook number if phone values and type values * are equal */ if (g_strcmp0(field->text, value) == 0 && field->type == type) return field; } return NULL; } static void add_phone_number(struct phonebook_contact *contact, const char *phone, int type) { struct phonebook_field *number; if (phone == NULL || strlen(phone) == 0) return; /* Not adding number if there is already added with the same value */ if (find_field(contact->numbers, phone, type)) return; number = g_new0(struct phonebook_field, 1); number->text = g_strdup(phone); number->type = type; contact->numbers = g_slist_append(contact->numbers, number); } static void add_email(struct phonebook_contact *contact, const char *address, int type) { struct phonebook_field *email; if (address == NULL || strlen(address) == 0) return; /* Not adding email if there is already added with the same value */ if (find_field(contact->emails, address, type)) return; email = g_new0(struct phonebook_field, 1); email->text = g_strdup(address); email->type = type; contact->emails = g_slist_append(contact->emails, email); } static gboolean addr_matches(struct phonebook_addr *a, struct phonebook_addr *b) { GSList *la, *lb; if (a->type != b->type) return FALSE; for (la = a->fields, lb = b->fields; la && lb; la = la->next, lb = lb->next) { char *field_a = la->data; char *field_b = lb->data; if (g_strcmp0(field_a, field_b) != 0) return FALSE; } return TRUE; } /* generates phonebook_addr struct from tracker address data string. */ static struct phonebook_addr *gen_addr(const char *address, int type) { struct phonebook_addr *addr; GSList *fields = NULL; char **addr_parts; int i; /* This test handles cases when address points to empty string * (or address is NULL pointer) or string containing only six * separators. It indicates that none of address fields is present * and there is no sense to create dummy phonebook_addr struct */ if (address == NULL || strlen(address) < ADDR_FIELD_AMOUNT) return NULL; addr_parts = g_strsplit(address, ADDR_DELIM, ADDR_FIELD_AMOUNT); for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) fields = g_slist_append(fields, g_strdup(addr_parts[i])); g_strfreev(addr_parts); addr = g_new0(struct phonebook_addr, 1); addr->fields = fields; addr->type = type; return addr; } static void add_address(struct phonebook_contact *contact, const char *address, int type) { struct phonebook_addr *addr; GSList *l; addr = gen_addr(address, type); if (addr == NULL) return; /* Not adding address if there is already added with the same value. * These type of checks have to be done because sometimes tracker * returns results for contact data in more than 1 row - then the same * address may be returned more than once in query results */ for (l = contact->addresses; l; l = l->next) { struct phonebook_addr *tmp = l->data; if (addr_matches(tmp, addr)) { phonebook_addr_free(addr); return; } } contact->addresses = g_slist_append(contact->addresses, addr); } static void add_url(struct phonebook_contact *contact, const char *url_val, int type) { struct phonebook_field *url; if (url_val == NULL || strlen(url_val) == 0) return; /* Not adding url if there is already added with the same value */ if (find_field(contact->urls, url_val, type)) return; url = g_new0(struct phonebook_field, 1); url->text = g_strdup(url_val); url->type = type; contact->urls = g_slist_append(contact->urls, url); } static GString *gen_vcards(GSList *contacts, const struct apparam_field *params) { GSList *l; GString *vcards; vcards = g_string_new(NULL); /* Generating VCARD string from contacts and freeing used contacts */ for (l = contacts; l; l = l->next) { struct contact_data *c_data = l->data; phonebook_add_contact(vcards, c_data->contact, params->filter, params->format); } return vcards; } static int pull_contacts_size(const char **reply, int num_fields, void *user_data) { struct phonebook_data *data = user_data; if (num_fields < 0) { data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data); return -EINTR; } if (reply != NULL) { data->index = atoi(reply[0]); return 0; } data->cb(NULL, 0, data->index, data->newmissedcalls, TRUE, data->user_data); return 0; /* * phonebook_data is freed in phonebook_req_finalize. Useful in * cases when call is terminated. */ } static void add_affiliation(char **field, const char *value) { if (strlen(*field) > 0 || value == NULL || strlen(value) == 0) return; g_free(*field); *field = g_strdup(value); } static void contact_init(struct phonebook_contact *contact, const char **reply) { if (reply[COL_FAMILY_NAME][0] == '\0' && reply[COL_GIVEN_NAME][0] == '\0' && reply[COL_ADDITIONAL_NAME][0] == '\0' && reply[COL_NAME_PREFIX][0] == '\0' && reply[COL_NAME_SUFFIX][0] == '\0') { if (reply[COL_FULL_NAME][0] != '\0') contact->family = g_strdup(reply[COL_FULL_NAME]); else contact->family = g_strdup(reply[COL_NICKNAME]); } else { contact->family = g_strdup(reply[COL_FAMILY_NAME]); contact->given = g_strdup(reply[COL_GIVEN_NAME]); contact->additional = g_strdup(reply[COL_ADDITIONAL_NAME]); contact->prefix = g_strdup(reply[COL_NAME_PREFIX]); contact->suffix = g_strdup(reply[COL_NAME_SUFFIX]); } contact->fullname = g_strdup(reply[COL_FULL_NAME]); contact->birthday = g_strdup(reply[COL_BIRTH_DATE]); contact->nickname = g_strdup(reply[COL_NICKNAME]); contact->photo = g_strdup(reply[COL_PHOTO]); contact->company = g_strdup(reply[COL_ORG_NAME]); contact->department = g_strdup(reply[COL_ORG_DEPARTMENT]); contact->role = g_strdup(reply[COL_ORG_ROLE]); contact->uid = g_strdup(reply[COL_UID]); contact->title = g_strdup(reply[COL_TITLE]); set_call_type(contact, reply[COL_DATE], reply[COL_SENT], reply[COL_ANSWERED]); } static enum phonebook_number_type get_phone_type(const char *affilation) { if (g_strcmp0(AFFILATION_HOME, affilation) == 0) return TEL_TYPE_HOME; else if (g_strcmp0(AFFILATION_WORK, affilation) == 0) return TEL_TYPE_WORK; return TEL_TYPE_OTHER; } static void add_aff_number(struct phonebook_contact *contact, const char *pnumber, const char *aff_type) { char **num_parts; char *type, *number; /* For phone taken directly from contacts data, phone number string * is represented as number type and number string - those strings are * separated by SUB_DELIM string */ num_parts = g_strsplit(pnumber, SUB_DELIM, 2); if (!num_parts) return; if (num_parts[0]) type = num_parts[0]; else goto failed; if (num_parts[1]) number = num_parts[1]; else goto failed; if (g_strrstr(type, FAX_NUM_TYPE)) add_phone_number(contact, number, TEL_TYPE_FAX); else if (g_strrstr(type, MOBILE_NUM_TYPE)) add_phone_number(contact, number, TEL_TYPE_MOBILE); else /* if this is no fax/mobile phone, then adding phone number * type based on type of the affilation field */ add_phone_number(contact, number, get_phone_type(aff_type)); failed: g_strfreev(num_parts); } static void contact_add_numbers(struct phonebook_contact *contact, const char **reply) { char **aff_numbers; int i; /* Filling phone numbers from contact's affilation */ aff_numbers = g_strsplit(reply[COL_PHONE_AFF], MAIN_DELIM, MAX_FIELDS); if (aff_numbers) for (i = 0; aff_numbers[i]; ++i) add_aff_number(contact, aff_numbers[i], reply[COL_AFF_TYPE]); g_strfreev(aff_numbers); } static enum phonebook_field_type get_field_type(const char *affilation) { if (g_strcmp0(AFFILATION_HOME, affilation) == 0) return FIELD_TYPE_HOME; else if (g_strcmp0(AFFILATION_WORK, affilation) == 0) return FIELD_TYPE_WORK; return FIELD_TYPE_OTHER; } static void add_aff_field(struct phonebook_contact *contact, const char *aff_email, add_field_t add_field_cb) { char **email_parts; char *type, *email; /* Emails from affilation data, are represented as real email * string and affilation type - those strings are separated by * SUB_DELIM string */ email_parts = g_strsplit(aff_email, SUB_DELIM, 2); if (!email_parts) return; if (email_parts[0]) email = email_parts[0]; else goto failed; if (email_parts[1]) type = email_parts[1]; else goto failed; add_field_cb(contact, email, get_field_type(type)); failed: g_strfreev(email_parts); } static void contact_add_emails(struct phonebook_contact *contact, const char **reply) { char **aff_emails; int i; /* Emails from affilation */ aff_emails = g_strsplit(reply[COL_EMAIL_AFF], MAIN_DELIM, MAX_FIELDS); if (aff_emails) for (i = 0; aff_emails[i] != NULL; ++i) add_aff_field(contact, aff_emails[i], add_email); g_strfreev(aff_emails); } static void contact_add_addresses(struct phonebook_contact *contact, const char **reply) { char **aff_addr; int i; /* Addresses from affilation */ aff_addr = g_strsplit(reply[COL_ADDR_AFF], MAIN_DELIM, MAX_FIELDS); if (aff_addr) for (i = 0; aff_addr[i] != NULL; ++i) add_aff_field(contact, aff_addr[i], add_address); g_strfreev(aff_addr); } static void contact_add_urls(struct phonebook_contact *contact, const char **reply) { char **aff_url; int i; /* Addresses from affilation */ aff_url = g_strsplit(reply[COL_URL], MAIN_DELIM, MAX_FIELDS); if (aff_url) for (i = 0; aff_url[i] != NULL; ++i) add_aff_field(contact, aff_url[i], add_url); g_strfreev(aff_url); } static void contact_add_organization(struct phonebook_contact *contact, const char **reply) { /* Adding fields connected by nco:hasAffiliation - they may be in * separate replies */ add_affiliation(&contact->title, reply[COL_TITLE]); add_affiliation(&contact->company, reply[COL_ORG_NAME]); add_affiliation(&contact->department, reply[COL_ORG_DEPARTMENT]); add_affiliation(&contact->role, reply[COL_ORG_ROLE]); } static void free_data_contacts(struct phonebook_data *data) { GSList *l; /* freeing contacts */ for (l = data->contacts; l; l = l->next) { struct contact_data *c_data = l->data; g_free(c_data->id); phonebook_contact_free(c_data->contact); g_free(c_data); } g_slist_free(data->contacts); data->contacts = NULL; } static void send_pull_part(struct phonebook_data *data, const struct apparam_field *params, gboolean lastpart) { GString *vcards; DBG(""); vcards = gen_vcards(data->contacts, params); data->cb(vcards->str, vcards->len, g_slist_length(data->contacts), data->newmissedcalls, lastpart, data->user_data); if (!lastpart) free_data_contacts(data); g_string_free(vcards, TRUE); } static int pull_contacts(const char **reply, int num_fields, void *user_data) { struct phonebook_data *data = user_data; const struct apparam_field *params = data->params; struct phonebook_contact *contact; struct contact_data *contact_data; int last_index, i; gboolean cdata_present = FALSE, part_sent = FALSE; static char *temp_id = NULL; if (num_fields < 0) { data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data); goto fail; } DBG("reply %p", reply); data->tracker_index++; if (reply == NULL) goto done; /* Trying to find contact in recently added contacts. It is needed for * contacts that have more than one telephone number filled */ contact = find_contact(data->contacts, reply[CONTACTS_ID_COL], reply[COL_DATE]); /* If contact is already created then adding only new phone numbers */ if (contact) { cdata_present = TRUE; goto add_numbers; } /* We are doing a PullvCardEntry, no need for those checks */ if (data->vcardentry) goto add_entry; /* Last four fields are always present, ignoring them */ for (i = 0; i < num_fields - 4; i++) { if (reply[i][0] != '\0') break; } if (i == num_fields - 4 && !g_str_equal(reply[CONTACTS_ID_COL], TRACKER_DEFAULT_CONTACT_ME)) return 0; if (g_strcmp0(temp_id, reply[CONTACTS_ID_COL])) { data->index++; g_free(temp_id); temp_id = g_strdup(reply[CONTACTS_ID_COL]); /* Incrementing counter for vcards in current part of data, * but only if liststartoffset has been already reached */ if (data->index > params->liststartoffset) data->vcard_part_count++; } if (data->vcard_part_count > VCARDS_PART_COUNT) { DBG("Part of vcard data ready for sending..."); data->vcard_part_count = 0; /* Sending part of data to PBAP core - more data can be still * fetched, so marking lastpart as FALSE */ send_pull_part(data, params, FALSE); /* Later, after adding contact data, need to return -EINTR to * stop fetching more data for this request. Data will be * downloaded again from this point, when phonebook_pull_read * will be called again with current request as a parameter*/ part_sent = TRUE; } last_index = params->liststartoffset + params->maxlistcount; if (data->index <= params->liststartoffset) return 0; /* max number of results achieved - need send vcards data that was * already collected and stop further data processing (these operations * will be invoked in "done" section) */ if (data->index > last_index && params->maxlistcount > 0) { DBG("Maxlistcount achieved"); goto done; } add_entry: contact = g_new0(struct phonebook_contact, 1); contact_init(contact, reply); add_numbers: contact_add_numbers(contact, reply); contact_add_emails(contact, reply); contact_add_addresses(contact, reply); contact_add_urls(contact, reply); contact_add_organization(contact, reply); DBG("contact %p", contact); /* Adding contacts data to wrapper struct - this data will be used to * generate vcard list */ if (!cdata_present) { contact_data = g_new0(struct contact_data, 1); contact_data->contact = contact; contact_data->id = g_strdup(reply[CONTACTS_ID_COL]); data->contacts = g_slist_append(data->contacts, contact_data); } if (part_sent) return -EINTR; return 0; done: /* Processing is end, this is definitely last part of transmission * (marking lastpart as TRUE) */ send_pull_part(data, params, TRUE); fail: g_free(temp_id); temp_id = NULL; return -EINTR; /* * phonebook_data is freed in phonebook_req_finalize. Useful in * cases when call is terminated. */ } static int add_to_cache(const char **reply, int num_fields, void *user_data) { struct phonebook_data *data = user_data; char *formatted; int i; if (reply == NULL || num_fields < 0) goto done; /* the first element is the URI, always not empty */ for (i = 1; i < num_fields; i++) { if (reply[i][0] != '\0') break; } if (i == num_fields && !g_str_equal(reply[0], TRACKER_DEFAULT_CONTACT_ME)) return 0; if (i == 7) formatted = g_strdup(reply[7]); else if (i == 6) formatted = g_strdup(reply[6]); else formatted = g_strdup_printf("%s;%s;%s;%s;%s", reply[1], reply[2], reply[3], reply[4], reply[5]); /* The owner vCard must have the 0 handle */ if (strcmp(reply[0], TRACKER_DEFAULT_CONTACT_ME) == 0) data->entry_cb(reply[0], 0, formatted, "", reply[6], data->user_data); else data->entry_cb(reply[0], PHONEBOOK_INVALID_HANDLE, formatted, "", reply[6], data->user_data); g_free(formatted); return 0; done: if (num_fields <= 0) data->ready_cb(data->user_data); return -EINTR; /* * phonebook_data is freed in phonebook_req_finalize. Useful in * cases when call is terminated. */ } int phonebook_init(void) { g_thread_init(NULL); g_type_init(); return 0; } void phonebook_exit(void) { } char *phonebook_set_folder(const char *current_folder, const char *new_folder, uint8_t flags, int *err) { char *tmp1, *tmp2, *base, *path = NULL; gboolean root, child; int ret = 0; int len; root = (g_strcmp0("/", current_folder) == 0); child = (new_folder && strlen(new_folder) != 0); switch (flags) { case 0x02: /* Go back to root */ if (!child) { path = g_strdup("/"); goto done; } path = g_build_filename(current_folder, new_folder, NULL); break; case 0x03: /* Go up 1 level */ if (root) { /* Already root */ path = g_strdup("/"); goto done; } /* * Removing one level of the current folder. Current folder * contains AT LEAST one level since it is not at root folder. * Use glib utility functions to handle invalid chars in the * folder path properly. */ tmp1 = g_path_get_basename(current_folder); tmp2 = g_strrstr(current_folder, tmp1); len = tmp2 - (current_folder + 1); g_free(tmp1); if (len == 0) base = g_strdup("/"); else base = g_strndup(current_folder, len); /* Return: one level only */ if (!child) { path = base; goto done; } path = g_build_filename(base, new_folder, NULL); g_free(base); break; default: ret = -EBADR; break; } done: if (path && !folder_is_valid(path)) ret = -ENOENT; if (ret < 0) { g_free(path); path = NULL; } if (err) *err = ret; return path; } static int pull_newmissedcalls(const char **reply, int num_fields, void *user_data) { struct phonebook_data *data = user_data; reply_list_foreach_t pull_cb; int col_amount, err; const char *query; int nmissed; if (num_fields < 0) { data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data); return -EINTR; } if (reply != NULL) { nmissed = atoi(reply[0]); data->newmissedcalls = nmissed <= UINT8_MAX ? nmissed : UINT8_MAX; DBG("newmissedcalls %d", data->newmissedcalls); return 0; } if (data->params->maxlistcount == 0) { query = name2count_query("/telecom/mch.vcf"); col_amount = COUNT_QUERY_COL_AMOUNT; pull_cb = pull_contacts_size; } else { query = name2query("/telecom/mch.vcf"); col_amount = PULL_QUERY_COL_AMOUNT; pull_cb = pull_contacts; } err = query_tracker(query, col_amount, pull_cb, data); if (err < 0) { data->cb(NULL, 0, err, 0, TRUE, data->user_data); return -EINTR; } return 0; } void phonebook_req_finalize(void *request) { struct phonebook_data *data = request; DBG(""); if (!data) return; /* canceling asynchronous operation on tracker if any is active */ if (data->query_canc) { g_cancellable_cancel(data->query_canc); g_object_unref(data->query_canc); } free_data_contacts(data); g_free(data->req_name); g_free(data); } void *phonebook_pull(const char *name, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct phonebook_data *data; DBG("name %s", name); data = g_new0(struct phonebook_data, 1); data->params = params; data->user_data = user_data; data->cb = cb; data->req_name = g_strdup(name); if (err) *err = 0; return data; } int phonebook_pull_read(void *request) { struct phonebook_data *data = request; reply_list_foreach_t pull_cb; const char *query; char *offset_query; int col_amount; int ret; if (!data) return -ENOENT; data->newmissedcalls = 0; if (g_strcmp0(data->req_name, "/telecom/mch.vcf") == 0 && data->tracker_index == 0) { /* new missed calls amount should be counted only once - it * will be done during generating first part of results of * missed calls history */ query = NEW_MISSED_CALLS_COUNT_QUERY; col_amount = COUNT_QUERY_COL_AMOUNT; pull_cb = pull_newmissedcalls; } else if (data->params->maxlistcount == 0) { query = name2count_query(data->req_name); col_amount = COUNT_QUERY_COL_AMOUNT; pull_cb = pull_contacts_size; } else { query = name2query(data->req_name); col_amount = PULL_QUERY_COL_AMOUNT; pull_cb = pull_contacts; } if (query == NULL) return -ENOENT; if (pull_cb == pull_contacts && data->tracker_index > 0) { /* Adding offset to pull query to download next parts of data * from tracker (phonebook_pull_read may be called many times * from PBAP core to fetch data partially) */ offset_query = g_strdup_printf(QUERY_OFFSET_FORMAT, query, data->tracker_index); ret = query_tracker(offset_query, col_amount, pull_cb, data); g_free(offset_query); return ret; } return query_tracker(query, col_amount, pull_cb, data); } void *phonebook_get_entry(const char *folder, const char *id, const struct apparam_field *params, phonebook_cb cb, void *user_data, int *err) { struct phonebook_data *data; char *query; int ret; DBG("folder %s id %s", folder, id); data = g_new0(struct phonebook_data, 1); data->user_data = user_data; data->params = params; data->cb = cb; data->vcardentry = TRUE; if (g_str_has_prefix(id, CONTACT_ID_PREFIX) == TRUE || g_strcmp0(id, TRACKER_DEFAULT_CONTACT_ME) == 0) query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id, id, id, id, id, id, id, id, id, id); else if (g_str_has_prefix(id, CALL_ID_PREFIX) == TRUE) query = g_strdup_printf(CONTACT_FROM_CALL_QUERY, id); else query = g_strdup_printf(CONTACTS_OTHER_QUERY_FROM_URI, id, id, id); ret = query_tracker(query, PULL_QUERY_COL_AMOUNT, pull_contacts, data); if (err) *err = ret; g_free(query); return data; } void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, phonebook_cache_ready_cb ready_cb, void *user_data, int *err) { struct phonebook_data *data; const char *query; int ret; DBG("name %s", name); query = folder2query(name); if (query == NULL) { if (err) *err = -ENOENT; return NULL; } data = g_new0(struct phonebook_data, 1); data->entry_cb = entry_cb; data->ready_cb = ready_cb; data->user_data = user_data; ret = query_tracker(query, 8, add_to_cache, data); if (err) *err = ret; return data; } obexd-0.46/ltmain.sh0000644000000000000000000105202211755212542011261 00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 obexd-0.46/compile0000755000000000000000000001533711755212544011030 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-01-04.17; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free # Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l*) lib=${1#-l} found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes set x "$@" "$dir/$lib.dll.lib" break fi if test -f "$dir/$lib.lib"; then found=yes set x "$@" "$dir/$lib.lib" break fi done IFS=$save_IFS test "$found" != yes && set x "$@" "$lib.lib" shift ;; -L*) func_file_conv "${1#-L}" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: obexd-0.46/AUTHORS0000644000000000000000000000113111755212521010500 00000000000000Marcel Holtmann Johan Hedberg Claudio Takahasi Luiz Augusto von Dentz Vinicius Costa Gomes Larry Junior Forrest Zhao Raymond Liu Radoslaw Jablonski Rafal Michalski Dmitriy Paliy Bartosz Szatkowski Lukasz Pawlik Slawomir Bochenski obexd-0.46/client/0000755000000000000000000000000011755212615010776 500000000000000obexd-0.46/client/bluetooth.c0000644000000000000000000003421411755212521013067 00000000000000/* * * OBEX Client * * Copyright (C) 2012 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include "log.h" #include "transport.h" #include "bluetooth.h" #define BT_BUS_NAME "org.bluez" #define BT_PATH "/" #define BT_ADAPTER_IFACE "org.bluez.Adapter" #define BT_MANAGER_IFACE "org.bluez.Manager" #define BT_RX_MTU 32767 #define BT_TX_MTU 32767 #define OBC_BT_ERROR obc_bt_error_quark() struct bluetooth_session { guint id; bdaddr_t src; bdaddr_t dst; uint16_t port; DBusConnection *conn; /* system bus connection */ sdp_session_t *sdp; GIOChannel *io; GSList *pending_calls; char *adapter; char *service; obc_transport_func func; void *user_data; }; static GSList *sessions = NULL; static GQuark obc_bt_error_quark(void) { return g_quark_from_static_string("obc-bluetooth-error-quark"); } static int send_method_call(struct bluetooth_session *session, const char *path, const char *interface, const char *method, DBusPendingCallNotifyFunction cb, int type, ...) { DBusMessage *msg; DBusPendingCall *call; va_list args; msg = dbus_message_new_method_call(BT_BUS_NAME, path, interface, method); if (!msg) { error("Unable to allocate new D-Bus %s message", method); return -ENOMEM; } va_start(args, type); if (!dbus_message_append_args_valist(msg, type, args)) { dbus_message_unref(msg); va_end(args); return -EINVAL; } va_end(args); if (!cb) { g_dbus_send_message(session->conn, msg); return 0; } if (!dbus_connection_send_with_reply(session->conn, msg, &call, -1)) { error("Sending %s failed", method); dbus_message_unref(msg); return -EIO; } dbus_pending_call_set_notify(call, cb, session, NULL); session->pending_calls = g_slist_prepend(session->pending_calls, call); return 0; } static void finalize_call(DBusPendingCall *call) { if (!dbus_pending_call_get_completed(call)) dbus_pending_call_cancel(call); dbus_pending_call_unref(call); } static void session_destroy(struct bluetooth_session *session) { GSList *l; DBG("%p", session); if (g_slist_find(sessions, session) == NULL) return; sessions = g_slist_remove(sessions, session); if (session->adapter) send_method_call(session, session->adapter, BT_ADAPTER_IFACE, "ReleaseSession", NULL, DBUS_TYPE_INVALID); l = session->pending_calls; while (l) { DBusPendingCall *call = l->data; l = l->next; session->pending_calls = g_slist_remove(session->pending_calls, call); finalize_call(call); } if (session->io != NULL) { g_io_channel_shutdown(session->io, TRUE, NULL); g_io_channel_unref(session->io); } if (session->conn) dbus_connection_unref(session->conn); g_free(session->service); g_free(session->adapter); g_free(session); } static void transport_callback(GIOChannel *io, GError *err, gpointer user_data) { struct bluetooth_session *session = user_data; DBG(""); if (session->func) session->func(io, err, session->user_data); if (err != NULL) session_destroy(session); } static GIOChannel *transport_connect(const bdaddr_t *src, const bdaddr_t *dst, uint16_t port, BtIOConnect function, gpointer user_data) { GIOChannel *io; GError *err = NULL; DBG("port %u", port); if (port > 31) { io = bt_io_connect(BT_IO_L2CAP, function, user_data, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, src, BT_IO_OPT_DEST_BDADDR, dst, BT_IO_OPT_PSM, port, BT_IO_OPT_MODE, BT_IO_MODE_ERTM, BT_IO_OPT_OMTU, BT_TX_MTU, BT_IO_OPT_IMTU, BT_RX_MTU, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } else { io = bt_io_connect(BT_IO_RFCOMM, function, user_data, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, src, BT_IO_OPT_DEST_BDADDR, dst, BT_IO_OPT_CHANNEL, port, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } if (io != NULL) return io; error("%s", err->message); g_error_free(err); return NULL; } static void search_callback(uint8_t type, uint16_t status, uint8_t *rsp, size_t size, void *user_data) { struct bluetooth_session *session = user_data; unsigned int scanned, bytesleft = size; int seqlen = 0; uint8_t dataType; uint16_t port = 0; GError *gerr = NULL; if (status || type != SDP_SVC_SEARCH_ATTR_RSP) goto failed; scanned = sdp_extract_seqtype(rsp, bytesleft, &dataType, &seqlen); if (!scanned || !seqlen) goto failed; rsp += scanned; bytesleft -= scanned; do { sdp_record_t *rec; sdp_list_t *protos; sdp_data_t *data; int recsize, ch = -1; recsize = 0; rec = sdp_extract_pdu(rsp, bytesleft, &recsize); if (!rec) break; if (!recsize) { sdp_record_free(rec); break; } if (!sdp_get_access_protos(rec, &protos)) { ch = sdp_get_proto_port(protos, RFCOMM_UUID); sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free, NULL); sdp_list_free(protos, NULL); protos = NULL; } data = sdp_data_get(rec, 0x0200); /* PSM must be odd and lsb of upper byte must be 0 */ if (data != NULL && (data->val.uint16 & 0x0101) == 0x0001) ch = data->val.uint16; sdp_record_free(rec); if (ch > 0) { port = ch; break; } scanned += recsize; rsp += recsize; bytesleft -= recsize; } while (scanned < size && bytesleft > 0); if (port == 0) goto failed; session->port = port; g_io_channel_set_close_on_unref(session->io, FALSE); g_io_channel_unref(session->io); session->io = transport_connect(&session->src, &session->dst, port, transport_callback, session); if (session->io != NULL) { sdp_close(session->sdp); session->sdp = NULL; return; } failed: if (session->io != NULL) { g_io_channel_shutdown(session->io, TRUE, NULL); g_io_channel_unref(session->io); session->io = NULL; } g_set_error(&gerr, OBC_BT_ERROR, -EIO, "Unable to find service record"); if (session->func) session->func(session->io, gerr, session->user_data); g_clear_error(&gerr); session_destroy(session); } static gboolean process_callback(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct bluetooth_session *session = user_data; if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) return FALSE; if (sdp_process(session->sdp) < 0) return FALSE; return TRUE; } static int bt_string2uuid(uuid_t *uuid, const char *string) { uint32_t data0, data4; uint16_t data1, data2, data3, data5; if (sscanf(string, "%08x-%04hx-%04hx-%04hx-%08x%04hx", &data0, &data1, &data2, &data3, &data4, &data5) == 6) { uint8_t val[16]; data0 = g_htonl(data0); data1 = g_htons(data1); data2 = g_htons(data2); data3 = g_htons(data3); data4 = g_htonl(data4); data5 = g_htons(data5); memcpy(&val[0], &data0, 4); memcpy(&val[4], &data1, 2); memcpy(&val[6], &data2, 2); memcpy(&val[8], &data3, 2); memcpy(&val[10], &data4, 4); memcpy(&val[14], &data5, 2); sdp_uuid128_create(uuid, val); return 0; } return -EINVAL; } static gboolean service_callback(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct bluetooth_session *session = user_data; sdp_list_t *search, *attrid; uint32_t range = 0x0000ffff; GError *gerr = NULL; uuid_t uuid; if (cond & G_IO_NVAL) return FALSE; if (cond & G_IO_ERR) goto failed; if (sdp_set_notify(session->sdp, search_callback, session) < 0) goto failed; if (bt_string2uuid(&uuid, session->service) < 0) goto failed; search = sdp_list_append(NULL, &uuid); attrid = sdp_list_append(NULL, &range); if (sdp_service_search_attr_async(session->sdp, search, SDP_ATTR_REQ_RANGE, attrid) < 0) { sdp_list_free(attrid, NULL); sdp_list_free(search, NULL); goto failed; } sdp_list_free(attrid, NULL); sdp_list_free(search, NULL); g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, process_callback, session); return FALSE; failed: g_io_channel_shutdown(session->io, TRUE, NULL); g_io_channel_unref(session->io); session->io = NULL; g_set_error(&gerr, OBC_BT_ERROR, -EIO, "Unable to find service record"); if (session->func) session->func(session->io, gerr, session->user_data); g_clear_error(&gerr); session_destroy(session); return FALSE; } static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst, GIOFunc function, gpointer user_data) { struct bluetooth_session *session = user_data; sdp_session_t *sdp; GIOChannel *io; sdp = sdp_connect(src, dst, SDP_NON_BLOCKING); if (sdp == NULL) return NULL; io = g_io_channel_unix_new(sdp_get_socket(sdp)); if (io == NULL) { sdp_close(sdp); return NULL; } g_io_add_watch(io, G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL, function, user_data); session->io = io; return sdp; } static int session_connect(struct bluetooth_session *session) { int err; if (session->port > 0) { session->io = transport_connect(&session->src, &session->dst, session->port, transport_callback, session); err = (session->io == NULL) ? -EINVAL : 0; } else { session->sdp = service_connect(&session->src, &session->dst, service_callback, session); err = (session->sdp == NULL) ? -ENOMEM : 0; } return err; } static void adapter_reply(DBusPendingCall *call, void *user_data) { struct bluetooth_session *session = user_data; DBusError err; DBusMessage *reply; GError *gerr = NULL; reply = dbus_pending_call_steal_reply(call); session->pending_calls = g_slist_remove(session->pending_calls, call); finalize_call(call); dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) { error("manager replied with an error: %s, %s", err.name, err.message); dbus_error_free(&err); goto failed; } if (session_connect(session) == 0) goto proceed; failed: g_set_error(&gerr, OBC_BT_ERROR, -EINVAL, "Unable to request session"); if (session->func) session->func(session->io, gerr, session->user_data); g_clear_error(&gerr); session_destroy(session); proceed: dbus_message_unref(reply); } static int request_session(struct bluetooth_session *session, const char *adapter) { session->adapter = g_strdup(adapter); return send_method_call(session, adapter, BT_ADAPTER_IFACE, "RequestSession", adapter_reply, DBUS_TYPE_INVALID); } static void manager_reply(DBusPendingCall *call, void *user_data) { struct bluetooth_session *session = user_data; DBusError err; DBusMessage *reply; char *adapter; GError *gerr = NULL; reply = dbus_pending_call_steal_reply(call); session->pending_calls = g_slist_remove(session->pending_calls, call); finalize_call(call); dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) { error("manager replied with an error: %s, %s", err.name, err.message); dbus_error_free(&err); goto failed; } if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &adapter, DBUS_TYPE_INVALID)) goto failed; DBG("adapter path %s", adapter); if (request_session(session, adapter) == 0) goto proceed; failed: g_set_error(&gerr, OBC_BT_ERROR, -EINVAL, "No adapter found"); if (session->func) session->func(session->io, gerr, session->user_data); g_clear_error(&gerr); session_destroy(session); proceed: dbus_message_unref(reply); } static int find_adapter(struct bluetooth_session *session, const char *source) { if (source == NULL) { bacpy(&session->src, BDADDR_ANY); return send_method_call(session, BT_PATH, BT_MANAGER_IFACE, "DefaultAdapter", manager_reply, DBUS_TYPE_INVALID); } str2ba(source, &session->src); return send_method_call(session, BT_PATH, BT_MANAGER_IFACE, "FindAdapter", manager_reply, DBUS_TYPE_STRING, &source, DBUS_TYPE_INVALID); } static guint bluetooth_connect(const char *source, const char *destination, const char *service, uint16_t port, obc_transport_func func, void *user_data) { struct bluetooth_session *session; static guint id = 0; DBG(""); if (destination == NULL) return 0; session = g_try_malloc0(sizeof(*session)); if (session == NULL) return 0; session->id = ++id; session->func = func; session->user_data = user_data; session->conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); if (session->conn == NULL) { g_free(session); return 0; } session->service = g_strdup(service); str2ba(destination, &session->dst); if (find_adapter(session, source) < 0) { g_free(session); return 0; } sessions = g_slist_prepend(sessions, session); return session->id; } static void bluetooth_disconnect(guint id) { GSList *l; DBG(""); for (l = sessions; l; l = l->next) { struct bluetooth_session *session = l->data; if (session->id == id) { session_destroy(session); return; } } } static int bluetooth_getpacketopt(GIOChannel *io, int *tx_mtu, int *rx_mtu) { int sk = g_io_channel_unix_get_fd(io); int type; int omtu = -1; int imtu = -1; socklen_t len = sizeof(int); DBG(""); if (getsockopt(sk, SOL_SOCKET, SO_TYPE, &type, &len) < 0) return -errno; if (type != SOCK_SEQPACKET) return -EINVAL; if (!bt_io_get(io, BT_IO_L2CAP, NULL, BT_IO_OPT_OMTU, &omtu, BT_IO_OPT_IMTU, &imtu, BT_IO_OPT_INVALID)) return -EINVAL; if (tx_mtu) *tx_mtu = omtu; if (rx_mtu) *rx_mtu = imtu; return 0; } static struct obc_transport bluetooth = { .name = "Bluetooth", .connect = bluetooth_connect, .getpacketopt = bluetooth_getpacketopt, .disconnect = bluetooth_disconnect, }; int bluetooth_init(void) { DBG(""); return obc_transport_register(&bluetooth); } void bluetooth_exit(void) { DBG(""); obc_transport_unregister(&bluetooth); } obexd-0.46/client/pbap.h0000644000000000000000000000163111755212521012006 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int pbap_init(void); void pbap_exit(void); obexd-0.46/client/transfer.h0000644000000000000000000000442211755212521012711 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obc_transfer; typedef void (*transfer_callback_t) (struct obc_transfer *transfer, gint64 transferred, GError *err, void *user_data); struct obc_transfer *obc_transfer_get(const char *type, const char *name, const char *filename, GError **err); struct obc_transfer *obc_transfer_put(const char *type, const char *name, const char *filename, const void *contents, size_t size, GError **err); gboolean obc_transfer_register(struct obc_transfer *transfer, DBusConnection *conn, const char *agent, GError **err); void obc_transfer_unregister(struct obc_transfer *transfer); gboolean obc_transfer_set_callback(struct obc_transfer *transfer, transfer_callback_t func, void *user_data); gboolean obc_transfer_start(struct obc_transfer *transfer, void *obex, GError **err); guint8 obc_transfer_get_operation(struct obc_transfer *transfer); void obc_transfer_set_params(struct obc_transfer *transfer, const void *data, size_t size); const void *obc_transfer_get_params(struct obc_transfer *transfer, size_t *size); int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents, size_t *size); void obc_transfer_set_name(struct obc_transfer *transfer, const char *name); int obc_transfer_set_filename(struct obc_transfer *transfer, const char *filename); const char *obc_transfer_get_path(struct obc_transfer *transfer); gint64 obc_transfer_get_size(struct obc_transfer *transfer); obexd-0.46/client/ftp.h0000644000000000000000000000155011755212521011655 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int ftp_init(void); void ftp_exit(void); obexd-0.46/client/transport.c0000644000000000000000000000371611755212521013121 00000000000000/* * * OBEX Server * * Copyright (C) 2012 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "transport.h" #include "log.h" static GSList *transports = NULL; struct obc_transport *obc_transport_find(const char *name) { GSList *l; for (l = transports; l; l = l->next) { struct obc_transport *transport = l->data; if (strcasecmp(name, transport->name) == 0) return transport; } return NULL; } int obc_transport_register(struct obc_transport *transport) { if (!transport) { error("Invalid transport"); return -EINVAL; } if (obc_transport_find(transport->name)) { error("Permission denied: transport %s already registered", transport->name); return -EPERM; } DBG("transport %p name %s registered", transport, transport->name); transports = g_slist_append(transports, transport); return 0; } void obc_transport_unregister(struct obc_transport *transport) { if (!g_slist_find(transports, transport)) { error("Unable to unregister: No such transport %p", transport); return; } DBG("transport %p name %s unregistered", transport, transport->name); transports = g_slist_remove(transports, transport); } obexd-0.46/client/obex-client.service.in0000644000000000000000000000010711071665561015117 00000000000000[D-BUS Service] Name=org.openobex.client Exec=@libexecdir@/obex-client obexd-0.46/client/opp.h0000644000000000000000000000151611755212521011664 00000000000000/* * * OBEX Client * * Copyright (C) 2011 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int opp_init(void); void opp_exit(void); obexd-0.46/client/opp.c0000644000000000000000000000233011755212521011652 00000000000000/* * * OBEX Client * * Copyright (C) 2011 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include "log.h" #include "transfer.h" #include "session.h" #include "driver.h" #include "opp.h" #define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb" static struct obc_driver opp = { .service = "OPP", .uuid = OPP_UUID, }; int opp_init(void) { DBG(""); return obc_driver_register(&opp); } void opp_exit(void) { DBG(""); obc_driver_unregister(&opp); } obexd-0.46/client/transport.h0000644000000000000000000000254111755212521013121 00000000000000/* * * OBEX Server * * Copyright (C) 2012 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ typedef void (*obc_transport_func)(GIOChannel *io, GError *err, gpointer user_data); struct obc_transport { const char *name; guint (*connect) (const char *source, const char *destination, const char *service, uint16_t port, obc_transport_func func, void *user_data); int (*getpacketopt) (GIOChannel *io, int *tx_mtu, int *rx_mtu); void (*disconnect) (guint id); }; int obc_transport_register(struct obc_transport *transport); void obc_transport_unregister(struct obc_transport *transport); struct obc_transport *obc_transport_find(const char *name); obexd-0.46/client/agent.c0000644000000000000000000001262311755212521012160 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include "log.h" #include "agent.h" #define AGENT_INTERFACE "org.openobex.Agent" struct pending_request { DBusPendingCall *call; DBusPendingCallNotifyFunction function; void *data; DBusFreeFunction destroy; }; struct obc_agent { DBusConnection *conn; char *name; char *path; guint watch; GFunc destroy; void *data; struct pending_request *pending; }; static void pending_request_free(struct pending_request *req) { if (req->call) dbus_pending_call_unref(req->call); if (req->destroy) req->destroy(req->data); g_free(req); } void obc_agent_free(struct obc_agent *agent) { if (agent->watch) g_dbus_remove_watch(agent->conn, agent->watch); if (agent->pending) { if (agent->pending->call) dbus_pending_call_cancel(agent->pending->call); pending_request_free(agent->pending); } dbus_connection_unref(agent->conn); g_free(agent->name); g_free(agent->path); g_free(agent); } static void agent_disconnected(DBusConnection *connection, void *user_data) { struct obc_agent *agent = user_data; agent->watch = 0; if (agent->destroy) agent->destroy(agent, agent->data); obc_agent_free(agent); } struct obc_agent *obc_agent_create(DBusConnection *conn, const char *name, const char *path, GFunc destroy, void *user_data) { struct obc_agent *agent; agent = g_new0(struct obc_agent, 1); agent->conn = dbus_connection_ref(conn); agent->name = g_strdup(name); agent->path = g_strdup(path); agent->destroy = destroy; agent->data = user_data; agent->watch = g_dbus_add_disconnect_watch(conn, name, agent_disconnected, agent, NULL); return agent; } static void agent_request_reply(DBusPendingCall *call, void *user_data) { struct obc_agent *agent = user_data; struct pending_request *req = agent->pending; agent->pending = NULL; if (req->function) req->function(call, req->data); pending_request_free(req); } int obc_agent_request(struct obc_agent *agent, const char *path, DBusPendingCallNotifyFunction function, void *user_data, DBusFreeFunction destroy) { struct pending_request *req; DBusMessage *message; if (agent->pending) return -EBUSY; DBG("%s", path); message = dbus_message_new_method_call(agent->name, agent->path, AGENT_INTERFACE, "Request"); dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); req = g_new0(struct pending_request, 1); req->function = function; req->destroy = destroy; req->data = user_data; if (!dbus_connection_send_with_reply(agent->conn, message, &req->call, -1)) { g_free(req); dbus_message_unref(message); return -ENOMEM; } agent->pending = req; dbus_message_unref(message); dbus_pending_call_set_notify(req->call, agent_request_reply, agent, NULL); return 0; } void obc_agent_notify_progress(struct obc_agent *agent, const char *path, guint64 transferred) { DBusMessage *message; DBG("%s", path); message = dbus_message_new_method_call(agent->name, agent->path, AGENT_INTERFACE, "Progress"); if (message == NULL) return; dbus_message_set_no_reply(message, TRUE); dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_UINT64, &transferred, DBUS_TYPE_INVALID); g_dbus_send_message(agent->conn, message); } void obc_agent_notify_complete(struct obc_agent *agent, const char *path) { DBusMessage *message; DBG("%s", path); message = dbus_message_new_method_call(agent->name, agent->path, AGENT_INTERFACE, "Complete"); if (message == NULL) return; dbus_message_set_no_reply(message, TRUE); dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); g_dbus_send_message(agent->conn, message); } void obc_agent_notify_error(struct obc_agent *agent, const char *path, const char *err) { DBusMessage *message; DBG("%s", path); message = dbus_message_new_method_call(agent->name, agent->path, AGENT_INTERFACE, "Error"); if (message == NULL) return; dbus_message_set_no_reply(message, TRUE); dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); g_dbus_send_message(agent->conn, message); } void obc_agent_release(struct obc_agent *agent) { DBusMessage *message; DBG(""); message = dbus_message_new_method_call(agent->name, agent->path, AGENT_INTERFACE, "Release"); dbus_message_set_no_reply(message, TRUE); g_dbus_send_message(agent->conn, message); } const char *obc_agent_get_name(struct obc_agent *agent) { return agent->name; } const char *obc_agent_get_path(struct obc_agent *agent) { return agent->path; } obexd-0.46/client/sync.h0000644000000000000000000000163111755212521012040 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int sync_init(void); void sync_exit(void); obexd-0.46/client/ftp.c0000644000000000000000000003232611755212521011655 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "log.h" #include "transfer.h" #include "session.h" #include "driver.h" #include "ftp.h" #define OBEX_FTP_UUID \ "\xF9\xEC\x7B\xC4\x95\x3C\x11\xD2\x98\x4E\x52\x54\x00\xDC\x9E\x09" #define OBEX_FTP_UUID_LEN 16 #define FTP_INTERFACE "org.openobex.FileTransfer" #define FTP_UUID "00001106-0000-1000-8000-00805f9b34fb" #define PCSUITE_UUID "00005005-0000-1000-8000-0002ee000001" static DBusConnection *conn = NULL; struct ftp_data { struct obc_session *session; }; static void async_cb(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { DBusMessage *reply, *msg = user_data; if (err != NULL) reply = g_dbus_create_error(msg, "org.openobex.Error.Failed", "%s", err->message); else reply = dbus_message_new_method_return(msg); g_dbus_send_message(conn, reply); dbus_message_unref(msg); } static DBusMessage *change_folder(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; const char *folder; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_setpath(session, folder, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } dbus_message_ref(message); return NULL; } static void append_variant(DBusMessageIter *iter, int type, void *val) { DBusMessageIter value; char sig[2] = { type, '\0' }; dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value); dbus_message_iter_append_basic(&value, type, val); dbus_message_iter_close_container(iter, &value); } static void dict_append_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry; if (type == DBUS_TYPE_STRING) { const char *str = *((const char **) val); if (str == NULL) return; } dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); append_variant(&entry, type, val); dbus_message_iter_close_container(dict, &entry); } static void xml_element(GMarkupParseContext *ctxt, const gchar *element, const gchar **names, const gchar **values, gpointer user_data, GError **gerr) { DBusMessageIter dict, *iter = user_data; gchar *key; gint i; if (strcasecmp("folder", element) != 0 && strcasecmp("file", element) != 0) return; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); dict_append_entry(&dict, "Type", DBUS_TYPE_STRING, &element); /* FIXME: User, Group, Other permission must be reviewed */ i = 0; for (key = (gchar *) names[i]; key; key = (gchar *) names[++i]) { key[0] = g_ascii_toupper(key[0]); if (g_str_equal("Size", key) == TRUE) { guint64 size; size = g_ascii_strtoll(values[i], NULL, 10); dict_append_entry(&dict, key, DBUS_TYPE_UINT64, &size); } else dict_append_entry(&dict, key, DBUS_TYPE_STRING, &values[i]); } dbus_message_iter_close_container(iter, &dict); } static const GMarkupParser parser = { xml_element, NULL, NULL, NULL, NULL }; static void get_file_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { DBusMessage *msg = user_data; DBusMessage *reply; if (err) reply = g_dbus_create_error(msg, "org.openobex.Error.Failed", "%s", err->message); else reply = dbus_message_new_method_return(msg); g_dbus_send_message(conn, reply); dbus_message_unref(msg); } static void list_folder_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { DBusMessage *msg = user_data; GMarkupParseContext *ctxt; DBusMessage *reply; DBusMessageIter iter, array; char *contents; size_t size; reply = dbus_message_new_method_return(msg); if (obc_transfer_get_contents(transfer, &contents, &size) < 0) goto done; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_ARRAY_AS_STRING DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &array); ctxt = g_markup_parse_context_new(&parser, 0, &array, NULL); g_markup_parse_context_parse(ctxt, contents, size, NULL); g_markup_parse_context_free(ctxt); dbus_message_iter_close_container(&iter, &array); g_free(contents); done: g_dbus_send_message(conn, reply); dbus_message_unref(msg); } static DBusMessage *create_folder(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; const char *folder; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_mkdir(session, folder, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } dbus_message_ref(message); return NULL; } static DBusMessage *list_folder(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; struct obc_transfer *transfer; GError *err = NULL; DBusMessage *reply; transfer = obc_transfer_get("x-obex/folder-listing", NULL, NULL, &err); if (transfer == NULL) goto fail; if (obc_session_queue(session, transfer, list_folder_callback, message, &err)) { dbus_message_ref(message); return NULL; } fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *get_file(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; struct obc_transfer *transfer; const char *target_file, *source_file; GError *err = NULL; DBusMessage *reply; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &target_file, DBUS_TYPE_STRING, &source_file, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); transfer = obc_transfer_get(NULL, source_file, target_file, &err); if (transfer == NULL) goto fail; if (obc_session_queue(session, transfer, get_file_callback, message, &err)) { dbus_message_ref(message); return NULL; } fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *put_file(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; struct obc_transfer *transfer; gchar *sourcefile, *targetfile; GError *err = NULL; DBusMessage *reply; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &sourcefile, DBUS_TYPE_STRING, &targetfile, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", "Invalid arguments in method call"); transfer = obc_transfer_put(NULL, targetfile, sourcefile, NULL, 0, &err); if (transfer == NULL) goto fail; if (obc_session_queue(session, transfer, NULL, NULL, &err)) return dbus_message_new_method_return(message); fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *copy_file(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; const char *filename, *destname; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &filename, DBUS_TYPE_STRING, &destname, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_copy(session, filename, destname, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } dbus_message_ref(message); return NULL; } static DBusMessage *move_file(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; const char *filename, *destname; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &filename, DBUS_TYPE_STRING, &destname, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_move(session, filename, destname, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } dbus_message_ref(message); return NULL; } static DBusMessage *delete(DBusConnection *connection, DBusMessage *message, void *user_data) { struct ftp_data *ftp = user_data; struct obc_session *session = ftp->session; const char *file; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_delete(session, file, async_cb, message, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } dbus_message_ref(message); return NULL; } static GDBusMethodTable ftp_methods[] = { { "ChangeFolder", "s", "", change_folder, G_DBUS_METHOD_FLAG_ASYNC }, { "CreateFolder", "s", "", create_folder, G_DBUS_METHOD_FLAG_ASYNC }, { "ListFolder", "", "aa{sv}", list_folder, G_DBUS_METHOD_FLAG_ASYNC }, { "GetFile", "ss", "", get_file, G_DBUS_METHOD_FLAG_ASYNC }, { "PutFile", "ss", "", put_file, G_DBUS_METHOD_FLAG_ASYNC }, { "CopyFile", "ss", "", copy_file, G_DBUS_METHOD_FLAG_ASYNC }, { "MoveFile", "ss", "", move_file, G_DBUS_METHOD_FLAG_ASYNC }, { "Delete", "s", "", delete, G_DBUS_METHOD_FLAG_ASYNC }, { } }; static void ftp_free(void *data) { struct ftp_data *ftp = data; obc_session_unref(ftp->session); g_free(ftp); } static int ftp_probe(struct obc_session *session) { struct ftp_data *ftp; const char *path; path = obc_session_get_path(session); DBG("%s", path); ftp = g_try_new0(struct ftp_data, 1); if (!ftp) return -ENOMEM; ftp->session = obc_session_ref(session); if (!g_dbus_register_interface(conn, path, FTP_INTERFACE, ftp_methods, NULL, NULL, ftp, ftp_free)) { ftp_free(ftp); return -ENOMEM; } return 0; } static void ftp_remove(struct obc_session *session) { const char *path = obc_session_get_path(session); DBG("%s", path); g_dbus_unregister_interface(conn, path, FTP_INTERFACE); } static struct obc_driver ftp = { .service = "FTP", .uuid = FTP_UUID, .target = OBEX_FTP_UUID, .target_len = OBEX_FTP_UUID_LEN, .probe = ftp_probe, .remove = ftp_remove }; static struct obc_driver pcsuite = { .service = "PCSUITE", .uuid = PCSUITE_UUID, .target = OBEX_FTP_UUID, .target_len = OBEX_FTP_UUID_LEN, .probe = ftp_probe, .remove = ftp_remove }; int ftp_init(void) { int err; DBG(""); conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (!conn) return -EIO; err = obc_driver_register(&ftp); if (err < 0) goto failed; err = obc_driver_register(&pcsuite); if (err < 0) { obc_driver_unregister(&ftp); goto failed; } return 0; failed: dbus_connection_unref(conn); conn = NULL; return err; } void ftp_exit(void) { DBG(""); dbus_connection_unref(conn); conn = NULL; obc_driver_unregister(&ftp); obc_driver_unregister(&pcsuite); } obexd-0.46/client/map.c0000644000000000000000000001441011755212521011633 00000000000000/* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski for Comarch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "log.h" #include "map.h" #include "transfer.h" #include "session.h" #include "driver.h" #define OBEX_MAS_UUID \ "\xBB\x58\x2B\x40\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66" #define OBEX_MAS_UUID_LEN 16 #define MAP_INTERFACE "org.openobex.MessageAccess" #define MAS_UUID "00001132-0000-1000-8000-00805f9b34fb" struct map_data { struct obc_session *session; DBusMessage *msg; }; static DBusConnection *conn = NULL; static void simple_cb(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { DBusMessage *reply; struct map_data *map = user_data; if (err != NULL) reply = g_dbus_create_error(map->msg, "org.openobex.Error.Failed", "%s", err->message); else reply = dbus_message_new_method_return(map->msg); g_dbus_send_message(conn, reply); dbus_message_unref(map->msg); } static DBusMessage *map_setpath(DBusConnection *connection, DBusMessage *message, void *user_data) { struct map_data *map = user_data; const char *folder; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &folder, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); obc_session_setpath(map->session, folder, simple_cb, map, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } map->msg = dbus_message_ref(message); return NULL; } static void buffer_cb(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct map_data *map = user_data; DBusMessage *reply; char *contents; size_t size; int perr; if (err != NULL) { reply = g_dbus_create_error(map->msg, "org.openobex.Error.Failed", "%s", err->message); goto done; } perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(map->msg, "org.openobex.Error.Failed", "Error reading contents: %s", strerror(-perr)); goto done; } reply = g_dbus_create_reply(map->msg, DBUS_TYPE_STRING, &contents, DBUS_TYPE_INVALID); g_free(contents); done: g_dbus_send_message(conn, reply); dbus_message_unref(map->msg); } static DBusMessage *map_get_folder_listing(DBusConnection *connection, DBusMessage *message, void *user_data) { struct map_data *map = user_data; struct obc_transfer *transfer; GError *err = NULL; DBusMessage *reply; transfer = obc_transfer_get("x-obex/folder-listing", NULL, NULL, &err); if (transfer == NULL) goto fail; if (obc_session_queue(map->session, transfer, buffer_cb, map, &err)) { map->msg = dbus_message_ref(message); return NULL; } fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *map_get_message_listing(DBusConnection *connection, DBusMessage *message, void *user_data) { struct map_data *map = user_data; struct obc_transfer *transfer; const char *folder; DBusMessageIter msg_iter; GError *err = NULL; DBusMessage *reply; dbus_message_iter_init(message, &msg_iter); if (dbus_message_iter_get_arg_type(&msg_iter) != DBUS_TYPE_STRING) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); dbus_message_iter_get_basic(&msg_iter, &folder); transfer = obc_transfer_get("x-bt/MAP-msg-listing", folder, NULL, &err); if (transfer == NULL) goto fail; if (obc_session_queue(map->session, transfer, buffer_cb, map, &err)) { map->msg = dbus_message_ref(message); return NULL; } fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static GDBusMethodTable map_methods[] = { { "SetFolder", "s", "", map_setpath, G_DBUS_METHOD_FLAG_ASYNC }, { "GetFolderListing", "a{ss}", "s", map_get_folder_listing, G_DBUS_METHOD_FLAG_ASYNC }, { "GetMessageListing", "sa{ss}", "s", map_get_message_listing, G_DBUS_METHOD_FLAG_ASYNC }, { } }; static void map_free(void *data) { struct map_data *map = data; obc_session_unref(map->session); g_free(map); } static int map_probe(struct obc_session *session) { struct map_data *map; const char *path; path = obc_session_get_path(session); DBG("%s", path); map = g_try_new0(struct map_data, 1); if (!map) return -ENOMEM; map->session = obc_session_ref(session); if (!g_dbus_register_interface(conn, path, MAP_INTERFACE, map_methods, NULL, NULL, map, map_free)) { map_free(map); return -ENOMEM; } return 0; } static void map_remove(struct obc_session *session) { const char *path = obc_session_get_path(session); DBG("%s", path); g_dbus_unregister_interface(conn, path, MAP_INTERFACE); } static struct obc_driver map = { .service = "MAP", .uuid = MAS_UUID, .target = OBEX_MAS_UUID, .target_len = OBEX_MAS_UUID_LEN, .probe = map_probe, .remove = map_remove }; int map_init(void) { int err; DBG(""); conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (!conn) return -EIO; err = obc_driver_register(&map); if (err < 0) { dbus_connection_unref(conn); conn = NULL; return err; } return 0; } void map_exit(void) { DBG(""); dbus_connection_unref(conn); conn = NULL; obc_driver_unregister(&map); } obexd-0.46/client/transfer.c0000644000000000000000000004130311755212521012703 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "transfer.h" #define TRANSFER_INTERFACE "org.openobex.Transfer" #define TRANSFER_BASEPATH "/org/openobex" #define OBC_TRANSFER_ERROR obc_transfer_error_quark() static guint64 counter = 0; struct transfer_callback { transfer_callback_t func; void *data; }; struct obc_transfer_params { void *data; size_t size; }; struct obc_transfer { GObex *obex; guint8 op; struct obc_transfer_params *params; struct transfer_callback *callback; DBusConnection *conn; DBusMessage *msg; char *agent; /* Transfer agent */ char *path; /* Transfer path */ gchar *filename; /* Transfer file location */ char *name; /* Transfer object name */ char *type; /* Transfer object type */ int fd; guint xfer; gint64 size; gint64 transferred; }; static GQuark obc_transfer_error_quark(void) { return g_quark_from_static_string("obc-transfer-error-quark"); } static void append_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry, value; const char *signature; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); switch (type) { case DBUS_TYPE_STRING: signature = DBUS_TYPE_STRING_AS_STRING; break; case DBUS_TYPE_BYTE: signature = DBUS_TYPE_BYTE_AS_STRING; break; case DBUS_TYPE_UINT64: signature = DBUS_TYPE_UINT64_AS_STRING; break; default: signature = DBUS_TYPE_VARIANT_AS_STRING; break; } dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, signature, &value); dbus_message_iter_append_basic(&value, type, val); dbus_message_iter_close_container(&entry, &value); dbus_message_iter_close_container(dict, &entry); } static DBusMessage *obc_transfer_get_properties(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_transfer *transfer = user_data; DBusMessage *reply; DBusMessageIter iter, dict; reply = dbus_message_new_method_return(message); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); append_entry(&dict, "Name", DBUS_TYPE_STRING, &transfer->name); append_entry(&dict, "Size", DBUS_TYPE_UINT64, &transfer->size); append_entry(&dict, "Filename", DBUS_TYPE_STRING, &transfer->filename); dbus_message_iter_close_container(&iter, &dict); return reply; } static void abort_complete(GObex *obex, GError *err, gpointer user_data) { struct obc_transfer *transfer = user_data; struct transfer_callback *callback = transfer->callback; DBusMessage *reply; transfer->xfer = 0; reply = dbus_message_new_method_return(transfer->msg); if (reply) g_dbus_send_message(transfer->conn, reply); dbus_message_unref(transfer->msg); transfer->msg = NULL; if (callback == NULL) return; if (err) { callback->func(transfer, transfer->transferred, err, callback->data); } else { GError *abort_err; abort_err = g_error_new(OBC_TRANSFER_ERROR, -ECANCELED, "%s", "Transfer cancelled by user"); callback->func(transfer, transfer->transferred, abort_err, callback->data); g_error_free(abort_err); } } static gboolean obc_transfer_abort(struct obc_transfer *transfer) { if (transfer->xfer == 0) return FALSE; return g_obex_cancel_transfer(transfer->xfer, abort_complete, transfer); } static DBusMessage *obc_transfer_cancel(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_transfer *transfer = user_data; const gchar *sender; sender = dbus_message_get_sender(message); if (g_strcmp0(transfer->agent, sender) != 0) return g_dbus_create_error(message, "org.openobex.Error.NotAuthorized", "Not Authorized"); if (!obc_transfer_abort(transfer)) return g_dbus_create_error(message, "org.openobex.Error.Failed", "Failed"); transfer->msg = dbus_message_ref(message); return NULL; } static GDBusMethodTable obc_transfer_methods[] = { { "GetProperties", "", "a{sv}", obc_transfer_get_properties }, { "Cancel", "", "", obc_transfer_cancel, G_DBUS_METHOD_FLAG_ASYNC }, { } }; static void obc_transfer_free(struct obc_transfer *transfer) { DBG("%p", transfer); if (transfer->xfer) g_obex_cancel_transfer(transfer->xfer, NULL, NULL); if (transfer->op == G_OBEX_OP_GET && transfer->transferred != transfer->size) remove(transfer->filename); if (transfer->fd > 0) close(transfer->fd); if (transfer->params != NULL) { g_free(transfer->params->data); g_free(transfer->params); } if (transfer->conn) dbus_connection_unref(transfer->conn); if (transfer->msg) dbus_message_unref(transfer->msg); if (transfer->obex) g_obex_unref(transfer->obex); g_free(transfer->callback); g_free(transfer->agent); g_free(transfer->filename); g_free(transfer->name); g_free(transfer->type); g_free(transfer->path); g_free(transfer); } static struct obc_transfer *obc_transfer_create(guint8 op, const char *filename, const char *name, const char *type) { struct obc_transfer *transfer; transfer = g_new0(struct obc_transfer, 1); transfer->op = op; transfer->filename = g_strdup(filename); transfer->name = g_strdup(name); transfer->type = g_strdup(type); return transfer; } gboolean obc_transfer_register(struct obc_transfer *transfer, DBusConnection *conn, const char *agent, GError **err) { /* for OBEX specific mime types we don't need to register a transfer */ if (transfer->type != NULL && (strncmp(transfer->type, "x-obex/", 7) == 0 || strncmp(transfer->type, "x-bt/", 5) == 0)) goto done; transfer->agent = g_strdup(agent); transfer->path = g_strdup_printf("%s/transfer%ju", TRANSFER_BASEPATH, counter++); transfer->conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (transfer->conn == NULL) { g_set_error(err, OBC_TRANSFER_ERROR, -EFAULT, "Unable to connect to D-Bus"); return FALSE; } if (g_dbus_register_interface(transfer->conn, transfer->path, TRANSFER_INTERFACE, obc_transfer_methods, NULL, NULL, transfer, NULL) == FALSE) { g_set_error(err, OBC_TRANSFER_ERROR, -EFAULT, "Unable to register to D-Bus"); return FALSE; } done: DBG("%p registered %s", transfer, transfer->path); return TRUE; } static gboolean transfer_open(struct obc_transfer *transfer, int flags, mode_t mode, GError **err) { int fd; if (transfer->filename != NULL) { fd = open(transfer->filename, flags, mode); if (fd < 0) { error("open(): %s(%d)", strerror(errno), errno); g_set_error(err, OBC_TRANSFER_ERROR, -errno, "Unable to open file"); return FALSE; } goto done; } fd = g_file_open_tmp("obex-clientXXXXXX", &transfer->filename, err); if (fd < 0) { error("g_file_open_tmp(): %s", (*err)->message); return FALSE; } remove(transfer->filename); done: transfer->fd = fd; return TRUE; } struct obc_transfer *obc_transfer_get(const char *type, const char *name, const char *filename, GError **err) { struct obc_transfer *transfer; int perr; transfer = obc_transfer_create(G_OBEX_OP_GET, filename, name, type); perr = transfer_open(transfer, O_WRONLY | O_CREAT | O_TRUNC, 0600, err); if (perr < 0) { obc_transfer_free(transfer); return NULL; } return transfer; } struct obc_transfer *obc_transfer_put(const char *type, const char *name, const char *filename, const void *contents, size_t size, GError **err) { struct obc_transfer *transfer; struct stat st; int perr; transfer = obc_transfer_create(G_OBEX_OP_PUT, filename, name, type); if (contents != NULL) { ssize_t w; if (!transfer_open(transfer, O_RDWR, 0, err)) goto fail; w = write(transfer->fd, contents, size); if (w < 0) { error("write(): %s(%d)", strerror(errno), errno); perr = -errno; goto fail; } else if ((size_t) w != size) { error("Unable to write all contents to file"); perr = -EFAULT; goto fail; } } else { if (!transfer_open(transfer, O_RDONLY, 0, err)) goto fail; } perr = fstat(transfer->fd, &st); if (perr < 0) { error("fstat(): %s(%d)", strerror(errno), errno); g_set_error(err, OBC_TRANSFER_ERROR, -errno, "Unable to get file status"); goto fail; } transfer->size = st.st_size; return transfer; fail: obc_transfer_free(transfer); return NULL; } void obc_transfer_unregister(struct obc_transfer *transfer) { if (transfer->path) { g_dbus_unregister_interface(transfer->conn, transfer->path, TRANSFER_INTERFACE); } DBG("%p unregistered %s", transfer, transfer->path); obc_transfer_free(transfer); } static gboolean get_xfer_progress(const void *buf, gsize len, gpointer user_data) { struct obc_transfer *transfer = user_data; struct transfer_callback *callback = transfer->callback; if (transfer->fd > 0) { gint w; w = write(transfer->fd, buf, len); if (w < 0) return FALSE; transfer->transferred += w; } if (callback && transfer->transferred != transfer->size) callback->func(transfer, transfer->transferred, NULL, callback->data); return TRUE; } static void xfer_complete(GObex *obex, GError *err, gpointer user_data) { struct obc_transfer *transfer = user_data; struct transfer_callback *callback = transfer->callback; transfer->xfer = 0; if (err) goto done; transfer->size = transfer->transferred; done: if (callback) callback->func(transfer, transfer->size, err, callback->data); } static void get_xfer_progress_first(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct obc_transfer *transfer = user_data; GObexPacket *req; GObexHeader *hdr; const guint8 *buf; gsize len; guint8 rspcode; gboolean final; if (err != NULL) { xfer_complete(obex, err, transfer); return; } rspcode = g_obex_packet_get_operation(rsp, &final); if (rspcode != G_OBEX_RSP_SUCCESS && rspcode != G_OBEX_RSP_CONTINUE) { err = g_error_new(OBC_TRANSFER_ERROR, rspcode, "Transfer failed (0x%02x)", rspcode); xfer_complete(obex, err, transfer); g_error_free(err); return; } hdr = g_obex_packet_get_header(rsp, G_OBEX_HDR_APPARAM); if (hdr) { g_obex_header_get_bytes(hdr, &buf, &len); if (len != 0) { if (transfer->params == NULL) transfer->params = g_new0(struct obc_transfer_params, 1); else g_free(transfer->params->data); transfer->params->data = g_memdup(buf, len); transfer->params->size = len; } } hdr = g_obex_packet_get_body(rsp); if (hdr) { g_obex_header_get_bytes(hdr, &buf, &len); if (len != 0) get_xfer_progress(buf, len, transfer); } if (rspcode == G_OBEX_RSP_SUCCESS) { xfer_complete(obex, err, transfer); return; } if (!g_obex_srm_active(obex)) { req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID); transfer->xfer = g_obex_get_req_pkt(obex, req, get_xfer_progress, xfer_complete, transfer, &err); } } static gssize put_xfer_progress(void *buf, gsize len, gpointer user_data) { struct obc_transfer *transfer = user_data; struct transfer_callback *callback = transfer->callback; gssize size; size = read(transfer->fd, buf, len); if (size <= 0) return size; if (callback) callback->func(transfer, transfer->transferred, NULL, callback->data); transfer->transferred += size; return size; } gboolean obc_transfer_set_callback(struct obc_transfer *transfer, transfer_callback_t func, void *user_data) { struct transfer_callback *callback; if (transfer->callback != NULL) return FALSE; callback = g_new0(struct transfer_callback, 1); callback->func = func; callback->data = user_data; transfer->callback = callback; return TRUE; } static gboolean transfer_start_get(struct obc_transfer *transfer, GError **err) { GObexPacket *req; if (transfer->xfer > 0) { g_set_error(err, OBC_TRANSFER_ERROR, -EALREADY, "Transfer already started"); return FALSE; } req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID); if (transfer->name != NULL) g_obex_packet_add_unicode(req, G_OBEX_HDR_NAME, transfer->name); if (transfer->type != NULL) g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, transfer->type, strlen(transfer->type) + 1); if (transfer->params != NULL) g_obex_packet_add_bytes(req, G_OBEX_HDR_APPARAM, transfer->params->data, transfer->params->size); transfer->xfer = g_obex_send_req(transfer->obex, req, -1, get_xfer_progress_first, transfer, err); if (transfer->xfer == 0) return FALSE; return TRUE; } static gboolean transfer_start_put(struct obc_transfer *transfer, GError **err) { GObexPacket *req; if (transfer->xfer > 0) { g_set_error(err, OBC_TRANSFER_ERROR, -EALREADY, "Transfer already started"); return FALSE; } req = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID); if (transfer->name != NULL) g_obex_packet_add_unicode(req, G_OBEX_HDR_NAME, transfer->name); if (transfer->type != NULL) g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, transfer->type, strlen(transfer->type) + 1); if (transfer->size < UINT32_MAX) g_obex_packet_add_uint32(req, G_OBEX_HDR_LENGTH, transfer->size); if (transfer->params != NULL) g_obex_packet_add_bytes(req, G_OBEX_HDR_APPARAM, transfer->params->data, transfer->params->size); transfer->xfer = g_obex_put_req_pkt(transfer->obex, req, put_xfer_progress, xfer_complete, transfer, err); if (transfer->xfer == 0) return FALSE; return TRUE; } gboolean obc_transfer_start(struct obc_transfer *transfer, void *obex, GError **err) { transfer->obex = g_obex_ref(obex); switch (transfer->op) { case G_OBEX_OP_GET: return transfer_start_get(transfer, err); case G_OBEX_OP_PUT: return transfer_start_put(transfer, err); } g_set_error(err, OBC_TRANSFER_ERROR, -ENOTSUP, "Not supported"); return FALSE; } guint8 obc_transfer_get_operation(struct obc_transfer *transfer) { return transfer->op; } void obc_transfer_set_params(struct obc_transfer *transfer, const void *data, size_t size) { if (transfer->params != NULL) { g_free(transfer->params->data); g_free(transfer->params); } if (data == NULL) return; transfer->params = g_new0(struct obc_transfer_params, 1); transfer->params->data = g_memdup(data, size); transfer->params->size = size; } const void *obc_transfer_get_params(struct obc_transfer *transfer, size_t *size) { if (transfer->params == NULL) return NULL; if (size != NULL) *size = transfer->params->size; return transfer->params->data; } int obc_transfer_get_contents(struct obc_transfer *transfer, char **contents, size_t *size) { struct stat st; ssize_t ret; if (contents == NULL) return -EINVAL; if (fstat(transfer->fd, &st) < 0) { error("fstat(): %s(%d)", strerror(errno), errno); return -errno; } if (lseek(transfer->fd, 0, SEEK_SET) < 0) { error("lseek(): %s(%d)", strerror(errno), errno); return -errno; } *contents = g_malloc(st.st_size + 1); ret = read(transfer->fd, *contents, st.st_size); if (ret < 0) { error("read(): %s(%d)", strerror(errno), errno); g_free(*contents); return -errno; } (*contents)[ret] = '\0'; if (size) *size = ret; return 0; } void obc_transfer_set_name(struct obc_transfer *transfer, const char *name) { g_free(transfer->name); transfer->name = g_strdup(name); } int obc_transfer_set_filename(struct obc_transfer *transfer, const char *filename) { int err; err = rename(transfer->filename, filename); if (err < 0) { error("rename(): %s (%d)", strerror(errno), errno); return -errno; } g_free(transfer->filename); transfer->filename = g_strdup(filename); return 0; } const char *obc_transfer_get_path(struct obc_transfer *transfer) { return transfer->path; } gint64 obc_transfer_get_size(struct obc_transfer *transfer) { return transfer->size; } obexd-0.46/client/pbap.c0000644000000000000000000006241411755212521012007 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include "log.h" #include "transfer.h" #include "session.h" #include "driver.h" #include "pbap.h" #define OBEX_PBAP_UUID \ "\x79\x61\x35\xF0\xF0\xC5\x11\xD8\x09\x66\x08\x00\x20\x0C\x9A\x66" #define OBEX_PBAP_UUID_LEN 16 #define ERROR_INF PBAP_INTERFACE ".Error" #define FORMAT_VCARD21 0x0 #define FORMAT_VCARD30 0x1 #define ORDER_INDEXED 0x0 #define ORDER_ALPHANUMERIC 0x1 #define ORDER_PHONETIC 0x2 #define ATTRIB_NAME 0x0 #define ATTRIB_NUMBER 0x1 #define ATTRIB_SOUND 0x2 #define DEFAULT_COUNT 65535 #define DEFAULT_OFFSET 0 #define PULLPHONEBOOK 0x1 #define GETPHONEBOOKSIZE 0x2 #define ORDER_TAG 0x01 #define SEARCHVALUE_TAG 0x02 #define SEARCHATTRIB_TAG 0x03 #define MAXLISTCOUNT_TAG 0x04 #define LISTSTARTOFFSET_TAG 0x05 #define FILTER_TAG 0x06 #define FORMAT_TAG 0X07 #define PHONEBOOKSIZE_TAG 0X08 #define NEWMISSEDCALLS_TAG 0X09 /* The following length is in the unit of byte */ #define ORDER_LEN 1 #define SEARCHATTRIB_LEN 1 #define MAXLISTCOUNT_LEN 2 #define LISTSTARTOFFSET_LEN 2 #define FILTER_LEN 8 #define FORMAT_LEN 1 #define PHONEBOOKSIZE_LEN 2 #define NEWMISSEDCALLS_LEN 1 #define get_be16(val) GUINT16_FROM_BE(bt_get_unaligned((guint16 *) val)) static const char *filter_list[] = { "VERSION", "FN", "N", "PHOTO", "BDAY", "ADR", "LABEL", "TEL", "EMAIL", "MAILER", "TZ", "GEO", "TITLE", "ROLE", "LOGO", "AGENT", "ORG", "NOTE", "REV", "SOUND", "URL", "UID", "KEY", "NICKNAME", "CATEGORIES", "PROID", "CLASS", "SORT-STRING", "X-IRMC-CALL-DATETIME", NULL }; #define FILTER_BIT_MAX 63 #define FILTER_ALL 0xFFFFFFFFFFFFFFFFULL #define PBAP_INTERFACE "org.openobex.PhonebookAccess" #define PBAP_UUID "0000112f-0000-1000-8000-00805f9b34fb" struct pbap_data { struct obc_session *session; char *path; guint8 format; guint8 order; uint64_t filter; }; struct pending_request { struct pbap_data *pbap; DBusMessage *msg; }; struct pullphonebook_apparam { uint8_t filter_tag; uint8_t filter_len; uint64_t filter; uint8_t format_tag; uint8_t format_len; uint8_t format; uint8_t maxlistcount_tag; uint8_t maxlistcount_len; uint16_t maxlistcount; uint8_t liststartoffset_tag; uint8_t liststartoffset_len; uint16_t liststartoffset; } __attribute__ ((packed)); struct pullvcardentry_apparam { uint8_t filter_tag; uint8_t filter_len; uint64_t filter; uint8_t format_tag; uint8_t format_len; uint8_t format; } __attribute__ ((packed)); struct apparam_hdr { uint8_t tag; uint8_t len; uint8_t val[0]; } __attribute__ ((packed)); #define APPARAM_HDR_SIZE 2 static DBusConnection *conn = NULL; static struct pending_request *pending_request_new(struct pbap_data *pbap, DBusMessage *message) { struct pending_request *p; p = g_new0(struct pending_request, 1); p->pbap = pbap; p->msg = dbus_message_ref(message); return p; } static void pending_request_free(struct pending_request *p) { dbus_message_unref(p->msg); g_free(p); } static void listing_element(GMarkupParseContext *ctxt, const gchar *element, const gchar **names, const gchar **values, gpointer user_data, GError **gerr) { DBusMessageIter *item = user_data, entry; gchar **key; const gchar *handle = NULL, *vcardname = NULL; if (g_str_equal(element, "card") != TRUE) return; for (key = (gchar **) names; *key; key++, values++) { if (g_str_equal(*key, "handle") == TRUE) handle = *values; else if (g_str_equal(*key, "name") == TRUE) vcardname = *values; } if (!handle || !vcardname) return; dbus_message_iter_open_container(item, DBUS_TYPE_STRUCT, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &handle); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &vcardname); dbus_message_iter_close_container(item, &entry); } static const GMarkupParser listing_parser = { listing_element, NULL, NULL, NULL, NULL }; static gchar *build_phonebook_path(const char *location, const char *item) { gchar *path = NULL, *tmp, *tmp1; if (!g_ascii_strcasecmp(location, "INT") || !g_ascii_strcasecmp(location, "INTERNAL")) path = g_strdup("telecom"); else if (!g_ascii_strncasecmp(location, "SIM", 3)) { if (strlen(location) == 3) tmp = g_strdup("SIM1"); else tmp = g_ascii_strup(location, 4); path = g_build_filename(tmp, "telecom", NULL); g_free(tmp); } else return NULL; if (!g_ascii_strcasecmp(item, "PB") || !g_ascii_strcasecmp(item, "ICH") || !g_ascii_strcasecmp(item, "OCH") || !g_ascii_strcasecmp(item, "MCH") || !g_ascii_strcasecmp(item, "CCH")) { tmp = path; tmp1 = g_ascii_strdown(item, -1); path = g_build_filename(tmp, tmp1, NULL); g_free(tmp); g_free(tmp1); } else { g_free(path); return NULL; } return path; } /* should only be called inside pbap_set_path */ static void pbap_reset_path(struct pbap_data *pbap) { if (!pbap->path) return; obc_session_setpath(pbap->session, pbap->path, NULL, NULL, NULL); } static void pbap_setpath_cb(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct pending_request *request = user_data; struct pbap_data *pbap = request->pbap; if (err != NULL) pbap_reset_path(pbap); if (err) { DBusMessage *reply = g_dbus_create_error(request->msg, ERROR_INF ".Failed", "%s", err->message); g_dbus_send_message(conn, reply); } else g_dbus_send_reply(conn, request->msg, DBUS_TYPE_INVALID); pending_request_free(request); } static void read_return_apparam(struct obc_transfer *transfer, guint16 *phone_book_size, guint8 *new_missed_calls) { const struct apparam_hdr *hdr; size_t size; *phone_book_size = 0; *new_missed_calls = 0; hdr = obc_transfer_get_params(transfer, &size); if (hdr == NULL) return; if (size < APPARAM_HDR_SIZE) return; while (size > APPARAM_HDR_SIZE) { if (hdr->len > size - APPARAM_HDR_SIZE) { error("Unexpected PBAP pullphonebook app" " length, tag %d, len %d", hdr->tag, hdr->len); return; } switch (hdr->tag) { case PHONEBOOKSIZE_TAG: if (hdr->len == PHONEBOOKSIZE_LEN) { guint16 val; memcpy(&val, hdr->val, sizeof(val)); *phone_book_size = get_be16(&val); } break; case NEWMISSEDCALLS_TAG: if (hdr->len == NEWMISSEDCALLS_LEN) *new_missed_calls = hdr->val[0]; break; default: error("Unexpected PBAP pullphonebook app" " parameter, tag %d, len %d", hdr->tag, hdr->len); } size -= APPARAM_HDR_SIZE + hdr->len; hdr += APPARAM_HDR_SIZE + hdr->len; } } static void pull_phonebook_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct pending_request *request = user_data; DBusMessage *reply; char *contents; size_t size; int perr; if (err) { reply = g_dbus_create_error(request->msg, "org.openobex.Error.Failed", "%s", err->message); goto send; } perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(request->msg, "org.openobex.Error.Failed", "Error reading contents: %s", strerror(-perr)); goto send; } reply = dbus_message_new_method_return(request->msg); dbus_message_append_args(reply, DBUS_TYPE_STRING, &contents, DBUS_TYPE_INVALID); g_free(contents); send: g_dbus_send_message(conn, reply); pending_request_free(request); } static void phonebook_size_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct pending_request *request = user_data; DBusMessage *reply; guint16 phone_book_size; guint8 new_missed_calls; if (err) { reply = g_dbus_create_error(request->msg, "org.openobex.Error.Failed", "%s", err->message); goto send; } reply = dbus_message_new_method_return(request->msg); read_return_apparam(transfer, &phone_book_size, &new_missed_calls); dbus_message_append_args(reply, DBUS_TYPE_UINT16, &phone_book_size, DBUS_TYPE_INVALID); send: g_dbus_send_message(conn, reply); pending_request_free(request); } static void pull_vcard_listing_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct pending_request *request = user_data; GMarkupParseContext *ctxt; DBusMessage *reply; DBusMessageIter iter, array; char *contents; size_t size; int perr; if (err) { reply = g_dbus_create_error(request->msg, "org.openobex.Error.Failed", "%s", err->message); goto send; } perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(request->msg, "org.openobex.Error.Failed", "Error reading contents: %s", strerror(-perr)); goto send; } reply = dbus_message_new_method_return(request->msg); dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING, &array); ctxt = g_markup_parse_context_new(&listing_parser, 0, &array, NULL); g_markup_parse_context_parse(ctxt, contents, size, NULL); g_markup_parse_context_free(ctxt); dbus_message_iter_close_container(&iter, &array); g_free(contents); send: g_dbus_send_message(conn, reply); pending_request_free(request); } static DBusMessage *pull_phonebook(struct pbap_data *pbap, DBusMessage *message, guint8 type, const char *name, uint64_t filter, guint8 format, guint16 maxlistcount, guint16 liststartoffset) { struct pending_request *request; struct pullphonebook_apparam apparam; struct obc_transfer *transfer; session_callback_t func; GError *err = NULL; DBusMessage *reply; transfer = obc_transfer_get("x-bt/phonebook", name, NULL, &err); if (transfer == NULL) goto fail; apparam.filter_tag = FILTER_TAG; apparam.filter_len = FILTER_LEN; apparam.filter = GUINT64_TO_BE(filter); apparam.format_tag = FORMAT_TAG; apparam.format_len = FORMAT_LEN; apparam.format = format; apparam.maxlistcount_tag = MAXLISTCOUNT_TAG; apparam.maxlistcount_len = MAXLISTCOUNT_LEN; apparam.maxlistcount = GUINT16_TO_BE(maxlistcount); apparam.liststartoffset_tag = LISTSTARTOFFSET_TAG; apparam.liststartoffset_len = LISTSTARTOFFSET_LEN; apparam.liststartoffset = GUINT16_TO_BE(liststartoffset); switch (type) { case PULLPHONEBOOK: func = pull_phonebook_callback; break; case GETPHONEBOOKSIZE: func = phonebook_size_callback; break; default: error("Unexpected type : 0x%2x", type); return NULL; } request = pending_request_new(pbap, message); obc_transfer_set_params(transfer, &apparam, sizeof(apparam)); if (obc_session_queue(pbap->session, transfer, func, request, &err)) return NULL; pending_request_free(request); fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static guint8 *fill_apparam(guint8 *dest, void *buf, guint8 tag, guint8 len) { if (dest && buf) { *dest++ = tag; *dest++ = len; memcpy(dest, buf, len); dest += len; } return dest; } static DBusMessage *pull_vcard_listing(struct pbap_data *pbap, DBusMessage *message, const char *name, guint8 order, char *searchval, guint8 attrib, guint16 count, guint16 offset) { struct pending_request *request; struct obc_transfer *transfer; guint8 *p, apparam[272]; gint apparam_size; GError *err = NULL; DBusMessage *reply; transfer = obc_transfer_get("x-bt/vcard-listing", name, NULL, &err); if (transfer == NULL) goto fail; /* trunc the searchval string if it's length exceed the max value of guint8 */ if (strlen(searchval) > 254) searchval[255] = '\0'; apparam_size = APPARAM_HDR_SIZE + ORDER_LEN + (APPARAM_HDR_SIZE + strlen(searchval) + 1) + (APPARAM_HDR_SIZE + SEARCHATTRIB_LEN) + (APPARAM_HDR_SIZE + MAXLISTCOUNT_LEN) + (APPARAM_HDR_SIZE + LISTSTARTOFFSET_LEN); p = apparam; p = fill_apparam(p, &order, ORDER_TAG, ORDER_LEN); p = fill_apparam(p, searchval, SEARCHVALUE_TAG, strlen(searchval) + 1); p = fill_apparam(p, &attrib, SEARCHATTRIB_TAG, SEARCHATTRIB_LEN); count = GUINT16_TO_BE(count); p = fill_apparam(p, &count, MAXLISTCOUNT_TAG, MAXLISTCOUNT_LEN); offset = GUINT16_TO_BE(offset); p = fill_apparam(p, &offset, LISTSTARTOFFSET_TAG, LISTSTARTOFFSET_LEN); request = pending_request_new(pbap, message); obc_transfer_set_params(transfer, apparam, apparam_size); if (obc_session_queue(pbap->session, transfer, pull_vcard_listing_callback, request, &err)) return NULL; pending_request_free(request); fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static int set_format(struct pbap_data *pbap, const char *formatstr) { if (!formatstr || g_str_equal(formatstr, "")) { pbap->format = FORMAT_VCARD21; return 0; } if (!g_ascii_strcasecmp(formatstr, "vcard21")) pbap->format = FORMAT_VCARD21; else if (!g_ascii_strcasecmp(formatstr, "vcard30")) pbap->format = FORMAT_VCARD30; else return -EINVAL; return 0; } static int set_order(struct pbap_data *pbap, const char *orderstr) { if (!orderstr || g_str_equal(orderstr, "")) { pbap->order = ORDER_INDEXED; return 0; } if (!g_ascii_strcasecmp(orderstr, "indexed")) pbap->order = ORDER_INDEXED; else if (!g_ascii_strcasecmp(orderstr, "alphanumeric")) pbap->order = ORDER_ALPHANUMERIC; else if (!g_ascii_strcasecmp(orderstr, "phonetic")) pbap->order = ORDER_PHONETIC; else return -EINVAL; return 0; } static uint64_t get_filter_mask(const char *filterstr) { int i, bit = -1; if (!filterstr) return 0; if (!g_ascii_strcasecmp(filterstr, "ALL")) return FILTER_ALL; for (i = 0; filter_list[i] != NULL; i++) if (!g_ascii_strcasecmp(filterstr, filter_list[i])) return 1ULL << i; if (strlen(filterstr) < 4 || strlen(filterstr) > 5 || g_ascii_strncasecmp(filterstr, "bit", 3) != 0) return 0; sscanf(&filterstr[3], "%d", &bit); if (bit >= 0 && bit <= FILTER_BIT_MAX) return 1ULL << bit; else return 0; } static int add_filter(struct pbap_data *pbap, const char *filterstr) { uint64_t mask; mask = get_filter_mask(filterstr); if (mask == 0) return -EINVAL; pbap->filter |= mask; return 0; } static int remove_filter(struct pbap_data *pbap, const char *filterstr) { uint64_t mask; mask = get_filter_mask(filterstr); if (mask == 0) return -EINVAL; pbap->filter &= ~mask; return 0; } static gchar **get_filter_strs(uint64_t filter, gint *size) { gchar **list, **item; gint i; gint filter_list_size = sizeof(filter_list) / sizeof(filter_list[0]) - 1; list = g_try_malloc0(sizeof(gchar **) * (FILTER_BIT_MAX + 2)); if (!list) return NULL; item = list; for (i = 0; i < filter_list_size; i++) if (filter & (1ULL << i)) *(item++) = g_strdup(filter_list[i]); for (i = filter_list_size; i <= FILTER_BIT_MAX; i++) if (filter & (1ULL << i)) *(item++) = g_strdup_printf("%s%d", "BIT", i); *item = NULL; *size = item - list; return list; } static DBusMessage *pbap_select(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; const char *item, *location; char *path; struct pending_request *request; GError *err = NULL; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &location, DBUS_TYPE_STRING, &item, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); path = build_phonebook_path(location, item); if (path == NULL) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", "Invalid path"); if (pbap->path != NULL && g_str_equal(pbap->path, path)) { g_free(path); return dbus_message_new_method_return(message); } request = pending_request_new(pbap, message); obc_session_setpath(pbap->session, path, pbap_setpath_cb, request, &err); if (err != NULL) { DBusMessage *reply; reply = g_dbus_create_error(message, ERROR_INF ".Failed", "%s", err->message); g_error_free(err); g_free(path); pending_request_free(request); return reply; } g_free(pbap->path); pbap->path = path; return NULL; } static DBusMessage *pbap_pull_all(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; DBusMessage * err; char *name; if (!pbap->path) return g_dbus_create_error(message, ERROR_INF ".Forbidden", "Call Select first of all"); name = g_strconcat(pbap->path, ".vcf", NULL); err = pull_phonebook(pbap, message, PULLPHONEBOOK, name, pbap->filter, pbap->format, DEFAULT_COUNT, DEFAULT_OFFSET); g_free(name); return err; } static DBusMessage *pbap_pull_vcard(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; struct pullvcardentry_apparam apparam; const char *name; struct pending_request *request; struct obc_transfer *transfer; GError *err = NULL; DBusMessage *reply; if (!pbap->path) return g_dbus_create_error(message, ERROR_INF ".Forbidden", "Call Select first of all"); if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); transfer = obc_transfer_get("x-bt/vcard", name, NULL, &err); if (transfer == NULL) goto fail; apparam.filter_tag = FILTER_TAG; apparam.filter_len = FILTER_LEN; apparam.filter = GUINT64_TO_BE(pbap->filter); apparam.format_tag = FORMAT_TAG; apparam.format_len = FORMAT_LEN; apparam.format = pbap->format; request = pending_request_new(pbap, message); obc_transfer_set_params(transfer, &apparam, sizeof(apparam)); if (obc_session_queue(pbap->session, transfer, pull_phonebook_callback, request, &err)) return NULL; pending_request_free(request); fail: reply = g_dbus_create_error(message, "org.openobex.Error.Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *pbap_list(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; if (!pbap->path) return g_dbus_create_error(message, ERROR_INF ".Forbidden", "Call Select first of all"); return pull_vcard_listing(pbap, message, "", pbap->order, "", ATTRIB_NAME, DEFAULT_COUNT, DEFAULT_OFFSET); } static DBusMessage *pbap_search(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; char *field, *value; guint8 attrib; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &field, DBUS_TYPE_STRING, &value, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); if (!pbap->path) return g_dbus_create_error(message, ERROR_INF ".Forbidden", "Call Select first of all"); if (!field || g_str_equal(field, "")) attrib = ATTRIB_NAME; else if (!g_ascii_strcasecmp(field, "name")) attrib = ATTRIB_NAME; else if (!g_ascii_strcasecmp(field, "number")) attrib = ATTRIB_NUMBER; else if (!g_ascii_strcasecmp(field, "sound")) attrib = ATTRIB_SOUND; else return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); return pull_vcard_listing(pbap, message, "", pbap->order, value, attrib, DEFAULT_COUNT, DEFAULT_OFFSET); } static DBusMessage *pbap_get_size(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; DBusMessage * err; char *name; if (!pbap->path) return g_dbus_create_error(message, ERROR_INF ".Forbidden", "Call Select first of all"); name = g_strconcat(pbap->path, ".vcf", NULL); err = pull_phonebook(pbap, message, GETPHONEBOOKSIZE, name, pbap->filter, pbap->format, 0, DEFAULT_OFFSET); g_free(name); return err; } static DBusMessage *pbap_set_format(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; const char *format; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &format, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); if (set_format(pbap, format) < 0) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", "InvalidFormat"); return dbus_message_new_method_return(message); } static DBusMessage *pbap_set_order(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; const char *order; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &order, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); if (set_order(pbap, order) < 0) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", "InvalidFilter"); return dbus_message_new_method_return(message); } static DBusMessage *pbap_set_filter(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; char **filters, **item; gint size; uint64_t oldfilter = pbap->filter; if (dbus_message_get_args(message, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &filters, &size, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); remove_filter(pbap, "ALL"); if (size == 0) goto done; for (item = filters; *item; item++) { if (add_filter(pbap, *item) < 0) { pbap->filter = oldfilter; g_strfreev(filters); return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", "InvalidFilters"); } } done: g_strfreev(filters); return dbus_message_new_method_return(message); } static DBusMessage *pbap_get_filter(DBusConnection *connection, DBusMessage *message, void *user_data) { struct pbap_data *pbap = user_data; gchar **filters = NULL; gint size; DBusMessage *reply; filters = get_filter_strs(pbap->filter, &size); reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &filters, size, DBUS_TYPE_INVALID); g_strfreev(filters); return reply; } static DBusMessage *pbap_list_filter_fields(DBusConnection *connection, DBusMessage *message, void *user_data) { gchar **filters = NULL; gint size; DBusMessage *reply; filters = get_filter_strs(FILTER_ALL, &size); reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &filters, size, DBUS_TYPE_INVALID); g_strfreev(filters); return reply; } static GDBusMethodTable pbap_methods[] = { { "Select", "ss", "", pbap_select, G_DBUS_METHOD_FLAG_ASYNC }, { "PullAll", "", "s", pbap_pull_all, G_DBUS_METHOD_FLAG_ASYNC }, { "Pull", "s", "s", pbap_pull_vcard, G_DBUS_METHOD_FLAG_ASYNC }, { "List", "", "a(ss)", pbap_list, G_DBUS_METHOD_FLAG_ASYNC }, { "Search", "ss", "a(ss)", pbap_search, G_DBUS_METHOD_FLAG_ASYNC }, { "GetSize", "", "q", pbap_get_size, G_DBUS_METHOD_FLAG_ASYNC }, { "SetFormat", "s", "", pbap_set_format }, { "SetOrder", "s", "", pbap_set_order }, { "SetFilter", "as", "", pbap_set_filter }, { "GetFilter", "", "as", pbap_get_filter }, { "ListFilterFields", "", "as", pbap_list_filter_fields }, { } }; static void pbap_free(void *data) { struct pbap_data *pbap = data; obc_session_unref(pbap->session); g_free(pbap->path); g_free(pbap); } static int pbap_probe(struct obc_session *session) { struct pbap_data *pbap; const char *path; path = obc_session_get_path(session); DBG("%s", path); pbap = g_try_new0(struct pbap_data, 1); if (!pbap) return -ENOMEM; pbap->session = obc_session_ref(session); if (!g_dbus_register_interface(conn, path, PBAP_INTERFACE, pbap_methods, NULL, NULL, pbap, pbap_free)) { pbap_free(pbap); return -ENOMEM; } return 0; } static void pbap_remove(struct obc_session *session) { const char *path = obc_session_get_path(session); DBG("%s", path); g_dbus_unregister_interface(conn, path, PBAP_INTERFACE); } static struct obc_driver pbap = { .service = "PBAP", .uuid = PBAP_UUID, .target = OBEX_PBAP_UUID, .target_len = OBEX_PBAP_UUID_LEN, .probe = pbap_probe, .remove = pbap_remove }; int pbap_init(void) { int err; DBG(""); conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (!conn) return -EIO; err = obc_driver_register(&pbap); if (err < 0) { dbus_connection_unref(conn); conn = NULL; return err; } return 0; } void pbap_exit(void) { DBG(""); dbus_connection_unref(conn); conn = NULL; obc_driver_unregister(&pbap); } obexd-0.46/client/sync.c0000644000000000000000000001474311755212521012043 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "log.h" #include "transfer.h" #include "session.h" #include "driver.h" #include "sync.h" #define OBEX_SYNC_UUID "IRMC-SYNC" #define OBEX_SYNC_UUID_LEN 9 #define SYNC_INTERFACE "org.openobex.Synchronization" #define ERROR_INF SYNC_INTERFACE ".Error" #define SYNC_UUID "00001104-0000-1000-8000-00805f9b34fb" struct sync_data { struct obc_session *session; char *phonebook_path; DBusMessage *msg; }; static DBusConnection *conn = NULL; static DBusMessage *sync_setlocation(DBusConnection *connection, DBusMessage *message, void *user_data) { struct sync_data *sync = user_data; const char *location; char *path = NULL, *tmp; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &location, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); if (!g_ascii_strcasecmp(location, "INT") || !g_ascii_strcasecmp(location, "INTERNAL")) path = g_strdup("telecom/pb.vcf"); else if (!g_ascii_strncasecmp(location, "SIM", 3)) { tmp = g_ascii_strup(location, 4); path = g_build_filename(tmp, "telecom/pb.vcf", NULL); g_free(tmp); } else return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", "InvalidPhonebook"); g_free(sync->phonebook_path); sync->phonebook_path = path; return dbus_message_new_method_return(message); } static void sync_getphonebook_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct sync_data *sync = user_data; DBusMessage *reply; char *contents; size_t size; int perr; if (err) { reply = g_dbus_create_error(sync->msg, "org.openobex.Error.Failed", "%s", err->message); goto send; } perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { reply = g_dbus_create_error(sync->msg, "org.openobex.Error.Failed", "Error reading contents: %s", strerror(-perr)); goto send; } reply = dbus_message_new_method_return(sync->msg); dbus_message_append_args(reply, DBUS_TYPE_STRING, &contents, DBUS_TYPE_INVALID); g_free(contents); send: g_dbus_send_message(conn, reply); dbus_message_unref(sync->msg); sync->msg = NULL; } static DBusMessage *sync_getphonebook(DBusConnection *connection, DBusMessage *message, void *user_data) { struct sync_data *sync = user_data; struct obc_transfer *transfer; GError *err = NULL; DBusMessage *reply; if (sync->msg) return g_dbus_create_error(message, ERROR_INF ".InProgress", "Transfer in progress"); /* set default phonebook_path to memory internal phonebook */ if (!sync->phonebook_path) sync->phonebook_path = g_strdup("telecom/pb.vcf"); transfer = obc_transfer_get("phonebook", sync->phonebook_path, NULL, &err); if (transfer == NULL) goto fail; if (obc_session_queue(sync->session, transfer, sync_getphonebook_callback, sync, &err)) { sync->msg = dbus_message_ref(message); return NULL; } fail: reply = g_dbus_create_error(message, ERROR_INF ".Failed", "%s", err->message); g_error_free(err); return reply; } static DBusMessage *sync_putphonebook(DBusConnection *connection, DBusMessage *message, void *user_data) { struct sync_data *sync = user_data; struct obc_transfer *transfer; const char *buf; GError *err = NULL; DBusMessage *reply; if (dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &buf, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, ERROR_INF ".InvalidArguments", NULL); /* set default phonebook_path to memory internal phonebook */ if (!sync->phonebook_path) sync->phonebook_path = g_strdup("telecom/pb.vcf"); transfer = obc_transfer_put(NULL, sync->phonebook_path, NULL, buf, strlen(buf), &err); if (transfer == NULL) goto fail; if (obc_session_queue(sync->session, transfer, NULL, NULL, &err)) return dbus_message_new_method_return(message); fail: reply = g_dbus_create_error(message, ERROR_INF ".Failed", "%s", err->message); g_error_free(err); return reply; } static GDBusMethodTable sync_methods[] = { { "SetLocation", "s", "", sync_setlocation }, { "GetPhonebook", "", "s", sync_getphonebook, G_DBUS_METHOD_FLAG_ASYNC }, { "PutPhonebook", "s", "", sync_putphonebook, G_DBUS_METHOD_FLAG_ASYNC }, {} }; static void sync_free(void *data) { struct sync_data *sync = data; obc_session_unref(sync->session); g_free(sync->phonebook_path); g_free(sync); } static int sync_probe(struct obc_session *session) { struct sync_data *sync; const char *path; path = obc_session_get_path(session); DBG("%s", path); sync = g_try_new0(struct sync_data, 1); if (!sync) return -ENOMEM; sync->session = obc_session_ref(session); if (!g_dbus_register_interface(conn, path, SYNC_INTERFACE, sync_methods, NULL, NULL, sync, sync_free)) { sync_free(sync); return -ENOMEM; } return 0; } static void sync_remove(struct obc_session *session) { const char *path = obc_session_get_path(session); DBG("%s", path); g_dbus_unregister_interface(conn, path, SYNC_INTERFACE); } static struct obc_driver sync = { .service = "SYNC", .uuid = SYNC_UUID, .target = OBEX_SYNC_UUID, .target_len = OBEX_SYNC_UUID_LEN, .probe = sync_probe, .remove = sync_remove }; int sync_init(void) { int err; DBG(""); conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (!conn) return -EIO; err = obc_driver_register(&sync); if (err < 0) { dbus_connection_unref(conn); conn = NULL; return err; } return 0; } void sync_exit(void) { DBG(""); dbus_connection_unref(conn); conn = NULL; obc_driver_unregister(&sync); } obexd-0.46/client/main.c0000644000000000000000000000751011755212521012005 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include "log.h" #include "manager.h" static GMainLoop *event_loop = NULL; static unsigned int __terminated = 0; static gboolean signal_handler(GIOChannel *channel, GIOCondition cond, gpointer user_data) { struct signalfd_siginfo si; ssize_t result; int fd; if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) return FALSE; fd = g_io_channel_unix_get_fd(channel); result = read(fd, &si, sizeof(si)); if (result != sizeof(si)) return FALSE; switch (si.ssi_signo) { case SIGINT: case SIGTERM: if (__terminated == 0) { info("Terminating"); g_main_loop_quit(event_loop); } __terminated = 1; break; case SIGUSR2: __obex_log_enable_debug(); break; case SIGPIPE: /* ignore */ break; } return TRUE; } static guint setup_signalfd(void) { GIOChannel *channel; guint source; sigset_t mask; int fd; sigemptyset(&mask); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGTERM); sigaddset(&mask, SIGUSR2); sigaddset(&mask, SIGPIPE); if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) { perror("Failed to set signal mask"); return 0; } fd = signalfd(-1, &mask, 0); if (fd < 0) { perror("Failed to create signal descriptor"); return 0; } channel = g_io_channel_unix_new(fd); g_io_channel_set_close_on_unref(channel, TRUE); g_io_channel_set_encoding(channel, NULL, NULL); g_io_channel_set_buffered(channel, FALSE); source = g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, signal_handler, NULL); g_io_channel_unref(channel); return source; } static char *option_debug = NULL; static gboolean option_stderr = FALSE; static gboolean parse_debug(const char *key, const char *value, gpointer user_data, GError **error) { if (value) option_debug = g_strdup(value); else option_debug = g_strdup("*"); return TRUE; } static GOptionEntry options[] = { { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug, "Enable debug information output", "DEBUG" }, { "stderr", 's', 0, G_OPTION_ARG_NONE, &option_stderr, "Write log information to stderr" }, { NULL }, }; int main(int argc, char *argv[]) { GOptionContext *context; GError *gerr = NULL; guint signal; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); g_option_context_parse(context, &argc, &argv, &gerr); if (gerr != NULL) { g_printerr("%s\n", gerr->message); g_error_free(gerr); exit(EXIT_FAILURE); } g_option_context_free(context); event_loop = g_main_loop_new(NULL, FALSE); signal = setup_signalfd(); __obex_log_init("obex-client", option_debug, !option_stderr); if (manager_init() < 0) exit(EXIT_FAILURE); DBG("Entering main loop"); g_main_loop_run(event_loop); g_source_remove(signal); manager_exit(); g_main_loop_unref(event_loop); __obex_log_cleanup(); return 0; } obexd-0.46/client/manager.h0000644000000000000000000000156011755212521012477 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int manager_init(void); void manager_exit(void); obexd-0.46/client/session.c0000644000000000000000000007155011755212521012551 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "transfer.h" #include "session.h" #include "agent.h" #include "driver.h" #include "transport.h" #define SESSION_INTERFACE "org.openobex.Session" #define SESSION_BASEPATH "/org/openobex" #define OBEX_IO_ERROR obex_io_error_quark() #define OBEX_IO_ERROR_FIRST (0xff + 1) enum { OBEX_IO_DISCONNECTED = OBEX_IO_ERROR_FIRST, OBEX_IO_BUSY, }; static guint64 counter = 0; struct callback_data { struct obc_session *session; session_callback_t func; void *data; }; struct pending_request { guint id; guint req_id; struct obc_session *session; struct obc_transfer *transfer; GFunc auth_complete; session_callback_t func; void *data; }; struct setpath_data { char **remaining; int index; session_callback_t func; void *user_data; }; struct obc_session { guint id; gint refcount; char *source; char *destination; uint8_t channel; struct obc_transport *transport; struct obc_driver *driver; gchar *path; /* Session path */ DBusConnection *conn; GObex *obex; struct obc_agent *agent; struct pending_request *p; gchar *owner; /* Session owner */ guint watch; GQueue *queue; }; static GSList *sessions = NULL; static void session_start_transfer(gpointer data, gpointer user_data); static void session_terminate_transfer(struct obc_session *session, struct obc_transfer *transfer, GError *gerr); static void transfer_progress(struct obc_transfer *transfer, gint64 transferred, GError *err, void *user_data); static GQuark obex_io_error_quark(void) { return g_quark_from_static_string("obex-io-error-quark"); } struct obc_session *obc_session_ref(struct obc_session *session) { g_atomic_int_inc(&session->refcount); DBG("%p: ref=%d", session, session->refcount); return session; } static void session_unregistered(struct obc_session *session) { char *path; if (session->driver && session->driver->remove) session->driver->remove(session); path = session->path; session->path = NULL; g_dbus_unregister_interface(session->conn, path, SESSION_INTERFACE); DBG("Session(%p) unregistered %s", session, path); g_free(path); } static struct pending_request *pending_request_new(struct obc_session *session, struct obc_transfer *transfer, GFunc auth_complete, session_callback_t func, void *data) { struct pending_request *p; static guint id = 0; p = g_new0(struct pending_request, 1); p->id = ++id; p->session = obc_session_ref(session); p->transfer = transfer; p->auth_complete = auth_complete; p->func = func; p->data = data; return p; } static void pending_request_free(struct pending_request *p) { if (p->transfer) obc_transfer_unregister(p->transfer); if (p->session) obc_session_unref(p->session); g_free(p); } static void session_free(struct obc_session *session) { DBG("%p", session); if (session->agent) { obc_agent_release(session->agent); obc_agent_free(session->agent); } if (session->queue) { g_queue_foreach(session->queue, (GFunc) pending_request_free, NULL); g_queue_free(session->queue); } if (session->watch) g_dbus_remove_watch(session->conn, session->watch); if (session->obex != NULL) g_obex_unref(session->obex); if (session->id > 0 && session->transport != NULL) session->transport->disconnect(session->id); if (session->path) session_unregistered(session); if (session->conn) dbus_connection_unref(session->conn); if (session->p) pending_request_free(session->p); sessions = g_slist_remove(sessions, session); g_free(session->path); g_free(session->owner); g_free(session->source); g_free(session->destination); g_free(session); } void obc_session_unref(struct obc_session *session) { gboolean ret; ret = g_atomic_int_dec_and_test(&session->refcount); DBG("%p: ref=%d", session, session->refcount); if (ret == FALSE) return; session_free(session); } static void connect_cb(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct callback_data *callback = user_data; GError *gerr = NULL; uint8_t rsp_code; if (err != NULL) { error("connect_cb: %s", err->message); gerr = g_error_copy(err); goto done; } rsp_code = g_obex_packet_get_operation(rsp, NULL); if (rsp_code != G_OBEX_RSP_SUCCESS) gerr = g_error_new(OBEX_IO_ERROR, -EIO, "OBEX Connect failed with 0x%02x", rsp_code); done: callback->func(callback->session, NULL, gerr, callback->data); if (gerr != NULL) g_error_free(gerr); obc_session_unref(callback->session); g_free(callback); } static void transport_func(GIOChannel *io, GError *err, gpointer user_data) { struct callback_data *callback = user_data; struct obc_session *session = callback->session; struct obc_driver *driver = session->driver; struct obc_transport *transport = session->transport; GObex *obex; GObexTransportType type; int tx_mtu = -1; int rx_mtu = -1; DBG(""); if (err != NULL) { error("%s", err->message); goto done; } g_io_channel_set_close_on_unref(io, FALSE); if (transport->getpacketopt && transport->getpacketopt(io, &tx_mtu, &rx_mtu) == 0) type = G_OBEX_TRANSPORT_PACKET; else type = G_OBEX_TRANSPORT_STREAM; obex = g_obex_new(io, type, tx_mtu, rx_mtu); if (obex == NULL) goto done; g_io_channel_set_close_on_unref(io, TRUE); if (driver->target != NULL) g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_TARGET, driver->target, driver->target_len, G_OBEX_HDR_INVALID); else g_obex_connect(obex, connect_cb, callback, &err, G_OBEX_HDR_INVALID); if (err != NULL) { error("%s", err->message); g_obex_unref(obex); goto done; } session->obex = obex; sessions = g_slist_prepend(sessions, session); return; done: callback->func(callback->session, NULL, err, callback->data); obc_session_unref(callback->session); g_free(callback); } static void owner_disconnected(DBusConnection *connection, void *user_data) { struct obc_session *session = user_data; DBG(""); obc_session_shutdown(session); } int obc_session_set_owner(struct obc_session *session, const char *name, GDBusWatchFunction func) { if (session == NULL) return -EINVAL; if (session->watch) g_dbus_remove_watch(session->conn, session->watch); session->watch = g_dbus_add_disconnect_watch(session->conn, name, func, session, NULL); if (session->watch == 0) return -EINVAL; session->owner = g_strdup(name); return 0; } static struct obc_session *session_find(const char *source, const char *destination, const char *service, uint8_t channel, const char *owner) { GSList *l; for (l = sessions; l; l = l->next) { struct obc_session *session = l->data; if (g_strcmp0(session->destination, destination)) continue; if (g_strcmp0(service, session->driver->service)) continue; if (source && g_strcmp0(session->source, source)) continue; if (channel && session->channel != channel) continue; if (g_strcmp0(owner, session->owner)) continue; return session; } return NULL; } static gboolean connection_complete(gpointer data) { struct callback_data *cb = data; cb->func(cb->session, NULL, NULL, cb->data); obc_session_unref(cb->session); g_free(cb); return FALSE; } static int session_connect(struct obc_session *session, session_callback_t function, void *user_data) { struct callback_data *callback; struct obc_transport *transport = session->transport; struct obc_driver *driver = session->driver; callback = g_try_malloc0(sizeof(*callback)); if (callback == NULL) return -ENOMEM; callback->func = function; callback->data = user_data; callback->session = obc_session_ref(session); /* Connection completed */ if (session->obex) { g_idle_add(connection_complete, callback); return 0; } /* Ongoing connection */ if (session->id > 0) { obc_session_unref(callback->session); g_free(callback); return 0; } session->id = transport->connect(session->source, session->destination, driver->uuid, session->channel, transport_func, callback); if (session->id == 0) { obc_session_unref(callback->session); g_free(callback); return -EINVAL; } return 0; } struct obc_session *obc_session_create(const char *source, const char *destination, const char *service, uint8_t channel, const char *owner, session_callback_t function, void *user_data) { DBusConnection *conn; struct obc_session *session; struct obc_transport *transport; struct obc_driver *driver; if (destination == NULL) return NULL; session = session_find(source, destination, service, channel, owner); if (session != NULL) goto proceed; /* FIXME: Do proper transport lookup when the API supports it */ transport = obc_transport_find("Bluetooth"); if (transport == NULL) return NULL; driver = obc_driver_find(service); if (driver == NULL) return NULL; conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); if (conn == NULL) return NULL; session = g_try_malloc0(sizeof(*session)); if (session == NULL) return NULL; session->refcount = 1; session->transport = transport; session->driver = driver; session->conn = conn; session->source = g_strdup(source); session->destination = g_strdup(destination); session->channel = channel; session->queue = g_queue_new(); if (owner) obc_session_set_owner(session, owner, owner_disconnected); proceed: if (session_connect(session, function, user_data) < 0) { obc_session_unref(session); return NULL; } DBG("session %p transport %s driver %s", session, session->transport->name, session->driver->service); return session; } void obc_session_shutdown(struct obc_session *session) { struct pending_request *p; GError *err; DBG("%p", session); obc_session_ref(session); /* Unregister any pending transfer */ err = g_error_new(OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session closed by user"); if (session->p != NULL && session->p->id != 0) { p = session->p; session->p = NULL; if (p->func) p->func(session, p->transfer, err, p->data); pending_request_free(p); } while ((p = g_queue_pop_head(session->queue))) { if (p->func) p->func(session, p->transfer, err, p->data); pending_request_free(p); } g_error_free(err); /* Unregister interfaces */ if (session->path) session_unregistered(session); /* Disconnect transport */ if (session->id > 0 && session->transport != NULL) { session->transport->disconnect(session->id); session->id = 0; } obc_session_unref(session); } static DBusMessage *assign_agent(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_session *session = user_data; const gchar *sender, *path; if (dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", "Invalid arguments in method call"); sender = dbus_message_get_sender(message); if (obc_session_set_agent(session, sender, path) < 0) return g_dbus_create_error(message, "org.openobex.Error.AlreadyExists", "Already exists"); return dbus_message_new_method_return(message); } static DBusMessage *release_agent(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_session *session = user_data; struct obc_agent *agent = session->agent; const gchar *sender; gchar *path; if (dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", "Invalid arguments in method call"); sender = dbus_message_get_sender(message); if (agent == NULL) return dbus_message_new_method_return(message); if (g_str_equal(sender, obc_agent_get_name(agent)) == FALSE || g_str_equal(path, obc_agent_get_path(agent)) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.NotAuthorized", "Not Authorized"); obc_agent_free(agent); return dbus_message_new_method_return(message); } static void append_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry, value; const char *signature; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); switch (type) { case DBUS_TYPE_STRING: signature = DBUS_TYPE_STRING_AS_STRING; break; case DBUS_TYPE_BYTE: signature = DBUS_TYPE_BYTE_AS_STRING; break; case DBUS_TYPE_UINT64: signature = DBUS_TYPE_UINT64_AS_STRING; break; default: signature = DBUS_TYPE_VARIANT_AS_STRING; break; } dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, signature, &value); dbus_message_iter_append_basic(&value, type, val); dbus_message_iter_close_container(&entry, &value); dbus_message_iter_close_container(dict, &entry); } static DBusMessage *session_get_properties(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_session *session = user_data; DBusMessage *reply; DBusMessageIter iter, dict; reply = dbus_message_new_method_return(message); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); if (session->source != NULL) append_entry(&dict, "Source", DBUS_TYPE_STRING, &session->source); append_entry(&dict, "Destination", DBUS_TYPE_STRING, &session->destination); append_entry(&dict, "Channel", DBUS_TYPE_BYTE, &session->channel); dbus_message_iter_close_container(&iter, &dict); return reply; } static GDBusMethodTable session_methods[] = { { "GetProperties", "", "a{sv}", session_get_properties }, { "AssignAgent", "o", "", assign_agent }, { "ReleaseAgent", "o", "", release_agent }, { } }; static void session_request_reply(DBusPendingCall *call, gpointer user_data) { struct obc_session *session = user_data; struct pending_request *p = session->p; struct obc_transfer *transfer = p->transfer; DBusMessage *reply = dbus_pending_call_steal_reply(call); const char *name; DBusError derr; int err; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { GError *gerr = NULL; error("Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); dbus_message_unref(reply); g_set_error(&gerr, OBEX_IO_ERROR, -ECANCELED, "%s", derr.message); session_terminate_transfer(session, transfer, gerr); g_clear_error(&gerr); return; } dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID); DBG("Agent.Request() reply: %s", name); if (strlen(name) == 0) goto done; if (obc_transfer_get_operation(transfer) == G_OBEX_OP_PUT) { obc_transfer_set_name(transfer, name); goto done; } err = obc_transfer_set_filename(transfer, name); if (err < 0) { GError *gerr = NULL; g_set_error(&gerr, OBEX_IO_ERROR, err, "Unable to set filename"); session_terminate_transfer(session, transfer, gerr); g_clear_error(&gerr); return; } done: if (p->auth_complete) p->auth_complete(session, transfer); dbus_message_unref(reply); return; } static gboolean session_request_proceed(gpointer data) { struct obc_session *session = data; struct pending_request *p = session->p; struct obc_transfer *transfer = p->transfer; if (p->auth_complete) p->auth_complete(p->session, transfer); return FALSE; } static int pending_request_auth(struct pending_request *p) { struct obc_session *session = p->session; struct obc_agent *agent = session->agent; const char *path; path = obc_transfer_get_path(p->transfer); if (agent == NULL || path == NULL) { g_idle_add(session_request_proceed, session); return 0; } return obc_agent_request(agent, path, session_request_reply, session, NULL); } guint obc_session_queue(struct obc_session *session, struct obc_transfer *transfer, session_callback_t func, void *user_data, GError **err) { struct pending_request *p; const char *agent; int perr; if (session->obex == NULL) { obc_transfer_unregister(transfer); g_set_error(err, OBEX_IO_ERROR, -ENOTCONN, "Session not connected"); return 0; } if (session->agent) agent = obc_agent_get_name(session->agent); else agent = NULL; if (!obc_transfer_register(transfer, session->conn, agent, err)) { obc_transfer_unregister(transfer); return 0; } obc_transfer_set_callback(transfer, transfer_progress, session); p = pending_request_new(session, transfer, session_start_transfer, func, user_data); if (session->p) { g_queue_push_tail(session->queue, p); return p->id; } perr = pending_request_auth(p); if (perr < 0) { g_set_error(err, OBEX_IO_ERROR, perr, "Authorization failed"); pending_request_free(p); return 0; } session->p = p; return p->id; } static void session_process_queue(struct obc_session *session) { struct pending_request *p; if (session->p != NULL) return; if (session->queue == NULL || g_queue_is_empty(session->queue)) return; obc_session_ref(session); while ((p = g_queue_pop_head(session->queue))) { int err; err = pending_request_auth(p); if (err == 0) { session->p = p; break; } if (p->func) { GError *gerr = NULL; g_set_error(&gerr, OBEX_IO_ERROR, err, "Authorization failed"); p->func(session, p->transfer, gerr, p->data); g_error_free(gerr); } pending_request_free(p); } obc_session_unref(session); } static gint pending_transfer_cmptransfer(gconstpointer a, gconstpointer b) { const struct pending_request *p = a; const struct obc_transfer *transfer = b; if (p->transfer == transfer) return 0; return -1; } static void session_terminate_transfer(struct obc_session *session, struct obc_transfer *transfer, GError *gerr) { struct pending_request *p = session->p; if (p == NULL || p->transfer != transfer) { GList *match; match = g_list_find_custom(session->queue->head, transfer, pending_transfer_cmptransfer); if (match == NULL) return; p = match->data; g_queue_delete_link(session->queue, match); } else session->p = NULL; obc_session_ref(session); if (p->func) p->func(session, p->transfer, gerr, p->data); pending_request_free(p); if (session->p == NULL) session_process_queue(session); obc_session_unref(session); } static void session_notify_complete(struct obc_session *session, struct obc_transfer *transfer) { struct obc_agent *agent = session->agent; const char *path; path = obc_transfer_get_path(transfer); if (agent == NULL || path == NULL) goto done; obc_agent_notify_complete(agent, path); done: DBG("Transfer(%p) complete", transfer); session_terminate_transfer(session, transfer, NULL); } static void session_notify_error(struct obc_session *session, struct obc_transfer *transfer, GError *err) { struct obc_agent *agent = session->agent; const char *path; path = obc_transfer_get_path(transfer); if (agent == NULL || path == NULL) goto done; obc_agent_notify_error(agent, path, err->message); done: error("Transfer(%p) Error: %s", transfer, err->message); session_terminate_transfer(session, transfer, err); } static void session_notify_progress(struct obc_session *session, struct obc_transfer *transfer, gint64 transferred) { struct obc_agent *agent = session->agent; const char *path; path = obc_transfer_get_path(transfer); if (agent == NULL || path == NULL) goto done; obc_agent_notify_progress(agent, path, transferred); done: DBG("Transfer(%p) progress: %ld bytes", transfer, (long int ) transferred); if (transferred == obc_transfer_get_size(transfer)) session_notify_complete(session, transfer); } static void transfer_progress(struct obc_transfer *transfer, gint64 transferred, GError *err, void *user_data) { struct obc_session *session = user_data; if (err != 0) goto fail; session_notify_progress(session, transfer, transferred); return; fail: session_notify_error(session, transfer, err); } static void session_start_transfer(gpointer data, gpointer user_data) { struct obc_session *session = data; struct obc_transfer *transfer = user_data; GError *err = NULL; if (!obc_transfer_start(transfer, session->obex, &err)) { session_notify_error(session, transfer, err); g_clear_error(&err); return; } DBG("Transfer(%p) started", transfer); } const char *obc_session_register(struct obc_session *session, GDBusDestroyFunction destroy) { if (session->path) return session->path; session->path = g_strdup_printf("%s/session%ju", SESSION_BASEPATH, counter++); if (g_dbus_register_interface(session->conn, session->path, SESSION_INTERFACE, session_methods, NULL, NULL, session, destroy) == FALSE) goto fail; if (session->driver->probe && session->driver->probe(session) < 0) { g_dbus_unregister_interface(session->conn, session->path, SESSION_INTERFACE); goto fail; } DBG("Session(%p) registered %s", session, session->path); return session->path; fail: g_free(session->path); session->path = NULL; return NULL; } static void agent_destroy(gpointer data, gpointer user_data) { struct obc_session *session = user_data; session->agent = NULL; } int obc_session_set_agent(struct obc_session *session, const char *name, const char *path) { struct obc_agent *agent; if (session == NULL) return -EINVAL; if (session->agent) return -EALREADY; agent = obc_agent_create(session->conn, name, path, agent_destroy, session); if (session->watch == 0) obc_session_set_owner(session, name, owner_disconnected); session->agent = agent; return 0; } const char *obc_session_get_agent(struct obc_session *session) { struct obc_agent *agent; if (session == NULL) return NULL; agent = session->agent; if (agent == NULL) return NULL; return obc_agent_get_name(session->agent); } const char *obc_session_get_owner(struct obc_session *session) { if (session == NULL) return NULL; return session->owner; } const char *obc_session_get_path(struct obc_session *session) { return session->path; } const char *obc_session_get_target(struct obc_session *session) { return session->driver->target; } static void setpath_complete(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct pending_request *p = user_data; struct setpath_data *data = p->data; if (data->func) data->func(session, NULL, err, data->user_data); g_strfreev(data->remaining); g_free(data); if (session->p == p) session->p = NULL; pending_request_free(p); session_process_queue(session); } static void setpath_cb(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct pending_request *p = user_data; struct setpath_data *data = p->data; char *next; guint8 code; p->req_id = 0; if (err != NULL) { setpath_complete(p->session, NULL, err, user_data); return; } code = g_obex_packet_get_operation(rsp, NULL); if (code != G_OBEX_RSP_SUCCESS) { GError *gerr = NULL; g_set_error(&gerr, OBEX_IO_ERROR, code, "%s", g_obex_strerror(code)); setpath_complete(p->session, NULL, err, user_data); g_clear_error(&gerr); return; } next = data->remaining[data->index]; if (next == NULL) { setpath_complete(p->session, NULL, NULL, user_data); return; } data->index++; p->req_id = g_obex_setpath(obex, next, setpath_cb, p, &err); if (err != NULL) { setpath_complete(p->session, NULL, err, data); g_error_free(err); } } guint obc_session_setpath(struct obc_session *session, const char *path, session_callback_t func, void *user_data, GError **err) { struct setpath_data *data; struct pending_request *p; const char *first = ""; if (session->obex == NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session disconnected"); return 0; } if (session->p != NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy"); return 0; } data = g_new0(struct setpath_data, 1); data->func = func; data->user_data = user_data; data->remaining = g_strsplit(path, "/", 3); p = pending_request_new(session, NULL, NULL, setpath_complete, data); /* Relative path */ if (path[0] != '/') { first = data->remaining[data->index]; data->index++; } p->req_id = g_obex_setpath(session->obex, first, setpath_cb, p, err); if (*err != NULL) goto fail; session->p = p; return p->id; fail: g_strfreev(data->remaining); g_free(data); pending_request_free(p); return 0; } static void async_cb(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct pending_request *p = user_data; struct obc_session *session = p->session; GError *gerr = NULL; uint8_t code; p->req_id = 0; if (err != NULL) { if (p->func) p->func(p->session, NULL, err, p->data); goto done; } code = g_obex_packet_get_operation(rsp, NULL); if (code != G_OBEX_RSP_SUCCESS) g_set_error(&gerr, OBEX_IO_ERROR, code, "%s", g_obex_strerror(code)); if (p->func) p->func(p->session, NULL, gerr, p->data); if (gerr != NULL) g_clear_error(&gerr); done: pending_request_free(p); session->p = NULL; session_process_queue(session); } guint obc_session_mkdir(struct obc_session *session, const char *folder, session_callback_t func, void *user_data, GError **err) { struct pending_request *p; if (session->obex == NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session disconnected"); return 0; } if (session->p != NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy"); return 0; } p = pending_request_new(session, NULL, NULL, func, user_data); p->req_id = g_obex_mkdir(session->obex, folder, async_cb, p, err); if (*err != NULL) { pending_request_free(p); return 0; } session->p = p; return p->id; } guint obc_session_copy(struct obc_session *session, const char *srcname, const char *destname, session_callback_t func, void *user_data, GError **err) { struct pending_request *p; if (session->obex == NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session disconnected"); return 0; } if (session->p != NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy"); return 0; } p = pending_request_new(session, NULL, NULL, func, user_data); p->req_id = g_obex_copy(session->obex, srcname, destname, async_cb, p, err); if (*err != NULL) { pending_request_free(p); return 0; } session->p = p; return p->id; } guint obc_session_move(struct obc_session *session, const char *srcname, const char *destname, session_callback_t func, void *user_data, GError **err) { struct pending_request *p; if (session->obex == NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session disconnected"); return 0; } if (session->p != NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy"); return 0; } p = pending_request_new(session, NULL, NULL, func, user_data); p->req_id = g_obex_move(session->obex, srcname, destname, async_cb, p, err); if (*err != NULL) { pending_request_free(p); return 0; } session->p = p; return p->id; } guint obc_session_delete(struct obc_session *session, const char *file, session_callback_t func, void *user_data, GError **err) { struct pending_request *p; if (session->obex == NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED, "Session disconnected"); return 0; } if (session->p != NULL) { g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy"); return 0; } p = pending_request_new(session, NULL, NULL, func, user_data); p->req_id = g_obex_delete(session->obex, file, async_cb, p, err); if (*err != NULL) { pending_request_free(p); return 0; } session->p = p; return p->id; } void obc_session_cancel(struct obc_session *session, guint id, gboolean remove) { struct pending_request *p = session->p; if (p == NULL || p->id != id) return; if (p->req_id == 0) return; g_obex_cancel_req(session->obex, p->req_id, remove); if (!remove) return; pending_request_free(p); session->p = NULL; session_process_queue(session); } obexd-0.46/client/bluetooth.h0000644000000000000000000000153211755212521013071 00000000000000/* * * OBEX Client * * Copyright (C) 2011 Intel Corporation * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int bluetooth_init(void); void bluetooth_exit(void); obexd-0.46/client/session.h0000644000000000000000000000564711755212521012562 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include struct obc_session; typedef void (*session_callback_t) (struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data); struct obc_session *obc_session_create(const char *source, const char *destination, const char *service, uint8_t channel, const char *owner, session_callback_t function, void *user_data); struct obc_session *obc_session_ref(struct obc_session *session); void obc_session_unref(struct obc_session *session); void obc_session_shutdown(struct obc_session *session); int obc_session_set_owner(struct obc_session *session, const char *name, GDBusWatchFunction func); const char *obc_session_get_owner(struct obc_session *session); int obc_session_set_agent(struct obc_session *session, const char *name, const char *path); const char *obc_session_get_agent(struct obc_session *session); const char *obc_session_get_path(struct obc_session *session); const char *obc_session_get_target(struct obc_session *session); const char *obc_session_register(struct obc_session *session, GDBusDestroyFunction destroy); guint obc_session_queue(struct obc_session *session, struct obc_transfer *transfer, session_callback_t func, void *user_data, GError **err); guint obc_session_setpath(struct obc_session *session, const char *path, session_callback_t func, void *user_data, GError **err); guint obc_session_mkdir(struct obc_session *session, const char *folder, session_callback_t func, void *user_data, GError **err); guint obc_session_copy(struct obc_session *session, const char *srcname, const char *destname, session_callback_t func, void *user_data, GError **err); guint obc_session_move(struct obc_session *session, const char *srcname, const char *destname, session_callback_t func, void *user_data, GError **err); guint obc_session_delete(struct obc_session *session, const char *file, session_callback_t func, void *user_data, GError **err); void obc_session_cancel(struct obc_session *session, guint id, gboolean remove); obexd-0.46/client/driver.c0000644000000000000000000000377211755212521012362 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "transfer.h" #include "session.h" #include "driver.h" #include "log.h" static GSList *drivers = NULL; struct obc_driver *obc_driver_find(const char *pattern) { GSList *l; for (l = drivers; l; l = l->next) { struct obc_driver *driver = l->data; if (strcasecmp(pattern, driver->service) == 0) return driver; if (strcasecmp(pattern, driver->uuid) == 0) return driver; } return NULL; } int obc_driver_register(struct obc_driver *driver) { if (!driver) { error("Invalid driver"); return -EINVAL; } if (obc_driver_find(driver->service)) { error("Permission denied: service %s already registered", driver->service); return -EPERM; } DBG("driver %p service %s registered", driver, driver->service); drivers = g_slist_append(drivers, driver); return 0; } void obc_driver_unregister(struct obc_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); return; } DBG("driver %p service %s unregistered", driver, driver->service); drivers = g_slist_remove(drivers, driver); } obexd-0.46/client/manager.c0000644000000000000000000004144611755212521012501 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include "log.h" #include "transfer.h" #include "session.h" #include "manager.h" #include "bluetooth.h" #include "opp.h" #include "ftp.h" #include "pbap.h" #include "sync.h" #include "map.h" #define CLIENT_SERVICE "org.openobex.client" #define CLIENT_INTERFACE "org.openobex.Client" #define CLIENT_PATH "/" struct send_data { DBusConnection *connection; DBusMessage *message; gchar *sender; gchar *agent; char *filename; GPtrArray *files; }; static GSList *sessions = NULL; static void shutdown_session(struct obc_session *session) { sessions = g_slist_remove(sessions, session); obc_session_shutdown(session); obc_session_unref(session); } static void unregister_session(void *data) { struct obc_session *session = data; if (g_slist_find(sessions, session) == NULL) return; sessions = g_slist_remove(sessions, session); obc_session_unref(session); } static void create_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct send_data *data = user_data; unsigned int i; if (err != NULL) { DBusMessage *error = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", err->message); g_dbus_send_message(data->connection, error); shutdown_session(session); goto done; } if (obc_session_get_target(session) != NULL) { const char *path; path = obc_session_register(session, unregister_session); g_dbus_send_reply(data->connection, data->message, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); goto done; } g_dbus_send_reply(data->connection, data->message, DBUS_TYPE_INVALID); obc_session_set_agent(session, data->sender, data->agent); for (i = 0; i < data->files->len; i++) { const gchar *filename = g_ptr_array_index(data->files, i); gchar *basename = g_path_get_basename(filename); struct obc_transfer *transfer; transfer = obc_transfer_put(NULL, basename, filename, NULL, 0, NULL); g_free(basename); if (transfer == NULL) break; if (!obc_session_queue(session, transfer, NULL, NULL, NULL)) break; } /* No need to keep a reference for SendFiles */ sessions = g_slist_remove(sessions, session); obc_session_unref(session); done: if (data->files) g_ptr_array_free(data->files, TRUE); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data->agent); g_free(data); } static int parse_device_dict(DBusMessageIter *iter, const char **source, const char **dest, const char **target, uint8_t *channel) { while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_DICT_ENTRY) { DBusMessageIter entry, value; const char *key; dbus_message_iter_recurse(iter, &entry); dbus_message_iter_get_basic(&entry, &key); dbus_message_iter_next(&entry); dbus_message_iter_recurse(&entry, &value); switch (dbus_message_iter_get_arg_type(&value)) { case DBUS_TYPE_STRING: if (g_str_equal(key, "Source") == TRUE) dbus_message_iter_get_basic(&value, source); else if (g_str_equal(key, "Destination") == TRUE) dbus_message_iter_get_basic(&value, dest); else if (g_str_equal(key, "Target") == TRUE) dbus_message_iter_get_basic(&value, target); break; case DBUS_TYPE_BYTE: if (g_str_equal(key, "Channel") == TRUE) dbus_message_iter_get_basic(&value, channel); break; } dbus_message_iter_next(iter); } return 0; } static DBusMessage *send_files(DBusConnection *connection, DBusMessage *message, void *user_data) { DBusMessageIter iter, array; struct obc_session *session; GPtrArray *files; struct send_data *data; const char *agent, *source = NULL, *dest = NULL, *target = NULL; const char *sender; uint8_t channel = 0; dbus_message_iter_init(message, &iter); dbus_message_iter_recurse(&iter, &array); parse_device_dict(&array, &source, &dest, &target, &channel); if (dest == NULL) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); dbus_message_iter_next(&iter); dbus_message_iter_recurse(&iter, &array); files = g_ptr_array_new(); if (files == NULL) return g_dbus_create_error(message, "org.openobex.Error.NoMemory", NULL); while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) { char *value; dbus_message_iter_get_basic(&array, &value); g_ptr_array_add(files, value); dbus_message_iter_next(&array); } dbus_message_iter_next(&iter); dbus_message_iter_get_basic(&iter, &agent); if (files->len == 0) { g_ptr_array_free(files, TRUE); return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); } sender = dbus_message_get_sender(message); data = g_try_malloc0(sizeof(*data)); if (data == NULL) { g_ptr_array_free(files, TRUE); return g_dbus_create_error(message, "org.openobex.Error.NoMemory", NULL); } data->connection = dbus_connection_ref(connection); data->message = dbus_message_ref(message); data->sender = g_strdup(sender); data->agent = g_strdup(agent); data->files = files; session = obc_session_create(source, dest, "OPP", channel, sender, create_callback, data); if (session != NULL) { sessions = g_slist_append(sessions, session); return NULL; } g_ptr_array_free(data->files, TRUE); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data->agent); g_free(data); return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); } static void pull_complete_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct send_data *data = user_data; if (err != NULL) { DBusMessage *error = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", err->message); g_dbus_send_message(data->connection, error); goto done; } g_dbus_send_reply(data->connection, data->message, DBUS_TYPE_INVALID); done: shutdown_session(session); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->filename); g_free(data->sender); g_free(data); } static void pull_obc_session_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct send_data *data = user_data; struct obc_transfer *pull; DBusMessage *reply; GError *gerr = NULL; if (err != NULL) { reply = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", err->message); goto fail; } pull = obc_transfer_get("text/x-vcard", NULL, data->filename, &gerr); if (!obc_session_queue(session, pull, pull_complete_callback, data, &gerr)) { reply = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", gerr->message); g_error_free(gerr); goto fail; } return; fail: g_dbus_send_message(data->connection, reply); shutdown_session(session); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->filename); g_free(data->sender); g_free(data); } static DBusMessage *pull_business_card(DBusConnection *connection, DBusMessage *message, void *user_data) { DBusMessageIter iter, dict; struct obc_session *session; struct send_data *data; const char *source = NULL, *dest = NULL, *target = NULL; const char *name = NULL; uint8_t channel = 0; dbus_message_iter_init(message, &iter); dbus_message_iter_recurse(&iter, &dict); parse_device_dict(&dict, &source, &dest, &target, &channel); if (dest == NULL) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); dbus_message_iter_get_basic(&iter, &name); data = g_try_malloc0(sizeof(*data)); if (data == NULL) return g_dbus_create_error(message, "org.openobex.Error.NoMemory", NULL); data->connection = dbus_connection_ref(connection); data->message = dbus_message_ref(message); data->sender = g_strdup(dbus_message_get_sender(message)); data->filename = g_strdup(name); session = obc_session_create(source, dest, "OPP", channel, data->sender, pull_obc_session_callback, data); if (session != NULL) { sessions = g_slist_append(sessions, session); return NULL; } dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data->filename); g_free(data); return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); } static DBusMessage *exchange_business_cards(DBusConnection *connection, DBusMessage *message, void *user_data) { return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); } static struct obc_session *find_session(const char *path) { GSList *l; for (l = sessions; l; l = l->next) { struct obc_session *session = l->data; if (g_str_equal(obc_session_get_path(session), path) == TRUE) return session; } return NULL; } static DBusMessage *create_session(DBusConnection *connection, DBusMessage *message, void *user_data) { DBusMessageIter iter, dict; struct obc_session *session; struct send_data *data; const char *source = NULL, *dest = NULL, *target = NULL; uint8_t channel = 0; dbus_message_iter_init(message, &iter); dbus_message_iter_recurse(&iter, &dict); parse_device_dict(&dict, &source, &dest, &target, &channel); if (dest == NULL || target == NULL) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); data = g_try_malloc0(sizeof(*data)); if (data == NULL) return g_dbus_create_error(message, "org.openobex.Error.NoMemory", NULL); data->connection = dbus_connection_ref(connection); data->message = dbus_message_ref(message); data->sender = g_strdup(dbus_message_get_sender(message)); session = obc_session_create(source, dest, target, channel, data->sender, create_callback, data); if (session != NULL) { sessions = g_slist_append(sessions, session); return NULL; } dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data); return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); } static DBusMessage *remove_session(DBusConnection *connection, DBusMessage *message, void *user_data) { struct obc_session *session; const gchar *sender, *path; if (dbus_message_get_args(message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); session = find_session(path); if (session == NULL) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); sender = dbus_message_get_sender(message); if (g_str_equal(sender, obc_session_get_owner(session)) == FALSE) return g_dbus_create_error(message, "org.openobex.Error.NotAuthorized", "Not Authorized"); shutdown_session(session); return dbus_message_new_method_return(message); } static void capabilities_complete_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct send_data *data = user_data; char *contents; size_t size; int perr; if (err != NULL) { DBusMessage *error = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", err->message); g_dbus_send_message(data->connection, error); goto done; } perr = obc_transfer_get_contents(transfer, &contents, &size); if (perr < 0) { DBusMessage *error = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "Error reading contents: %s", strerror(-perr)); g_dbus_send_message(data->connection, error); goto done; } g_dbus_send_reply(data->connection, data->message, DBUS_TYPE_STRING, &contents, DBUS_TYPE_INVALID); g_free(contents); done: shutdown_session(session); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data); } static void capability_obc_session_callback(struct obc_session *session, struct obc_transfer *transfer, GError *err, void *user_data) { struct send_data *data = user_data; struct obc_transfer *pull; DBusMessage *reply; GError *gerr = NULL; if (err != NULL) { reply = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", err->message); goto fail; } pull = obc_transfer_get("x-obex/capability", NULL, data->filename, &gerr); if (!obc_session_queue(session, pull, capabilities_complete_callback, data, &gerr)) { reply = g_dbus_create_error(data->message, "org.openobex.Error.Failed", "%s", gerr->message); g_error_free(gerr); goto fail; } return; fail: g_dbus_send_message(data->connection, reply); shutdown_session(session); dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data); } static DBusMessage *get_capabilities(DBusConnection *connection, DBusMessage *message, void *user_data) { DBusMessageIter iter, dict; struct obc_session *session; struct send_data *data; const char *source = NULL, *dest = NULL, *target = NULL; uint8_t channel = 0; dbus_message_iter_init(message, &iter); dbus_message_iter_recurse(&iter, &dict); parse_device_dict(&dict, &source, &dest, &target, &channel); if (dest == NULL) return g_dbus_create_error(message, "org.openobex.Error.InvalidArguments", NULL); data = g_try_malloc0(sizeof(*data)); if (data == NULL) return g_dbus_create_error(message, "org.openobex.Error.NoMemory", NULL); data->connection = dbus_connection_ref(connection); data->message = dbus_message_ref(message); data->sender = g_strdup(dbus_message_get_sender(message)); if (!target) target = "OPP"; session = obc_session_create(source, dest, target, channel, data->sender, capability_obc_session_callback, data); if (session != NULL) { sessions = g_slist_append(sessions, session); return NULL; } dbus_message_unref(data->message); dbus_connection_unref(data->connection); g_free(data->sender); g_free(data); return g_dbus_create_error(message, "org.openobex.Error.Failed", NULL); } static GDBusMethodTable client_methods[] = { { "SendFiles", "a{sv}aso", "", send_files, G_DBUS_METHOD_FLAG_ASYNC }, { "PullBusinessCard", "a{sv}s", "", pull_business_card, G_DBUS_METHOD_FLAG_ASYNC }, { "ExchangeBusinessCards", "a{sv}ss", "", exchange_business_cards, G_DBUS_METHOD_FLAG_ASYNC }, { "CreateSession", "a{sv}", "o", create_session, G_DBUS_METHOD_FLAG_ASYNC }, { "RemoveSession", "o", "", remove_session, G_DBUS_METHOD_FLAG_ASYNC }, { "GetCapabilities", "a{sv}", "s", get_capabilities, G_DBUS_METHOD_FLAG_ASYNC }, { } }; static DBusConnection *conn = NULL; static struct obc_module { const char *name; int (*init) (void); void (*exit) (void); } modules[] = { { "bluetooth", bluetooth_init, bluetooth_exit }, { "opp", opp_init, opp_exit }, { "ftp", ftp_init, ftp_exit }, { "pbap", pbap_init, pbap_exit }, { "sync", sync_init, sync_exit }, { "map", map_init, map_exit }, { } }; int manager_init(void) { DBusError derr; struct obc_module *module; dbus_error_init(&derr); conn = g_dbus_setup_bus(DBUS_BUS_SESSION, CLIENT_SERVICE, &derr); if (dbus_error_is_set(&derr) == TRUE) { error("%s: %s", derr.name, derr.message); dbus_error_free(&derr); return -1; } if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE, client_methods, NULL, NULL, NULL, NULL) == FALSE) { error("Can't register client interface"); dbus_connection_unref(conn); conn = NULL; return -1; } for (module = modules; module && module->init; module++) { if (module->init() < 0) continue; DBG("Module %s loaded", module->name); } return 0; } void manager_exit(void) { struct obc_module *module; if (conn == NULL) return; for (module = modules; module && module->exit; module++) module->exit(); g_dbus_unregister_interface(conn, CLIENT_PATH, CLIENT_INTERFACE); dbus_connection_unref(conn); } obexd-0.46/client/agent.h0000644000000000000000000000323511755212521012164 00000000000000/* * * OBEX Client * * Copyright (C) 2007-2010 Intel Corporation * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include struct obc_agent; struct obc_agent *obc_agent_create(DBusConnection *conn, const char *name, const char *path, GFunc destroy, void *user_data); void obc_agent_free(struct obc_agent *agent); const char *obc_agent_get_name(struct obc_agent *agent); const char *obc_agent_get_path(struct obc_agent *agent); int obc_agent_request(struct obc_agent *agent, const char *path, DBusPendingCallNotifyFunction function, void *user_data, DBusFreeFunction destroy); void obc_agent_notify_progress(struct obc_agent *agent, const char *path, guint64 transferred); void obc_agent_notify_complete(struct obc_agent *agent, const char *path); void obc_agent_notify_error(struct obc_agent *agent, const char *path, const char *err); void obc_agent_release(struct obc_agent *agent); obexd-0.46/client/map.h0000644000000000000000000000155611755212521011647 00000000000000/* * * OBEX Client * * Copyright (C) 2011 Bartosz Szatkowski for Comarch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ int map_init(void); void map_exit(void); obexd-0.46/client/driver.h0000644000000000000000000000224211755212521012356 00000000000000/* * * OBEX Server * * Copyright (C) 2007-2010 Marcel Holtmann * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ struct obc_driver { const char *service; const char *uuid; void *target; gsize target_len; int (*probe) (struct obc_session *session); void (*remove) (struct obc_session *session); }; int obc_driver_register(struct obc_driver *driver); void obc_driver_unregister(struct obc_driver *driver); struct obc_driver *obc_driver_find(const char *pattern); obexd-0.46/gobex/0000755000000000000000000000000011755212614010623 500000000000000obexd-0.46/gobex/gobex-packet.c0000644000000000000000000002327211755212521013263 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "gobex-defs.h" #include "gobex-packet.h" #include "gobex-debug.h" #define FINAL_BIT 0x80 struct _GObexPacket { guint8 opcode; gboolean final; GObexDataPolicy data_policy; union { void *buf; /* Non-header data */ const void *buf_ref; /* Reference to non-header data */ } data; gsize data_len; gsize hlen; /* Length of all encoded headers */ GSList *headers; GObexDataProducer get_body; gpointer get_body_data; }; GObexHeader *g_obex_packet_get_header(GObexPacket *pkt, guint8 id) { GSList *l; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); for (l = pkt->headers; l != NULL; l = g_slist_next(l)) { GObexHeader *hdr = l->data; if (g_obex_header_get_id(hdr) == id) return hdr; } return NULL; } GObexHeader *g_obex_packet_get_body(GObexPacket *pkt) { GObexHeader *body; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); body = g_obex_packet_get_header(pkt, G_OBEX_HDR_BODY); if (body != NULL) return body; return g_obex_packet_get_header(pkt, G_OBEX_HDR_BODY_END); } guint8 g_obex_packet_get_operation(GObexPacket *pkt, gboolean *final) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (final) *final = pkt->final; return pkt->opcode; } gboolean g_obex_packet_prepend_header(GObexPacket *pkt, GObexHeader *header) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); pkt->headers = g_slist_prepend(pkt->headers, header); pkt->hlen += g_obex_header_get_length(header); return TRUE; } gboolean g_obex_packet_add_header(GObexPacket *pkt, GObexHeader *header) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); pkt->headers = g_slist_append(pkt->headers, header); pkt->hlen += g_obex_header_get_length(header); return TRUE; } gboolean g_obex_packet_add_body(GObexPacket *pkt, GObexDataProducer func, gpointer user_data) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (pkt->get_body != NULL) return FALSE; pkt->get_body = func; pkt->get_body_data = user_data; return TRUE; } gboolean g_obex_packet_add_unicode(GObexPacket *pkt, guint8 id, const char *str) { GObexHeader *hdr; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); hdr = g_obex_header_new_unicode(id, str); if (hdr == NULL) return FALSE; return g_obex_packet_add_header(pkt, hdr); } gboolean g_obex_packet_add_bytes(GObexPacket *pkt, guint8 id, const void *data, gsize len) { GObexHeader *hdr; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); hdr = g_obex_header_new_bytes(id, data, len); if (hdr == NULL) return FALSE; return g_obex_packet_add_header(pkt, hdr); } gboolean g_obex_packet_add_uint8(GObexPacket *pkt, guint8 id, guint8 val) { GObexHeader *hdr; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); hdr = g_obex_header_new_uint8(id, val); if (hdr == NULL) return FALSE; return g_obex_packet_add_header(pkt, hdr); } gboolean g_obex_packet_add_uint32(GObexPacket *pkt, guint8 id, guint32 val) { GObexHeader *hdr; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); hdr = g_obex_header_new_uint32(id, val); if (hdr == NULL) return FALSE; return g_obex_packet_add_header(pkt, hdr); } const void *g_obex_packet_get_data(GObexPacket *pkt, gsize *len) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (pkt->data_len == 0) { *len = 0; return NULL; } *len = pkt->data_len; switch (pkt->data_policy) { case G_OBEX_DATA_INHERIT: case G_OBEX_DATA_COPY: return pkt->data.buf; case G_OBEX_DATA_REF: return pkt->data.buf_ref; } g_assert_not_reached(); } gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len, GObexDataPolicy data_policy) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (pkt->data.buf || pkt->data.buf_ref) return FALSE; pkt->data_policy = data_policy; pkt->data_len = len; switch (data_policy) { case G_OBEX_DATA_COPY: pkt->data.buf = g_memdup(data, len); break; case G_OBEX_DATA_REF: pkt->data.buf_ref = data; break; case G_OBEX_DATA_INHERIT: pkt->data.buf = (void *) data; break; } return TRUE; } GObexPacket *g_obex_packet_new_valist(guint8 opcode, gboolean final, guint8 first_hdr_id, va_list args) { GObexPacket *pkt; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", opcode); pkt = g_new0(GObexPacket, 1); pkt->opcode = opcode; pkt->final = final; pkt->headers = g_obex_header_create_list(first_hdr_id, args, &pkt->hlen); pkt->data_policy = G_OBEX_DATA_COPY; return pkt; } GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final, guint8 first_hdr_id, ...) { GObexPacket *pkt; va_list args; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", opcode); va_start(args, first_hdr_id); pkt = g_obex_packet_new_valist(opcode, final, first_hdr_id, args); va_end(args); return pkt; } void g_obex_packet_free(GObexPacket *pkt) { g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); switch (pkt->data_policy) { case G_OBEX_DATA_INHERIT: case G_OBEX_DATA_COPY: g_free(pkt->data.buf); break; case G_OBEX_DATA_REF: break; } g_slist_foreach(pkt->headers, (GFunc) g_obex_header_free, NULL); g_slist_free(pkt->headers); g_free(pkt); } static gboolean parse_headers(GObexPacket *pkt, const void *data, gsize len, GObexDataPolicy data_policy, GError **err) { const guint8 *buf = data; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); while (len > 0) { GObexHeader *header; gsize parsed; header = g_obex_header_decode(buf, len, data_policy, &parsed, err); if (header == NULL) return FALSE; pkt->headers = g_slist_append(pkt->headers, header); pkt->hlen += parsed; len -= parsed; buf += parsed; } return TRUE; } static const guint8 *get_bytes(void *to, const guint8 *from, gsize count) { memcpy(to, from, count); return (from + count); } GObexPacket *g_obex_packet_decode(const void *data, gsize len, gsize header_offset, GObexDataPolicy data_policy, GError **err) { const guint8 *buf = data; guint16 packet_len; guint8 opcode; GObexPacket *pkt; gboolean final; g_obex_debug(G_OBEX_DEBUG_PACKET, ""); if (data_policy == G_OBEX_DATA_INHERIT) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_INVALID_ARGS, "Invalid data policy"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return NULL; } if (len < 3 + header_offset) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Not enough data to decode packet"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return NULL; } buf = get_bytes(&opcode, buf, sizeof(opcode)); buf = get_bytes(&packet_len, buf, sizeof(packet_len)); packet_len = g_ntohs(packet_len); if (packet_len != len) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Incorrect packet length (%u != %zu)", packet_len, len); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return NULL; } final = (opcode & FINAL_BIT) ? TRUE : FALSE; opcode &= ~FINAL_BIT; pkt = g_obex_packet_new(opcode, final, G_OBEX_HDR_INVALID); if (header_offset == 0) goto headers; g_obex_packet_set_data(pkt, buf, header_offset, data_policy); buf += header_offset; headers: if (!parse_headers(pkt, buf, len - (3 + header_offset), data_policy, err)) goto failed; return pkt; failed: g_obex_packet_free(pkt); return NULL; } static gssize get_body(GObexPacket *pkt, guint8 *buf, gsize len) { guint16 u16; gssize ret; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (len < 3) return -ENOBUFS; ret = pkt->get_body(buf + 3, len - 3, pkt->get_body_data); if (ret < 0) return ret; if (ret > 0) buf[0] = G_OBEX_HDR_BODY; else buf[0] = G_OBEX_HDR_BODY_END; u16 = g_htons(ret + 3); memcpy(&buf[1], &u16, sizeof(u16)); return ret; } gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len) { gssize ret; gsize count; guint16 u16; GSList *l; g_obex_debug(G_OBEX_DEBUG_PACKET, "opcode 0x%02x", pkt->opcode); if (3 + pkt->data_len + pkt->hlen > len) return -ENOBUFS; buf[0] = pkt->opcode; if (pkt->final) buf[0] |= FINAL_BIT; if (pkt->data_len > 0) { if (pkt->data_policy == G_OBEX_DATA_REF) memcpy(&buf[3], pkt->data.buf_ref, pkt->data_len); else memcpy(&buf[3], pkt->data.buf, pkt->data_len); } count = 3 + pkt->data_len; for (l = pkt->headers; l != NULL; l = g_slist_next(l)) { GObexHeader *hdr = l->data; if (count >= len) return -ENOBUFS; ret = g_obex_header_encode(hdr, buf + count, len - count); if (ret < 0) return ret; count += ret; } if (pkt->get_body) { ret = get_body(pkt, buf + count, len - count); if (ret < 0) return ret; if (ret == 0) { if (pkt->opcode == G_OBEX_RSP_CONTINUE) buf[0] = G_OBEX_RSP_SUCCESS; buf[0] |= FINAL_BIT; } count += ret + 3; } u16 = g_htons(count); memcpy(&buf[1], &u16, sizeof(u16)); return count; } obexd-0.46/gobex/gobex.h0000644000000000000000000001054211755212521012017 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GOBEX_H #define __GOBEX_H #include #include #include #include typedef enum { G_OBEX_TRANSPORT_STREAM, G_OBEX_TRANSPORT_PACKET, } GObexTransportType; typedef struct _GObex GObex; typedef void (*GObexFunc) (GObex *obex, GError *err, gpointer user_data); typedef void (*GObexRequestFunc) (GObex *obex, GObexPacket *req, gpointer user_data); typedef void (*GObexResponseFunc) (GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data); gboolean g_obex_send(GObex *obex, GObexPacket *pkt, GError **err); guint g_obex_send_req(GObex *obex, GObexPacket *req, gint timeout, GObexResponseFunc func, gpointer user_data, GError **err); gboolean g_obex_cancel_req(GObex *obex, guint req_id, gboolean remove_callback); gboolean g_obex_pending_req_abort(GObex *obex, GError **err); gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err, guint8 first_hdr_type, ...); void g_obex_set_disconnect_function(GObex *obex, GObexFunc func, gpointer user_data); guint g_obex_add_request_function(GObex *obex, guint8 opcode, GObexRequestFunc func, gpointer user_data); gboolean g_obex_remove_request_function(GObex *obex, guint id); void g_obex_suspend(GObex *obex); void g_obex_resume(GObex *obex); gboolean g_obex_srm_active(GObex *obex); GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type, gssize rx_mtu, gssize tx_mtu); GObex *g_obex_ref(GObex *obex); void g_obex_unref(GObex *obex); /* High level client functions */ guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data, GError **err, guint8 first_hdr_id, ...); guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func, gpointer user_data, GError **err); guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func, gpointer user_data, GError **err); guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func, gpointer user_data, GError **err); guint g_obex_copy(GObex *obex, const char *name, const char *dest, GObexResponseFunc func, gpointer user_data, GError **err); guint g_obex_move(GObex *obex, const char *name, const char *dest, GObexResponseFunc func, gpointer user_data, GError **err); /* Transfer related high-level functions */ guint g_obex_put_req(GObex *obex, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...); guint g_obex_put_req_pkt(GObex *obex, GObexPacket *req, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err); guint g_obex_get_req(GObex *obex, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...); guint g_obex_get_req_pkt(GObex *obex, GObexPacket *req, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err); guint g_obex_put_rsp(GObex *obex, GObexPacket *req, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...); guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...); guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err); gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func, gpointer user_data); const char *g_obex_strerror(guint8 err_code); guint8 g_obex_errno_to_rsp(int err); #endif /* __GOBEX_H */ obexd-0.46/gobex/gobex-defs.h0000644000000000000000000000277011755212521012742 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GOBEX_DEFS_H #define __GOBEX_DEFS_H #include typedef enum { G_OBEX_DATA_INHERIT, G_OBEX_DATA_COPY, G_OBEX_DATA_REF, } GObexDataPolicy; #define G_OBEX_ERROR_FIRST (0xff + 1) #define G_OBEX_PROTO_ERROR(code) ((code) < G_OBEX_ERROR_FIRST) typedef enum { G_OBEX_ERROR_PARSE_ERROR = G_OBEX_ERROR_FIRST, G_OBEX_ERROR_INVALID_ARGS, G_OBEX_ERROR_DISCONNECTED, G_OBEX_ERROR_TIMEOUT, G_OBEX_ERROR_CANCELLED, G_OBEX_ERROR_FAILED, } GObexError; typedef gssize (*GObexDataProducer) (void *buf, gsize len, gpointer user_data); typedef gboolean (*GObexDataConsumer) (const void *buf, gsize len, gpointer user_data); #define G_OBEX_ERROR g_obex_error_quark() GQuark g_obex_error_quark(void); #endif /* __GOBEX_DEFS_H */ obexd-0.46/gobex/gobex-header.h0000644000000000000000000000626111755212521013250 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GOBEX_HEADER_H #define __GOBEX_HEADER_H #include #include /* Header ID's */ #define G_OBEX_HDR_INVALID 0x00 #define G_OBEX_HDR_COUNT 0xc0 #define G_OBEX_HDR_NAME 0x01 #define G_OBEX_HDR_TYPE 0x42 #define G_OBEX_HDR_LENGTH 0xc3 #define G_OBEX_HDR_TIME 0x44 #define G_OBEX_HDR_DESCRIPTION 0x05 #define G_OBEX_HDR_TARGET 0x46 #define G_OBEX_HDR_HTTP 0x47 #define G_OBEX_HDR_BODY 0x48 #define G_OBEX_HDR_BODY_END 0x49 #define G_OBEX_HDR_WHO 0x4a #define G_OBEX_HDR_CONNECTION 0xcb #define G_OBEX_HDR_APPARAM 0x4c #define G_OBEX_HDR_AUTHCHAL 0x4d #define G_OBEX_HDR_AUTHRESP 0x4e #define G_OBEX_HDR_CREATOR 0xcf #define G_OBEX_HDR_WANUUID 0x50 #define G_OBEX_HDR_OBJECTCLASS 0x51 #define G_OBEX_HDR_SESSIONPARAM 0x52 #define G_OBEX_HDR_SESSIONSEQ 0x93 #define G_OBEX_HDR_ACTION 0x94 #define G_OBEX_HDR_DESTNAME 0x15 #define G_OBEX_HDR_PERMISSIONS 0xd6 #define G_OBEX_HDR_SRM 0x97 #define G_OBEX_HDR_SRMP 0x98 /* Action header values */ #define G_OBEX_ACTION_COPY 0x00 #define G_OBEX_ACTION_MOVE 0x01 #define G_OBEX_ACTION_SETPERM 0x02 /* SRM header values */ #define G_OBEX_SRM_DISABLE 0x00 #define G_OBEX_SRM_ENABLE 0x01 #define G_OBEX_SRM_INDICATE 0x02 /* SRMP header values */ #define G_OBEX_SRMP_NEXT 0x00 #define G_OBEX_SRMP_WAIT 0x01 #define G_OBEX_SRMP_NEXT_WAIT 0x02 typedef struct _GObexHeader GObexHeader; gboolean g_obex_header_get_unicode(GObexHeader *header, const char **str); gboolean g_obex_header_get_bytes(GObexHeader *header, const guint8 **val, gsize *len); gboolean g_obex_header_get_uint8(GObexHeader *header, guint8 *val); gboolean g_obex_header_get_uint32(GObexHeader *header, guint32 *val); GObexHeader *g_obex_header_new_unicode(guint8 id, const char *str); GObexHeader *g_obex_header_new_bytes(guint8 id, const void *data, gsize len); GObexHeader *g_obex_header_new_uint8(guint8 id, guint8 val); GObexHeader *g_obex_header_new_uint32(guint8 id, guint32 val); GSList *g_obex_header_create_list(guint8 first_hdr_id, va_list args, gsize *total_len); guint8 g_obex_header_get_id(GObexHeader *header); guint16 g_obex_header_get_length(GObexHeader *header); gssize g_obex_header_encode(GObexHeader *header, void *buf, gsize buf_len); GObexHeader *g_obex_header_decode(const void *data, gsize len, GObexDataPolicy data_policy, gsize *parsed, GError **err); void g_obex_header_free(GObexHeader *header); #endif /* __GOBEX_HEADER_H */ obexd-0.46/gobex/gobex-debug.h0000644000000000000000000000360611755212521013106 00000000000000/* * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GOBEX_DEBUG_H #define __GOBEX_DEBUG_H #include #include #include #define G_OBEX_DEBUG_NONE 1 #define G_OBEX_DEBUG_ERROR (1 << 1) #define G_OBEX_DEBUG_COMMAND (1 << 2) #define G_OBEX_DEBUG_TRANSFER (1 << 3) #define G_OBEX_DEBUG_HEADER (1 << 4) #define G_OBEX_DEBUG_PACKET (1 << 5) #define G_OBEX_DEBUG_DATA (1 << 6) extern guint gobex_debug; #define g_obex_debug(level, format, ...) \ if (gobex_debug & level) \ g_debug("%s:%s() " format, __FILE__, __FUNCTION__, \ ## __VA_ARGS__) static inline void g_obex_dump(const char *prefix, const void *buf, gsize len) { const guint8 *data = buf; int n = 0; if (!(gobex_debug & G_OBEX_DEBUG_DATA)) return; while (len > 0) { int i, size; printf("%s %04x:", prefix, n); size = len > 16 ? 16 : len; for (i = 0; i < size; i++) printf("%02x%s", data[i], (i + 1) % 8 ? " " : " "); for (; i < 16; i++) printf(" %s", (i + 1) % 8 ? " " : " "); for (i = 0; i < size; i++) printf("%1c", isprint(data[i]) ? data[i] : '.'); printf("\n"); data += size; len -= size; n += size; } } #endif /* __GOBEX_DEBUG_H */ obexd-0.46/gobex/gobex-packet.h0000644000000000000000000001025711755212521013267 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef __GOBEX_PACKET_H #define __GOBEX_PACKET_H #include #include #include #include /* Request opcodes */ #define G_OBEX_OP_CONNECT 0x00 #define G_OBEX_OP_DISCONNECT 0x01 #define G_OBEX_OP_PUT 0x02 #define G_OBEX_OP_GET 0x03 #define G_OBEX_OP_SETPATH 0x05 #define G_OBEX_OP_ACTION 0x06 #define G_OBEX_OP_SESSION 0x07 #define G_OBEX_OP_ABORT 0x7f /* Response codes */ #define G_OBEX_RSP_CONTINUE 0x10 #define G_OBEX_RSP_SUCCESS 0x20 #define G_OBEX_RSP_CREATED 0x21 #define G_OBEX_RSP_ACCEPTED 0x22 #define G_OBEX_RSP_NON_AUTHORITATIVE 0x23 #define G_OBEX_RSP_NO_CONTENT 0x24 #define G_OBEX_RSP_RESET_CONTENT 0x25 #define G_OBEX_RSP_PARTIAL_CONTENT 0x26 #define G_OBEX_RSP_MULTIPLE_CHOICES 0x30 #define G_OBEX_RSP_MOVED_PERMANENTLY 0x31 #define G_OBEX_RSP_MOVED_TEMPORARILY 0x32 #define G_OBEX_RSP_SEE_OTHER 0x33 #define G_OBEX_RSP_NOT_MODIFIED 0x34 #define G_OBEX_RSP_USE_PROXY 0x35 #define G_OBEX_RSP_BAD_REQUEST 0x40 #define G_OBEX_RSP_UNAUTHORIZED 0x41 #define G_OBEX_RSP_PAYMENT_REQUIRED 0x42 #define G_OBEX_RSP_FORBIDDEN 0x43 #define G_OBEX_RSP_NOT_FOUND 0x44 #define G_OBEX_RSP_METHOD_NOT_ALLOWED 0x45 #define G_OBEX_RSP_NOT_ACCEPTABLE 0x46 #define G_OBEX_RSP_PROXY_AUTH_REQUIRED 0x47 #define G_OBEX_RSP_REQUEST_TIME_OUT 0x48 #define G_OBEX_RSP_CONFLICT 0x49 #define G_OBEX_RSP_GONE 0x4a #define G_OBEX_RSP_LENGTH_REQUIRED 0x4b #define G_OBEX_RSP_PRECONDITION_FAILED 0x4c #define G_OBEX_RSP_REQ_ENTITY_TOO_LARGE 0x4d #define G_OBEX_RSP_REQ_URL_TOO_LARGE 0x4e #define G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE 0x4f #define G_OBEX_RSP_INTERNAL_SERVER_ERROR 0x50 #define G_OBEX_RSP_NOT_IMPLEMENTED 0x51 #define G_OBEX_RSP_BAD_GATEWAY 0x52 #define G_OBEX_RSP_SERVICE_UNAVAILABLE 0x53 #define G_OBEX_RSP_GATEWAY_TIMEOUT 0x54 #define G_OBEX_RSP_VERSION_NOT_SUPPORTED 0x55 #define G_OBEX_RSP_DATABASE_FULL 0x60 #define G_OBEX_RSP_DATABASE_LOCKED 0x61 typedef struct _GObexPacket GObexPacket; GObexHeader *g_obex_packet_get_header(GObexPacket *pkt, guint8 id); GObexHeader *g_obex_packet_get_body(GObexPacket *pkt); guint8 g_obex_packet_get_operation(GObexPacket *pkt, gboolean *final); gboolean g_obex_packet_prepend_header(GObexPacket *pkt, GObexHeader *header); gboolean g_obex_packet_add_header(GObexPacket *pkt, GObexHeader *header); gboolean g_obex_packet_add_body(GObexPacket *pkt, GObexDataProducer func, gpointer user_data); gboolean g_obex_packet_add_unicode(GObexPacket *pkt, guint8 id, const char *str); gboolean g_obex_packet_add_bytes(GObexPacket *pkt, guint8 id, const void *data, gsize len); gboolean g_obex_packet_add_uint8(GObexPacket *pkt, guint8 id, guint8 val); gboolean g_obex_packet_add_uint32(GObexPacket *pkt, guint8 id, guint32 val); gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len, GObexDataPolicy data_policy); const void *g_obex_packet_get_data(GObexPacket *pkt, gsize *len); GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final, guint8 first_hdr_id, ...); GObexPacket *g_obex_packet_new_valist(guint8 opcode, gboolean final, guint8 first_hdr_id, va_list args); void g_obex_packet_free(GObexPacket *pkt); GObexPacket *g_obex_packet_decode(const void *data, gsize len, gsize header_offset, GObexDataPolicy data_policy, GError **err); gssize g_obex_packet_encode(GObexPacket *pkt, guint8 *buf, gsize len); #endif /* __GOBEX_PACKET_H */ obexd-0.46/gobex/gobex-header.c0000644000000000000000000002661311755212521013246 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include "gobex-header.h" #include "gobex-debug.h" /* Header types */ #define G_OBEX_HDR_ENC_UNICODE (0 << 6) #define G_OBEX_HDR_ENC_BYTES (1 << 6) #define G_OBEX_HDR_ENC_UINT8 (2 << 6) #define G_OBEX_HDR_ENC_UINT32 (3 << 6) #define G_OBEX_HDR_ENC(id) ((id) & 0xc0) struct _GObexHeader { guint8 id; gboolean extdata; gsize vlen; /* Length of value */ gsize hlen; /* Length of full encoded header */ union { char *string; /* UTF-8 converted from UTF-16 */ guint8 *data; /* Own buffer */ const guint8 *extdata; /* Reference to external buffer */ guint8 u8; guint32 u32; } v; }; static glong utf8_to_utf16(gunichar2 **utf16, const char *utf8) { glong utf16_len; int i; if (*utf8 == '\0') { *utf16 = NULL; return 0; } *utf16 = g_utf8_to_utf16(utf8, -1, NULL, &utf16_len, NULL); if (*utf16 == NULL) return -1; /* g_utf8_to_utf16 produces host-byteorder UTF-16, * but OBEX requires network byteorder (big endian) */ for (i = 0; i < utf16_len; i++) (*utf16)[i] = g_htons((*utf16)[i]); utf16_len = (utf16_len + 1) << 1; return utf16_len; } static guint8 *put_bytes(guint8 *to, const void *from, gsize count) { memcpy(to, from, count); return (to + count); } static const guint8 *get_bytes(void *to, const guint8 *from, gsize count) { memcpy(to, from, count); return (from + count); } gssize g_obex_header_encode(GObexHeader *header, void *buf, gsize buf_len) { guint8 *ptr = buf; guint16 u16; guint32 u32; gunichar2 *utf16; glong utf16_len; g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); if (buf_len < header->hlen) return -1; ptr = put_bytes(ptr, &header->id, sizeof(header->id)); switch (G_OBEX_HDR_ENC(header->id)) { case G_OBEX_HDR_ENC_UNICODE: utf16_len = utf8_to_utf16(&utf16, header->v.string); if (utf16_len < 0 || (guint16) utf16_len > buf_len) return -1; g_assert_cmpuint(utf16_len + 3, ==, header->hlen); u16 = g_htons(utf16_len + 3); ptr = put_bytes(ptr, &u16, sizeof(u16)); ptr = put_bytes(ptr, utf16, utf16_len); g_free(utf16); break; case G_OBEX_HDR_ENC_BYTES: u16 = g_htons(header->hlen); ptr = put_bytes(ptr, &u16, sizeof(u16)); if (header->extdata) ptr = put_bytes(ptr, header->v.extdata, header->vlen); else ptr = put_bytes(ptr, header->v.data, header->vlen); break; case G_OBEX_HDR_ENC_UINT8: *ptr = header->v.u8; break; case G_OBEX_HDR_ENC_UINT32: u32 = g_htonl(header->v.u32); ptr = put_bytes(ptr, &u32, sizeof(u32)); break; default: g_assert_not_reached(); } return header->hlen; } GObexHeader *g_obex_header_decode(const void *data, gsize len, GObexDataPolicy data_policy, gsize *parsed, GError **err) { GObexHeader *header; const guint8 *ptr = data; guint16 hdr_len; gsize str_len; GError *conv_err = NULL; if (len < 2) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too short header in packet"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return NULL; } header = g_new0(GObexHeader, 1); ptr = get_bytes(&header->id, ptr, sizeof(header->id)); g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); switch (G_OBEX_HDR_ENC(header->id)) { case G_OBEX_HDR_ENC_UNICODE: if (len < 3) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Not enough data for unicode header (0x%02x)", header->id); goto failed; } ptr = get_bytes(&hdr_len, ptr, sizeof(hdr_len)); hdr_len = g_ntohs(hdr_len); if (hdr_len == 3) { header->v.string = g_strdup(""); header->vlen = 0; header->hlen = hdr_len; *parsed = hdr_len; break; } if (hdr_len > len || hdr_len < 5) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Invalid unicode header (0x%02x) length (%u)", header->id, hdr_len); goto failed; } header->v.string = g_convert((const char *) ptr, hdr_len - 5, "UTF8", "UTF16BE", NULL, &str_len, &conv_err); if (header->v.string == NULL) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Unicode conversion failed: %s", conv_err->message); g_error_free(conv_err); goto failed; } header->vlen = (gsize) str_len; header->hlen = hdr_len; *parsed = hdr_len; break; case G_OBEX_HDR_ENC_BYTES: if (len < 3) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too short byte array header"); goto failed; } ptr = get_bytes(&hdr_len, ptr, sizeof(hdr_len)); hdr_len = g_ntohs(hdr_len); if (hdr_len > len) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too long byte array header"); goto failed; } if (hdr_len < 3) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too small byte array length"); goto failed; } header->vlen = hdr_len - 3; header->hlen = hdr_len; switch (data_policy) { case G_OBEX_DATA_COPY: header->v.data = g_memdup(ptr, header->vlen); break; case G_OBEX_DATA_REF: header->extdata = TRUE; header->v.extdata = ptr; break; default: g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_INVALID_ARGS, "Invalid data policy"); goto failed; } *parsed = hdr_len; break; case G_OBEX_HDR_ENC_UINT8: header->vlen = 1; header->hlen = 2; header->v.u8 = *ptr; *parsed = 2; break; case G_OBEX_HDR_ENC_UINT32: if (len < 5) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too short uint32 header"); goto failed; } header->vlen = 4; header->hlen = 5; ptr = get_bytes(&header->v.u32, ptr, sizeof(header->v.u32)); header->v.u32 = g_ntohl(header->v.u32); *parsed = 5; break; default: g_assert_not_reached(); } return header; failed: if (*err) g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); g_obex_header_free(header); return NULL; } void g_obex_header_free(GObexHeader *header) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); switch (G_OBEX_HDR_ENC(header->id)) { case G_OBEX_HDR_ENC_UNICODE: g_free(header->v.string); break; case G_OBEX_HDR_ENC_BYTES: if (!header->extdata) g_free(header->v.data); break; case G_OBEX_HDR_ENC_UINT8: case G_OBEX_HDR_ENC_UINT32: break; default: g_assert_not_reached(); } g_free(header); } gboolean g_obex_header_get_unicode(GObexHeader *header, const char **str) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UNICODE) return FALSE; *str = header->v.string; g_obex_debug(G_OBEX_DEBUG_HEADER, "%s", *str); return TRUE; } gboolean g_obex_header_get_bytes(GObexHeader *header, const guint8 **val, gsize *len) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_BYTES) return FALSE; *len = header->vlen; if (header->extdata) *val = header->v.extdata; else *val = header->v.data; return TRUE; } gboolean g_obex_header_get_uint8(GObexHeader *header, guint8 *val) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UINT8) return FALSE; *val = header->v.u8; g_obex_debug(G_OBEX_DEBUG_HEADER, "%u", *val); return TRUE; } gboolean g_obex_header_get_uint32(GObexHeader *header, guint32 *val) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(header->id)); if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UINT32) return FALSE; *val = header->v.u32; g_obex_debug(G_OBEX_DEBUG_HEADER, "%u", *val); return TRUE; } GObexHeader *g_obex_header_new_unicode(guint8 id, const char *str) { GObexHeader *header; gsize len; g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(id)); if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UNICODE) return NULL; header = g_new0(GObexHeader, 1); header->id = id; len = g_utf8_strlen(str, -1); header->vlen = len; header->hlen = len == 0 ? 3 : 3 + ((len + 1) * 2); header->v.string = g_strdup(str); g_obex_debug(G_OBEX_DEBUG_HEADER, "%s", header->v.string); return header; } GObexHeader *g_obex_header_new_bytes(guint8 id, const void *data, gsize len) { GObexHeader *header; g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(id)); if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_BYTES) return NULL; header = g_new0(GObexHeader, 1); header->id = id; header->vlen = len; header->hlen = len + 3; header->v.data = g_memdup(data, len); return header; } GObexHeader *g_obex_header_new_uint8(guint8 id, guint8 val) { GObexHeader *header; g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(id)); if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UINT8) return NULL; header = g_new0(GObexHeader, 1); header->id = id; header->vlen = 1; header->hlen = 2; header->v.u8 = val; g_obex_debug(G_OBEX_DEBUG_HEADER, "%u", header->v.u8); return header; } GObexHeader *g_obex_header_new_uint32(guint8 id, guint32 val) { GObexHeader *header; g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x", G_OBEX_HDR_ENC(id)); if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UINT32) return NULL; header = g_new0(GObexHeader, 1); header->id = id; header->vlen = 4; header->hlen = 5; header->v.u32 = val; g_obex_debug(G_OBEX_DEBUG_HEADER, "%u", header->v.u32); return header; } guint8 g_obex_header_get_id(GObexHeader *header) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x id 0x%02x", G_OBEX_HDR_ENC(header->id), header->id); return header->id; } guint16 g_obex_header_get_length(GObexHeader *header) { g_obex_debug(G_OBEX_DEBUG_HEADER, "header 0x%02x length %zu", G_OBEX_HDR_ENC(header->id), header->hlen); return header->hlen; } GSList *g_obex_header_create_list(guint8 first_hdr_id, va_list args, gsize *total_len) { unsigned int id = first_hdr_id; GSList *l = NULL; g_obex_debug(G_OBEX_DEBUG_HEADER, ""); *total_len = 0; while (id != G_OBEX_HDR_INVALID) { GObexHeader *hdr; const char *str; const void *bytes; unsigned int val; gsize len; switch (G_OBEX_HDR_ENC(id)) { case G_OBEX_HDR_ENC_UNICODE: str = va_arg(args, const char *); hdr = g_obex_header_new_unicode(id, str); break; case G_OBEX_HDR_ENC_BYTES: bytes = va_arg(args, void *); len = va_arg(args, gsize); hdr = g_obex_header_new_bytes(id, bytes, len); break; case G_OBEX_HDR_ENC_UINT8: val = va_arg(args, unsigned int); hdr = g_obex_header_new_uint8(id, val); break; case G_OBEX_HDR_ENC_UINT32: val = va_arg(args, unsigned int); hdr = g_obex_header_new_uint32(id, val); break; default: g_assert_not_reached(); } l = g_slist_append(l, hdr); *total_len += hdr->hlen; id = va_arg(args, int); } return l; } obexd-0.46/gobex/gobex-defs.c0000644000000000000000000000171111755212521012727 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include "gobex-defs.h" GQuark g_obex_error_quark(void) { return g_quark_from_static_string("g-obex-error-quark"); } obexd-0.46/gobex/gobex.c0000644000000000000000000010075711755212521012022 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include "gobex.h" #include "gobex-debug.h" #define G_OBEX_DEFAULT_MTU 4096 #define G_OBEX_MINIMUM_MTU 255 #define G_OBEX_MAXIMUM_MTU 65535 #define G_OBEX_DEFAULT_TIMEOUT 10 #define G_OBEX_ABORT_TIMEOUT 5 #define G_OBEX_OP_NONE 0xff #define FINAL_BIT 0x80 #define CONNID_INVALID 0xffffffff guint gobex_debug = 0; struct srm_config { guint8 op; gboolean enabled; guint8 srm; guint8 srmp; gboolean outgoing; }; struct _GObex { gint ref_count; GIOChannel *io; guint io_source; gboolean (*read) (GObex *obex, GError **err); gboolean (*write) (GObex *obex, GError **err); guint8 *rx_buf; size_t rx_data; guint16 rx_pkt_len; guint8 rx_last_op; guint8 *tx_buf; size_t tx_data; size_t tx_sent; gboolean suspended; gboolean use_srm; struct srm_config *srm; guint write_source; gssize io_rx_mtu; gssize io_tx_mtu; guint16 rx_mtu; guint16 tx_mtu; guint32 conn_id; GQueue *tx_queue; GSList *req_handlers; GObexFunc disconn_func; gpointer disconn_func_data; struct pending_pkt *pending_req; }; struct pending_pkt { guint id; GObex *obex; GObexPacket *pkt; guint timeout; guint timeout_id; GObexResponseFunc rsp_func; gpointer rsp_data; gboolean cancelled; }; struct req_handler { guint id; guint8 opcode; GObexRequestFunc func; gpointer user_data; }; struct connect_data { guint8 version; guint8 flags; guint16 mtu; } __attribute__ ((packed)); struct setpath_data { guint8 flags; guint8 constants; } __attribute__ ((packed)); static struct error_code { guint8 code; const char *name; } obex_errors[] = { { G_OBEX_RSP_CONTINUE, "Continue" }, { G_OBEX_RSP_SUCCESS, "Success" }, { G_OBEX_RSP_CREATED, "Created" }, { G_OBEX_RSP_ACCEPTED, "Accepted" }, { G_OBEX_RSP_NON_AUTHORITATIVE, "Non Authoritative" }, { G_OBEX_RSP_NO_CONTENT, "No Content" }, { G_OBEX_RSP_RESET_CONTENT, "Reset Content" }, { G_OBEX_RSP_PARTIAL_CONTENT, "Partial Content" }, { G_OBEX_RSP_MULTIPLE_CHOICES, "Multiple Choices" }, { G_OBEX_RSP_MOVED_PERMANENTLY, "Moved Permanently" }, { G_OBEX_RSP_MOVED_TEMPORARILY, "Moved Temporarily" }, { G_OBEX_RSP_SEE_OTHER, "See Other" }, { G_OBEX_RSP_NOT_MODIFIED, "Not Modified" }, { G_OBEX_RSP_USE_PROXY, "Use Proxy" }, { G_OBEX_RSP_BAD_REQUEST, "Bad Request" }, { G_OBEX_RSP_UNAUTHORIZED, "Unauthorized" }, { G_OBEX_RSP_PAYMENT_REQUIRED, "Payment Required" }, { G_OBEX_RSP_FORBIDDEN, "Forbidden" }, { G_OBEX_RSP_NOT_FOUND, "Not Found" }, { G_OBEX_RSP_METHOD_NOT_ALLOWED, "Method Not Allowed" }, { G_OBEX_RSP_NOT_ACCEPTABLE, "Not Acceptable" }, { G_OBEX_RSP_PROXY_AUTH_REQUIRED, "Proxy Authentication Required" }, { G_OBEX_RSP_REQUEST_TIME_OUT, "Request Time Out" }, { G_OBEX_RSP_CONFLICT, "Conflict" }, { G_OBEX_RSP_GONE, "Gone" }, { G_OBEX_RSP_LENGTH_REQUIRED, "Length Required" }, { G_OBEX_RSP_PRECONDITION_FAILED, "Precondition Failed" }, { G_OBEX_RSP_REQ_ENTITY_TOO_LARGE, "Request Entity Too Large" }, { G_OBEX_RSP_REQ_URL_TOO_LARGE, "Request URL Too Large" }, { G_OBEX_RSP_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type" }, { G_OBEX_RSP_INTERNAL_SERVER_ERROR, "Internal Server Error" }, { G_OBEX_RSP_NOT_IMPLEMENTED, "Not Implemented" }, { G_OBEX_RSP_BAD_GATEWAY, "Bad Gateway" }, { G_OBEX_RSP_SERVICE_UNAVAILABLE, "Service Unavailable" }, { G_OBEX_RSP_GATEWAY_TIMEOUT, "Gateway Timeout" }, { G_OBEX_RSP_VERSION_NOT_SUPPORTED, "Version Not Supported" }, { G_OBEX_RSP_DATABASE_FULL, "Database Full" }, { G_OBEX_RSP_DATABASE_LOCKED, "Database Locked" }, { 0x00, NULL } }; const char *g_obex_strerror(guint8 err_code) { struct error_code *error; for (error = obex_errors; error->name != NULL; error++) { if (error->code == err_code) return error->name; } return ""; } static ssize_t req_header_offset(guint8 opcode) { switch (opcode) { case G_OBEX_OP_CONNECT: return sizeof(struct connect_data); case G_OBEX_OP_SETPATH: return sizeof(struct setpath_data); case G_OBEX_OP_DISCONNECT: case G_OBEX_OP_PUT: case G_OBEX_OP_GET: case G_OBEX_OP_SESSION: case G_OBEX_OP_ABORT: case G_OBEX_OP_ACTION: return 0; default: return -1; } } static ssize_t rsp_header_offset(guint8 opcode) { switch (opcode) { case G_OBEX_OP_CONNECT: return sizeof(struct connect_data); case G_OBEX_OP_SETPATH: case G_OBEX_OP_DISCONNECT: case G_OBEX_OP_PUT: case G_OBEX_OP_GET: case G_OBEX_OP_SESSION: case G_OBEX_OP_ABORT: case G_OBEX_OP_ACTION: return 0; default: return -1; } } static void pending_pkt_free(struct pending_pkt *p) { if (p->obex != NULL) g_obex_unref(p->obex); if (p->timeout_id > 0) g_source_remove(p->timeout_id); g_obex_packet_free(p->pkt); g_free(p); } static gboolean req_timeout(gpointer user_data) { GObex *obex = user_data; struct pending_pkt *p = obex->pending_req; GError *err; g_assert(p != NULL); obex->pending_req = NULL; err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_TIMEOUT, "Timed out waiting for response"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); if (p->rsp_func) p->rsp_func(obex, err, NULL, p->rsp_data); g_error_free(err); pending_pkt_free(p); return FALSE; } static gboolean write_stream(GObex *obex, GError **err) { GIOStatus status; gsize bytes_written; gchar *buf; buf = (gchar *) &obex->tx_buf[obex->tx_sent]; status = g_io_channel_write_chars(obex->io, buf, obex->tx_data, &bytes_written, err); if (status != G_IO_STATUS_NORMAL) return FALSE; g_obex_dump("<", buf, bytes_written); obex->tx_sent += bytes_written; obex->tx_data -= bytes_written; return TRUE; } static gboolean write_packet(GObex *obex, GError **err) { GIOStatus status; gsize bytes_written; gchar *buf; buf = (gchar *) &obex->tx_buf[obex->tx_sent]; status = g_io_channel_write_chars(obex->io, buf, obex->tx_data, &bytes_written, err); if (status != G_IO_STATUS_NORMAL) return FALSE; if (bytes_written != obex->tx_data) return FALSE; g_obex_dump("<", buf, bytes_written); obex->tx_sent += bytes_written; obex->tx_data -= bytes_written; return TRUE; } static void set_srmp(GObex *obex, guint8 srmp, gboolean outgoing) { struct srm_config *config = obex->srm; if (config == NULL) return; /* Dont't reset if direction doesn't match */ if (srmp > G_OBEX_SRMP_NEXT_WAIT && config->outgoing != outgoing) return; config->srmp = srmp; config->outgoing = outgoing; } static void set_srm(GObex *obex, guint8 op, guint8 srm) { struct srm_config *config = obex->srm; gboolean enable; if (config == NULL) { if (srm == G_OBEX_SRM_DISABLE) return; config = g_new0(struct srm_config, 1); config->op = op; config->srm = srm; obex->srm = config; return; } /* Indicate response, treat it as request */ if (config->srm == G_OBEX_SRM_INDICATE) { if (srm != G_OBEX_SRM_ENABLE) goto done; config->srm = srm; return; } enable = (srm == G_OBEX_SRM_ENABLE); if (config->enabled == enable) goto done; config->enabled = enable; g_obex_debug(G_OBEX_DEBUG_COMMAND, "SRM %s", config->enabled ? "Enabled" : "Disabled"); done: if (config->enabled) return; g_free(obex->srm); obex->srm = NULL; } static void check_srm_final(GObex *obex, guint8 op) { if (obex->srm == NULL || !obex->srm->enabled) return; switch (obex->srm->op) { case G_OBEX_OP_CONNECT: return; default: if (op <= G_OBEX_RSP_CONTINUE) return; } set_srm(obex, op, G_OBEX_SRM_DISABLE); } static void setup_srm(GObex *obex, GObexPacket *pkt, gboolean outgoing) { GObexHeader *hdr; guint8 op; gboolean final; if (!obex->use_srm) return; op = g_obex_packet_get_operation(pkt, &final); hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRM); if (hdr != NULL) { guint8 srm; g_obex_header_get_uint8(hdr, &srm); g_obex_debug(G_OBEX_DEBUG_COMMAND, "srm 0x%02x", srm); set_srm(obex, op, srm); } hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRMP); if (hdr != NULL) { guint8 srmp; g_obex_header_get_uint8(hdr, &srmp); g_obex_debug(G_OBEX_DEBUG_COMMAND, "srmp 0x%02x", srmp); set_srmp(obex, srmp, outgoing); } else set_srmp(obex, -1, outgoing); if (final) check_srm_final(obex, op); } static gboolean write_data(GIOChannel *io, GIOCondition cond, gpointer user_data) { GObex *obex = user_data; if (cond & G_IO_NVAL) return FALSE; if (cond & (G_IO_HUP | G_IO_ERR)) goto stop_tx; if (obex->tx_data == 0) { struct pending_pkt *p = g_queue_pop_head(obex->tx_queue); ssize_t len; if (p == NULL) goto stop_tx; setup_srm(obex, p->pkt, TRUE); if (g_obex_srm_active(obex)) goto encode; /* Can't send a request while there's a pending one */ if (obex->pending_req && p->id > 0) { g_queue_push_head(obex->tx_queue, p); goto stop_tx; } encode: len = g_obex_packet_encode(p->pkt, obex->tx_buf, obex->tx_mtu); if (len == -EAGAIN) { g_queue_push_head(obex->tx_queue, p); g_obex_suspend(obex); goto stop_tx; } if (len < 0) { pending_pkt_free(p); goto done; } if (p->id > 0) { if (obex->pending_req != NULL) pending_pkt_free(obex->pending_req); obex->pending_req = p; p->timeout_id = g_timeout_add_seconds(p->timeout, req_timeout, obex); } else { /* During packet encode final bit can be set */ if (obex->tx_buf[0] & FINAL_BIT) check_srm_final(obex, obex->tx_buf[0] & ~FINAL_BIT); pending_pkt_free(p); } obex->tx_data = len; obex->tx_sent = 0; } if (obex->suspended) { obex->write_source = 0; return FALSE; } if (!obex->write(obex, NULL)) goto stop_tx; done: if (obex->tx_data > 0 || g_queue_get_length(obex->tx_queue) > 0) return TRUE; stop_tx: obex->rx_last_op = G_OBEX_OP_NONE; obex->tx_data = 0; obex->write_source = 0; return FALSE; } static void enable_tx(GObex *obex) { GIOCondition cond; if (obex->suspended) return; if (obex->write_source > 0) return; cond = G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL; obex->write_source = g_io_add_watch(obex->io, cond, write_data, obex); } static gboolean g_obex_send_internal(GObex *obex, struct pending_pkt *p, GError **err) { if (obex->io == NULL) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_DISCONNECTED, "The transport is not connected"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return FALSE; } if (g_obex_packet_get_operation(p->pkt, NULL) == G_OBEX_OP_ABORT) g_queue_push_head(obex->tx_queue, p); else g_queue_push_tail(obex->tx_queue, p); if (obex->pending_req == NULL || p->id == 0) enable_tx(obex); return TRUE; } static void init_connect_data(GObex *obex, struct connect_data *data) { guint16 u16; memset(data, 0, sizeof(*data)); data->version = 0x10; data->flags = 0; u16 = g_htons(obex->rx_mtu); memcpy(&data->mtu, &u16, sizeof(u16)); } static void prepare_connect_rsp(GObex *obex, GObexPacket *rsp) { GObexHeader *connid; struct connect_data data; static guint32 next_connid = 1; init_connect_data(obex, &data); g_obex_packet_set_data(rsp, &data, sizeof(data), G_OBEX_DATA_COPY); connid = g_obex_packet_get_header(rsp, G_OBEX_HDR_CONNECTION); if (connid != NULL) { g_obex_header_get_uint32(connid, &obex->conn_id); return; } obex->conn_id = next_connid++; connid = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION, obex->conn_id); g_obex_packet_prepend_header(rsp, connid); } static void prepare_srm_rsp(GObex *obex, GObexPacket *pkt) { GObexHeader *hdr; if (!obex->use_srm || obex->srm == NULL) return; if (obex->srm->enabled) return; hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRM); if (hdr != NULL) return; hdr = g_obex_header_new_uint8(G_OBEX_HDR_SRM, G_OBEX_SRM_ENABLE); g_obex_packet_prepend_header(pkt, hdr); } gboolean g_obex_send(GObex *obex, GObexPacket *pkt, GError **err) { struct pending_pkt *p; gboolean ret; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); if (obex == NULL || pkt == NULL) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_INVALID_ARGS, "Invalid arguments"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return FALSE; } switch (obex->rx_last_op) { case G_OBEX_OP_CONNECT: prepare_connect_rsp(obex, pkt); break; case G_OBEX_OP_GET: case G_OBEX_OP_PUT: prepare_srm_rsp(obex, pkt); break; } p = g_new0(struct pending_pkt, 1); p->pkt = pkt; ret = g_obex_send_internal(obex, p, err); if (ret == FALSE) pending_pkt_free(p); return ret; } static void prepare_srm_req(GObex *obex, GObexPacket *pkt) { GObexHeader *hdr; if (!obex->use_srm) return; if (obex->srm != NULL && obex->srm->enabled) return; hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRM); if (hdr != NULL) return; hdr = g_obex_header_new_uint8(G_OBEX_HDR_SRM, G_OBEX_SRM_ENABLE); g_obex_packet_prepend_header(pkt, hdr); } guint g_obex_send_req(GObex *obex, GObexPacket *req, gint timeout, GObexResponseFunc func, gpointer user_data, GError **err) { GObexHeader *hdr; struct pending_pkt *p; static guint id = 1; guint8 op; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); op = g_obex_packet_get_operation(req, NULL); if (op == G_OBEX_OP_PUT || op == G_OBEX_OP_GET) { /* Only enable SRM automatically for GET and PUT */ prepare_srm_req(obex, req); } if (obex->conn_id == CONNID_INVALID) goto create_pending; if (obex->rx_last_op == G_OBEX_RSP_CONTINUE) goto create_pending; if (g_obex_srm_active(obex) && obex->pending_req != NULL) goto create_pending; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_CONNECTION); if (hdr != NULL) goto create_pending; hdr = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION, obex->conn_id); g_obex_packet_prepend_header(req, hdr); create_pending: p = g_new0(struct pending_pkt, 1); p->pkt = req; p->id = id++; p->rsp_func = func; p->rsp_data = user_data; if (timeout < 0) p->timeout = G_OBEX_DEFAULT_TIMEOUT; else p->timeout = timeout; if (!g_obex_send_internal(obex, p, err)) { pending_pkt_free(p); return 0; } return p->id; } static gint pending_pkt_cmp(gconstpointer a, gconstpointer b) { const struct pending_pkt *p = a; guint id = GPOINTER_TO_UINT(b); return (p->id - id); } gboolean g_obex_pending_req_abort(GObex *obex, GError **err) { struct pending_pkt *p = obex->pending_req; GObexPacket *req; if (p->cancelled) return TRUE; p->cancelled = TRUE; g_source_remove(p->timeout_id); p->timeout = G_OBEX_ABORT_TIMEOUT; p->timeout_id = g_timeout_add_seconds(p->timeout, req_timeout, obex); req = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_INVALID); return g_obex_send(obex, req, err); } static gboolean cancel_complete(gpointer user_data) { struct pending_pkt *p = user_data; GObex *obex = p->obex; GError *err; g_assert(p->rsp_func != NULL); err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "The request was cancelled"); p->rsp_func(obex, err, NULL, p->rsp_data); g_error_free(err); pending_pkt_free(p); return FALSE; } gboolean g_obex_cancel_req(GObex *obex, guint req_id, gboolean remove_callback) { GList *match; struct pending_pkt *p; if (obex->pending_req && obex->pending_req->id == req_id) { if (!g_obex_pending_req_abort(obex, NULL)) { p = obex->pending_req; obex->pending_req = NULL; goto immediate_completion; } if (remove_callback) obex->pending_req->rsp_func = NULL; return TRUE; } match = g_queue_find_custom(obex->tx_queue, GUINT_TO_POINTER(req_id), pending_pkt_cmp); if (match == NULL) return FALSE; p = match->data; g_queue_delete_link(obex->tx_queue, match); immediate_completion: p->cancelled = TRUE; p->obex = g_obex_ref(obex); if (remove_callback || p->rsp_func == NULL) pending_pkt_free(p); else g_idle_add(cancel_complete, p); return TRUE; } gboolean g_obex_send_rsp(GObex *obex, guint8 rspcode, GError **err, guint8 first_hdr_type, ...) { GObexPacket *rsp; va_list args; va_start(args, first_hdr_type); rsp = g_obex_packet_new_valist(rspcode, TRUE, first_hdr_type, args); va_end(args); return g_obex_send(obex, rsp, err); } void g_obex_set_disconnect_function(GObex *obex, GObexFunc func, gpointer user_data) { obex->disconn_func = func; obex->disconn_func_data = user_data; } static gint req_handler_cmpop(gconstpointer a, gconstpointer b) { const struct req_handler *handler = a; guint opcode = GPOINTER_TO_UINT(b); return (gint) handler->opcode - (gint) opcode; } static gint req_handler_cmpid(gconstpointer a, gconstpointer b) { const struct req_handler *handler = a; guint id = GPOINTER_TO_UINT(b); return (gint) handler->id - (gint) id; } guint g_obex_add_request_function(GObex *obex, guint8 opcode, GObexRequestFunc func, gpointer user_data) { struct req_handler *handler; static guint next_id = 1; handler = g_new0(struct req_handler, 1); handler->id = next_id++; handler->opcode = opcode; handler->func = func; handler->user_data = user_data; obex->req_handlers = g_slist_prepend(obex->req_handlers, handler); return handler->id; } gboolean g_obex_remove_request_function(GObex *obex, guint id) { struct req_handler *handler; GSList *match; match = g_slist_find_custom(obex->req_handlers, GUINT_TO_POINTER(id), req_handler_cmpid); if (match == NULL) return FALSE; handler = match->data; obex->req_handlers = g_slist_delete_link(obex->req_handlers, match); g_free(handler); return TRUE; } void g_obex_suspend(GObex *obex) { g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); if (obex->write_source > 0) { g_source_remove(obex->write_source); obex->write_source = 0; } obex->suspended = TRUE; } void g_obex_resume(GObex *obex) { g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); obex->suspended = FALSE; if (g_queue_get_length(obex->tx_queue) > 0 || obex->tx_data > 0) enable_tx(obex); } gboolean g_obex_srm_active(GObex *obex) { gboolean ret = FALSE; if (!obex->use_srm) return FALSE; if (obex->srm == NULL || !obex->srm->enabled) goto done; if (obex->srm->srmp <= G_OBEX_SRMP_NEXT_WAIT) goto done; ret = TRUE; done: g_obex_debug(G_OBEX_DEBUG_COMMAND, "%s", ret ? "yes" : "no"); return ret; } static void parse_connect_data(GObex *obex, GObexPacket *pkt) { const struct connect_data *data; GObexHeader *connid; guint16 u16; size_t data_len; data = g_obex_packet_get_data(pkt, &data_len); if (data == NULL || data_len != sizeof(*data)) return; memcpy(&u16, &data->mtu, sizeof(u16)); obex->tx_mtu = g_ntohs(u16); if (obex->io_tx_mtu > 0 && obex->tx_mtu > obex->io_tx_mtu) obex->tx_mtu = obex->io_tx_mtu; obex->tx_buf = g_realloc(obex->tx_buf, obex->tx_mtu); connid = g_obex_packet_get_header(pkt, G_OBEX_HDR_CONNECTION); if (connid != NULL) g_obex_header_get_uint32(connid, &obex->conn_id); } static gboolean parse_response(GObex *obex, GObexPacket *rsp) { struct pending_pkt *p = obex->pending_req; guint8 opcode, rspcode; gboolean final; rspcode = g_obex_packet_get_operation(rsp, &final); opcode = g_obex_packet_get_operation(p->pkt, NULL); if (opcode == G_OBEX_OP_CONNECT) parse_connect_data(obex, rsp); setup_srm(obex, rsp, FALSE); if (!g_obex_srm_active(obex)) return final; /* * Resposes have final bit set but in case of GET with SRM * we should not remove the request since the remote side will * continue sending responses until the transfer is finished */ if (opcode == G_OBEX_OP_GET && rspcode == G_OBEX_RSP_CONTINUE) { g_source_remove(p->timeout_id); p->timeout_id = g_timeout_add_seconds(p->timeout, req_timeout, obex); return FALSE; } return final; } static void handle_response(GObex *obex, GError *err, GObexPacket *rsp) { struct pending_pkt *p = obex->pending_req; gboolean disconn = err ? TRUE : FALSE, final_rsp = TRUE; if (rsp != NULL) final_rsp = parse_response(obex, rsp); if (p->cancelled) err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "The operation was cancelled"); if (err) g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); if (p->rsp_func) { p->rsp_func(obex, err, rsp, p->rsp_data); /* Check if user callback removed the request */ if (p != obex->pending_req) return; } if (p->cancelled) g_error_free(err); if (final_rsp) { pending_pkt_free(p); obex->pending_req = NULL; } if (!disconn && g_queue_get_length(obex->tx_queue) > 0) enable_tx(obex); } static gboolean check_connid(GObex *obex, GObexPacket *pkt) { GObexHeader *hdr; guint32 id; if (obex->conn_id == CONNID_INVALID) return TRUE; hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_CONNECTION); if (hdr == NULL) return TRUE; g_obex_header_get_uint32(hdr, &id); return obex->conn_id == id; } static int parse_request(GObex *obex, GObexPacket *req) { guint8 op; gboolean final; op = g_obex_packet_get_operation(req, &final); switch (op) { case G_OBEX_OP_CONNECT: parse_connect_data(obex, req); break; case G_OBEX_OP_ABORT: break; default: if (check_connid(obex, req)) break; return -G_OBEX_RSP_SERVICE_UNAVAILABLE; } setup_srm(obex, req, FALSE); return op; } static void handle_request(GObex *obex, GObexPacket *req) { GSList *match; int op; op = parse_request(obex, req); if (op < 0) goto fail; match = g_slist_find_custom(obex->req_handlers, GUINT_TO_POINTER(op), req_handler_cmpop); if (match) { struct req_handler *handler = match->data; handler->func(obex, req, handler->user_data); return; } op = -G_OBEX_RSP_NOT_IMPLEMENTED; fail: g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", g_obex_strerror(-op)); g_obex_send_rsp(obex, -op, NULL, G_OBEX_HDR_INVALID); } static gboolean read_stream(GObex *obex, GError **err) { GIOChannel *io = obex->io; GIOStatus status; gsize rbytes, toread; guint16 u16; gchar *buf; if (obex->rx_data >= 3) goto read_body; rbytes = 0; toread = 3 - obex->rx_data; buf = (gchar *) &obex->rx_buf[obex->rx_data]; status = g_io_channel_read_chars(io, buf, toread, &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) return TRUE; obex->rx_data += rbytes; if (obex->rx_data < 3) goto done; memcpy(&u16, &buf[1], sizeof(u16)); obex->rx_pkt_len = g_ntohs(u16); if (obex->rx_pkt_len > obex->rx_mtu) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Too big incoming packet"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return FALSE; } read_body: if (obex->rx_data >= obex->rx_pkt_len) goto done; do { toread = obex->rx_pkt_len - obex->rx_data; buf = (gchar *) &obex->rx_buf[obex->rx_data]; status = g_io_channel_read_chars(io, buf, toread, &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) goto done; obex->rx_data += rbytes; } while (rbytes > 0 && obex->rx_data < obex->rx_pkt_len); done: g_obex_dump(">", obex->rx_buf, obex->rx_data); return TRUE; } static gboolean read_packet(GObex *obex, GError **err) { GIOChannel *io = obex->io; GError *read_err = NULL; GIOStatus status; gsize rbytes; guint16 u16; if (obex->rx_data > 0) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "RX buffer not empty before reading packet"); goto fail; } status = g_io_channel_read_chars(io, (gchar *) obex->rx_buf, obex->rx_mtu, &rbytes, &read_err); if (status != G_IO_STATUS_NORMAL) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Unable to read data: %s", read_err->message); g_error_free(read_err); goto fail; } obex->rx_data += rbytes; if (rbytes < 3) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Incomplete packet received"); goto fail; } memcpy(&u16, &obex->rx_buf[1], sizeof(u16)); obex->rx_pkt_len = g_ntohs(u16); if (obex->rx_pkt_len != rbytes) { g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Data size doesn't match packet size (%zu != %u)", rbytes, obex->rx_pkt_len); return FALSE; } g_obex_dump(">", obex->rx_buf, obex->rx_data); return TRUE; fail: g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", (*err)->message); return FALSE; } static gboolean incoming_data(GIOChannel *io, GIOCondition cond, gpointer user_data) { GObex *obex = user_data; GObexPacket *pkt; ssize_t header_offset; GError *err = NULL; guint8 opcode; if (cond & G_IO_NVAL) return FALSE; if (cond & (G_IO_HUP | G_IO_ERR)) { err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_DISCONNECTED, "Transport got disconnected"); goto failed; } if (!obex->read(obex, &err)) goto failed; if (obex->rx_data < 3 || obex->rx_data < obex->rx_pkt_len) return TRUE; obex->rx_last_op = obex->rx_buf[0] & ~FINAL_BIT; if (obex->pending_req) { struct pending_pkt *p = obex->pending_req; opcode = g_obex_packet_get_operation(p->pkt, NULL); header_offset = rsp_header_offset(opcode); } else { opcode = obex->rx_last_op; /* Unexpected response -- fail silently */ if (opcode > 0x1f && opcode != G_OBEX_OP_ABORT) { obex->rx_data = 0; return TRUE; } header_offset = req_header_offset(opcode); } if (header_offset < 0) { err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR, "Unknown header offset for opcode 0x%02x", opcode); goto failed; } pkt = g_obex_packet_decode(obex->rx_buf, obex->rx_data, header_offset, G_OBEX_DATA_REF, &err); if (pkt == NULL) goto failed; /* Protect against user callback freeing the object */ g_obex_ref(obex); if (obex->pending_req) handle_response(obex, NULL, pkt); else handle_request(obex, pkt); obex->rx_data = 0; g_obex_unref(obex); if (err != NULL) g_error_free(err); if (pkt != NULL) g_obex_packet_free(pkt); return TRUE; failed: if (err) g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); g_io_channel_unref(obex->io); obex->io = NULL; obex->io_source = 0; obex->rx_data = 0; /* Protect against user callback freeing the object */ g_obex_ref(obex); if (obex->pending_req) handle_response(obex, err, NULL); if (obex->disconn_func) obex->disconn_func(obex, err, obex->disconn_func_data); g_obex_unref(obex); g_error_free(err); return FALSE; } static GDebugKey keys[] = { { "error", G_OBEX_DEBUG_ERROR }, { "command", G_OBEX_DEBUG_COMMAND }, { "transfer", G_OBEX_DEBUG_TRANSFER }, { "header", G_OBEX_DEBUG_HEADER }, { "packet", G_OBEX_DEBUG_PACKET }, { "data", G_OBEX_DEBUG_DATA }, }; GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type, gssize io_rx_mtu, gssize io_tx_mtu) { GObex *obex; GIOCondition cond; if (gobex_debug == 0) { const char *env = g_getenv("GOBEX_DEBUG"); if (env) gobex_debug = g_parse_debug_string(env, keys, 6); else gobex_debug = G_OBEX_DEBUG_NONE; } g_obex_debug(G_OBEX_DEBUG_COMMAND, ""); if (io == NULL) return NULL; if (io_rx_mtu >= 0 && io_rx_mtu < G_OBEX_MINIMUM_MTU) return NULL; if (io_tx_mtu >= 0 && io_tx_mtu < G_OBEX_MINIMUM_MTU) return NULL; obex = g_new0(GObex, 1); obex->io = g_io_channel_ref(io); obex->ref_count = 1; obex->conn_id = CONNID_INVALID; obex->rx_last_op = G_OBEX_OP_NONE; obex->io_rx_mtu = io_rx_mtu; obex->io_tx_mtu = io_tx_mtu; if (io_rx_mtu > G_OBEX_MAXIMUM_MTU) obex->rx_mtu = G_OBEX_MAXIMUM_MTU; else if (io_rx_mtu < G_OBEX_MINIMUM_MTU) obex->rx_mtu = G_OBEX_DEFAULT_MTU; else obex->rx_mtu = io_rx_mtu; obex->tx_mtu = G_OBEX_MINIMUM_MTU; obex->tx_queue = g_queue_new(); obex->rx_buf = g_malloc(obex->rx_mtu); obex->tx_buf = g_malloc(obex->tx_mtu); switch (transport_type) { case G_OBEX_TRANSPORT_STREAM: obex->read = read_stream; obex->write = write_stream; break; case G_OBEX_TRANSPORT_PACKET: obex->use_srm = TRUE; obex->read = read_packet; obex->write = write_packet; break; default: g_obex_unref(obex); return NULL; } g_io_channel_set_encoding(io, NULL, NULL); g_io_channel_set_buffered(io, FALSE); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; obex->io_source = g_io_add_watch(io, cond, incoming_data, obex); return obex; } GObex *g_obex_ref(GObex *obex) { if (obex == NULL) return NULL; g_atomic_int_inc(&obex->ref_count); g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", obex->ref_count); return obex; } void g_obex_unref(GObex *obex) { gboolean last_ref; last_ref = g_atomic_int_dec_and_test(&obex->ref_count); g_obex_debug(G_OBEX_DEBUG_COMMAND, "ref %u", obex->ref_count); if (!last_ref) return; g_slist_free_full(obex->req_handlers, g_free); g_queue_foreach(obex->tx_queue, (GFunc) pending_pkt_free, NULL); g_queue_free(obex->tx_queue); if (obex->io != NULL) g_io_channel_unref(obex->io); if (obex->io_source > 0) g_source_remove(obex->io_source); if (obex->write_source > 0) g_source_remove(obex->write_source); g_free(obex->rx_buf); g_free(obex->tx_buf); g_free(obex->srm); if (obex->pending_req) pending_pkt_free(obex->pending_req); g_free(obex); } /* Higher level functions */ guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data, GError **err, guint8 first_hdr_id, ...) { GObexPacket *req; struct connect_data data; va_list args; g_obex_debug(G_OBEX_DEBUG_COMMAND, ""); va_start(args, first_hdr_id); req = g_obex_packet_new_valist(G_OBEX_OP_CONNECT, TRUE, first_hdr_id, args); va_end(args); init_connect_data(obex, &data); g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func, gpointer user_data, GError **err) { GObexPacket *req; struct setpath_data data; const char *folder; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_INVALID); memset(&data, 0, sizeof(data)); if (path != NULL && strncmp("..", path, 2) == 0) { data.flags = 0x03; folder = (path[2] == '/') ? &path[3] : NULL; } else { data.flags = 0x02; folder = path; } if (folder != NULL) { GObexHeader *hdr; hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, folder); g_obex_packet_add_header(req, hdr); } g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint g_obex_mkdir(GObex *obex, const char *path, GObexResponseFunc func, gpointer user_data, GError **err) { GObexPacket *req; struct setpath_data data; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_NAME, path, G_OBEX_HDR_INVALID); memset(&data, 0, sizeof(data)); g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint g_obex_delete(GObex *obex, const char *name, GObexResponseFunc func, gpointer user_data, GError **err) { GObexPacket *req; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_NAME, name, G_OBEX_HDR_INVALID); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint g_obex_copy(GObex *obex, const char *name, const char *dest, GObexResponseFunc func, gpointer user_data, GError **err) { GObexPacket *req; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); req = g_obex_packet_new(G_OBEX_OP_ACTION, TRUE, G_OBEX_HDR_ACTION, G_OBEX_ACTION_COPY, G_OBEX_HDR_NAME, name, G_OBEX_HDR_DESTNAME, dest, G_OBEX_HDR_INVALID); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint g_obex_move(GObex *obex, const char *name, const char *dest, GObexResponseFunc func, gpointer user_data, GError **err) { GObexPacket *req; g_obex_debug(G_OBEX_DEBUG_COMMAND, "conn %u", obex->conn_id); req = g_obex_packet_new(G_OBEX_OP_ACTION, TRUE, G_OBEX_HDR_ACTION, G_OBEX_ACTION_MOVE, G_OBEX_HDR_NAME, name, G_OBEX_HDR_DESTNAME, dest, G_OBEX_HDR_INVALID); return g_obex_send_req(obex, req, -1, func, user_data, err); } guint8 g_obex_errno_to_rsp(int err) { switch (err) { case 0: return G_OBEX_RSP_SUCCESS; case -EPERM: case -EACCES: return G_OBEX_RSP_FORBIDDEN; case -ENOENT: return G_OBEX_RSP_NOT_FOUND; case -EINVAL: case -EBADR: return G_OBEX_RSP_BAD_REQUEST; case -EFAULT: return G_OBEX_RSP_SERVICE_UNAVAILABLE; case -ENOSYS: return G_OBEX_RSP_NOT_IMPLEMENTED; case -ENOTEMPTY: case -EEXIST: return G_OBEX_RSP_PRECONDITION_FAILED; default: return G_OBEX_RSP_INTERNAL_SERVER_ERROR; } } obexd-0.46/gobex/gobex-transfer.c0000644000000000000000000003713511755212521013643 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "gobex.h" #include "gobex-debug.h" #define FIRST_PACKET_TIMEOUT 60 static GSList *transfers = NULL; static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data); struct transfer { guint id; guint8 opcode; GObex *obex; guint req_id; guint put_id; guint get_id; guint abort_id; GObexDataProducer data_producer; GObexDataConsumer data_consumer; GObexFunc complete_func; gpointer user_data; }; static void transfer_free(struct transfer *transfer) { g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); transfers = g_slist_remove(transfers, transfer); if (transfer->req_id > 0) g_obex_cancel_req(transfer->obex, transfer->req_id, TRUE); if (transfer->put_id > 0) g_obex_remove_request_function(transfer->obex, transfer->put_id); if (transfer->get_id > 0) g_obex_remove_request_function(transfer->obex, transfer->get_id); if (transfer->abort_id > 0) g_obex_remove_request_function(transfer->obex, transfer->abort_id); g_obex_unref(transfer->obex); g_free(transfer); } static struct transfer *find_transfer(guint id) { GSList *l; for (l = transfers; l != NULL; l = g_slist_next(l)) { struct transfer *t = l->data; if (t->id == id) return t; } return NULL; } static void transfer_complete(struct transfer *transfer, GError *err) { guint id = transfer->id; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", id); transfer->complete_func(transfer->obex, err, transfer->user_data); /* Check if the complete_func removed the transfer */ if (find_transfer(id) == NULL) return; transfer_free(transfer); } static void transfer_abort_response(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct transfer *transfer = user_data; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); transfer->req_id = 0; /* Intentionally override error */ err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "Operation was aborted"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); transfer_complete(transfer, err); g_error_free(err); } static gssize put_get_data(void *buf, gsize len, gpointer user_data) { struct transfer *transfer = user_data; GObexPacket *req; GError *err = NULL; gssize ret; ret = transfer->data_producer(buf, len, transfer->user_data); if (ret == 0 || ret == -EAGAIN) return ret; if (ret > 0) { /* Check if SRM is active */ if (!g_obex_srm_active(transfer->obex)) return ret; /* Generate next packet */ req = g_obex_packet_new(transfer->opcode, FALSE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(req, put_get_data, transfer); transfer->req_id = g_obex_send_req(transfer->obex, req, -1, transfer_response, transfer, &err); goto done; } req = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_INVALID); transfer->req_id = g_obex_send_req(transfer->obex, req, -1, transfer_abort_response, transfer, &err); done: if (err != NULL) { transfer_complete(transfer, err); g_error_free(err); } return ret; } static gboolean handle_get_body(struct transfer *transfer, GObexPacket *rsp, GError **err) { GObexHeader *body = g_obex_packet_get_body(rsp); gboolean ret; const guint8 *buf; gsize len; if (body == NULL) return TRUE; g_obex_header_get_bytes(body, &buf, &len); if (len == 0) return TRUE; ret = transfer->data_consumer(buf, len, transfer->user_data); if (ret == FALSE) g_set_error(err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "Data consumer callback failed"); return ret; } static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct transfer *transfer = user_data; GObexPacket *req; gboolean rspcode, final; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); transfer->req_id = 0; if (err != NULL) { transfer_complete(transfer, err); return; } rspcode = g_obex_packet_get_operation(rsp, &final); if (rspcode != G_OBEX_RSP_SUCCESS && rspcode != G_OBEX_RSP_CONTINUE) { err = g_error_new(G_OBEX_ERROR, rspcode, "Transfer failed (0x%02x)", rspcode); goto failed; } if (transfer->opcode == G_OBEX_OP_GET) { handle_get_body(transfer, rsp, &err); if (err != NULL) goto failed; } if (rspcode == G_OBEX_RSP_SUCCESS) { transfer_complete(transfer, NULL); return; } if (transfer->opcode == G_OBEX_OP_PUT) { req = g_obex_packet_new(transfer->opcode, FALSE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(req, put_get_data, transfer); } else if (!g_obex_srm_active(transfer->obex)) { req = g_obex_packet_new(transfer->opcode, TRUE, G_OBEX_HDR_INVALID); } else return; transfer->req_id = g_obex_send_req(obex, req, -1, transfer_response, transfer, &err); failed: if (err != NULL) { g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); transfer_complete(transfer, err); g_error_free(err); } } static struct transfer *transfer_new(GObex *obex, guint8 opcode, GObexFunc complete_func, gpointer user_data) { static guint next_id = 1; struct transfer *transfer; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p opcode %u", obex, opcode); transfer = g_new0(struct transfer, 1); transfer->id = next_id++; transfer->opcode = opcode; transfer->obex = g_obex_ref(obex); transfer->complete_func = complete_func; transfer->user_data = user_data; transfers = g_slist_append(transfers, transfer); return transfer; } guint g_obex_put_req_pkt(GObex *obex, GObexPacket *req, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err) { struct transfer *transfer; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); if (g_obex_packet_get_operation(req, NULL) != G_OBEX_OP_PUT) return 0; transfer = transfer_new(obex, G_OBEX_OP_PUT, complete_func, user_data); transfer->data_producer = data_func; g_obex_packet_add_body(req, put_get_data, transfer); transfer->req_id = g_obex_send_req(obex, req, FIRST_PACKET_TIMEOUT, transfer_response, transfer, err); if (transfer->req_id == 0) { transfer_free(transfer); return 0; } g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); return transfer->id; } guint g_obex_put_req(GObex *obex, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...) { GObexPacket *req; va_list args; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); va_start(args, first_hdr_id); req = g_obex_packet_new_valist(G_OBEX_OP_PUT, FALSE, first_hdr_id, args); va_end(args); return g_obex_put_req_pkt(obex, req, data_func, complete_func, user_data, err); } static void transfer_abort_req(GObex *obex, GObexPacket *req, gpointer user_data) { struct transfer *transfer = user_data; GObexPacket *rsp; GError *err; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "Request was aborted"); rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID); g_obex_send(obex, rsp, NULL); transfer_complete(transfer, err); g_error_free(err); } static guint8 put_get_bytes(struct transfer *transfer, GObexPacket *req) { GObexHeader *body; gboolean final; guint8 rsp; const guint8 *buf; gsize len; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); g_obex_packet_get_operation(req, &final); if (final) rsp = G_OBEX_RSP_SUCCESS; else rsp = G_OBEX_RSP_CONTINUE; body = g_obex_packet_get_body(req); if (body == NULL) return rsp; g_obex_header_get_bytes(body, &buf, &len); if (len == 0) return rsp; if (transfer->data_consumer(buf, len, transfer->user_data) == FALSE) rsp = G_OBEX_RSP_FORBIDDEN; return rsp; } static void transfer_put_req_first(struct transfer *transfer, GObexPacket *req, guint8 first_hdr_id, va_list args) { GError *err = NULL; GObexPacket *rsp; guint8 rspcode; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); rspcode = put_get_bytes(transfer, req); rsp = g_obex_packet_new_valist(rspcode, TRUE, first_hdr_id, args); if (!g_obex_send(transfer->obex, rsp, &err)) { transfer_complete(transfer, err); g_error_free(err); } if (rspcode != G_OBEX_RSP_CONTINUE) transfer_complete(transfer, NULL); } static void transfer_put_req(GObex *obex, GObexPacket *req, gpointer user_data) { struct transfer *transfer = user_data; GError *err = NULL; GObexPacket *rsp; guint8 rspcode; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); rspcode = put_get_bytes(transfer, req); /* Don't send continue while in SRM */ if (g_obex_srm_active(transfer->obex) && rspcode == G_OBEX_RSP_CONTINUE) goto done; rsp = g_obex_packet_new(rspcode, TRUE, G_OBEX_HDR_INVALID); if (!g_obex_send(obex, rsp, &err)) { transfer_complete(transfer, err); g_error_free(err); } done: if (rspcode != G_OBEX_RSP_CONTINUE) transfer_complete(transfer, NULL); } guint g_obex_put_rsp(GObex *obex, GObexPacket *req, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...) { struct transfer *transfer; va_list args; guint id; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); transfer = transfer_new(obex, G_OBEX_OP_PUT, complete_func, user_data); transfer->data_consumer = data_func; va_start(args, first_hdr_id); transfer_put_req_first(transfer, req, first_hdr_id, args); va_end(args); if (!g_slist_find(transfers, transfer)) return 0; id = g_obex_add_request_function(obex, G_OBEX_OP_PUT, transfer_put_req, transfer); transfer->put_id = id; id = g_obex_add_request_function(obex, G_OBEX_OP_ABORT, transfer_abort_req, transfer); transfer->abort_id = id; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); return transfer->id; } guint g_obex_get_req_pkt(GObex *obex, GObexPacket *req, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err) { struct transfer *transfer; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); if (g_obex_packet_get_operation(req, NULL) != G_OBEX_OP_GET) return 0; transfer = transfer_new(obex, G_OBEX_OP_GET, complete_func, user_data); transfer->data_consumer = data_func; transfer->req_id = g_obex_send_req(obex, req, FIRST_PACKET_TIMEOUT, transfer_response, transfer, err); if (transfer->req_id == 0) { transfer_free(transfer); return 0; } g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); return transfer->id; } guint g_obex_get_req(GObex *obex, GObexDataConsumer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...) { struct transfer *transfer; GObexPacket *req; va_list args; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); transfer = transfer_new(obex, G_OBEX_OP_GET, complete_func, user_data); transfer->data_consumer = data_func; va_start(args, first_hdr_id); req = g_obex_packet_new_valist(G_OBEX_OP_GET, TRUE, first_hdr_id, args); va_end(args); transfer->req_id = g_obex_send_req(obex, req, FIRST_PACKET_TIMEOUT, transfer_response, transfer, err); if (transfer->req_id == 0) { transfer_free(transfer); return 0; } g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); return transfer->id; } static gssize get_get_data(void *buf, gsize len, gpointer user_data) { struct transfer *transfer = user_data; GObexPacket *req, *rsp; GError *err = NULL; gssize ret; guint8 op; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); ret = transfer->data_producer(buf, len, transfer->user_data); if (ret > 0) { if (!g_obex_srm_active(transfer->obex)) return ret; /* Generate next response */ rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(rsp, get_get_data, transfer); if (!g_obex_send(transfer->obex, rsp, &err)) { transfer_complete(transfer, err); g_error_free(err); } return ret; } if (ret == -EAGAIN) return ret; if (ret == 0) { transfer_complete(transfer, NULL); return ret; } op = g_obex_errno_to_rsp(ret); req = g_obex_packet_new(op, TRUE, G_OBEX_HDR_INVALID); g_obex_send(transfer->obex, req, NULL); err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED, "Data producer function failed"); g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message); transfer_complete(transfer, err); g_error_free(err); return ret; } static void transfer_get_req_first(struct transfer *transfer, GObexPacket *rsp) { GError *err = NULL; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); g_obex_packet_add_body(rsp, get_get_data, transfer); if (!g_obex_send(transfer->obex, rsp, &err)) { transfer_complete(transfer, err); g_error_free(err); } } static void transfer_get_req(GObex *obex, GObexPacket *req, gpointer user_data) { struct transfer *transfer = user_data; GError *err = NULL; GObexPacket *rsp; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(rsp, get_get_data, transfer); if (!g_obex_send(obex, rsp, &err)) { transfer_complete(transfer, err); g_error_free(err); } } guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err) { struct transfer *transfer; guint id; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); transfer = transfer_new(obex, G_OBEX_OP_GET, complete_func, user_data); transfer->data_producer = data_func; transfer_get_req_first(transfer, rsp); if (!g_slist_find(transfers, transfer)) return 0; id = g_obex_add_request_function(obex, G_OBEX_OP_GET, transfer_get_req, transfer); transfer->get_id = id; id = g_obex_add_request_function(obex, G_OBEX_OP_ABORT, transfer_abort_req, transfer); transfer->abort_id = id; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id); return transfer->id; } guint g_obex_get_rsp(GObex *obex, GObexDataProducer data_func, GObexFunc complete_func, gpointer user_data, GError **err, guint8 first_hdr_id, ...) { GObexPacket *rsp; va_list args; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "obex %p", obex); va_start(args, first_hdr_id); rsp = g_obex_packet_new_valist(G_OBEX_RSP_CONTINUE, TRUE, first_hdr_id, args); va_end(args); return g_obex_get_rsp_pkt(obex, rsp, data_func, complete_func, user_data, err); } gboolean g_obex_cancel_transfer(guint id, GObexFunc complete_func, gpointer user_data) { struct transfer *transfer = NULL; gboolean ret = TRUE; g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", id); transfer = find_transfer(id); if (transfer == NULL) return FALSE; if (complete_func == NULL) goto done; transfer->complete_func = complete_func; transfer->user_data = user_data; ret = g_obex_pending_req_abort(transfer->obex, NULL); if (ret) return TRUE; done: transfer_free(transfer); return ret; } obexd-0.46/tools/0000755000000000000000000000000011755212615010660 500000000000000obexd-0.46/tools/test-client.c0000644000000000000000000002510411755212521013175 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include #include #include #include #include static GMainLoop *main_loop = NULL; static GObex *obex = NULL; static gboolean option_packet = FALSE; static gboolean option_bluetooth = FALSE; static char *option_source = NULL; static char *option_dest = NULL; static int option_channel = -1; static int option_imtu = -1; static int option_omtu = -1; static void sig_term(int sig) { g_print("Terminating due to signal %d\n", sig); g_main_loop_quit(main_loop); } static GOptionEntry options[] = { { "unix", 'u', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_bluetooth, "Use a UNIX socket" }, { "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth, "Use Bluetooth" }, { "source", 's', 0, G_OPTION_ARG_STRING, &option_source, "Bluetooth adapter address", "00:..." }, { "destination", 'd', 0, G_OPTION_ARG_STRING, &option_dest, "Remote bluetooth address", "00:..." }, { "channel", 'c', 0, G_OPTION_ARG_INT, &option_channel, "Transport channel", "CHANNEL" }, { "packet", 'p', 0, G_OPTION_ARG_NONE, &option_packet, "Packet based transport" }, { "stream", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_packet, "Stream based transport" }, { "input-mtu", 'i', 0, G_OPTION_ARG_INT, &option_imtu, "Transport input MTU", "MTU" }, { "output-mtu", 'o', 0, G_OPTION_ARG_INT, &option_omtu, "Transport output MTU", "MTU" }, { NULL }, }; static void conn_complete(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { if (err != NULL) g_print("Connect failed: %s\n", err->message); else g_print("Connect succeeded\n"); } static void cmd_connect(int argc, char **argv) { g_obex_connect(obex, conn_complete, NULL, NULL, G_OBEX_HDR_INVALID); } struct transfer_data { int fd; }; static void transfer_complete(GObex *obex, GError *err, gpointer user_data) { struct transfer_data *data = user_data; if (err != NULL) g_printerr("failed: %s\n", err->message); else g_print("transfer succeeded\n"); close(data->fd); g_free(data); } static gssize put_data_cb(void *buf, gsize len, gpointer user_data) { struct transfer_data *data = user_data; return read(data->fd, buf, len); } static void cmd_put(int argc, char **argv) { struct transfer_data *data; GError *err = NULL; int fd; if (argc < 2) { g_printerr("Filename required\n"); return; } fd = open(argv[1], O_RDONLY | O_NOCTTY, 0); if (fd < 0) { g_printerr("open: %s\n", strerror(errno)); return; } data = g_new0(struct transfer_data, 1); data->fd = fd; g_obex_put_req(obex, put_data_cb, transfer_complete, data, &err, G_OBEX_HDR_NAME, argv[1], G_OBEX_HDR_INVALID); if (err != NULL) { g_printerr("put failed: %s\n", err->message); g_error_free(err); close(data->fd); g_free(data); } } static gboolean get_data_cb(const void *buf, gsize len, gpointer user_data) { struct transfer_data *data = user_data; if (write(data->fd, buf, len) < 0) { g_printerr("write: %s\n", strerror(errno)); return FALSE; } return TRUE; } static void cmd_get(int argc, char **argv) { struct transfer_data *data; GError *err = NULL; int fd; if (argc < 2) { g_printerr("Filename required\n"); return; } fd = open(argv[1], O_WRONLY | O_CREAT | O_NOCTTY, 0600); if (fd < 0) { g_printerr("open: %s\n", strerror(errno)); return; } data = g_new0(struct transfer_data, 1); data->fd = fd; g_obex_get_req(obex, get_data_cb, transfer_complete, data, &err, G_OBEX_HDR_NAME, argv[1], G_OBEX_HDR_INVALID); if (err != NULL) { g_printerr("put failed: %s\n", err->message); g_error_free(err); close(data->fd); g_free(data); } } static void cmd_help(int argc, char **argv); static void cmd_exit(int argc, char **argv) { g_main_loop_quit(main_loop); } static struct { const char *cmd; void (*func)(int argc, char **argv); const char *params; const char *desc; } commands[] = { { "help", cmd_help, "", "Show this help"}, { "exit", cmd_exit, "", "Exit application" }, { "quit", cmd_exit, "", "Exit application" }, { "connect", cmd_connect, "[target]", "OBEX Connect" }, { "put", cmd_put, "", "Send a file" }, { "get", cmd_get, "", "Receive a file" }, { NULL }, }; static void cmd_help(int argc, char **argv) { int i; for (i = 0; commands[i].cmd; i++) printf("%-15s %-30s %s\n", commands[i].cmd, commands[i].params, commands[i].desc); } static void parse_line(char *line_read) { gchar **argvp; int argcp; int i; if (line_read == NULL) { g_print("\n"); g_main_loop_quit(main_loop); return; } line_read = g_strstrip(line_read); if (*line_read == '\0') { free(line_read); return; } add_history(line_read); g_shell_parse_argv(line_read, &argcp, &argvp, NULL); free(line_read); for (i = 0; commands[i].cmd; i++) if (strcasecmp(commands[i].cmd, argvp[0]) == 0) break; if (commands[i].cmd) commands[i].func(argcp, argvp); else g_print("%s: command not found\n", argvp[0]); g_strfreev(argvp); } static gboolean prompt_read(GIOChannel *chan, GIOCondition cond, gpointer user_data) { if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { g_main_loop_quit(main_loop); return FALSE; } rl_callback_read_char(); return TRUE; } static void disconn_func(GObex *obex, GError *err, gpointer user_data) { g_printerr("Disconnected: %s\n", err ? err->message : "(no error)"); g_main_loop_quit(main_loop); } static void transport_connect(GIOChannel *io, GObexTransportType transport) { GIOChannel *input; GIOCondition events; g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); g_io_channel_set_close_on_unref(io, TRUE); obex = g_obex_new(io, transport, option_imtu, option_omtu); g_obex_set_disconnect_function(obex, disconn_func, NULL); input = g_io_channel_unix_new(STDIN_FILENO); g_io_channel_set_close_on_unref(input, TRUE); events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL; g_io_add_watch(input, events, prompt_read, NULL); g_io_channel_unref(input); rl_callback_handler_install("client> ", parse_line); } static GIOChannel *unix_connect(GObexTransportType transport) { GIOChannel *io; struct sockaddr_un addr = { AF_UNIX, "\0/gobex/server" }; int sk, err, sock_type; if (option_packet) sock_type = SOCK_SEQPACKET; else sock_type = SOCK_STREAM; sk = socket(PF_LOCAL, sock_type, 0); if (sk < 0) { err = errno; g_printerr("Can't create unix socket: %s (%d)\n", strerror(err), err); return NULL; } if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { err = errno; g_printerr("connect: %s (%d)\n", strerror(err), err); return NULL; } io = g_io_channel_unix_new(sk); g_print("Unix socket created: %d\n", sk); transport_connect(io, transport); return io; } static void conn_callback(GIOChannel *io, GError *err, gpointer user_data) { GObexTransportType transport = GPOINTER_TO_UINT(user_data); if (err != NULL) { g_printerr("%s\n", err->message); return; } g_print("Bluetooth socket connected\n"); transport_connect(io, transport); } static GIOChannel *bluetooth_connect(GObexTransportType transport) { GIOChannel *io; GError *err = NULL; BtIOType type; BtIOOption option; if (option_dest == NULL || option_channel < 0) return NULL; if (option_channel > 31) { type = option_packet ? BT_IO_L2CAP : BT_IO_L2ERTM; option = BT_IO_OPT_PSM; } else { type = BT_IO_RFCOMM; option = BT_IO_OPT_CHANNEL; } if (option_source) { if (type == BT_IO_L2CAP) { io = bt_io_connect(type, conn_callback, GUINT_TO_POINTER(transport), NULL, &err, BT_IO_OPT_SOURCE, option_source, BT_IO_OPT_DEST, option_dest, option, option_channel, BT_IO_OPT_MODE, BT_IO_MODE_ERTM, BT_IO_OPT_OMTU, option_omtu, BT_IO_OPT_IMTU, option_imtu, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } else { io = bt_io_connect(type, conn_callback, GUINT_TO_POINTER(transport), NULL, &err, BT_IO_OPT_SOURCE, option_source, BT_IO_OPT_DEST, option_dest, option, option_channel, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } } else { if (type == BT_IO_L2CAP) { io = bt_io_connect(type, conn_callback, GUINT_TO_POINTER(transport), NULL, &err, BT_IO_OPT_DEST, option_dest, option, option_channel, BT_IO_OPT_MODE, BT_IO_MODE_ERTM, BT_IO_OPT_OMTU, option_omtu, BT_IO_OPT_IMTU, option_imtu, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } else { io = bt_io_connect(type, conn_callback, GUINT_TO_POINTER(transport), NULL, &err, BT_IO_OPT_DEST, option_dest, option, option_channel, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); } } if (io != NULL) return io; g_printerr("%s\n", err->message); g_error_free(err); return NULL; } int main(int argc, char *argv[]) { GOptionContext *context; GError *err = NULL; struct sigaction sa; GIOChannel *io; GObexTransportType transport; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); g_option_context_parse(context, &argc, &argv, &err); if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } if (option_packet) transport = G_OBEX_TRANSPORT_PACKET; else transport = G_OBEX_TRANSPORT_STREAM; if (option_bluetooth) io = bluetooth_connect(transport); else io = unix_connect(transport); if (io == NULL) exit(EXIT_FAILURE); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(main_loop); rl_callback_handler_remove(); clear_history(); g_obex_unref(obex); g_option_context_free(context); g_main_loop_unref(main_loop); exit(EXIT_SUCCESS); } obexd-0.46/tools/test-server.c0000644000000000000000000002523011755212521013225 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include static GMainLoop *main_loop = NULL; static GSList *clients = NULL; static gboolean option_packet = FALSE; static gboolean option_bluetooth = FALSE; static int option_channel = -1; static int option_imtu = -1; static int option_omtu = -1; static char *option_root = NULL; static void sig_term(int sig) { g_print("Terminating due to signal %d\n", sig); g_main_loop_quit(main_loop); } static GOptionEntry options[] = { { "unix", 'u', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_bluetooth, "Use a UNIX socket" }, { "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth, "Use Bluetooth" }, { "channel", 'c', 0, G_OPTION_ARG_INT, &option_channel, "Transport channel", "CHANNEL" }, { "packet", 'p', 0, G_OPTION_ARG_NONE, &option_packet, "Packet based transport" }, { "stream", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_packet, "Stream based transport" }, { "root", 'r', 0, G_OPTION_ARG_STRING, &option_root, "Root dir", "/..." }, { "input-mtu", 'i', 0, G_OPTION_ARG_INT, &option_imtu, "Transport input MTU", "MTU" }, { "output-mtu", 'o', 0, G_OPTION_ARG_INT, &option_omtu, "Transport output MTU", "MTU" }, { NULL }, }; static void disconn_func(GObex *obex, GError *err, gpointer user_data) { g_print("Client disconnected: %s\n", err ? err->message : ""); clients = g_slist_remove(clients, obex); g_obex_unref(obex); } struct transfer_data { int fd; }; static void transfer_complete(GObex *obex, GError *err, gpointer user_data) { struct transfer_data *data = user_data; if (err != NULL) g_printerr("transfer failed: %s\n", err->message); else g_print("transfer succeeded\n"); close(data->fd); g_free(data); } static gboolean recv_data(const void *buf, gsize len, gpointer user_data) { struct transfer_data *data = user_data; g_print("received %zu bytes of data\n", len); if (write(data->fd, buf, len) < 0) { g_printerr("write: %s\n", strerror(errno)); return FALSE; } return TRUE; } static void handle_put(GObex *obex, GObexPacket *req, gpointer user_data) { GError *err = NULL; GObexHeader *hdr; const char *type, *name; struct transfer_data *data; gsize type_len; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_TYPE); if (hdr != NULL) { g_obex_header_get_bytes(hdr, (const guint8 **) &type, &type_len); if (type[type_len - 1] != '\0') { g_printerr("non-nul terminated type header\n"); type = NULL; } } else type = NULL; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_NAME); if (hdr != NULL) g_obex_header_get_unicode(hdr, &name); else name = NULL; g_print("put type \"%s\" name \"%s\"\n", type ? type : "", name ? name : ""); data = g_new0(struct transfer_data, 1); data->fd = open(name, O_WRONLY | O_CREAT | O_NOCTTY, 0600); if (data->fd < 0) { g_printerr("open(%s): %s\n", name, strerror(errno)); g_free(data); g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL, G_OBEX_HDR_INVALID); return; } g_obex_put_rsp(obex, req, recv_data, transfer_complete, data, &err, G_OBEX_HDR_INVALID); if (err != NULL) { g_printerr("Unable to send response: %s\n", err->message); g_error_free(err); g_free(data); } } static gssize send_data(void *buf, gsize len, gpointer user_data) { struct transfer_data *data = user_data; gssize ret; ret = read(data->fd, buf, len); g_print("sending %zu bytes of data\n", ret); return ret; } static void handle_get(GObex *obex, GObexPacket *req, gpointer user_data) { GError *err = NULL; struct transfer_data *data; const char *type, *name; GObexHeader *hdr; gsize type_len; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_TYPE); if (hdr != NULL) { g_obex_header_get_bytes(hdr, (const guint8 **) &type, &type_len); if (type[type_len - 1] != '\0') { g_printerr("non-nul terminated type header\n"); type = NULL; } } else type = NULL; hdr = g_obex_packet_get_header(req, G_OBEX_HDR_NAME); if (hdr != NULL) g_obex_header_get_unicode(hdr, &name); else name = NULL; g_print("get type \"%s\" name \"%s\"\n", type ? type : "", name ? name : ""); data = g_new0(struct transfer_data, 1); data->fd = open(name, O_RDONLY | O_NOCTTY, 0); if (data->fd < 0) { g_printerr("open(%s): %s\n", name, strerror(errno)); g_free(data); g_obex_send_rsp(obex, G_OBEX_RSP_FORBIDDEN, NULL, G_OBEX_HDR_INVALID); return; } g_obex_get_rsp(obex, send_data, transfer_complete, data, &err, G_OBEX_HDR_INVALID); if (err != NULL) { g_printerr("Unable to send response: %s\n", err->message); g_error_free(err); g_free(data); } } static void handle_connect(GObex *obex, GObexPacket *req, gpointer user_data) { GObexPacket *rsp; g_print("connect\n"); rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID); g_obex_send(obex, rsp, NULL); } static void transport_accept(GIOChannel *io) { GObex *obex; GObexTransportType transport; g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); g_io_channel_set_close_on_unref(io, TRUE); if (option_packet) transport = G_OBEX_TRANSPORT_PACKET; else transport = G_OBEX_TRANSPORT_STREAM; obex = g_obex_new(io, transport, option_imtu, option_omtu); g_obex_set_disconnect_function(obex, disconn_func, NULL); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, NULL); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, NULL); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_connect, NULL); clients = g_slist_append(clients, obex); } static gboolean unix_accept(GIOChannel *chan, GIOCondition cond, gpointer data) { struct sockaddr_un addr; socklen_t addrlen; int sk, cli_sk; GIOChannel *io; if (cond & G_IO_NVAL) return FALSE; if (cond & (G_IO_HUP | G_IO_ERR)) { g_io_channel_shutdown(chan, TRUE, NULL); return FALSE; } sk = g_io_channel_unix_get_fd(chan); memset(&addr, 0, sizeof(addr)); addrlen = sizeof(addr); cli_sk = accept(sk, (struct sockaddr *) &addr, &addrlen); if (cli_sk < 0) { g_printerr("accept: %s (%d)\n", strerror(errno), errno); return TRUE; } g_print("Accepted new client connection on unix socket (fd=%d)\n", cli_sk); io = g_io_channel_unix_new(cli_sk); transport_accept(io); g_io_channel_unref(io); return TRUE; } static void bluetooth_accept(GIOChannel *io, GError *err, gpointer data) { if (err) { g_printerr("accept: %s\n", err->message); return; } g_print("Accepted new client connection on bluetooth socket\n"); transport_accept(io); } static gboolean bluetooth_watch(GIOChannel *chan, GIOCondition cond, gpointer data) { if (cond & G_IO_NVAL) return FALSE; g_io_channel_shutdown(chan, TRUE, NULL); return FALSE; } static guint bluetooth_listen(void) { GIOChannel *io; guint id; GError *err = NULL; BtIOType type; BtIOOption option; if (option_channel == -1) { g_printerr("Bluetooth channel not set\n"); return 0; } if (option_packet || option_channel > 31) { type = option_packet ? BT_IO_L2CAP : BT_IO_L2ERTM; option = BT_IO_OPT_PSM; } else { type = BT_IO_RFCOMM; option = BT_IO_OPT_CHANNEL; } if (type == BT_IO_L2CAP) io = bt_io_listen(type, bluetooth_accept, NULL, NULL, NULL, &err, option, option_channel, BT_IO_OPT_MODE, BT_IO_MODE_ERTM, BT_IO_OPT_OMTU, option_omtu, BT_IO_OPT_IMTU, option_imtu, BT_IO_OPT_INVALID); else io = bt_io_listen(type, bluetooth_accept, NULL, NULL, NULL, &err, option, option_channel, BT_IO_OPT_INVALID); if (io == NULL) { g_printerr("%s\n", err->message); g_error_free(err); return 0; } g_print("Bluetooth socket created\n"); id = g_io_add_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, bluetooth_watch, NULL); g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); g_io_channel_set_close_on_unref(io, TRUE); g_io_channel_unref(io); return id; } static guint unix_listen(void) { GIOChannel *io; struct sockaddr_un addr = { AF_UNIX, "\0/gobex/server" }; int sk, err, sock_type; guint id; if (option_packet) sock_type = SOCK_SEQPACKET; else sock_type = SOCK_STREAM; sk = socket(PF_LOCAL, sock_type, 0); if (sk < 0) { err = errno; g_printerr("Can't create unix socket: %s (%d)\n", strerror(err), err); return 0; } if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) { g_printerr("Can't bind unix socket: %s (%d)\n", strerror(errno), errno); close(sk); return 0; } if (listen(sk, 1) < 0) { g_printerr("Can't listen on unix socket: %s (%d)\n", strerror(errno), errno); close(sk); return 0; } g_print("Unix socket created: %d\n", sk); io = g_io_channel_unix_new(sk); id = g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, unix_accept, NULL); g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK, NULL); g_io_channel_set_close_on_unref(io, TRUE); g_io_channel_unref(io); return id; } int main(int argc, char *argv[]) { GOptionContext *context; GError *err = NULL; struct sigaction sa; guint server_id; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); g_option_context_parse(context, &argc, &argv, &err); if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); exit(EXIT_FAILURE); } if (option_root && chdir(option_root) > 0) { perror("chdir:"); exit(EXIT_FAILURE); } if (option_bluetooth) server_id = bluetooth_listen(); else server_id = unix_listen(); if (server_id == 0) exit(EXIT_FAILURE); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(main_loop); g_source_remove(server_id); g_slist_free_full(clients, (GDestroyNotify) g_obex_unref); g_option_context_free(context); g_main_loop_unref(main_loop); exit(EXIT_SUCCESS); } obexd-0.46/TODO0000644000000000000000000000317511755212521010132 00000000000000Background ========== - Priority scale: High, Medium and Low - Complexity scale: C1, C2, C4 and C8. The complexity scale is exponential, with complexity 1 being the lowest complexity. Complexity is a function of both task 'complexity' and task 'scope'. The general rule of thumb is that a complexity 1 task should take 1-2 weeks for a person very familiar with BlueZ codebase. Higher complexity tasks require more time and have higher uncertainty. Higher complexity tasks should be refined into several lower complexity tasks once the task is better understood. General ========== - OBEX Actions are used to perform actions not primarily defined as OBEX commands. This actions include, for example, moving, copying and setting the permissions of objects. OBEX actions would be very useful when implementing virtual filesystems over OBEX. Priority: Medium Complexity: C2 - Single Response Mode (SRM): The Single Response Mode header shall be used to enable this mode, while the SRMP header may be used to alter the normal processing of SRM for a single request/response exchange during the current operation. The use of the SRMP header is optional; however, GOEP devices that support SRM shall be able to receive and process this header. SRMP headers should be used judiciously as this will impact the overall throughput of the operation using SRM. Receipt of invalid or unexpected Single Response Mode or SRMP header values shall be ignored by the receiving device. When SRM is active the action of suspending a request can be notified using SRMP “wait” option (0x01). Priority: Low Complexity: C4 obexd-0.46/unit/0000755000000000000000000000000011755212615010477 500000000000000obexd-0.46/unit/test-gobex-packet.c0000644000000000000000000001426411755212521014114 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include "util.h" static uint8_t pkt_connect[] = { G_OBEX_OP_CONNECT, 0x00, 0x0c, 0x10, 0x00, 0x10, 0x00, G_OBEX_HDR_TARGET, 0x00, 0x05, 0xab, 0xcd }; static uint8_t pkt_put_action[] = { G_OBEX_OP_PUT, 0x00, 0x05, G_OBEX_HDR_ACTION, 0xab }; static uint8_t pkt_put_body[] = { G_OBEX_OP_PUT, 0x00, 0x0a, G_OBEX_HDR_BODY, 0x00, 0x07, 1, 2, 3, 4 }; static uint8_t pkt_put[] = { G_OBEX_OP_PUT, 0x00, 0x03 }; static uint8_t pkt_nval_len[] = { G_OBEX_OP_PUT, 0xab, 0xcd, 0x12 }; static guint8 pkt_put_long[] = { G_OBEX_OP_PUT, 0x00, 0x32, G_OBEX_HDR_CONNECTION, 0x01, 0x02, 0x03, 0x04, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_ACTION, 0xab, G_OBEX_HDR_BODY, 0x00, 0x08, 0, 1, 2, 3, 4 }; static void test_pkt(void) { GObexPacket *pkt; pkt = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID); g_assert(pkt != NULL); g_obex_packet_free(pkt); } static void test_decode_pkt(void) { GObexPacket *pkt; GError *err = NULL; pkt = g_obex_packet_decode(pkt_put, sizeof(pkt_put), 0, G_OBEX_DATA_REF, &err); g_assert_no_error(err); g_obex_packet_free(pkt); } static void test_decode_pkt_header(void) { GObexPacket *pkt; GObexHeader *header; GError *err = NULL; gboolean ret; guint8 val; pkt = g_obex_packet_decode(pkt_put_action, sizeof(pkt_put_action), 0, G_OBEX_DATA_REF, &err); g_assert_no_error(err); header = g_obex_packet_get_header(pkt, G_OBEX_HDR_ACTION); g_assert(header != NULL); ret = g_obex_header_get_uint8(header, &val); g_assert(ret == TRUE); g_assert(val == 0xab); g_obex_packet_free(pkt); } static void test_decode_connect(void) { GObexPacket *pkt; GObexHeader *header; GError *err = NULL; gboolean ret; const guint8 *buf; guint8 target[] = { 0xab, 0xcd }; gsize len; pkt = g_obex_packet_decode(pkt_connect, sizeof(pkt_connect), 4, G_OBEX_DATA_REF, &err); g_assert_no_error(err); g_assert(pkt != NULL); header = g_obex_packet_get_header(pkt, G_OBEX_HDR_TARGET); g_assert(header != NULL); ret = g_obex_header_get_bytes(header, &buf, &len); g_assert(ret == TRUE); assert_memequal(target, sizeof(target), buf, len); g_obex_packet_free(pkt); } static void test_decode_nval(void) { GObexPacket *pkt; GError *err = NULL; pkt = g_obex_packet_decode(pkt_nval_len, sizeof(pkt_nval_len), 0, G_OBEX_DATA_REF, &err); g_assert_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR); g_assert(pkt == NULL); g_error_free(err); } static void test_decode_encode(void) { GObexPacket *pkt; GError *err = NULL; uint8_t buf[255]; gssize len; pkt = g_obex_packet_decode(pkt_put_action, sizeof(pkt_put_action), 0, G_OBEX_DATA_REF, &err); g_assert_no_error(err); len = g_obex_packet_encode(pkt, buf, sizeof(buf)); if (len < 0) { g_printerr("Encoding failed: %s\n", g_strerror(-len)); g_assert_not_reached(); } assert_memequal(pkt_put_action, sizeof(pkt_put_action), buf, len); g_obex_packet_free(pkt); } static gssize get_body_data(void *buf, gsize len, gpointer user_data) { uint8_t data[] = { 1, 2, 3, 4 }; memcpy(buf, data, sizeof(data)); return sizeof(data); } static void test_encode_on_demand(void) { GObexPacket *pkt; uint8_t buf[255]; gssize len; pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(pkt, get_body_data, NULL); len = g_obex_packet_encode(pkt, buf, sizeof(buf)); if (len < 0) { g_printerr("Encoding failed: %s\n", g_strerror(-len)); g_assert_not_reached(); } assert_memequal(pkt_put_body, sizeof(pkt_put_body), buf, len); g_obex_packet_free(pkt); } static gssize get_body_data_fail(void *buf, gsize len, gpointer user_data) { return -EIO; } static void test_encode_on_demand_fail(void) { GObexPacket *pkt; uint8_t buf[255]; gssize len; pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(pkt, get_body_data_fail, NULL); len = g_obex_packet_encode(pkt, buf, sizeof(buf)); g_assert_cmpint(len, ==, -EIO); g_obex_packet_free(pkt); } static void test_create_args(void) { GObexPacket *pkt; guint8 buf[255], body[] = { 0x00, 0x01, 0x02, 0x03, 0x04 }; gssize len; pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_CONNECTION, 0x01020304, G_OBEX_HDR_TYPE, "foo/bar", strlen("foo/bar") + 1, G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_ACTION, 0xab, G_OBEX_HDR_BODY, body, sizeof(body), G_OBEX_HDR_INVALID); g_assert(pkt != NULL); len = g_obex_packet_encode(pkt, buf, sizeof(buf)); g_assert(len > 0); assert_memequal(pkt_put_long, sizeof(pkt_put_long), buf, len); g_obex_packet_free(pkt); } int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/gobex/test_pkt", test_pkt); g_test_add_func("/gobex/test_decode_pkt", test_decode_pkt); g_test_add_func("/gobex/test_decode_pkt_header", test_decode_pkt_header); g_test_add_func("/gobex/test_decode_connect", test_decode_connect); g_test_add_func("/gobex/test_decode_nval", test_decode_nval); g_test_add_func("/gobex/test_encode_pkt", test_decode_encode); g_test_add_func("/gobex/test_encode_on_demand", test_encode_on_demand); g_test_add_func("/gobex/test_encode_on_demand_fail", test_encode_on_demand_fail); g_test_add_func("/gobex/test_create_args", test_create_args); g_test_run(); return 0; } obexd-0.46/unit/util.h0000644000000000000000000000313311755212521011541 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include enum { TEST_ERROR_TIMEOUT, TEST_ERROR_UNEXPECTED, }; struct test_buf { const void *data; gssize len; }; struct test_data { guint count; GError *err; struct test_buf recv[4]; struct test_buf send[4]; guint provide_delay; GObex *obex; guint id; gsize total; GMainLoop *mainloop; }; #define TEST_ERROR test_error_quark() GQuark test_error_quark(void); void dump_bufs(const void *mem1, size_t len1, const void *mem2, size_t len2); void assert_memequal(const void *mem1, size_t len1, const void *mem2, size_t len2); GObex *create_gobex(int fd, GObexTransportType transport_type, gboolean close_on_unref); void create_endpoints(GObex **obex, GIOChannel **io, int sock_type); gboolean test_io_cb(GIOChannel *io, GIOCondition cond, gpointer user_data); gboolean test_timeout(gpointer user_data); obexd-0.46/unit/test-gobex-header.c0000644000000000000000000003250711755212521014075 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include "util.h" static uint8_t hdr_connid[] = { G_OBEX_HDR_CONNECTION, 1, 2, 3, 4 }; static uint8_t hdr_name_empty[] = { G_OBEX_HDR_NAME, 0x00, 0x03 }; static uint8_t hdr_name_ascii[] = { G_OBEX_HDR_NAME, 0x00, 0x0b, 0x00, 'f', 0x00, 'o', 0x00, 'o', 0x00, 0x00 }; static uint8_t hdr_name_umlaut[] = { G_OBEX_HDR_NAME, 0x00, 0x0b, 0x00, 0xe5, 0x00, 0xe4, 0x00, 0xf6, 0x00, 0x00 }; static uint8_t hdr_body[] = { G_OBEX_HDR_BODY, 0x00, 0x07, 1, 2, 3, 4 }; static uint8_t hdr_actionid[] = { G_OBEX_HDR_ACTION, 0xab }; static uint8_t hdr_uint32_nval[] = { G_OBEX_HDR_CONNECTION, 1, 2 }; static uint8_t hdr_unicode_nval_short[] = { G_OBEX_HDR_NAME, 0x12, 0x34, 0x00, 'a', 0x00, 'b', 0x00, 0x00 }; static uint8_t hdr_unicode_nval_data[] = { G_OBEX_HDR_NAME, 0x00, 0x01, 0x00, 'a', 0x00, 'b' }; static uint8_t hdr_bytes_nval_short[] = { G_OBEX_HDR_BODY, 0xab, 0xcd, 0x01, 0x02, 0x03 }; static uint8_t hdr_bytes_nval_data[] = { G_OBEX_HDR_BODY, 0xab }; static uint8_t hdr_bytes_nval_len[] = { G_OBEX_HDR_BODY, 0x00, 0x00 }; static void test_header_name_empty(void) { GObexHeader *header; uint8_t buf[1024]; size_t len; header = g_obex_header_new_unicode(G_OBEX_HDR_NAME, ""); g_assert(header != NULL); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_name_empty, sizeof(hdr_name_empty), buf, len); g_obex_header_free(header); } static void test_header_name_ascii(void) { GObexHeader *header; uint8_t buf[1024]; size_t len; header = g_obex_header_new_unicode(G_OBEX_HDR_NAME, "foo"); g_assert(header != NULL); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_name_ascii, sizeof(hdr_name_ascii), buf, len); g_obex_header_free(header); } static void test_header_name_umlaut(void) { GObexHeader *header; uint8_t buf[1024]; size_t len; header = g_obex_header_new_unicode(G_OBEX_HDR_NAME, "åäö"); g_assert(header != NULL); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_name_umlaut, sizeof(hdr_name_umlaut), buf, len); g_obex_header_free(header); } static void test_header_bytes(void) { GObexHeader *header; uint8_t buf[1024], data[] = { 1, 2, 3, 4 }; size_t len; header = g_obex_header_new_bytes(G_OBEX_HDR_BODY, data, sizeof(data)); g_assert(header != NULL); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_body, sizeof(hdr_body), buf, len); g_obex_header_free(header); } static void test_header_uint8(void) { GObexHeader *header; uint8_t buf[1024]; size_t len; header = g_obex_header_new_uint8(G_OBEX_HDR_ACTION, 0xab); g_assert(header != NULL); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_actionid, sizeof(hdr_actionid), buf, len); g_obex_header_free(header); } static void test_header_uint32(void) { GObexHeader *header; uint8_t buf[1024]; size_t len; header = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION, 0x01020304); len = g_obex_header_encode(header, buf, sizeof(buf)); assert_memequal(hdr_connid, sizeof(hdr_connid), buf, len); g_obex_header_free(header); } static GObexHeader *parse_and_encode(uint8_t *buf, size_t buf_len) { GObexHeader *header; uint8_t encoded[1024]; size_t len; GError *err = NULL; header = g_obex_header_decode(buf, buf_len, G_OBEX_DATA_REF, &len, &err); g_assert_no_error(err); g_assert_cmpuint(len, ==, buf_len); len = g_obex_header_encode(header, encoded, sizeof(encoded)); assert_memequal(buf, buf_len, encoded, len); return header; } static void test_header_encode_connid(void) { GObexHeader *header; gboolean ret; guint32 val; header = parse_and_encode(hdr_connid, sizeof(hdr_connid)); ret = g_obex_header_get_uint32(header, &val); g_assert(ret == TRUE); g_assert(val == 0x01020304); g_obex_header_free(header); } static void test_header_encode_name_ascii(void) { GObexHeader *header; const char *str; gboolean ret; header = parse_and_encode(hdr_name_ascii, sizeof(hdr_name_ascii)); ret = g_obex_header_get_unicode(header, &str); g_assert(ret == TRUE); g_assert_cmpstr(str, ==, "foo"); g_obex_header_free(header); } static void test_header_encode_name_umlaut(void) { GObexHeader *header; const char *str; gboolean ret; header = parse_and_encode(hdr_name_umlaut, sizeof(hdr_name_umlaut)); ret = g_obex_header_get_unicode(header, &str); g_assert(ret == TRUE); g_assert_cmpstr(str, ==, "åäö"); g_obex_header_free(header); } static void test_header_encode_name_empty(void) { GObexHeader *header; const char *str; gboolean ret; header = parse_and_encode(hdr_name_empty, sizeof(hdr_name_empty)); ret = g_obex_header_get_unicode(header, &str); g_assert(ret == TRUE); g_assert_cmpstr(str, ==, ""); g_obex_header_free(header); } static void test_header_encode_body(void) { GObexHeader *header; guint8 expected[] = { 1, 2, 3, 4}; const guint8 *buf; size_t len; gboolean ret; header = parse_and_encode(hdr_body, sizeof(hdr_body)); ret = g_obex_header_get_bytes(header, &buf, &len); g_assert(ret == TRUE); assert_memequal(expected, sizeof(expected), buf, len); g_obex_header_free(header); } static void test_header_encode_actionid(void) { GObexHeader *header; gboolean ret; guint8 val; header = parse_and_encode(hdr_actionid, sizeof(hdr_actionid)); ret = g_obex_header_get_uint8(header, &val); g_assert(ret == TRUE); g_assert_cmpuint(val, ==, 0xab); g_obex_header_free(header); } static void test_decode_header_connid(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_connid, sizeof(hdr_connid), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_connid)); g_obex_header_free(header); } static void test_decode_header_name_ascii(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_name_ascii, sizeof(hdr_name_ascii), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_name_ascii)); g_obex_header_free(header); } static void test_decode_header_name_empty(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_name_empty, sizeof(hdr_name_empty), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_name_empty)); g_obex_header_free(header); } static void test_decode_header_name_umlaut(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_name_umlaut, sizeof(hdr_name_umlaut), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_name_umlaut)); g_obex_header_free(header); } static void test_decode_header_body(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_body, sizeof(hdr_body), G_OBEX_DATA_COPY, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_body)); g_obex_header_free(header); } static void test_decode_header_body_extdata(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_body, sizeof(hdr_body), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_body)); g_obex_header_free(header); } static void test_decode_header_actionid(void) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(hdr_actionid, sizeof(hdr_actionid), G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_actionid)); g_obex_header_free(header); } static void decode_header_nval(uint8_t *buf, size_t len) { GObexHeader *header; size_t parsed; GError *err = NULL; header = g_obex_header_decode(buf, len, G_OBEX_DATA_REF, &parsed, &err); g_assert_error(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR); g_assert(header == NULL); g_error_free(err); } static void test_decode_header_uint32_nval(void) { decode_header_nval(hdr_uint32_nval, sizeof(hdr_uint32_nval)); } static void test_decode_header_unicode_nval_short(void) { decode_header_nval(hdr_unicode_nval_short, sizeof(hdr_unicode_nval_short)); } static void test_decode_header_unicode_nval_data(void) { decode_header_nval(hdr_unicode_nval_data, sizeof(hdr_unicode_nval_data)); } static void test_decode_header_bytes_nval_short(void) { decode_header_nval(hdr_bytes_nval_short, sizeof(hdr_bytes_nval_short)); } static void test_decode_header_bytes_nval_data(void) { decode_header_nval(hdr_bytes_nval_data, sizeof(hdr_bytes_nval_data)); } static void test_decode_header_bytes_nval_len(void) { decode_header_nval(hdr_bytes_nval_len, sizeof(hdr_bytes_nval_len)); } static void test_decode_header_multi(void) { GObexHeader *header; GByteArray *buf; size_t parsed; GError *err = NULL; buf = g_byte_array_sized_new(sizeof(hdr_connid) + sizeof(hdr_name_ascii) + sizeof(hdr_actionid) + sizeof(hdr_body)); g_byte_array_append(buf, hdr_connid, sizeof(hdr_connid)); g_byte_array_append(buf, hdr_name_ascii, sizeof(hdr_name_ascii)); g_byte_array_append(buf, hdr_actionid, sizeof(hdr_actionid)); g_byte_array_append(buf, hdr_body, sizeof(hdr_body)); header = g_obex_header_decode(buf->data, buf->len, G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_connid)); g_byte_array_remove_range(buf, 0, parsed); g_obex_header_free(header); header = g_obex_header_decode(buf->data, buf->len, G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_name_ascii)); g_byte_array_remove_range(buf, 0, parsed); g_obex_header_free(header); header = g_obex_header_decode(buf->data, buf->len, G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_actionid)); g_byte_array_remove_range(buf, 0, parsed); g_obex_header_free(header); header = g_obex_header_decode(buf->data, buf->len, G_OBEX_DATA_REF, &parsed, &err); g_assert_no_error(err); g_assert_cmpuint(parsed, ==, sizeof(hdr_body)); g_byte_array_remove_range(buf, 0, parsed); g_obex_header_free(header); g_byte_array_unref(buf); } int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/gobex/test_decode_header_connid", test_decode_header_connid); g_test_add_func("/gobex/test_decode_header_name_empty", test_decode_header_name_empty); g_test_add_func("/gobex/test_decode_header_name_ascii", test_decode_header_name_ascii); g_test_add_func("/gobex/test_decode_header_name_umlaut", test_decode_header_name_umlaut); g_test_add_func("/gobex/test_decode_header_body", test_decode_header_body); g_test_add_func("/gobex/test_decode_header_body_extdata", test_decode_header_body_extdata); g_test_add_func("/gobex/test_decode_header_actionid", test_decode_header_actionid); g_test_add_func("/gobex/test_decode_header_multi", test_decode_header_multi); g_test_add_func("/gobex/test_decode_header_uint32_nval", test_decode_header_uint32_nval); g_test_add_func("/gobex/test_decode_header_unicode_nval_short", test_decode_header_unicode_nval_short); g_test_add_func("/gobex/test_decode_header_unicode_nval_data", test_decode_header_unicode_nval_data); g_test_add_func("/gobex/test_decode_header_bytes_nval_short", test_decode_header_bytes_nval_short); g_test_add_func("/gobex/test_decode_header_bytes_nval_data", test_decode_header_bytes_nval_data); g_test_add_func("/gobex/test_decode_header_bytes_nval_len", test_decode_header_bytes_nval_len); g_test_add_func("/gobex/test_header_encode_connid", test_header_encode_connid); g_test_add_func("/gobex/test_header_encode_name_empty", test_header_encode_name_empty); g_test_add_func("/gobex/test_header_encode_name_ascii", test_header_encode_name_ascii); g_test_add_func("/gobex/test_header_encode_name_umlaut", test_header_encode_name_umlaut); g_test_add_func("/gobex/test_header_encode_body", test_header_encode_body); g_test_add_func("/gobex/test_header_encode_connid", test_header_encode_actionid); g_test_add_func("/gobex/test_header_name_empty", test_header_name_empty); g_test_add_func("/gobex/test_header_name_ascii", test_header_name_ascii); g_test_add_func("/gobex/test_header_name_umlaut", test_header_name_umlaut); g_test_add_func("/gobex/test_header_bytes", test_header_bytes); g_test_add_func("/gobex/test_header_uint8", test_header_uint8); g_test_add_func("/gobex/test_header_uint32", test_header_uint32); g_test_run(); return 0; } obexd-0.46/unit/test-gobex.c0000644000000000000000000007025411755212521012650 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include "util.h" #define FINAL_BIT 0x80 static GMainLoop *mainloop = NULL; static uint8_t pkt_connect_req[] = { G_OBEX_OP_CONNECT | FINAL_BIT, 0x00, 0x07, 0x10, 0x00, 0x10, 0x00 }; static uint8_t pkt_connect_rsp[] = { 0x20 | FINAL_BIT, 0x00, 0x07, 0x10, 0x00, 0x10, 0x00 }; static uint8_t pkt_setpath_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x10, 0x02, 0x00, G_OBEX_HDR_NAME, 0x00, 0x0b, 0, 'd', 0, 'i', 0, 'r', 0, 0 }; static uint8_t pkt_setpath_up_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x05, 0x03, 0x00 }; static uint8_t pkt_setpath_up_down_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x10, 0x03, 0x00, G_OBEX_HDR_NAME, 0x00, 0x0b, 0, 'd', 0, 'i', 0, 'r', 0, 0 }; static uint8_t pkt_success_rsp[] = { 0x20 | FINAL_BIT, 0x00, 0x03 }; static uint8_t pkt_mkdir_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x10, 0x00, 0x00, G_OBEX_HDR_NAME, 0x00, 0x0b, 0, 'd', 0, 'i', 0, 'r', 0, 0 }; static uint8_t pkt_delete_req[] = { G_OBEX_OP_PUT | FINAL_BIT, 0x00, 0x16, G_OBEX_HDR_NAME, 0x00, 0x13, 0, 'f', 0, 'o', 0, 'o', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 }; static uint8_t pkt_copy_req[] = { G_OBEX_OP_ACTION | FINAL_BIT, 0x00, 0x1b, G_OBEX_HDR_ACTION, 0x00, G_OBEX_HDR_NAME, 0x00, 0x0b, 0, 'f', 0, 'o', 0, 'o', 0, 0, G_OBEX_HDR_DESTNAME, 0x00, 0x0b, 0, 'b', 0, 'a', 0, 'r', 0, 0 }; static uint8_t pkt_move_req[] = { G_OBEX_OP_ACTION | FINAL_BIT, 0x00, 0x1b, G_OBEX_HDR_ACTION, 0x01, G_OBEX_HDR_NAME, 0x00, 0x0b, 0, 'f', 0, 'o', 0, 'o', 0, 0, G_OBEX_HDR_DESTNAME, 0x00, 0x0b, 0, 'b', 0, 'a', 0, 'r', 0, 0 }; static uint8_t pkt_nval_connect_rsp[] = { 0x10 | FINAL_BIT, 0x00, 0x05, 0x10, 0x00, }; static uint8_t pkt_abort_rsp[] = { 0x90, 0x00, 0x03 }; static uint8_t pkt_nval_short_rsp[] = { 0x10 | FINAL_BIT, 0x12 }; static uint8_t pkt_put_body[] = { G_OBEX_OP_PUT, 0x00, 0x0a, G_OBEX_HDR_BODY, 0x00, 0x07, 1, 2, 3, 4 }; static gboolean timeout(gpointer user_data) { GError **err = user_data; if (!g_main_loop_is_running(mainloop)) return FALSE; g_set_error(err, TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out"); g_main_loop_quit(mainloop); return FALSE; } static void connect_rsp(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { guint8 rsp_code; gboolean final; GError **test_err = user_data; if (err != NULL) { g_assert(*test_err == NULL); *test_err = g_error_copy(err); goto done; } rsp_code = g_obex_packet_get_operation(rsp, &final); if (rsp_code != 0x20) { g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected response 0x%02x", rsp_code); goto done; } if (!final) { g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Connect response didn't have final bit"); goto done; } done: g_main_loop_quit(mainloop); } static void nval_connect_rsp(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { GError **test_err = user_data; if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR)) g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Did not get expected parse error"); g_main_loop_quit(mainloop); } static void timeout_rsp(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { GError **test_err = user_data; if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_TIMEOUT)) g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Did not get expected timeout error"); g_main_loop_quit(mainloop); } static gboolean recv_and_send(GIOChannel *io, void *data, gsize len, GError **err) { gsize bytes_written, rbytes; char buf[255]; GIOStatus status; status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) { g_set_error(err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "read failed with status %d", status); return FALSE; } if (data == NULL) return TRUE; g_io_channel_write_chars(io, data, len, &bytes_written, NULL); if (bytes_written != len) { g_set_error(err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unable to write to socket"); return FALSE; } return TRUE; } static gboolean send_connect_rsp(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError **err = user_data; if (!recv_and_send(io, pkt_connect_rsp, sizeof(pkt_connect_rsp), err)) g_main_loop_quit(mainloop); return FALSE; } static gboolean send_nval_connect_rsp(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError **err = user_data; if (!recv_and_send(io, pkt_nval_connect_rsp, sizeof(pkt_nval_connect_rsp), err)) g_main_loop_quit(mainloop); return FALSE; } static gboolean send_nval_short_rsp(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError **err = user_data; if (!recv_and_send(io, pkt_nval_short_rsp, sizeof(pkt_nval_short_rsp), err)) g_main_loop_quit(mainloop); return FALSE; } static gboolean send_nothing(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError **err = user_data; if (!recv_and_send(io, NULL, 0, err)) g_main_loop_quit(mainloop); return FALSE; } static void send_req(GObexPacket *req, GObexResponseFunc rsp_func, GIOFunc send_rsp_func, gint req_timeout, int transport_type) { GError *gerr = NULL; GIOChannel *io; GIOCondition cond; guint io_id, timer_id, test_time; GObex *obex; create_endpoints(&obex, &io, transport_type); g_obex_send_req(obex, req, req_timeout, rsp_func, &gerr, &gerr); g_assert_no_error(gerr); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, send_rsp_func, &gerr); mainloop = g_main_loop_new(NULL, FALSE); if (req_timeout > 0) test_time = req_timeout + 1; else test_time = 1; timer_id = g_timeout_add_seconds(test_time, timeout, &gerr); g_main_loop_run(mainloop); g_main_loop_unref(mainloop); mainloop = NULL; g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(gerr); } static void send_connect(GObexResponseFunc rsp_func, GIOFunc send_rsp_func, gint req_timeout, int transport_type) { GObexPacket *req; guint8 connect_data[] = { 0x10, 0x00, 0x10, 0x00 }; req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID); g_assert(req != NULL); g_obex_packet_set_data(req, connect_data, sizeof(connect_data), G_OBEX_DATA_REF); send_req(req, rsp_func, send_rsp_func, req_timeout, transport_type); } static void test_send_connect_req_stream(void) { send_connect(connect_rsp, send_connect_rsp, -1, SOCK_STREAM); } static void test_send_connect_req_pkt(void) { send_connect(connect_rsp, send_connect_rsp, -1, SOCK_SEQPACKET); } static void test_send_nval_connect_req_stream(void) { send_connect(nval_connect_rsp, send_nval_connect_rsp, -1, SOCK_STREAM); } static void test_send_nval_connect_req_pkt(void) { send_connect(nval_connect_rsp, send_nval_connect_rsp, -1, SOCK_SEQPACKET); } static void test_send_nval_connect_req_short_pkt(void) { send_connect(nval_connect_rsp, send_nval_short_rsp, -1, SOCK_SEQPACKET); } static void test_send_connect_req_timeout_stream(void) { send_connect(timeout_rsp, send_nothing, 0, SOCK_STREAM); } static void test_send_connect_req_timeout_pkt(void) { send_connect(timeout_rsp, send_nothing, 0, SOCK_SEQPACKET); } struct req_info { GObex *obex; guint id; GError *err; }; static void req_done(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct req_info *r = user_data; if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED)) g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Did not get expected cancelled error"); g_main_loop_quit(mainloop); } static void test_cancel_req_immediate(void) { GObexPacket *req; struct req_info r; gboolean ret; create_endpoints(&r.obex, NULL, SOCK_STREAM); r.err = NULL; req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID); r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err); g_assert_no_error(r.err); g_assert(r.id != 0); ret = g_obex_cancel_req(r.obex, r.id, FALSE); g_assert(ret == TRUE); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_assert_no_error(r.err); g_obex_unref(r.obex); g_main_loop_unref(mainloop); } static gboolean cancel_server(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct req_info *r = user_data; GIOStatus status; gsize bytes_written, rbytes; char buf[255]; status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Reading data failed with status %d", status); goto failed; } if (rbytes < 3) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Not enough data from socket"); goto failed; } if ((uint8_t) buf[0] == (G_OBEX_OP_PUT | FINAL_BIT)) { if (!g_obex_cancel_req(r->obex, r->id, FALSE)) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Cancelling request failed"); goto failed; } return TRUE; } if ((uint8_t) buf[0] != (G_OBEX_OP_ABORT | FINAL_BIT)) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Neither Put nor Abort packet received"); goto failed; } g_io_channel_write_chars(io, (gchar *) pkt_abort_rsp, sizeof(pkt_abort_rsp), &bytes_written, NULL); if (bytes_written != sizeof(pkt_abort_rsp)) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unable to write to socket"); goto failed; } return TRUE; failed: g_main_loop_quit(mainloop); return FALSE; } static void test_cancel_req_delay(int transport_type) { GIOChannel *io; guint io_id, timer_id; struct req_info r; GObexPacket *req; GIOCondition cond; create_endpoints(&r.obex, &io, transport_type); r.err = NULL; req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID); r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err); g_assert_no_error(r.err); g_assert(r.id != 0); mainloop = g_main_loop_new(NULL, FALSE); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, cancel_server, &r); timer_id = g_timeout_add_seconds(2, timeout, &r.err); g_main_loop_run(mainloop); g_assert_no_error(r.err); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(r.obex); g_main_loop_unref(mainloop); } static void test_cancel_req_delay_stream(void) { test_cancel_req_delay(SOCK_STREAM); } static void test_cancel_req_delay_pkt(void) { test_cancel_req_delay(SOCK_SEQPACKET); } struct rcv_buf_info { GError *err; const guint8 *buf; gsize len; }; static gboolean rcv_data(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct rcv_buf_info *r = user_data; GIOStatus status; gsize rbytes; char buf[255]; if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected condition %d on socket", cond); goto done; } status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Reading data failed with status %d", status); goto done; } if (rbytes != r->len) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Got %zu bytes instead of %zu", rbytes, sizeof(pkt_connect_req)); dump_bufs(r->buf, r->len, buf, rbytes); goto done; } if (memcmp(buf, r->buf, rbytes) != 0) { g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Mismatch with received data"); dump_bufs(r->buf, r->len, buf, rbytes); goto done; } done: g_main_loop_quit(mainloop); return FALSE; } static void test_send_connect(int transport_type) { guint8 connect_data[] = { 0x10, 0x00, 0x10, 0x00 }; struct rcv_buf_info r; GIOChannel *io; GIOCondition cond; GObexPacket *req; guint io_id, timer_id; GObex *obex; create_endpoints(&obex, &io, transport_type); memset(&r, 0, sizeof(r)); r.buf = pkt_connect_req; r.len = sizeof(pkt_connect_req); req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID); g_assert(req != NULL); g_obex_packet_set_data(req, connect_data, sizeof(connect_data), G_OBEX_DATA_REF); g_obex_send(obex, req, &r.err); g_assert_no_error(r.err); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, rcv_data, &r); mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, timeout, &r.err); g_main_loop_run(mainloop); g_main_loop_unref(mainloop); mainloop = NULL; g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(r.err); } static void test_send_connect_stream(void) { test_send_connect(SOCK_STREAM); } static void test_send_connect_pkt(void) { test_send_connect(SOCK_SEQPACKET); } static void unexpected_disconn(GObex *obex, GError *err, gpointer user_data) { GError **test_err = user_data; if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_PARSE_ERROR)) g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Didn't get parse error as expected"); g_main_loop_quit(mainloop); } static void test_recv_unexpected(void) { GError *err = NULL; GObexPacket *req; GIOChannel *io; guint timer_id; GObex *obex; guint8 buf[255]; gssize len; create_endpoints(&obex, &io, SOCK_STREAM); g_obex_set_disconnect_function(obex, unexpected_disconn, &err); req = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID); len = g_obex_packet_encode(req, buf, sizeof(buf)); g_obex_packet_free(req); g_assert_cmpint(len, >=, 0); g_io_channel_write_chars(io, (gchar *) buf, len, NULL, &err); g_assert_no_error(err); mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, timeout, &err); g_main_loop_run(mainloop); g_main_loop_unref(mainloop); mainloop = NULL; g_source_remove(timer_id); g_io_channel_unref(io); g_obex_unref(obex); g_assert_no_error(err); } static gssize get_body_data(void *buf, gsize len, gpointer user_data) { uint8_t data[] = { 1, 2, 3, 4 }; memcpy(buf, data, sizeof(data)); return sizeof(data); } static gssize get_body_data_fail(void *buf, gsize len, gpointer user_data) { g_main_loop_quit(mainloop); return -1; } static void test_send_on_demand(int transport_type, GObexDataProducer func) { struct rcv_buf_info r; GIOChannel *io; GIOCondition cond; GObexPacket *req; guint io_id, timer_id; GObex *obex; create_endpoints(&obex, &io, transport_type); memset(&r, 0, sizeof(r)); r.buf = pkt_put_body; r.len = sizeof(pkt_put_body); req = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID); g_obex_packet_add_body(req, func, &r); g_obex_send(obex, req, &r.err); g_assert_no_error(r.err); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, rcv_data, &r); mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, timeout, &r.err); g_main_loop_run(mainloop); g_main_loop_unref(mainloop); mainloop = NULL; g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(r.err); } static void test_send_on_demand_stream(void) { test_send_on_demand(SOCK_STREAM, get_body_data); } static void test_send_on_demand_pkt(void) { test_send_on_demand(SOCK_SEQPACKET, get_body_data); } static void test_send_on_demand_fail_stream(void) { test_send_on_demand(SOCK_STREAM, get_body_data_fail); } static void test_send_on_demand_fail_pkt(void) { test_send_on_demand(SOCK_SEQPACKET, get_body_data_fail); } static void handle_connect_req(GObex *obex, GObexPacket *req, gpointer user_data) { GError **test_err = user_data; if (g_obex_packet_get_operation(req, NULL) != G_OBEX_OP_CONNECT) g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected operation"); g_main_loop_quit(mainloop); } static void handle_connect_err(GObex *obex, GError *err, gpointer user_data) { GError **test_err = user_data; g_main_loop_quit(mainloop); if (err != NULL) *test_err = g_error_copy(err); else *test_err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Disconnected"); } static void recv_connect(int transport_type) { GError *gerr = NULL; guint timer_id; GObex *obex; GIOChannel *io; GIOStatus status; gsize bytes_written; create_endpoints(&obex, &io, transport_type); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_connect_req, &gerr); g_obex_set_disconnect_function(obex, handle_connect_err, &gerr); status = g_io_channel_write_chars(io, (gchar *) pkt_connect_req, sizeof(pkt_connect_req), &bytes_written, NULL); g_assert_cmpint(status, ==, G_IO_STATUS_NORMAL); g_assert_cmpuint(bytes_written, ==, sizeof(pkt_connect_req)); mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, timeout, &gerr); g_main_loop_run(mainloop); g_source_remove(timer_id); g_obex_unref(obex); g_io_channel_unref(io); g_main_loop_unref(mainloop); mainloop = NULL; g_assert_no_error(gerr); } static void test_recv_connect_stream(void) { recv_connect(SOCK_STREAM); } static void test_recv_connect_pkt(void) { recv_connect(SOCK_SEQPACKET); } static void disconn_ev(GObex *obex, GError *err, gpointer user_data) { GError **test_err = user_data; if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_DISCONNECTED)) g_set_error(test_err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Did not get expected disconnect error"); g_main_loop_quit(mainloop); } static void test_disconnect(void) { GError *gerr = NULL; guint timer_id; GObex *obex; GIOChannel *io; create_endpoints(&obex, &io, SOCK_STREAM); g_obex_set_disconnect_function(obex, disconn_ev, &gerr); timer_id = g_timeout_add_seconds(1, timeout, &gerr); mainloop = g_main_loop_new(NULL, FALSE); g_io_channel_shutdown(io, FALSE, NULL); g_main_loop_run(mainloop); g_assert_no_error(gerr); g_source_remove(timer_id); g_io_channel_unref(io); g_obex_unref(obex); g_main_loop_unref(mainloop); mainloop = NULL; } static void test_ref_unref(void) { GObex *obex; obex = create_gobex(STDIN_FILENO, G_OBEX_TRANSPORT_STREAM, FALSE); g_assert(obex != NULL); obex = g_obex_ref(obex); g_obex_unref(obex); g_obex_unref(obex); } static void test_basic(void) { GObex *obex; obex = create_gobex(STDIN_FILENO, G_OBEX_TRANSPORT_STREAM, FALSE); g_assert(obex != NULL); g_obex_unref(obex); } static void test_null_io(void) { GObex *obex; obex = g_obex_new(NULL, 0, -1, -1); g_assert(obex == NULL); } static void req_complete(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } static void test_connect(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_connect_req, sizeof(pkt_connect_req) } }, { { pkt_connect_rsp, sizeof(pkt_connect_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, req_complete, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_setpath(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_setpath_req, sizeof(pkt_setpath_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_setpath(obex, "dir", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_setpath_up(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_setpath_up_req, sizeof(pkt_setpath_up_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_setpath(obex, "..", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_setpath_up_down(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_setpath_up_down_req, sizeof(pkt_setpath_up_down_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_setpath(obex, "../dir", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_mkdir(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_mkdir_req, sizeof(pkt_mkdir_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_mkdir(obex, "dir", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_delete(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_delete_req, sizeof(pkt_delete_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_delete(obex, "foo.txt", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_copy(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_copy_req, sizeof(pkt_copy_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_copy(obex, "foo", "bar", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_move(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { pkt_move_req, sizeof(pkt_move_req) } }, { { pkt_success_rsp, sizeof(pkt_success_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_move(obex, "foo", "bar", req_complete, &d, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/gobex/null_io", test_null_io); g_test_add_func("/gobex/basic", test_basic); g_test_add_func("/gobex/ref_unref", test_ref_unref); g_test_add_func("/gobex/test_disconnect", test_disconnect); g_test_add_func("/gobex/test_recv_connect_stream", test_recv_connect_stream); g_test_add_func("/gobex/test_recv_connect_pkt", test_recv_connect_pkt); g_test_add_func("/gobex/test_send_connect_stream", test_send_connect_stream); g_test_add_func("/gobex/test_send_connect_pkt", test_send_connect_pkt); g_test_add_func("/gobex/test_recv_unexpected", test_recv_unexpected); g_test_add_func("/gobex/test_send_on_demand_stream", test_send_on_demand_stream); g_test_add_func("/gobex/test_send_on_demand_pkt", test_send_on_demand_pkt); g_test_add_func("/gobex/test_send_on_demand_fail_stream", test_send_on_demand_fail_stream); g_test_add_func("/gobex/test_send_on_demand_fail_pkt", test_send_on_demand_fail_pkt); g_test_add_func("/gobex/test_send_connect_req_stream", test_send_connect_req_stream); g_test_add_func("/gobex/test_send_connect_req_pkt", test_send_connect_req_pkt); g_test_add_func("/gobex/test_send_nval_connect_req_stream", test_send_nval_connect_req_stream); g_test_add_func("/gobex/test_send_nval_connect_req_pkt", test_send_nval_connect_req_pkt); g_test_add_func("/gobex/test_send_nval_connect_req_short_pkt", test_send_nval_connect_req_short_pkt); g_test_add_func("/gobex/test_send_connect_req_timeout_stream", test_send_connect_req_timeout_stream); g_test_add_func("/gobex/test_send_connect_req_timeout_pkt", test_send_connect_req_timeout_pkt); g_test_add_func("/gobex/test_cancel_req_immediate", test_cancel_req_immediate); g_test_add_func("/gobex/test_cancel_req_delay_stream", test_cancel_req_delay_stream); g_test_add_func("/gobex/test_cancel_req_delay_pkt", test_cancel_req_delay_pkt); g_test_add_func("/gobex/test_connect", test_connect); g_test_add_func("/gobex/test_setpath", test_setpath); g_test_add_func("/gobex/test_setpath_up", test_setpath_up); g_test_add_func("/gobex/test_setpath_up_down", test_setpath_up_down); g_test_add_func("/gobex/test_mkdir", test_mkdir); g_test_add_func("/gobex/test_delete", test_delete); g_test_add_func("/gobex/test_copy", test_copy); g_test_add_func("/gobex/test_move", test_move); g_test_run(); return 0; } obexd-0.46/unit/test-gobex-transfer.c0000644000000000000000000016233611755212521014475 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include #include #include "util.h" #define FINAL_BIT 0x80 #define RANDOM_PACKETS 4 static guint8 put_req_first[] = { G_OBEX_OP_PUT, 0x00, 0x30, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 put_req_first_srm[] = { G_OBEX_OP_PUT, 0x00, 0x32, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_SRM, G_OBEX_SRM_ENABLE, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 put_req_zero[255] = { G_OBEX_OP_PUT, 0x00, 0xff, G_OBEX_HDR_BODY, 0x00, 0xfc }; static guint8 put_req_last[] = { G_OBEX_OP_PUT | FINAL_BIT, 0x00, 0x06, G_OBEX_HDR_BODY_END, 0x00, 0x03 }; static guint8 abort_req[] = { G_OBEX_OP_ABORT | FINAL_BIT, 0x00, 0x03 }; static guint8 put_rsp_first[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x03 }; static guint8 put_rsp_first_srm[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x05, G_OBEX_HDR_SRM, 0x01 }; static guint8 put_rsp_first_srm_wait[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x07, G_OBEX_HDR_SRM, 0x01, G_OBEX_HDR_SRMP, 0x01 }; static guint8 put_rsp_last[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x03 }; static guint8 get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x23, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 }; static guint8 get_req_first_app[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x2a, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_APPARAM, 0x00, 0x07, 0, 1, 2, 3 }; static guint8 get_req_first_srm[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x25, G_OBEX_HDR_SRM, 0x01, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 }; static guint8 get_req_first_srm_wait[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x27, G_OBEX_HDR_SRM, 0x01, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_SRMP, 0x01 }; static guint8 get_req_last[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x03, }; static guint8 get_rsp_first_app[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x0A, G_OBEX_HDR_APPARAM, 0x00, 0x07, 0, 1, 2, 3 }; static guint8 get_rsp_first[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x10, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 get_rsp_first_srm[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x12, G_OBEX_HDR_SRM, 0x01, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 get_rsp_first_srm_wait_next[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x14, G_OBEX_HDR_SRM, 0x01, G_OBEX_HDR_SRMP, 0x02, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 get_rsp_zero[255] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0xff, G_OBEX_HDR_BODY, 0x00, 0xfc }; static guint8 get_rsp_zero_wait_next[255] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0xff, G_OBEX_HDR_SRMP, 0x02, G_OBEX_HDR_BODY, 0x00, 0xfa }; static guint8 get_rsp_last[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x06, G_OBEX_HDR_BODY_END, 0x00, 0x03 }; static guint8 conn_req[] = { G_OBEX_OP_CONNECT | FINAL_BIT, 0x00, 0x07, 0x10, 0x00, 0x10, 0x00 }; static guint8 conn_rsp[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c, 0x10, 0x00, 0x10, 0x00, G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01 }; static guint8 conn_req_srm[] = { G_OBEX_OP_CONNECT | FINAL_BIT, 0x00, 0x09, 0x10, 0x00, 0x10, 0x00, G_OBEX_HDR_SRM, 0x02 }; static guint8 conn_rsp_srm[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0e, 0x10, 0x00, 0x10, 0x00, G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01, G_OBEX_HDR_SRM, 0x01 }; static guint8 unavailable_rsp[] = { G_OBEX_RSP_SERVICE_UNAVAILABLE | FINAL_BIT, 0x00, 0x03 }; static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28, G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 }; static guint8 conn_get_req_wrg[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28, G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0xFF, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 }; static guint8 conn_put_req_first[] = { G_OBEX_OP_PUT, 0x00, 0x35, G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01, G_OBEX_HDR_TYPE, 0x00, 0x0b, 'f', 'o', 'o', '/', 'b', 'a', 'r', '\0', G_OBEX_HDR_NAME, 0x00, 0x15, 0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0, G_OBEX_HDR_BODY, 0x00, 0x0d, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static guint8 hdr_type[] = "foo/bar"; static guint8 hdr_app[] = { 0, 1, 2, 3 }; static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; static void transfer_complete(GObex *obex, GError *err, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } static gboolean resume_obex(gpointer user_data) { g_obex_resume(user_data); return FALSE; } static gssize provide_seq(void *buf, gsize len, gpointer user_data) { struct test_data *d = user_data; int fd; gssize ret; if (d->count == RANDOM_PACKETS - 1) return 0; fd = open("/dev/urandom", O_RDONLY | O_NOCTTY, 0); if (fd < 0) { g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "open(/dev/urandom): %s", strerror(errno)); g_main_loop_quit(d->mainloop); return -1; } ret = read(fd, buf, len); close(fd); return ret; } static gssize provide_eagain(void *buf, gsize len, gpointer user_data) { struct test_data *d = user_data; if (d->count > 0) return 0; if (len < sizeof(body_data)) { g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Got data request for only %zu bytes", len); g_main_loop_quit(d->mainloop); return -1; } if (d->provide_delay > 0) { g_timeout_add(d->provide_delay, resume_obex, d->obex); d->provide_delay = 0; return -EAGAIN; } memcpy(buf, body_data, sizeof(body_data)); return sizeof(body_data); } static gssize provide_data(void *buf, gsize len, gpointer user_data) { struct test_data *d = user_data; if (d->total > 0) return 0; if (len < sizeof(body_data)) { g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Got data request for only %zu bytes", len); g_main_loop_quit(d->mainloop); return -1; } memcpy(buf, body_data, sizeof(body_data)); if (d->provide_delay > 0) { g_obex_suspend(d->obex); g_timeout_add(d->provide_delay, resume_obex, d->obex); } d->total += sizeof(body_data); return sizeof(body_data); } static void test_put_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static gboolean rcv_data(const void *buf, gsize len, gpointer user_data) { struct test_data *d = user_data; if (len != sizeof(body_data)) d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected byte count %zu", len); if (memcmp(buf, body_data, sizeof(body_data)) != 0) { dump_bufs(body_data, sizeof(body_data), buf, len); d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected byte count %zu", len); } return TRUE; } static void handle_put(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_PUT) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_put_rsp(obex, req, rcv_data, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_put_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_last, sizeof(put_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, &d); g_io_channel_write_chars(io, (char *) put_req_first, sizeof(put_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static gboolean rcv_seq(const void *buf, gsize len, gpointer user_data) { return TRUE; } static void handle_put_seq(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_PUT) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_put_rsp(obex, req, rcv_seq, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_stream_put_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_zero, sizeof(put_req_zero) }, { put_req_zero, sizeof(put_req_zero) }, { put_req_last, sizeof(put_req_last) }, { NULL, -1 } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); g_io_channel_write_chars(io, (char *) put_req_first, sizeof(put_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS - 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static gboolean cancel_transfer(gpointer user_data) { struct test_data *d = user_data; if (d->id > 0) g_obex_cancel_transfer(d->id, transfer_complete, user_data); return FALSE; } static gssize abort_data(void *buf, gsize len, gpointer user_data) { g_idle_add_full(G_PRIORITY_HIGH, cancel_transfer, user_data, NULL); return provide_data(buf, len, user_data); } static void test_stream_put_req_abort(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, { abort_req, sizeof(abort_req) } }, { { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); d.id = g_obex_put_req(obex, abort_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED); } static void test_stream_put_rsp_abort(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_zero, sizeof(put_req_zero) }, { abort_req, sizeof(abort_req) }, { NULL, -1 }, { NULL, -1 } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); g_io_channel_write_chars(io, (char *) put_req_first, sizeof(put_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS - 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED); } static void handle_put_seq_wait(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_PUT) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_put_rsp(obex, req, rcv_seq, transfer_complete, d, &d->err, G_OBEX_HDR_SRMP, G_OBEX_SRMP_WAIT, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_packet_put_rsp_wait(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first_srm_wait, sizeof(put_rsp_first_srm_wait) }, { put_rsp_first, sizeof(put_rsp_first) }, { NULL, -1 }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_zero, sizeof(put_req_zero) }, { put_req_zero, sizeof(put_req_zero) }, { put_req_last, sizeof(put_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq_wait, &d); g_io_channel_write_chars(io, (char *) put_req_first_srm, sizeof(put_req_first_srm), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_put_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first_srm, sizeof(put_rsp_first_srm) }, { NULL, -1 }, { NULL, -1 }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_zero, sizeof(put_req_zero) }, { put_req_zero, sizeof(put_req_zero) }, { put_req_last, sizeof(put_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); g_io_channel_write_chars(io, (char *) put_req_first_srm, sizeof(put_req_first_srm), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_stream_get_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, { NULL, 0 }, { NULL, 0 }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_get_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm, sizeof(get_req_first_srm) }, { NULL, -1 }, { NULL, -1 }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first_srm, sizeof(get_rsp_first_srm) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_get_req_wait(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm_wait, sizeof(get_req_first_srm_wait) }, { get_req_last, sizeof(get_req_last) }, { NULL, -1 }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first_srm, sizeof(get_rsp_first_srm) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_zero, sizeof(get_rsp_zero) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_SRMP, G_OBEX_SRMP_WAIT, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_get_req_wait_next(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm, sizeof(get_req_first_srm) }, { get_req_last, sizeof(get_req_last) }, { get_req_last, sizeof(get_req_last) }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first_srm_wait_next, sizeof(get_rsp_first_srm_wait_next) }, { get_rsp_zero_wait_next, sizeof(get_rsp_zero_wait_next) }, { get_rsp_zero_wait_next, sizeof(get_rsp_zero_wait_next) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_req_app(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_app, sizeof(get_req_first_app) }, { get_req_last, sizeof(get_req_last) }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first_app, sizeof(get_rsp_first_app) }, { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_APPARAM, hdr_app, sizeof(hdr_app), G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 3); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void handle_get_eagain(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_GET) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_get_rsp(obex, provide_eagain, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void handle_get(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_GET) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_get_rsp(obex, provide_data, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_stream_put_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "random.bin", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_put_req_wait(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first_srm_wait, sizeof(put_rsp_first_srm_wait) }, { put_rsp_first, sizeof(put_rsp_first) }, { NULL, 0 }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "random.bin", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_put_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first_srm, sizeof(put_rsp_first_srm) }, { NULL, 0 }, { NULL, 0 }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "random.bin", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_put_req_eagain(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_eagain, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_last, sizeof(get_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d); g_io_channel_write_chars(io, (char *) get_req_first, sizeof(get_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void handle_get_seq(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_GET) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_get_rsp(obex, provide_seq, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_stream_get_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_last, sizeof(get_req_last) }, { get_req_last, sizeof(get_req_last) }, { get_req_last, sizeof(get_req_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d); g_io_channel_write_chars(io, (char *) get_req_first, sizeof(get_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS - 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_packet_get_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { get_rsp_last, sizeof(get_rsp_last) } }, { { NULL, 0 }, { NULL, 0 }, { get_req_last, sizeof(get_req_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d); g_io_channel_write_chars(io, (char *) get_req_first_srm, sizeof(get_req_first_srm), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS - 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void handle_get_seq_srm_wait(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_GET) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_get_rsp(obex, provide_seq, transfer_complete, d, &d->err, G_OBEX_HDR_SRMP, G_OBEX_SRMP_WAIT, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_packet_get_rsp_wait(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_last, sizeof(get_req_last) }, { NULL, 0 }, { get_req_last, sizeof(get_req_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq_srm_wait, &d); g_io_channel_write_chars(io, (char *) get_req_first_srm, sizeof(get_req_first_srm), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS - 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void handle_get_app(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); GObexPacket *rsp; if (op != G_OBEX_OP_GET) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } g_obex_add_request_function(d->obex, G_OBEX_OP_GET, handle_get, d); rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_APPARAM, hdr_app, sizeof(hdr_app), G_OBEX_HDR_INVALID); if (g_obex_send(d->obex, rsp, NULL) == FALSE) g_main_loop_quit(d->mainloop); } static void test_get_rsp_app(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first_app, sizeof(get_rsp_first_app) }, { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_first, sizeof(get_req_first) }, { get_req_last, sizeof(get_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_app, &d); g_io_channel_write_chars(io, (char *) get_req_first_app, sizeof(get_req_first_app), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_put_req_delay(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, { put_req_last, sizeof(put_req_last) } }, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_rsp_delay(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_last, sizeof(get_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d); g_io_channel_write_chars(io, (char *) get_req_first, sizeof(get_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static gboolean rcv_data_delay(const void *buf, gsize len, gpointer user_data) { struct test_data *d = user_data; if (len != sizeof(body_data)) d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected byte count %zu", len); if (memcmp(buf, body_data, sizeof(body_data)) != 0) { dump_bufs(body_data, sizeof(body_data), buf, len); d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected byte count %zu", len); } if (d->provide_delay > 0) { g_obex_suspend(d->obex); g_timeout_add(d->provide_delay, resume_obex, d->obex); } return TRUE; } static void handle_put_delay(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); guint id; if (op != G_OBEX_OP_PUT) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } id = g_obex_put_rsp(obex, req, rcv_data_delay, transfer_complete, d, &d->err, G_OBEX_HDR_INVALID); if (id == 0) g_main_loop_quit(d->mainloop); } static void test_put_rsp_delay(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } }, { { put_req_last, sizeof(put_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_delay, &d); g_io_channel_write_chars(io, (char *) put_req_first, sizeof(put_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_req_delay(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, { get_req_last, sizeof(get_req_last) } }, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data_delay, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_get_rsp_eagain(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } }, { { get_req_last, sizeof(get_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_eagain, &d); g_io_channel_write_chars(io, (char *) get_req_first, sizeof(get_req_first), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void conn_complete(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } static void test_conn_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) } }, { { conn_rsp, sizeof(conn_rsp) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void handle_conn_rsp(GObex *obex, GObexPacket *req, gpointer user_data) { struct test_data *d = user_data; guint8 op = g_obex_packet_get_operation(req, NULL); GObexPacket *rsp; if (op != G_OBEX_OP_CONNECT) { d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unexpected opcode 0x%02x", op); g_main_loop_quit(d->mainloop); return; } rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_CONNECTION, 1, G_OBEX_HDR_INVALID); g_obex_send(obex, rsp, &d->err); } static void test_conn_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) } }, { { NULL, -1 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 1); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void conn_complete_get_req(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) { d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } g_obex_get_req(obex, rcv_data, transfer_complete, d, &d->err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); } static void test_conn_get_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) }, { conn_get_req_first, sizeof(conn_get_req_first) }, { get_req_last, sizeof(get_req_last) }}, { { conn_rsp, sizeof(conn_rsp) } , { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_get_req, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 3); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_conn_get_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, { get_rsp_first, sizeof(get_rsp_first) }, { get_rsp_last, sizeof(get_rsp_last) } }, { { conn_get_req_first, sizeof(conn_get_req_first) }, { get_req_last, sizeof(get_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d); g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void conn_complete_put_req(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) { d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } g_obex_put_req(obex, provide_data, transfer_complete, d, &d->err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "file.txt", G_OBEX_HDR_INVALID); } static void test_conn_put_req(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) }, { conn_put_req_first, sizeof(conn_put_req_first) }, { put_req_last, sizeof(put_req_last) }}, { { conn_rsp, sizeof(conn_rsp) } , { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 3); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_conn_put_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } }, { { conn_put_req_first, sizeof(conn_put_req_first) }, { put_req_last, sizeof(put_req_last) }, { NULL, 0 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, &d); g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void test_conn_get_wrg_rsp(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, { unavailable_rsp, sizeof(unavailable_rsp) } }, { { conn_get_req_wrg, sizeof(conn_get_req_wrg) }, { NULL, -1 } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req), NULL, &d.err); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, 2); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void conn_complete_put_req_seq(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) { d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } g_obex_put_req(obex, provide_seq, transfer_complete, d, &d->err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "random.bin", G_OBEX_HDR_INVALID); } static void test_conn_put_req_seq(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) } , { NULL, 0 }, { NULL, 0 }, { put_req_last, sizeof(put_req_last) } }, { { conn_rsp, sizeof(conn_rsp) } , { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_first, sizeof(put_rsp_first) }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_STREAM); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req_seq, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } static void conn_complete_put_req_seq_srm(GObex *obex, GError *err, GObexPacket *rsp, gpointer user_data) { struct test_data *d = user_data; if (err != NULL) { d->err = g_error_copy(err); g_main_loop_quit(d->mainloop); } g_obex_put_req(obex, provide_seq, transfer_complete, d, &d->err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), G_OBEX_HDR_NAME, "random.bin", G_OBEX_HDR_INVALID); } static void test_conn_put_req_seq_srm(void) { GIOChannel *io; GIOCondition cond; guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req_srm, sizeof(conn_req_srm) } , { NULL, 0 }, { NULL, 0 }, { put_req_last, sizeof(put_req_last) } }, { { conn_rsp_srm, sizeof(conn_rsp_srm) } , { NULL, 0 }, { NULL, 0 }, { put_rsp_last, sizeof(put_rsp_last) } } }; create_endpoints(&obex, &io, SOCK_SEQPACKET); d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req_seq_srm, &d, &d.err, G_OBEX_HDR_SRM, G_OBEX_SRM_INDICATE, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); g_main_loop_run(d.mainloop); g_assert_cmpuint(d.count, ==, RANDOM_PACKETS); g_main_loop_unref(d.mainloop); g_source_remove(timer_id); g_io_channel_unref(io); g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); } int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/gobex/test_conn_req", test_conn_req); g_test_add_func("/gobex/test_conn_rsp", test_conn_rsp); g_test_add_func("/gobex/test_put_req", test_put_req); g_test_add_func("/gobex/test_put_rsp", test_put_rsp); g_test_add_func("/gobex/test_get_req", test_get_req); g_test_add_func("/gobex/test_get_rsp", test_get_rsp); g_test_add_func("/gobex/test_get_req_app", test_get_req_app); g_test_add_func("/gobex/test_get_rsp_app", test_get_rsp_app); g_test_add_func("/gobex/test_put_req_delay", test_put_req_delay); g_test_add_func("/gobex/test_put_rsp_delay", test_put_rsp_delay); g_test_add_func("/gobex/test_get_req_delay", test_get_req_delay); g_test_add_func("/gobex/test_get_rsp_delay", test_get_rsp_delay); g_test_add_func("/gobex/test_put_req_eagain", test_put_req_eagain); g_test_add_func("/gobex/test_get_req_eagain", test_get_rsp_eagain); g_test_add_func("/gobex/test_stream_put_req", test_stream_put_req); g_test_add_func("/gobex/test_stream_put_rsp", test_stream_put_rsp); g_test_add_func("/gobex/test_stream_put_req_abort", test_stream_put_req_abort); g_test_add_func("/gobex/test_stream_put_rsp_abort", test_stream_put_rsp_abort); g_test_add_func("/gobex/test_stream_get_req", test_stream_get_req); g_test_add_func("/gobex/test_stream_get_rsp", test_stream_get_rsp); g_test_add_func("/gobex/test_conn_get_req", test_conn_get_req); g_test_add_func("/gobex/test_conn_get_rsp", test_conn_get_rsp); g_test_add_func("/gobex/test_conn_put_req", test_conn_put_req); g_test_add_func("/gobex/test_conn_put_rsp", test_conn_put_rsp); g_test_add_func("/gobex/test_conn_get_wrg_rsp", test_conn_get_wrg_rsp); g_test_add_func("/gobex/test_conn_put_req_seq", test_conn_put_req_seq); g_test_add_func("/gobex/test_packet_put_req", test_packet_put_req); g_test_add_func("/gobex/test_packet_put_req_wait", test_packet_put_req_wait); g_test_add_func("/gobex/test_packet_put_rsp", test_packet_put_rsp); g_test_add_func("/gobex/test_packet_put_rsp_wait", test_packet_put_rsp_wait); g_test_add_func("/gobex/test_packet_get_rsp", test_packet_get_rsp); g_test_add_func("/gobex/test_packet_get_rsp_wait", test_packet_get_rsp_wait); g_test_add_func("/gobex/test_packet_get_req", test_packet_get_req); g_test_add_func("/gobex/test_packet_get_req_wait", test_packet_get_req_wait); g_test_add_func("/gobex/test_packet_get_req_wait_next", test_packet_get_req_wait_next); g_test_add_func("/gobex/test_conn_put_req_seq_srm", test_conn_put_req_seq_srm); g_test_run(); return 0; } obexd-0.46/unit/util.c0000644000000000000000000001077011755212521011541 00000000000000/* * * OBEX library with GLib integration * * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include "util.h" GQuark test_error_quark(void) { return g_quark_from_static_string("test-error-quark"); } static void dump_bytes(const uint8_t *buf, size_t buf_len) { size_t i; for (i = 0; i < buf_len; i++) g_printerr("%02x ", buf[i]); g_printerr("\n"); } void dump_bufs(const void *mem1, size_t len1, const void *mem2, size_t len2) { g_printerr("\nExpected: "); dump_bytes(mem1, len1); g_printerr("Got: "); dump_bytes(mem2, len2); } void assert_memequal(const void *mem1, size_t len1, const void *mem2, size_t len2) { if (len1 == len2 && memcmp(mem1, mem2, len1) == 0) return; dump_bufs(mem1, len1, mem2, len2); g_assert(0); } GObex *create_gobex(int fd, GObexTransportType transport_type, gboolean close_on_unref) { GIOChannel *io; GObex *obex; io = g_io_channel_unix_new(fd); g_assert(io != NULL); g_io_channel_set_close_on_unref(io, close_on_unref); obex = g_obex_new(io, transport_type, -1, -1); g_io_channel_unref(io); return obex; } void create_endpoints(GObex **obex, GIOChannel **io, int sock_type) { GObexTransportType transport_type; int sv[2]; if (socketpair(AF_UNIX, sock_type | SOCK_NONBLOCK, 0, sv) < 0) { g_printerr("socketpair: %s", strerror(errno)); abort(); } if (sock_type == SOCK_STREAM) transport_type = G_OBEX_TRANSPORT_STREAM; else transport_type = G_OBEX_TRANSPORT_PACKET; *obex = create_gobex(sv[0], transport_type, TRUE); g_assert(*obex != NULL); if (io == NULL) { close(sv[1]); return; } *io = g_io_channel_unix_new(sv[1]); g_assert(*io != NULL); g_io_channel_set_encoding(*io, NULL, NULL); g_io_channel_set_buffered(*io, FALSE); g_io_channel_set_close_on_unref(*io, TRUE); } gboolean test_timeout(gpointer user_data) { struct test_data *d = user_data; if (!g_main_loop_is_running(d->mainloop)) return FALSE; d->err = g_error_new(TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out"); g_main_loop_quit(d->mainloop); return FALSE; } gboolean test_io_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct test_data *d = user_data; GIOStatus status; gsize bytes_written, rbytes, send_buf_len, expect_len; char buf[65535]; const char *send_buf, *expect; expect = d->recv[d->count].data; expect_len = d->recv[d->count].len; send_buf = d->send[d->count].data; send_buf_len = d->send[d->count].len; d->count++; if (!(cond & G_IO_IN)) goto send; status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL); if (status != G_IO_STATUS_NORMAL) { g_print("io_cb count %u\n", d->count); g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Reading data failed with status %d", status); goto failed; } if (rbytes < expect_len) { g_print("io_cb count %u\n", d->count); dump_bufs(expect, expect_len, buf, rbytes); g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Not enough data from socket"); goto failed; } if (memcmp(buf, expect, expect_len) != 0) { g_print("io_cb count %u\n", d->count); dump_bufs(expect, expect_len, buf, rbytes); g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Received data is not correct"); goto failed; } send: if ((gssize) send_buf_len < 0) goto failed; g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written, NULL); if (bytes_written != send_buf_len) { g_print("io_cb count %u\n", d->count); g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED, "Unable to write to socket"); goto failed; } if (d->recv[d->count].len < 0 || (gssize) expect_len < 0) return test_io_cb(io, G_IO_OUT, user_data); return TRUE; failed: g_main_loop_quit(d->mainloop); return FALSE; } obexd-0.46/README0000644000000000000000000000132511755212521010315 00000000000000OBEX Server and Client ********************** Copyright (C) 2007-2010 Marcel Holtmann Compilation and installation ============================ In order to compile OBEX daemons you need following software packages: - GCC compiler - D-Bus library - GLib library - Bluetooth library To configure run: ./configure --prefix=/usr --libexecdir=/usr/lib/obex \ --mandir=/usr/share/man --sysconfdir=/etc Configure automatically searches for all required components and packages. To compile and install run: make && make install Information =========== Mailing lists: linux-bluetooth@vger.kernel.org For additional information about the project visit BlueZ web site: http://www.bluez.org obexd-0.46/config.sub0000755000000000000000000010517611755212544011436 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: obexd-0.46/test/0000755000000000000000000000000011755212615010477 500000000000000obexd-0.46/test/list-folders0000755000000000000000000000142511364341101012743 00000000000000#!/usr/bin/python import sys import dbus def list_folder(folder): bus = dbus.SessionBus() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") session_path = client.CreateSession({ "Destination": sys.argv[1], "Target": "ftp"}) ftp = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.FileTransfer") if folder: for node in folder.split("/"): ftp.ChangeFolder(node) for i in ftp.ListFolder(): if i["Type"] == "folder": print "%s/" % (i["Name"]) else: print "%s" % (i["Name"]) if __name__ == '__main__': if len(sys.argv) < 2: print "Usage: %s [folder]" % (sys.argv[0]) sys.exit(1) folder = None if len(sys.argv) == 3: folder = sys.argv[2] list_folder(folder) obexd-0.46/test/send-files0000755000000000000000000000432711364341101012371 00000000000000#!/usr/bin/python import gobject import os import sys import time import dbus import dbus.service import dbus.mainloop.glib class Agent(dbus.service.Object): def __init__(self, conn=None, obj_path=None): dbus.service.Object.__init__(self, conn, obj_path) @dbus.service.method("org.openobex.Agent", in_signature="o", out_signature="s") def Request(self, path): print "Transfer Request" self.transfer = dbus.Interface(bus.get_object("org.openobex.client", path), "org.openobex.Transfer") properties = self.transfer.GetProperties() for key in properties.keys(): print " %s = %s" % (key, properties[key]) self.start = True return "" @dbus.service.method("org.openobex.Agent", in_signature="ot", out_signature="") def Progress(self, path, transferred): if (self.start): print "Transfer Started" properties = self.transfer.GetProperties() self.transfer_size = properties['Size'] self.start_time = time.time() self.start = False else: speed = transferred / abs((time.time() - self.start_time) * 1000) progress = "(" + str(transferred) + "/" + str(self.transfer_size) + " bytes) @ " + str(int(speed)) + " kB/s" out = "\rTransfer progress " + progress sys.stdout.write(out) sys.stdout.flush() return @dbus.service.method("org.openobex.Agent", in_signature="o", out_signature="") def Complete(self, path): print "\nTransfer finished" return @dbus.service.method("org.openobex.Agent", in_signature="os", out_signature="") def Error(self, path, error): print "\nTransfer finished with an error: %s" % (error) return @dbus.service.method("org.openobex.Agent", in_signature="", out_signature="") def Release(self): mainloop.quit() return if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") if (len(sys.argv) < 3): print "Usage: %s [file*]" % (sys.argv[0]) sys.exit(1) path = "/test/agent" agent = Agent(bus, path) mainloop = gobject.MainLoop() files = [os.path.realpath(f) for f in sys.argv[2:]] client.SendFiles({ "Destination": sys.argv[1] }, files, path) mainloop.run() obexd-0.46/test/pbap-client0000755000000000000000000000210111503171163012526 00000000000000#!/usr/bin/python import sys import dbus bus = dbus.SessionBus() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") print "Creating Session" session_path = client.CreateSession({"Destination": sys.argv[1], "Target": "PBAP"}) pbap = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.PhonebookAccess") session = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.Session") paths = ["PB", "ICH", "OCH", "MCH", "CCH"] for path in paths: print "\n--- Select Phonebook %s ---\n" % (path) pbap.Select("int", path) print "\n--- GetSize ---\n" ret = pbap.GetSize() print "Size = %d\n" % (ret) print "\n--- List vCard ---\n" ret = pbap.List() for item in ret: print "%s : %s" % (item[0], item[1]) pbap.SetFormat("vcard30") pbap.SetFilter(["VERSION", "FN", "TEL"]); ret = pbap.Pull(item[0]) print "%s" % (ret) print "\n--- PullAll ---\n" pbap.SetFormat("vcard30") pbap.SetFilter(["VERSION", "FN", "TEL"]); ret = pbap.PullAll() print "%s" % (ret) obexd-0.46/test/map-client0000755000000000000000000000357011755212521012377 00000000000000#!/usr/bin/python import gobject import dbus import dbus.mainloop.glib from optparse import OptionParser def parse_options(): parser.add_option("-d", "--device", dest="device", help="Device to connect", metavar="DEVICE") parser.add_option("-c", "--chdir", dest="new_dir", help="Change current directory to DIR", metavar="DIR") parser.add_option("-l", "--lsdir", action="store_true", dest="ls_dir", help="List folders in current directory") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") parser.add_option("-L", "--lsmsg", action="store", dest="ls_msg", help="List messages in supplied CWD subdir") return parser.parse_args() def set_folder(session, new_dir): for node in new_dir.split("/"): session.SetFolder(node) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) parser = OptionParser() (options, args) = parse_options() if not options.device: parser.print_help() exit(0) bus = dbus.SessionBus() mainloop = gobject.MainLoop() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") session_path = client.CreateSession({ "Destination": options.device, "Target": "map"}) session = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.Session") map = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.MessageAccess") if options.new_dir: set_folder(map, options.new_dir) if options.ls_dir: print map.GetFolderListing(dict()) if options.ls_msg is not None: print map.GetMessageListing(options.ls_msg, dict()) mainloop.run() obexd-0.46/test/exchange-business-cards0000755000000000000000000000055111177066076015061 00000000000000#!/usr/bin/python import sys import dbus bus = dbus.SessionBus() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") if (len(sys.argv) < 4): print "Usage: %s " % (sys.argv[0]) sys.exit(1) client.ExchangeBusinessCards({ "Destination": sys.argv[1] }, sys.argv[2], sys.argv[3]) obexd-0.46/test/ftp-client0000755000000000000000000001226111755212521012410 00000000000000#!/usr/bin/python import gobject import sys import dbus import dbus.service import dbus.mainloop.glib import os.path from optparse import OptionParser class Agent(dbus.service.Object): def __init__(self, conn=None, obj_path=None, verbose=False): dbus.service.Object.__init__(self, conn, obj_path) self.verbose = verbose @dbus.service.method("org.openobex.Agent", in_signature="o", out_signature="s") def Request(self, path): return "" @dbus.service.method("org.openobex.Agent", in_signature="ot", out_signature="") def Progress(self, path, transferred): if self.verbose: print "Transfer progress (%d bytes)" % (transferred) return @dbus.service.method("org.openobex.Agent", in_signature="o", out_signature="") def Complete(self, path): if self.verbose: print "Transfer finished" mainloop.quit() @dbus.service.method("org.openobex.Agent", in_signature="os", out_signature="") def Error(self, path, error): print "Transfer finished with an error: %s" % (error) mainloop.quit() @dbus.service.method("org.openobex.Agent", in_signature="", out_signature="") def Release(self): mainloop.quit() def parse_options(): parser.add_option("-d", "--device", dest="device", help="Device to connect", metavar="DEVICE") parser.add_option("-c", "--chdir", dest="new_dir", help="Change current directory to DIR", metavar="DIR") parser.add_option("-l", "--list", action="store_true", dest="list_dir", help="List the current directory") parser.add_option("-g", "--get", dest="get_file", help="Get FILE", metavar="FILE") parser.add_option("-p", "--put", dest="put_file", help="Put FILE", metavar="FILE") parser.add_option("-y", "--copy", dest="copy_file", help="Copy FILE", metavar="FILE") parser.add_option("-m", "--move", dest="move_file", help="Move FILE", metavar="FILE") parser.add_option("-n", "--destname", dest="dest_file", help="Destination FILE", metavar="FILE") parser.add_option("-r", "--remove", dest="remove_file", help="Remove FILE", metavar="FILE") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") return parser.parse_args() def error(err): print err def void_reply(): pass def change_folder(session, new_dir): for node in new_dir.split("/"): session.ChangeFolder(node) def list_folder(session): for i in session.ListFolder(): if i["Type"] == "folder": print "%s/" % (i["Name"]) else: print "%s" % (i["Name"]) def put_file(session, filename): session.PutFile(os.path.abspath(filename), os.path.basename(filename), reply_handler=void_reply, error_handler=error) def get_file(session, filename): session.GetFile(os.path.abspath(filename), os.path.basename(filename), reply_handler=void_reply, error_handler=error) def remove_file(session, filename): session.Delete(filename, reply_handler=void_reply, error_handler=error) def move_file(session, filename, destname): session.MoveFile(filename, destname, reply_handler=void_reply, error_handler=error) def copy_file(session, filename, destname): session.CopyFile(filename, destname, reply_handler=void_reply, error_handler=error) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) parser = OptionParser() (options, args) = parse_options() if not options.device: parser.print_help() sys.exit(0) bus = dbus.SessionBus() mainloop = gobject.MainLoop() path = "/test/agent" agent = Agent(bus, path, options.verbose) client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") session_path = client.CreateSession({ "Destination": options.device, "Target": "ftp"}) session = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.Session") session.AssignAgent(path) ftp = dbus.Interface(bus.get_object("org.openobex.client", session_path), "org.openobex.FileTransfer") if options.new_dir: change_folder(ftp, options.new_dir) if options.list_dir: list_folder(ftp) if options.get_file: get_file(ftp, options.get_file) if options.put_file: put_file(ftp, options.put_file) if options.move_file: move_file(ftp, options.move_file, options.dest_file) if options.copy_file: copy_file(ftp, options.copy_file, options.dest_file) if options.remove_file: remove_file(ftp, options.remove_file) mainloop.run() obexd-0.46/test/simple-agent0000755000000000000000000000625111177066076012744 00000000000000#!/usr/bin/python import gobject import sys import dbus import dbus.service import dbus.mainloop.glib class Agent(dbus.service.Object): def __init__(self, conn=None, obj_path=None): dbus.service.Object.__init__(self, conn, obj_path) self.pending_auth = False @dbus.service.method("org.openobex.Agent", in_signature="osssii", out_signature="s") def Authorize(self, dpath, device, filename, ftype, length, time): global transfers self.pending_auth = True print "Authorize (%s, %s, %s) Y/n" % (path, device, filename) auth = raw_input().strip("\n ") if auth == "n" or auth == "N": self.pending_auth = False raise dbus.DBusException("org.openobex.Error.Rejected: " "Not Autorized") print "Full filename (including path):" self.pending_auth = False transfers.append(Transfer(dpath, filename, 0, length)) return raw_input().strip("\n ") @dbus.service.method("org.openobex.Agent", in_signature="", out_signature="") def Cancel(self): print "Authorization Canceled" self.pending_auth = False class Transfer(object): def __init__(self, dpath, filename=None, transfered=-1, size=-1): self.dpath = dpath self.filename = filename self.transfered = transfered self.size = size def update(self, filename=None, transfered=-1, total=-1): if filename: self.filename = filename self.transfered = transfered self.size = total def cancel(self): transfer_iface = dbus.Interface(bus.get_object("org.openobex", self.dpath), "org.openobex.Transfer") transfer_iface.Cancel() def __str__(self): p = float(self.transfered) / float(self.size) * 100 return "%s (%s) (%.2f%%)" % (self.filename, self.dpath, p) __repr__ = __str__ if __name__ == '__main__': global transfers def new_transfer(dpath): print "new transfer" bus.add_signal_receiver(progress, dbus_interface="org.openobex.Transfer", signal_name="Progress", path_keyword="dpath") def transfer_completed(dpath, success): global transfers print "\ntransfer completed => %s" % (success and "Success" or "Fail") transfers = [t for t in transfers if t.dpath != dpath] def progress(total, current, dpath): s = [] for t in transfers: if t.dpath == dpath: t.update(None, current, total) s.append("%s" % (t)) sys.stdout.write(" ".join(s) + "\r") sys.stdout.flush() transfers = [] dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() manager = dbus.Interface(bus.get_object("org.openobex", "/"), "org.openobex.Manager") bus.add_signal_receiver(new_transfer, dbus_interface="org.openobex.Manager", signal_name="TransferStarted") bus.add_signal_receiver(transfer_completed, dbus_interface="org.openobex.Manager", signal_name="TransferCompleted") path = "/test/agent" agent = Agent(bus, path) mainloop = gobject.MainLoop() manager.RegisterAgent(path) print "Agent registered" cont = True while cont: try: mainloop.run() except KeyboardInterrupt: if agent.pending_auth: agent.Cancel() elif len(transfers) > 0: for a in transfers: a.cancel() else: cont = False # manager.UnregisterAgent(path) # print "Agent unregistered" obexd-0.46/test/pull-business-card0000755000000000000000000000121611376220271014055 00000000000000#!/usr/bin/python import sys import dbus import gobject import dbus.mainloop.glib def success(): mainloop.quit() return def failure(error): print error mainloop.quit() return if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) mainloop = gobject.MainLoop() bus = dbus.SessionBus() client = dbus.Interface(bus.get_object("org.openobex.client", "/"), "org.openobex.Client") if (len(sys.argv) < 3): print "Usage: %s " % (sys.argv[0]) sys.exit(1) client.PullBusinessCard({ "Destination": sys.argv[1] }, sys.argv[2], reply_handler=success, error_handler=failure) mainloop.run()