megatools-1.9.98/0000755000175000001440000000000013006640511010605 500000000000000megatools-1.9.98/Makefile.am0000644000175000001440000000420113006623036012561 00000000000000# {{{ global flags BUILT_SOURCES = CLEANFILES = EXTRA_DIST = DISTCLEANFILES = AM_CFLAGS = \ $(GLIB_CFLAGS) \ $(OPENSSL_CFLAGS) \ $(LIBCURL_CFLAGS) \ -DG_LOG_DOMAIN=\"Mega\" \ -I$(srcdir)/lib \ -I$(srcdir) # }}} # {{{ libmega noinst_LIBRARIES = libmega.a libmega_a_SOURCES = \ lib/sjson.gen.c \ lib/sjson.h \ lib/http.c \ lib/http.h \ lib/mega.c \ lib/mega.h \ lib/tools.c \ lib/tools.h \ lib/alloc.h \ lib/mega.h # }}} # {{{ tools EXTRA_DIST += \ lib/sjson.c LDADD = \ libmega.a \ $(GLIB_LIBS) \ $(OPENSSL_LIBS) \ $(LIBCURL_LIBS) bin_PROGRAMS = megadf megadl megaget megals megamkdir megaput megareg megarm megacopy megadf_SOURCES = tools/df.c megadl_SOURCES = tools/dl.c megaget_SOURCES = tools/get.c megals_SOURCES = tools/ls.c megamkdir_SOURCES = tools/mkdir.c megaput_SOURCES = tools/put.c megareg_SOURCES = tools/reg.c megarm_SOURCES = tools/rm.c megacopy_SOURCES = tools/copy.c # }}} # {{{ docs MAN1 = megadf megadl megaget megals megamkdir megaput megareg megarm megacopy MAN5 = megarc MAN7 = megatools EXTRA_DIST += \ docs/asciidoc.conf \ docs/footer.txt \ docs/remote-paths.txt \ docs/basic-options.txt \ docs/auth-options.txt \ $(addprefix docs/,$(addsuffix .txt, $(MAN1) $(MAN5) $(MAN7))) if ENABLE_DOCS man1_MANS = $(addprefix docs/,$(addsuffix .1, $(MAN1))) man5_MANS = $(addprefix docs/,$(addsuffix .5, $(MAN5))) man7_MANS = $(addprefix docs/,$(addsuffix .7, $(MAN7))) MANS_ALL = $(man1_MANS) $(man5_MANS) $(man7_MANS) BUILT_SOURCES += $(MANS_ALL) DISTCLEANFILES += $(MANS_ALL) EXTRA_DIST += $(MANS_ALL) %.1 %.5 %.7: %.txt docs/auth-options.txt docs/basic-options.txt docs/remote-paths.txt docs/footer.txt docs/asciidoc.conf $(AM_V_GEN)mkdir -p "$(top_builddir)/docs" $(AM_V_GEN)a2x --asciidoc-opts="-f $(top_srcdir)/docs/asciidoc.conf -o $@" --destination-dir $(top_builddir)/docs -f manpage $< @sed -i 's/\[FIXME: manual]/Megatools Manual/' $@ @sed -i 's/\[FIXME: source]/megatools $(VERSION)/' $@ endif # }}} # {{{ tests EXTRA_DIST += LICENSE HACKING doc_DATA = LICENSE NEWS TODO README INSTALL HACKING # }}} export MAKEFLAGS += --no-print-directory -s ACLOCAL_AMFLAGS = -I m4 megatools-1.9.98/config.h.in0000644000175000001440000000127513006623047012562 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* 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 megatools-1.9.98/configure0000755000175000001440000055566613006622763012474 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for megatools 1.9.98. # # Report bugs to . # # # 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" 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 and megous@megous.com $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do $0: 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'" 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='megatools' PACKAGE_TARNAME='megatools' PACKAGE_VERSION='1.9.98' PACKAGE_STRING='megatools 1.9.98' PACKAGE_BUGREPORT='megous@megous.com' PACKAGE_URL='' ac_unique_file="Makefile.am" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS A2X ENABLE_DOCS_FALSE ENABLE_DOCS_TRUE LIBCURL_LIBS LIBCURL_CFLAGS OPENSSL_LIBS OPENSSL_CFLAGS GLIB_COMPILE_RESOURCES GLIB_MKENUMS GOBJECT_QUERY GLIB_GENMARSHAL GLIB_LIBS GLIB_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG MEGA_REQUIRES EGREP GREP CPP RANLIB 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_glibtest enable_warnings enable_docs ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR OPENSSL_CFLAGS OPENSSL_LIBS LIBCURL_CFLAGS LIBCURL_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 megatools 1.9.98 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/megatools] --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 _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of megatools 1.9.98:";; 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 --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --disable-glibtest do not try to compile and run a test GLIB program --enable-warnings Build with compiler warnings enabled. --disable-docs Don't build and install man pages. 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 OPENSSL_CFLAGS C compiler flags for OPENSSL, overriding pkg-config OPENSSL_LIBS linker flags for OPENSSL, overriding pkg-config LIBCURL_CFLAGS C compiler flags for LIBCURL, overriding pkg-config LIBCURL_LIBS linker flags for LIBCURL, 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 . _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 megatools configure 1.9.98 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_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_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 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 megatools $as_me 1.9.98, 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 ac_config_headers="$ac_config_headers config.h" am__api_version='1.15' 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; } # 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 ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file 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 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 if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done 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; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file 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 --is-lightweight"; then am_missing_run="$MISSING " 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+set}" != 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; } 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 # 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=1;; 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='\' 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='megatools' VERSION='1.9.98' 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"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). 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}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi { $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 # 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='\' 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 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 whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_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. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != 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 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 10 /bin/sh. echo '/* dummy */' > 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 -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 #AC_LIBTOOL_WIN32_DLL #AM_PROG_LIBTOOL 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 # Define requirements GLIB_VERSION="2.32.0" LIBCURL_REQUIRES="libcurl" OPENSSL_REQUIRES="openssl" MEGA_REQUIRES="gio-2.0 >= $GLIB_VERSION $LIBCURL_REQUIRES $OPENSSL_REQUIRES" # for libmega.pc # check for glib/gio # Check whether --enable-glibtest was given. if test "${enable_glibtest+set}" = set; then : enableval=$enable_glibtest; else enable_glibtest=yes fi pkg_config_args=glib-2.0 for module in . gobject gio do case "$module" in gmodule) pkg_config_args="$pkg_config_args gmodule-2.0" ;; gmodule-no-export) pkg_config_args="$pkg_config_args gmodule-no-export-2.0" ;; gobject) pkg_config_args="$pkg_config_args gobject-2.0" ;; gthread) pkg_config_args="$pkg_config_args gthread-2.0" ;; gio*) pkg_config_args="$pkg_config_args $module-2.0" ;; esac done 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.16 { $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 no_glib="" if test "x$PKG_CONFIG" = x ; then no_glib=yes PKG_CONFIG=no fi min_glib_version=$GLIB_VERSION { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB - version >= $min_glib_version" >&5 $as_echo_n "checking for GLIB - version >= $min_glib_version... " >&6; } if test x$PKG_CONFIG != xno ; then ## don't try to run the test against uninstalled libtool libs if $PKG_CONFIG --uninstalled $pkg_config_args; then echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" enable_glibtest=no fi if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then : else no_glib=yes fi fi if test x"$no_glib" = x ; then GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable=glib_compile_resources gio-2.0` GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x$enable_glibtest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS" rm -f conf.glibtest if test "$cross_compiling" = yes; then : echo $ac_n "cross compiling; assumed OK... $ac_c" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { unsigned int major, minor, micro; fclose (fopen ("conf.glibtest", "w")); if (sscanf("$min_glib_version", "%u.%u.%u", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_glib_version"); exit(1); } if ((glib_major_version != $glib_config_major_version) || (glib_minor_version != $glib_config_minor_version) || (glib_micro_version != $glib_config_micro_version)) { printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, glib_major_version, glib_minor_version, glib_micro_version); printf ("*** was found! If pkg-config was correct, then it is best\n"); printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); printf("*** required on your system.\n"); printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); printf("*** to point to the correct configuration files\n"); } else if ((glib_major_version != GLIB_MAJOR_VERSION) || (glib_minor_version != GLIB_MINOR_VERSION) || (glib_micro_version != GLIB_MICRO_VERSION)) { printf("*** GLIB header files (version %d.%d.%d) do not match\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); printf("*** library (version %d.%d.%d)\n", glib_major_version, glib_minor_version, glib_micro_version); } else { if ((glib_major_version > major) || ((glib_major_version == major) && (glib_minor_version > minor)) || ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) { return 0; } else { printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n", glib_major_version, glib_minor_version, glib_micro_version); printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n", major, minor, micro); printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); printf("***\n"); printf("*** If you have already installed a sufficiently new version, this error\n"); printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); printf("*** being found. The easiest way to fix this is to remove the old version\n"); printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); printf("*** correct copy of pkg-config. (In this case, you will have to\n"); printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); printf("*** so that the correct libraries are found at run-time))\n"); } } return 1; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else no_glib=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_glib" = x ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&5 $as_echo "yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&6; } : else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$PKG_CONFIG" = "no" ; then echo "*** A new enough version of pkg-config was not found." echo "*** See http://www.freedesktop.org/software/pkgconfig/" else if test -f conf.glibtest ; then : else echo "*** Could not run GLIB test program, checking why..." ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GLIB or finding the wrong" echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" else echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means GLIB is incorrectly installed." fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi GLIB_CFLAGS="" GLIB_LIBS="" GLIB_GENMARSHAL="" GOBJECT_QUERY="" GLIB_MKENUMS="" GLIB_COMPILE_RESOURCES="" as_fn_error $? "Glib $GLIB_VERSION or later is required to build megatools" "$LINENO" 5 fi rm -f conf.glibtest # check openssl pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5 $as_echo_n "checking for OPENSSL... " >&6; } if test -n "$OPENSSL_CFLAGS"; then pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$OPENSSL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "$OPENSSL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "$OPENSSL_REQUIRES" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$OPENSSL_LIBS"; then pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$OPENSSL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "$OPENSSL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "$OPENSSL_REQUIRES" 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 OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$OPENSSL_REQUIRES" 2>&1` else OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$OPENSSL_REQUIRES" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OPENSSL_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ($OPENSSL_REQUIRES) were not met: $OPENSSL_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi # check libcurl pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBCURL" >&5 $as_echo_n "checking for LIBCURL... " >&6; } if test -n "$LIBCURL_CFLAGS"; then pkg_cv_LIBCURL_CFLAGS="$LIBCURL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$LIBCURL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "$LIBCURL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBCURL_CFLAGS=`$PKG_CONFIG --cflags "$LIBCURL_REQUIRES" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBCURL_LIBS"; then pkg_cv_LIBCURL_LIBS="$LIBCURL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$LIBCURL_REQUIRES\""; } >&5 ($PKG_CONFIG --exists --print-errors "$LIBCURL_REQUIRES") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBCURL_LIBS=`$PKG_CONFIG --libs "$LIBCURL_REQUIRES" 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 LIBCURL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$LIBCURL_REQUIRES" 2>&1` else LIBCURL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$LIBCURL_REQUIRES" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBCURL_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ($LIBCURL_REQUIRES) were not met: $LIBCURL_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBCURL_CFLAGS and LIBCURL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "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. Alternatively, you may set the environment variables LIBCURL_CFLAGS and LIBCURL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBCURL_CFLAGS=$pkg_cv_LIBCURL_CFLAGS LIBCURL_LIBS=$pkg_cv_LIBCURL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi # enable dev compiler warnings # Check whether --enable-warnings was given. if test "${enable_warnings+set}" = set; then : enableval=$enable_warnings; fi if test "x$enable_warnings" = "xyes"; then : CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -Wno-pointer-sign -Wno-missing-field-initializers" if $CC --version | head -n1 | grep '(GCC) 4\.8' &>/dev/null; then : CFLAGS="$CFLAGS -Wno-unused-local-typedefs" fi else CFLAGS="$CFLAGS -Wno-pointer-sign -Wno-unused-variable" enable_warnings=no fi # enable docs building # Check whether --enable-docs was given. if test "${enable_docs+set}" = set; then : enableval=$enable_docs; fi if test "x$enable_docs" != xno; then ENABLE_DOCS_TRUE= ENABLE_DOCS_FALSE='#' else ENABLE_DOCS_TRUE='#' ENABLE_DOCS_FALSE= fi if test "x$enable_docs" != "xno"; then : # Extract the first word of "a2x", so it can be a program name with args. set dummy a2x; 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_A2X+:} false; then : $as_echo_n "(cached) " >&6 else case $A2X in [\\/]* | ?:[\\/]*) ac_cv_path_A2X="$A2X" # 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_A2X="$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 test -z "$ac_cv_path_A2X" && ac_cv_path_A2X="no" ;; esac fi A2X=$ac_cv_path_A2X if test -n "$A2X"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $A2X" >&5 $as_echo "$A2X" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$A2X" = xno; then : as_fn_error $? "a2x is required to build docs, install asciidoc" "$LINENO" 5 fi enable_docs=yes 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 { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } 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 "${ENABLE_DOCS_TRUE}" && test -z "${ENABLE_DOCS_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DOCS\" 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 megatools $as_me 1.9.98, 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 ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ megatools config.status 1.9.98 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" _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" ;; "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"" || { # Older Autoconf 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"` # 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'`; 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 } ;; 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 cat << EOF Configured features: docs build: $enable_docs warnings: $enable_warnings Run make now. NOTE: On FreeBSD, you need to use GNU make (gmake) EOF megatools-1.9.98/aclocal.m40000644000175000001440000017153213006622762012406 00000000000000# generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 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_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 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'.])]) # Configure paths for GLIB # Owen Taylor 1997-2001 dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject, dnl gthread, or gio is specified in MODULES, pass to pkg-config dnl AC_DEFUN([AM_PATH_GLIB_2_0], [dnl dnl Get the cflags and libraries from pkg-config dnl AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program], , enable_glibtest=yes) pkg_config_args=glib-2.0 for module in . $4 do case "$module" in gmodule) pkg_config_args="$pkg_config_args gmodule-2.0" ;; gmodule-no-export) pkg_config_args="$pkg_config_args gmodule-no-export-2.0" ;; gobject) pkg_config_args="$pkg_config_args gobject-2.0" ;; gthread) pkg_config_args="$pkg_config_args gthread-2.0" ;; gio*) pkg_config_args="$pkg_config_args $module-2.0" ;; esac done PKG_PROG_PKG_CONFIG([0.16]) no_glib="" if test "x$PKG_CONFIG" = x ; then no_glib=yes PKG_CONFIG=no fi min_glib_version=ifelse([$1], ,2.0.0,$1) AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) if test x$PKG_CONFIG != xno ; then ## don't try to run the test against uninstalled libtool libs if $PKG_CONFIG --uninstalled $pkg_config_args; then echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" enable_glibtest=no fi if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then : else no_glib=yes fi fi if test x"$no_glib" = x ; then GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable=glib_compile_resources gio-2.0` GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_glibtest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS" dnl dnl Now check if the installed GLIB is sufficiently new. (Also sanity dnl checks the results of pkg-config to some extent) dnl rm -f conf.glibtest AC_TRY_RUN([ #include #include #include int main () { unsigned int major, minor, micro; fclose (fopen ("conf.glibtest", "w")); if (sscanf("$min_glib_version", "%u.%u.%u", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_glib_version"); exit(1); } if ((glib_major_version != $glib_config_major_version) || (glib_minor_version != $glib_config_minor_version) || (glib_micro_version != $glib_config_micro_version)) { printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, glib_major_version, glib_minor_version, glib_micro_version); printf ("*** was found! If pkg-config was correct, then it is best\n"); printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); printf("*** required on your system.\n"); printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); printf("*** to point to the correct configuration files\n"); } else if ((glib_major_version != GLIB_MAJOR_VERSION) || (glib_minor_version != GLIB_MINOR_VERSION) || (glib_micro_version != GLIB_MICRO_VERSION)) { printf("*** GLIB header files (version %d.%d.%d) do not match\n", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); printf("*** library (version %d.%d.%d)\n", glib_major_version, glib_minor_version, glib_micro_version); } else { if ((glib_major_version > major) || ((glib_major_version == major) && (glib_minor_version > minor)) || ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) { return 0; } else { printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n", glib_major_version, glib_minor_version, glib_micro_version); printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n", major, minor, micro); printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); printf("***\n"); printf("*** If you have already installed a sufficiently new version, this error\n"); printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); printf("*** being found. The easiest way to fix this is to remove the old version\n"); printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); printf("*** correct copy of pkg-config. (In this case, you will have to\n"); printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); printf("*** so that the correct libraries are found at run-time))\n"); } } return 1; } ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_glib" = x ; then AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$PKG_CONFIG" = "no" ; then echo "*** A new enough version of pkg-config was not found." echo "*** See http://www.freedesktop.org/software/pkgconfig/" else if test -f conf.glibtest ; then : else echo "*** Could not run GLIB test program, checking why..." ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS" AC_TRY_LINK([ #include #include ], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GLIB or finding the wrong" echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means GLIB is incorrectly installed."]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi fi GLIB_CFLAGS="" GLIB_LIBS="" GLIB_GENMARSHAL="" GOBJECT_QUERY="" GLIB_MKENUMS="" GLIB_COMPILE_RESOURCES="" ifelse([$3], , :, [$3]) fi AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_GENMARSHAL) AC_SUBST(GOBJECT_QUERY) AC_SUBST(GLIB_MKENUMS) AC_SUBST(GLIB_COMPILE_RESOURCES) rm -f conf.glibtest ]) dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- dnl serial 11 (pkg-config-0.29.1) dnl dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.1]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. 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 ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl 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]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. 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 ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. 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 ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl 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 ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR # Copyright (C) 2002-2014 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. # 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.15' 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.15], [], [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.15])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-2014 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. # 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], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2014 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. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$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-2014 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. # 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", "OBJC", "OBJCXX", "UPC", or "GJC". # 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 m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" 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 10 /bin/sh. echo '/* dummy */' > 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], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) 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-2014 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. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf 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"` # 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'`; 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"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2014 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 macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # 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.65])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], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) 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], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [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([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). 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])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro 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 # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) 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-2014 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. # 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+set}" != 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-2014 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. # 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-2014 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. # 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], [AS_HELP_STRING([--]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 ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2014 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. # 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 ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2014 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. # 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 is modern enough. # If it is, 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 --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2014 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. # _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])]) # Copyright (C) 1999-2014 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. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != 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 AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2014 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. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2014 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. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # 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 ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file 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 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 if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done 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]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2014 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. # 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], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) 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-2014 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. # 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-2014 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. # _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-2014 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. # _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}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} 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 megatools-1.9.98/NEWS0000644000175000001440000002500613006627054011236 00000000000000megatools 1.9.98 - 2016-11-03 ============================= Bugfix release with some UI imporvements. New features: - Support upload/download speed limit settings - Support socks proxy - Improved progress reporting - Support for OpenSSL 1.1.x Removals: - Remove undocummented --abort-on-error option. Tools now always report errors through exit status. - Remove libmega.so public library support and a lot of unused code that was planned to be used for 2.0 - Remove megamv (it was never implemented and confused users) - Remove megafs (it was just an experiment and confused users) Cleanups: - Cleanup build system a bit - Cleanup CLI option handling, improved --help output Fixes: - Enable automatic decompression (CURLOPT_ACCEPT_ENCODING) (by protomouse) (This finally fixes the problem with HTTP compression.) - Exit status from all the tools is now correctly reported - Fix syncing of symlinked files - Support very long passwords in the password prompt (up to 1024 chars) megatools 1.9.97 - 2016-02-02 ============================= Bugfix release. Fixes: - Mega started compressing HTTP responses to API calls. Megatools now uses libcurl to handle API requests, so HTTP compression is now supproted. megatools 1.9.96 - 2016-01-02 ============================= Bugfix release. Fixes: - Refer to mega.nz and use mega.nz links instead of deprecated mega.co.nz - Fix various build issues megatools 1.9.95 - 2015-04-15 ============================= Bugfix and optimization release. Fixes: - Improve compatibility wit older curl (whatever version is in centos 6.5) - Fix regression in megadl: fails to download exported folders #90 - Remove megamv as it is not and will not be implemented in 1.9 branch - Slow down progress reporting on windows to once per second #102 - Correct the default values in mega_session_load() Improvements: - Rename megasync to megacopy to avoid conflict with official mega sync client - Optimize session loading - issue #100 - Optimize session loading - further optimization - issue #100 - There's no need to use dbus-launcher when running megatools outside running desktop to avoid a warning message. megatools 1.9.94 - 2015-01-02 ============================= Bugfix and optimization release. Fixes: - Force use of IPv4 addresses - Fix path sanitization so that trailing slashes are ignored - Document config file oddities in megarc manpage - Add info on how to build/install megatools on various distros Improvements: - Optimize path handling code so that filesystems with many files are usable. Previously, megatools would hang for quite some time when updating it's path map. - Use non-recursive makefile to build megatools megatools 1.9.93 - 2014-10-24 ============================= Added OpenSSL exemption to the license. Fixes: - megadf now returns correct values - fixed path sanitization in mega_session_stat - raised safety limit os size of POST responses from 32 to 256 MiB - show progress when downloading folder using megadl - optimized buffer allocation during donwload and upload - report details of errors when stream callback fails to read/write file - fix detection of convert executeable for preview generation - allow to disable file previews megatools 1.9.92 - 2014-08-24 ============================= Created stable branch for bugfixes. This is the release from the stable branch. This release contains mostly small bug fixes. Most important change is that Megatools now recognizes server busy errors as reported by mega.nz via HTTP status 500 Server Is Busy, and retries the communication. This reduces command failures by a lot, and you'll not see 500 Server Is Busy errors anymore. Another major news is update to the windows package. There are now two packages for 32bit and 64bit windows platform, and all dlls were updated to their latest versions. Other news: - Added 64bit windows package - Unmask Megatools to Mega.nz (user Megatools/VERSION User-Agent) - Check for a2x if --enable-docs-build=yes - Megadl now reports file download errors - Add megadl --print-names option - Fix megasync error (issue #45 on github) - Fix megadl used with pipe (--path -) on windows (issue #38) - Installation instructions for Mac - Add info about Gentoo ebuild to the README file (issue #26) - Fix Megatools thumbnails for PDF (issue #5) - Do repeated API calls after 500 Server Is Busy and increase retry delay - Fix issue to download a file with accent with megaget (issue #22) megatools 1.9.91 - 2013-04-14 ============================= Please note, that megatools is using GNOME release versioning. That means that in MAJOR.MINOR.PATCH, odd MINOR number signifies development version of the tools. PATCH version is increased on each public release. By using odd MINOR versions of the software you are using an unstable branch. That doesn't mean it will be crashing on you, but it may have certain quirks, and oddities, missing or incomplete features, etc. Next stable release is going to be 2.0.0. To the news: - Added man pages for all tools - Removed megastream in favor of mega{dl,get} --path - - Megadf - fix unsigned overflow when server reports 0 total space - Implemented --debug option - Win32: Drop requirement for manual setup of GIO_EXTRA_MODULES - Load certificates from the binaries folder on windows - Enable CA validation for TLS connections - Fix compilation on FreeBSD by adding --enable-warnings - Add note that on FreeBSD GNU make must be used to build the tools - Fix typedef redefinitions (error on older gcc's) - Fix megals --names logic - megaput/megaget/megadl/megasync: --no-progress support - Fix mega_session_dl streaming mode segfault - megamkdir/megarm: Check for required arguments - Pretty print JSON in debug output AUR package is available at https://aur.archlinux.org/packages/megatools/ Ubunut PPA is availble at https://launchpad.net/~megous/+archive/ppa If someone wants to take over packaging for Ubuntu or Debian, that would be very appretiated, as my speciality is Arch Linux. megatools 1.9.90 - 2013-04-11 ============================= Implemented much simpler and faster json parser than json-glib, which was used before. Megatools now use sjson, which you can find at: https://github.com/megous/sjson Json-glib dependency was thus dropped. Initial work on getting rid of dependency on libcurl. Initial work on the new libmega library with support for gobject-introspection based bindings to various languages: JavaScript, Python, Ruby, LUA,... Experimental implementation of Mega API in JavaScript (gjs), this should help people develop GNOME GUI for Mega in the future. New command line tools: megafs - mount mega.nz filesystem usong FUSE (Linux only) megamv - move and rename remote files and directories megatools 1.2.2 - 2013-04-11 ============================ Bugs fixed: - Trash and Inbox paths are no longer mixed up (bug reported by Ovidiu) - megadl segfault - megaput --path /Root/nonexistent-file local-file (remote file would get the name of the local file, instead of nonexistent-file) - megals /Root/file-name would return nothing - Segfault with password length over 15 chars - Fix file size parsing to make it work with files over 2GB in size megatools 1.2.1 - 2013-03-12 ============================ Added support for OpenSUSE 12.1 and newer versions. Build libmega statically for binary distribution to ease installation outside of /usr/local. megatools 1.2.0 - 2013-03-12 ============================ Megatools now support download of shared files and folders. Megatools support creating thumbnails for image and video files uploaded to Mega. This is enabled only on Linux, as it requires ffmpegthumbnailer and convert (from ImageMagick package). You can now manage your contacts list via: - mkdir /Contacts/some@email.com - rm /Contacts/some.other@email.com Exported folders can be downloaded using megadl. All tools gained a few more options to help with scripting needs. If you don't provide password on command-line or in config file you'll be asked for it when the tool runs. Megals tool gained many new options. OpenSSL locks are now properly initialized. megatools 1.1.1 - 2013-03-10 ============================ Binary packages for linux support more Linux distributions. Supported distros include (both 32bit and 64bit editions): - Ubuntu LTS 12.04.2 and later - Fedora 17 and later - Current Arch Linux - Suse (with a package for ubuntu) - ...and probably any recent distribution with all dependencies installed Package structure was changed to allow easy installation to /usr/local. To install, run: sudo tar -x -f megatools-1.1.1-i686.tar.gz -C / --no-overwrite-dir Tools now use shared library, which you can use to develop your own Mega tools. For example: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gcc -o sample sample.c -Wl,-rpath,/usr/local/lib `pkg-config --cflags --libs libmega` Sample source code sample.c can be found in /usr/local/share/doc/megatools/ To develop mega apps, you'll need to install development packages on distros like Fedora or Ubuntu. For example on Fedora: yum install openssl-devel json-glib-devel libcurl-devel glib2-devel Or on Ubuntu: apt-get install libssl-dev libjson-glib-dev libcurl4-openssl-dev gcc make pkg-config megatools 1.1.0 - 2013-03-09 ============================ Megareg tool is now implemented, and can be used to register new accounts without the need for Mega website. Unless you login to Mega, Mega will never be able to get your password key. Tools don't show version banner anymore, unless asked for via --version option. Megadl learned to handle SIGPIPE if server drops connection, and megadl tries to write into a closed socket. megatools 1.0.0 - 2013-03-08 ============================ This is initial public release of megatools. Current features are: - Local caching of remote session/filesystem information for faster execution. Cache is encrypted with your password key. - Support for configuration file to put login information in. This is not wildly secure, but it's convenient. - Initial set of tools to manipulate remote filesystem: megadf Show your cloud storage space usage/quota megals List all remote files megamkdir Create remote directory megarm Remove remote file or directory megaput Upload individual files megaget Download individual files megadl Download file from a "public" Mega link (doesn't require login) megastream Streaming download of a file (can be used to preview videos or music) megasync Upload or download a directory tree See TODO for features that are comming in the future releases. megatools-1.9.98/configure.ac0000644000175000001440000000407612727144210013026 00000000000000AC_PREREQ(2.60) AC_INIT([megatools],[1.9.98],[megous@megous.com],[megatools]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE([silent-rules foreign subdir-objects -Wno-portability]) AM_MAINTAINER_MODE AM_SILENT_RULES([yes]) AC_PROG_CC AC_PROG_RANLIB AM_PROG_CC_C_O #AC_LIBTOOL_WIN32_DLL #AM_PROG_LIBTOOL AC_HEADER_STDC # Define requirements GLIB_VERSION="2.32.0" LIBCURL_REQUIRES="libcurl" OPENSSL_REQUIRES="openssl" MEGA_REQUIRES="gio-2.0 >= $GLIB_VERSION $LIBCURL_REQUIRES $OPENSSL_REQUIRES" # for libmega.pc AC_SUBST(MEGA_REQUIRES) # check for glib/gio AM_PATH_GLIB_2_0([$GLIB_VERSION],,AC_MSG_ERROR([Glib $GLIB_VERSION or later is required to build megatools]),[gobject gio]) # check openssl PKG_CHECK_MODULES(OPENSSL, [$OPENSSL_REQUIRES]) AC_SUBST(OPENSSL_CFLAGS) AC_SUBST(OPENSSL_LIBS) # check libcurl PKG_CHECK_MODULES(LIBCURL, [$LIBCURL_REQUIRES]) AC_SUBST(LIBCURL_CFLAGS) AC_SUBST(LIBCURL_LIBS) # enable dev compiler warnings AC_ARG_ENABLE([warnings], AC_HELP_STRING([--enable-warnings], [Build with compiler warnings enabled.])) AS_IF([test "x$enable_warnings" = "xyes"], [ CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -Wno-pointer-sign -Wno-missing-field-initializers" AS_IF([$CC --version | head -n1 | grep '(GCC) 4\.8' &>/dev/null], [CFLAGS="$CFLAGS -Wno-unused-local-typedefs"]) ], [ CFLAGS="$CFLAGS -Wno-pointer-sign -Wno-unused-variable" enable_warnings=no ]) # enable docs building AC_ARG_ENABLE([docs], AC_HELP_STRING([--disable-docs], [Don't build and install man pages.])) AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) AS_IF([test "x$enable_docs" != "xno"], [ AC_PATH_PROG([A2X], [a2x], [no]) AS_IF([test "x$A2X" = xno], [ AC_MSG_ERROR([a2x is required to build docs, install asciidoc]) ]) enable_docs=yes ]) AC_CONFIG_FILES([ Makefile ]) AC_OUTPUT cat << EOF Configured features: docs build: $enable_docs warnings: $enable_warnings Run make now. NOTE: On FreeBSD, you need to use GNU make (gmake) EOF megatools-1.9.98/missing0000755000175000001440000001533012575147303012141 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written 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 case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man 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 # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # 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: megatools-1.9.98/compile0000755000175000001440000001624512575147303012126 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2014 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_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 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 lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # 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) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -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: megatools-1.9.98/LICENSE0000644000175000001440000004462212451646654011563 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, 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 Lesser 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 Street, 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 Lesser General Public License instead of this License. OpenSSL Exemption ----------------- In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it here. megatools-1.9.98/depcomp0000755000175000001440000005601612575147303012125 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2014 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 # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} 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" # Avoid interferences from the environment. gccflag= dashmflag= # 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 if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc 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 -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## 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). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - 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 -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # 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. ## 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. tr ' ' "$nl" < "$tmpdepfile" \ | 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 -ne 0; then 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 ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # 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 ;; 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. set_dir_from "$object" set_base_from "$object" 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 -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then 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. set_dir_from "$object" set_base_from "$object" 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 -ne 0; then 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,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_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. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool 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$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; 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 -ne 0; then 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/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash 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|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | 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" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | 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::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$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: megatools-1.9.98/install-sh0000755000175000001440000003452312575147303012553 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2013-12-25.23; # 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. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # 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_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 is_target_a_directory=possibly 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 *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi 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 if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi 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 "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` 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-writable 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 oIFS=$IFS IFS=/ set -f set fnord $dstdir shift 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` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && 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: megatools-1.9.98/lib/0000755000175000001440000000000013006640511011353 500000000000000megatools-1.9.98/lib/http.c0000644000175000001440000002704013006625442012427 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "http.h" #include "config.h" #include #include #include // curlver.h: this macro was added in May 14, 2015 #ifndef CURL_AT_LEAST_VERSION #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif #define DEBUG_CURL 0 struct _http { CURL* curl; GHashTable* headers; http_progress_fn progress_cb; gpointer progress_data; time_t last_progress; }; http* http_new(void) { http* h = g_new0(http, 1); h->curl = curl_easy_init(); if (!h->curl) { g_free(h); return NULL; } #if CURL_AT_LEAST_VERSION(7,21,6) curl_easy_setopt(h->curl, CURLOPT_ACCEPT_ENCODING, ""); #else curl_easy_setopt(h->curl, CURLOPT_ENCODING, ""); #endif curl_easy_setopt(h->curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); #if DEBUG_CURL == 1 curl_easy_setopt(h->curl, CURLOPT_VERBOSE, 1L); #endif //XXX: don't use alarm signal to time out dns queries //curl_easy_setopt(h->curl, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(h->curl, CURLOPT_FOLLOWLOCATION, 1L); h->headers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); // set default headers http_set_referer(h, "https://mega.co.nz/"); http_set_user_agent(h, "Megatools (" VERSION ")"); return h; } void http_set_header(http* h, const gchar* name, const gchar* value) { g_return_if_fail(h != NULL); g_return_if_fail(name != NULL); g_return_if_fail(value != NULL); g_hash_table_insert(h->headers, g_strdup(name), g_strdup(value)); } void http_set_content_type(http* h, const gchar* type) { http_set_header(h, "Content-Type", type); } void http_set_content_length(http* h, goffset len) { gchar* tmp = g_strdup_printf("%" G_GOFFSET_FORMAT, len); http_set_header(h, "Content-Length", tmp); g_free(tmp); } void http_no_expect(http* h) { http_set_header(h, "Expect", ""); } void http_set_referer(http* h, const gchar* referer) { http_set_header(h, "Referer", referer); } void http_set_user_agent(http* h, const gchar* ua) { http_set_header(h, "User-Agent", ua); } static int curl_progress(http* h, double dltotal, double dlnow, double ultotal, double ulnow) { if (h->progress_cb #ifdef G_OS_WIN32 && (!h->last_progress || h->last_progress + 1 < time(NULL)) #endif ) { #ifdef G_OS_WIN32 h->last_progress = time(NULL); #endif if (!h->progress_cb(dltotal + ultotal, dlnow + ulnow, h->progress_data)) return 1; // cancel } return 0; } void http_set_speed(http* h, gint max_ul, gint max_dl) { if (max_ul >= 0) curl_easy_setopt(h->curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)max_ul * 1024); if (max_dl >= 0) curl_easy_setopt(h->curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)max_dl * 1024); } void http_set_proxy(http* h, const gchar* proxy) { curl_easy_setopt(h->curl, CURLOPT_PROXY, proxy); } void http_set_progress_callback(http* h, http_progress_fn cb, gpointer data) { if (cb) { h->progress_cb = cb; h->progress_data = data; curl_easy_setopt(h->curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(h->curl, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)curl_progress); curl_easy_setopt(h->curl, CURLOPT_PROGRESSDATA, h); } else { curl_easy_setopt(h->curl, CURLOPT_NOPROGRESS, 1L); } } static void add_header(gchar* key, gchar* val, struct curl_slist** l) { gchar* tmp = g_strdup_printf("%s: %s", key, val); *l = curl_slist_append(*l, tmp); g_free(tmp); } static size_t append_gstring(void *buffer, size_t size, size_t nmemb, GString *str) { if (size * nmemb > 0) g_string_append_len(str, buffer, size * nmemb); return nmemb; } GString* http_post(http* h, const gchar* url, const gchar* body, gssize body_len, GError** err) { struct curl_slist* headers = NULL; glong http_status = 0; GString* response; CURLcode res; g_return_val_if_fail(h != NULL, NULL); g_return_val_if_fail(url != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); // setup post headers and url curl_easy_setopt(h->curl, CURLOPT_POST, 1L); curl_easy_setopt(h->curl, CURLOPT_URL, url); g_hash_table_foreach(h->headers, (GHFunc)add_header, &headers); curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, headers); // pass request body if (body) { curl_easy_setopt(h->curl, CURLOPT_NOBODY, 0L); curl_easy_setopt(h->curl, CURLOPT_POSTFIELDS, body); curl_easy_setopt(h->curl, CURLOPT_POSTFIELDSIZE, body_len); } else { curl_easy_setopt(h->curl, CURLOPT_NOBODY, 1L); curl_easy_setopt(h->curl, CURLOPT_POSTFIELDS, NULL); curl_easy_setopt(h->curl, CURLOPT_POSTFIELDSIZE, 0L); } // prepare buffer for the response body response = g_string_sized_new(1024); curl_easy_setopt(h->curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)append_gstring); curl_easy_setopt(h->curl, CURLOPT_WRITEDATA, response); // perform HTTP request res = curl_easy_perform(h->curl); // check the result if (res == CURLE_OK) { if (curl_easy_getinfo(h->curl, CURLINFO_RESPONSE_CODE, &http_status) == CURLE_OK) { if (http_status == 200 || http_status == 201) { goto out; } else if (http_status == 500) { g_set_error(err, HTTP_ERROR, HTTP_ERROR_SERVER_BUSY, "Server returned %ld (probably busy)", http_status); } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Server returned %ld", http_status); } } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Can't get http status code"); } } else if (res == CURLE_GOT_NOTHING) { g_set_error(err, HTTP_ERROR, HTTP_ERROR_NO_RESPONSE, "CURL error: %s", curl_easy_strerror(res)); } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "CURL error: %s", curl_easy_strerror(res)); } g_string_free(response, TRUE); response = NULL; out: curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, NULL); curl_slist_free_all(headers); if (response) return response; return NULL; } struct _stream_data { http_data_fn cb; gpointer user_data; }; static size_t curl_read(void *buffer, size_t size, size_t nmemb, struct _stream_data* data) { return data->cb(buffer, size * nmemb, data->user_data); } GString* http_post_stream_upload(http* h, const gchar* url, goffset len, http_data_fn read_cb, gpointer user_data, GError** err) { struct curl_slist* headers = NULL; glong http_status = 0; GString* response; CURLcode res; struct _stream_data data; g_return_val_if_fail(h != NULL, NULL); g_return_val_if_fail(url != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); http_no_expect(h); // setup post headers and url curl_easy_setopt(h->curl, CURLOPT_POST, 1L); curl_easy_setopt(h->curl, CURLOPT_URL, url); // setup request post body writer http_set_content_length(h, len); curl_easy_setopt(h->curl, CURLOPT_POSTFIELDSIZE_LARGE, len); data.cb = read_cb; data.user_data = user_data; curl_easy_setopt(h->curl, CURLOPT_READFUNCTION, (curl_read_callback)curl_read); curl_easy_setopt(h->curl, CURLOPT_READDATA, &data); // prepare buffer for the response body response = g_string_sized_new(512); curl_easy_setopt(h->curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)append_gstring); curl_easy_setopt(h->curl, CURLOPT_WRITEDATA, response); g_hash_table_foreach(h->headers, (GHFunc)add_header, &headers); curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, headers); // perform HTTP request res = curl_easy_perform(h->curl); // check the result if (res == CURLE_OK) { if (curl_easy_getinfo(h->curl, CURLINFO_RESPONSE_CODE, &http_status) == CURLE_OK) { if (http_status == 200) { goto out; } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Server returned %ld", http_status); } } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Can't get http status code"); } } else if (res == CURLE_GOT_NOTHING) { g_set_error(err, HTTP_ERROR, HTTP_ERROR_NO_RESPONSE, "CURL error: %s", curl_easy_strerror(res)); } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "CURL error: %s", curl_easy_strerror(res)); } g_string_free(response, TRUE); response = NULL; out: curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, NULL); curl_slist_free_all(headers); if (response) return response; return NULL; } static size_t curl_write(void *buffer, size_t size, size_t nmemb, struct _stream_data* data) { return data->cb(buffer, size * nmemb, data->user_data); } static CURLcode curl_easy_perform_retry_empty(CURL* curl) { gint delay = 250000; // repeat after 250ms 500ms 1s ... CURLcode res; again: res = curl_easy_perform(curl); if (res == CURLE_GOT_NOTHING) { g_usleep(delay); delay = delay * 2; if (delay > 4 * 1000 * 1000) return CURLE_GOT_NOTHING; goto again; } return res; } gboolean http_post_stream_download(http* h, const gchar* url, http_data_fn write_cb, gpointer user_data, GError** err) { struct curl_slist* headers = NULL; glong http_status = 0; CURLcode res; struct _stream_data data; gboolean status = FALSE; g_return_val_if_fail(h != NULL, FALSE); g_return_val_if_fail(url != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); http_no_expect(h); // setup post headers and url curl_easy_setopt(h->curl, CURLOPT_POST, 1L); curl_easy_setopt(h->curl, CURLOPT_URL, url); // request is empty curl_easy_setopt(h->curl, CURLOPT_POSTFIELDSIZE, 0); // setup response writer data.cb = write_cb; data.user_data = user_data; curl_easy_setopt(h->curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curl_write); curl_easy_setopt(h->curl, CURLOPT_WRITEDATA, &data); g_hash_table_foreach(h->headers, (GHFunc)add_header, &headers); curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, headers); // perform HTTP request res = curl_easy_perform_retry_empty(h->curl); // check the result if (res == CURLE_OK) { if (curl_easy_getinfo(h->curl, CURLINFO_RESPONSE_CODE, &http_status) == CURLE_OK) { if (http_status == 200) { status = TRUE; goto out; } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Server returned %ld", http_status); } } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "Can't get http status code"); } } else { g_set_error(err, HTTP_ERROR, HTTP_ERROR_OTHER, "CURL error: %s", curl_easy_strerror(res)); } out: curl_easy_setopt(h->curl, CURLOPT_HTTPHEADER, NULL); curl_slist_free_all(headers); return status; } void http_free(http* h) { if (!h) return; g_hash_table_destroy(h->headers); curl_easy_cleanup(h->curl); memset(h, 0, sizeof(http)); g_free(h); } GQuark http_error_quark(void) { return g_quark_from_static_string("http-error-quark"); } megatools-1.9.98/lib/sjson.h0000644000175000001440000001237313006625442012614 00000000000000/** * sjson - fast string based JSON parser/generator library * Copyright (C) 2013 OndÅ™ej Jirman * * WWW: https://github.com/megous/sjson * * 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 3 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 . */ #ifndef __S_JSON_H__ #define __S_JSON_H__ #include // json value types typedef enum { S_JSON_TYPE_NONE = 0, S_JSON_TYPE_OBJECT, S_JSON_TYPE_ARRAY, S_JSON_TYPE_STRING, S_JSON_TYPE_NUMBER, S_JSON_TYPE_BOOL, S_JSON_TYPE_NULL, S_JSON_TYPE_INVALID } SJsonType; typedef struct _SJsonGen SJsonGen; // parser gboolean s_json_is_valid (const gchar* json); gchar* s_json_get (const gchar* json); SJsonType s_json_get_type (const gchar* json); const gchar* s_json_get_element_first (const gchar* json); const gchar* s_json_get_element_next (const gchar* iter); const gchar* s_json_get_element (const gchar* json, guint index); gchar** s_json_get_elements (const gchar* json); const gchar* s_json_get_member_first (const gchar* json, const gchar** value); const gchar* s_json_get_member_next (const gchar** value); const gchar* s_json_get_member (const gchar* json, const gchar* name); gchar* s_json_get_string (const gchar* json); gint64 s_json_get_int (const gchar* json, gint64 fallback); gdouble s_json_get_double (const gchar* json, gdouble fallback); gboolean s_json_get_bool (const gchar* json); gboolean s_json_is_null (const gchar* json); gchar* s_json_get_member_string (const gchar* json, const gchar* name); gint64 s_json_get_member_int (const gchar* json, const gchar* name, gint64 fallback); gdouble s_json_get_member_double (const gchar* json, const gchar* name, gdouble fallback); gboolean s_json_get_member_bool (const gchar* json, const gchar* name); gboolean s_json_member_is_null (const gchar* json, const gchar* name); // helper utils gboolean s_json_string_match (const gchar* json_str, const gchar* c_str); // json path const gchar* s_json_path (const gchar* json, const gchar* path); // generator SJsonGen* s_json_gen_new (void); void s_json_gen_start_object (SJsonGen* json); void s_json_gen_end_object (SJsonGen* json); void s_json_gen_start_array (SJsonGen* json); void s_json_gen_end_array (SJsonGen* json); void s_json_gen_json (SJsonGen* json, const gchar* v); void s_json_gen_build (SJsonGen* json, const gchar* fmt, ...); void s_json_gen_string (SJsonGen* json, const gchar* v); void s_json_gen_int (SJsonGen* json, gint64 v); void s_json_gen_double (SJsonGen* json, gdouble v); void s_json_gen_bool (SJsonGen* json, gboolean v); void s_json_gen_null (SJsonGen* json); void s_json_gen_member_json (SJsonGen* json, const gchar* name, const gchar* v); void s_json_gen_member_build (SJsonGen* json, const gchar* name, const gchar* fmt, ...); void s_json_gen_member_string (SJsonGen* json, const gchar* name, const gchar* v); void s_json_gen_member_int (SJsonGen* json, const gchar* name, gint64 v); void s_json_gen_member_double (SJsonGen* json, const gchar* name, gdouble v); void s_json_gen_member_bool (SJsonGen* json, const gchar* name, gboolean v); void s_json_gen_member_null (SJsonGen* json, const gchar* name); void s_json_gen_member_array (SJsonGen* json, const gchar* name); void s_json_gen_member_object (SJsonGen* json, const gchar* name); gchar* s_json_gen_done (SJsonGen* json); // builder gchar* s_json_buildv (const gchar* format, va_list args); gchar* s_json_build (const gchar* format, ...); // formatters gchar* s_json_pretty (const gchar* json); gchar* s_json_compact (const gchar* json); // iterator macros #define S_JSON_FOREACH_ELEMENT(json, iter) \ G_STMT_START { \ const gchar* iter; \ for (iter = s_json_get_element_first(json); iter; iter = s_json_get_element_next(iter)) { #define S_JSON_FOREACH_MEMBER(json, key, value) \ G_STMT_START { \ const gchar *key, *value; \ for (key = s_json_get_member_first(json, &value); key; key = s_json_get_member_next(&value)) { #define S_JSON_FOREACH_END() \ }} G_STMT_END; #endif megatools-1.9.98/lib/sjson.c0000644000175000001440000006340513006625442012611 00000000000000/** * sjson - fast string based JSON parser/generator library * Copyright (C) 2013 OndÅ™ej Jirman * * WWW: https://github.com/megous/sjson * * 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 3 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 . */ #include #include #include "sjson.h" enum { TOK_NONE = 0, // no more tokens TOK_OBJ_START, TOK_OBJ_END, TOK_ARRAY_START, TOK_ARRAY_END, TOK_COLON, TOK_COMMA, TOK_STRING, TOK_NOESC_STRING, TOK_NUMBER, TOK_FALSE, TOK_TRUE, TOK_NULL, TOK_INVALID }; /*!re2c re2c:define:YYCTYPE = "guchar"; re2c:define:YYCURSOR = c; re2c:define:YYMARKER = m; re2c:yyfill:enable = 0; re2c:yych:conversion = 1; re2c:indent:top = 1; WS = [ \t\n\r]+; INT = ("0" | [1-9] [0-9]*); MINUS = "-"; FRAC = ("." [0-9]+); EXP = [eE] [+-]? [0-9]+; NUMBER = MINUS? INT FRAC? EXP?; CHAR = [^\\"\000]; CTL = "\\" ["\\/bfnrt]; UNICODE = "\\u" [0-9a-fA-F]{4}; STRING = "\"" (CHAR|CTL|UNICODE)* "\""; NOESC_STRING = "\"" (CHAR)* "\""; IDENT = [A-Za-z_-][a-zA-Z0-9_-]*; */ static gint s_json_get_token(const gchar* json, const gchar** start, const gchar** end) { g_return_val_if_fail(json != NULL, FALSE); const guchar* c = (const guchar*)json; const guchar* m = NULL; const guchar* s; gint token; while (TRUE) { s = c; /*!re2c WS { continue; } "{" { token = TOK_OBJ_START; goto done; } "}" { token = TOK_OBJ_END; goto done; } "[" { token = TOK_ARRAY_START; goto done; } "]" { token = TOK_ARRAY_END; goto done; } NOESC_STRING { token = TOK_NOESC_STRING; goto done; } STRING { token = TOK_STRING; goto done; } ":" { token = TOK_COLON; goto done; } "," { token = TOK_COMMA; goto done; } NUMBER { token = TOK_NUMBER; goto done; } "true" { token = TOK_TRUE; goto done; } "false" { token = TOK_FALSE; goto done; } "null" { token = TOK_NULL; goto done; } [\000] { return TOK_NONE; } . | "\n" { return TOK_INVALID; } */ } done: if (start) *start = s; if (end) *end = c; return token; } static SJsonType token_to_type(gint token) { switch (token) { case TOK_NONE : return S_JSON_TYPE_NONE; case TOK_OBJ_START : return S_JSON_TYPE_OBJECT; case TOK_ARRAY_START : return S_JSON_TYPE_ARRAY; case TOK_STRING : return S_JSON_TYPE_STRING; case TOK_NOESC_STRING: return S_JSON_TYPE_STRING; case TOK_NUMBER : return S_JSON_TYPE_NUMBER; case TOK_FALSE : return S_JSON_TYPE_BOOL; case TOK_TRUE : return S_JSON_TYPE_BOOL; case TOK_NULL : return S_JSON_TYPE_NULL; default : return S_JSON_TYPE_INVALID; } } // public api static gboolean s_json_is_valid_inner(const gchar* json, const gchar** end) { const gchar* next; gint token; g_return_val_if_fail(json != NULL, FALSE); token = s_json_get_token(json, NULL, &next); if (token == TOK_ARRAY_START) { const gchar* array_elem = next; const gchar* array_next = NULL; gboolean expect_comma = FALSE; while (TRUE) { // check end of array token = s_json_get_token(array_elem, NULL, &array_next); if (token == TOK_ARRAY_END) { if (end) *end = array_next; return TRUE; } if (expect_comma) { if (token == TOK_COMMA) array_elem = array_next; // skip comma else return FALSE; } // check element if (!s_json_is_valid_inner(array_elem, &array_elem)) return FALSE; expect_comma = TRUE; } } else if (token == TOK_OBJ_START) { const gchar* obj_next = next; gboolean expect_comma = FALSE; while (TRUE) { // check end of object token = s_json_get_token(obj_next, NULL, &obj_next); if (token == TOK_OBJ_END) { if (end) *end = obj_next; return TRUE; } // eat comma if (expect_comma) { if (token != TOK_COMMA) return FALSE; token = s_json_get_token(obj_next, NULL, &obj_next); } // check member name and colon if (token != TOK_STRING && token != TOK_NOESC_STRING) return FALSE; token = s_json_get_token(obj_next, NULL, &obj_next); if (token != TOK_COLON) return FALSE; // check member value if (!s_json_is_valid_inner(obj_next, &obj_next)) return FALSE; expect_comma = TRUE; } } else if (token == TOK_STRING || token == TOK_NOESC_STRING || token == TOK_NUMBER || token == TOK_FALSE || token == TOK_TRUE || token == TOK_NULL) { if (end) *end = next; return TRUE; } return FALSE; } gboolean s_json_is_valid(const gchar* json) { const gchar* next; g_return_val_if_fail(json != NULL, FALSE); return s_json_is_valid_inner(json, &next) && s_json_get_token(next, NULL, NULL) == TOK_NONE; } gchar* s_json_get(const gchar* json) { const gchar* next; const gchar* start = NULL; g_return_val_if_fail(json != NULL, NULL); if (s_json_is_valid_inner(json, &next)) { s_json_get_token(json, &start, NULL); // must set start return g_strndup(start, next - start); } return NULL; } SJsonType s_json_get_type(const gchar* json) { g_return_val_if_fail(json != NULL, S_JSON_TYPE_INVALID); return token_to_type(s_json_get_token(json, NULL, NULL)); } const gchar* s_json_get_element_first(const gchar* json) { const gchar* next_elem; gint token; g_return_val_if_fail(json != NULL, NULL); token = s_json_get_token(json, NULL, &next_elem); if (token != TOK_ARRAY_START) return NULL; if (s_json_get_token(next_elem, NULL, NULL) == TOK_ARRAY_END) return NULL; return next_elem; } const gchar* s_json_get_element_next(const gchar* iter) { const gchar* next_elem; gint token; g_return_val_if_fail(iter != NULL, NULL); if (!s_json_is_valid_inner(iter, &next_elem)) return NULL; token = s_json_get_token(next_elem, NULL, &next_elem); if (token != TOK_COMMA) return NULL; return next_elem; } const gchar* s_json_get_element(const gchar* json, guint index) { guint current_index = 0; g_return_val_if_fail(json != NULL, NULL); S_JSON_FOREACH_ELEMENT(json, elem) if (current_index == index) return elem; current_index++; S_JSON_FOREACH_END() return NULL; } gchar** s_json_get_elements(const gchar* json) { GPtrArray* arr; g_return_val_if_fail(json != NULL, NULL); arr = g_ptr_array_sized_new(64); S_JSON_FOREACH_ELEMENT(json, elem) g_ptr_array_add(arr, (gchar*)elem); S_JSON_FOREACH_END() g_ptr_array_add(arr, NULL); return (gchar**)g_ptr_array_free(arr, FALSE); } const gchar* s_json_get_member_first(const gchar* json, const gchar** value) { const gchar* key; const gchar* colon; const gchar* val; gint token; g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(value != NULL, NULL); if (s_json_get_token(json, NULL, &key) != TOK_OBJ_START) return NULL; token = s_json_get_token(key, NULL, &colon); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (s_json_get_token(colon, NULL, &val) != TOK_COLON) return NULL; *value = val; return key; } const gchar* s_json_get_member_next(const gchar** value) { const gchar* comma; const gchar* key; const gchar* colon; const gchar* val; gint token; g_return_val_if_fail(value != NULL && *value != NULL, NULL); if (!s_json_is_valid_inner(*value, &comma)) return NULL; if (s_json_get_token(comma, NULL, &key) != TOK_COMMA) return NULL; token = s_json_get_token(key, NULL, &colon); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (s_json_get_token(colon, NULL, &val) != TOK_COLON) return NULL; *value = val; return key; } const gchar* s_json_get_member(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); S_JSON_FOREACH_MEMBER(json, key, value) if (s_json_string_match(key, name)) return value; S_JSON_FOREACH_END() return NULL; } gchar* s_json_get_string(const gchar* json) { const gchar* start; const gchar* end; gint token; g_return_val_if_fail(json != NULL, NULL); token = s_json_get_token(json, &start, &end); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (token == TOK_NOESC_STRING) return g_strndup(start + 1, (end - start) - 2); GString* str = g_string_sized_new(end - start); const guchar* c = (const guchar*)start + 1; const guchar* m = NULL; const guchar* s; while (TRUE) { s = c; /*!re2c CHAR+ { g_string_append_len(str, s, c - s); continue; } CTL { gchar ch = (gchar)s[1]; if (ch == 'b') g_string_append_c(str, '\b'); else if (ch == 'n') g_string_append_c(str, '\n'); else if (ch == 'r') g_string_append_c(str, '\r'); else if (ch == 't') g_string_append_c(str, '\t'); else if (ch == 'f') g_string_append_c(str, '\f'); else g_string_append_c(str, ch); continue; } UNICODE { guint ch = 0; sscanf(s + 2, "%4x", &ch); g_string_append_unichar(str, ch); continue; } "\"" { return g_string_free(str, FALSE); } . | "\n" | [\000] { g_assert_not_reached(); } */ } return NULL; } gint64 s_json_get_int(const gchar* json, gint64 fallback) { const gchar* start; const gchar* end; g_return_val_if_fail(json != NULL, fallback); if (s_json_get_token(json, &start, &end) != TOK_NUMBER) return fallback; gchar* str = g_alloca(end - start + 1); memcpy(str, start, end - start); str[end - start] = 0; gint64 v = fallback; sscanf(str, "%" G_GINT64_FORMAT, &v); return v; } gdouble s_json_get_double(const gchar* json, gdouble fallback) { const gchar* start; const gchar* end; g_return_val_if_fail(json != NULL, fallback); if (s_json_get_token(json, &start, &end) != TOK_NUMBER) return fallback; gchar* str = g_alloca(end - start + 1); memcpy(str, start, end - start); str[end - start] = 0; gdouble v = fallback; sscanf(str, "%lf", &v); return v; } gboolean s_json_get_bool(const gchar* json) { g_return_val_if_fail(json != NULL, FALSE); gint token = s_json_get_token(json, NULL, NULL); if (token == TOK_TRUE) return TRUE; return FALSE; } gboolean s_json_is_null(const gchar* json) { g_return_val_if_fail(json != NULL, FALSE); gint token = s_json_get_token(json, NULL, NULL); if (token == TOK_NULL) return TRUE; return FALSE; } gboolean s_json_string_match(const gchar* json_str, const gchar* c_str) { const gchar *start, *end; gint token; g_return_val_if_fail(json_str != NULL, FALSE); g_return_val_if_fail(c_str != NULL, FALSE); token = s_json_get_token(json_str, &start, &end); if (token == TOK_NOESC_STRING) { // fast path gsize json_len = ((end - start) - 2); gint rs = strncmp(start + 1, c_str, json_len); return rs == 0 ? strlen(c_str) == json_len : FALSE; } else if (token == TOK_STRING) { // slow path gchar* str = s_json_get_string(json_str); gint rs = strcmp(str, c_str); g_free(str); return rs == 0; } else { return FALSE; } } // helpers gchar* s_json_get_member_string(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_string(member); return NULL; } gint64 s_json_get_member_int(const gchar* json, const gchar* name, gint64 fallback) { g_return_val_if_fail(json != NULL, fallback); g_return_val_if_fail(name != NULL, fallback); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_int(member, fallback); return fallback; } gdouble s_json_get_member_double(const gchar* json, const gchar* name, gdouble fallback) { g_return_val_if_fail(json != NULL, fallback); g_return_val_if_fail(name != NULL, fallback); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_double(member, fallback); return fallback; } gboolean s_json_get_member_bool(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_bool(member); return FALSE; } gboolean s_json_member_is_null(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); const gchar* member = s_json_get_member(json, name); if (member) return s_json_is_null(member); return TRUE; } // generator api struct _SJsonGen { GString* str; }; SJsonGen* s_json_gen_new(void) { SJsonGen* gen = g_slice_new(SJsonGen); gen->str = g_string_sized_new(512); return gen; } static void strip_comma(SJsonGen* json) { if (json->str->len > 0) { if (json->str->str[json->str->len - 1] == ',') g_string_truncate(json->str, json->str->len - 1); } } void s_json_gen_start_object(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append_c(json->str, '{'); } void s_json_gen_end_object(SJsonGen* json) { g_return_if_fail(json != NULL); strip_comma(json); g_string_append(json->str, "},"); } void s_json_gen_start_array(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append_c(json->str, '['); } void s_json_gen_end_array(SJsonGen* json) { g_return_if_fail(json != NULL); strip_comma(json); g_string_append(json->str, "],"); } static void escape_string(GString* str, const gchar* v) { g_return_if_fail(str != NULL); g_return_if_fail(v != NULL); const guchar* c = (const guchar*)v; const guchar* m = NULL; const guchar* s; g_string_append_c(str, '"'); while (TRUE) { s = c; /*!re2c [\n] { g_string_append(str, "\\n"); continue; } [\r] { g_string_append(str, "\\r"); continue; } [\b] { g_string_append(str, "\\b"); continue; } [\t] { g_string_append(str, "\\t"); continue; } [\f] { g_string_append(str, "\\f"); continue; } [\"] { g_string_append(str, "\\\""); continue; } [\\] { g_string_append(str, "\\\\"); continue; } [\000] { break; } [^\n\r\b\t"\\\000]+ { g_string_append_len(str, (gchar*)s, c - s); continue; } */ } g_string_append_c(str, '"'); } void s_json_gen_build(SJsonGen* json, const gchar* fmt, ...) { va_list args; gchar* v; g_return_if_fail(json != NULL); g_return_if_fail(fmt != NULL); va_start(args, fmt); v = s_json_buildv(fmt, args); va_end(args); s_json_gen_json(json, v); g_free(v); } void s_json_gen_json(SJsonGen* json, const gchar* v) { g_return_if_fail(json != NULL); if (v) { g_string_append(json->str, v); g_string_append_c(json->str, ','); } else s_json_gen_null(json); } void s_json_gen_string(SJsonGen* json, const gchar* v) { g_return_if_fail(json != NULL); if (v) { escape_string(json->str, v); g_string_append_c(json->str, ','); } else s_json_gen_null(json); } void s_json_gen_int(SJsonGen* json, gint64 v) { g_return_if_fail(json != NULL); g_string_append_printf(json->str, "%" G_GINT64_FORMAT ",", v); } void s_json_gen_double(SJsonGen* json, gdouble v) { g_return_if_fail(json != NULL); g_string_append_printf(json->str, "%lg,", v); } void s_json_gen_bool(SJsonGen* json, gboolean v) { g_return_if_fail(json != NULL); g_string_append(json->str, v ? "true," : "false,"); } void s_json_gen_null(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append(json->str, "null,"); } void s_json_gen_member_build(SJsonGen* json, const gchar* name, const gchar* fmt, ...) { va_list args; gchar* v; g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); g_return_if_fail(fmt != NULL); va_start(args, fmt); v = s_json_buildv(fmt, args); va_end(args); s_json_gen_member_json(json, name, v); g_free(v); } void s_json_gen_member_json(SJsonGen* json, const gchar* name, const gchar* v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_json(json, v); } void s_json_gen_member_string(SJsonGen* json, const gchar* name, const gchar* v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_string(json, v); } void s_json_gen_member_int(SJsonGen* json, const gchar* name, gint64 v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_int(json, v); } void s_json_gen_member_double(SJsonGen* json, const gchar* name, gdouble v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_double(json, v); } void s_json_gen_member_bool(SJsonGen* json, const gchar* name, gboolean v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_bool(json, v); } void s_json_gen_member_null(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_null(json); } void s_json_gen_member_array(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_start_array(json); } void s_json_gen_member_object(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_start_object(json); } gchar* s_json_gen_done(SJsonGen* json) { g_return_val_if_fail(json != NULL, NULL); strip_comma(json); gchar* str = g_string_free(json->str, FALSE); g_slice_free(SJsonGen, json); if (s_json_is_valid(str)) return str; g_free(str); return NULL; } // build // formats: // - % ? format // format: sidbnjSJ gchar* s_json_buildv(const gchar* format, va_list args) { g_return_val_if_fail(format != NULL, NULL); GString* str = g_string_sized_new(strlen(format)); const guchar* c = (const guchar*)format; const guchar* m = NULL; const guchar* s; #define IS_NULLABLE (s[1] == '?') #define FMT_FULL(arg_type, code_format, code_leave) \ gboolean is_null = (IS_NULLABLE ? va_arg(args, gboolean) : FALSE); \ gchar fmt = s[IS_NULLABLE ? 2 : 1]; \ arg_type arg = va_arg(args, arg_type); \ if (is_null) { \ g_string_append(str, "null"); \ } else { \ code_format \ } \ code_leave \ continue; #define FMT(arg_type, code) FMT_FULL(arg_type, code, ) while (TRUE) { s = c; /*!re2c (WS | "{" | "}" | "[" | "]" | NOESC_STRING | STRING | ":" | "," | NUMBER | "true" | "false" | "null")+ { g_string_append_len(str, s, c - s); continue; } IDENT { g_string_append_c(str, '"'); g_string_append_len(str, s, c - s); g_string_append_c(str, '"'); continue; } FMT = "%" "?"?; FMT [sS] { FMT_FULL(gchar*, if (arg) escape_string(str, arg); else g_string_append(str, "null");, if (fmt == 'S') g_free(arg);) } FMT [jJ] { FMT_FULL(gchar*, if (arg) { const gchar* end; if (s_json_is_valid_inner(arg, &end)) g_string_append_len(str, arg, end - arg); else g_string_append(str, "null"); } else { g_string_append(str, "null"); }, if (fmt == 'J') g_free(arg);) } FMT [i] { FMT(gint64, g_string_append_printf(str, "%" G_GINT64_FORMAT, arg);) } FMT [d] { FMT(gdouble, g_string_append_printf(str, "%lg" , arg);) } FMT [b] { FMT(gboolean, g_string_append(str, arg ? "true" : "false");) } [\000] { break; } . | "\n" { goto err; } */ } if (s_json_is_valid(str->str)) return g_string_free(str, FALSE); err: g_string_free(str, TRUE); return NULL; } gchar* s_json_build(const gchar* format, ...) { va_list args; gchar* json; g_return_val_if_fail(format != NULL, NULL); va_start(args, format); json = s_json_buildv(format, args); va_end(args); return json; } gchar* s_json_pretty(const gchar* json) { const gchar* start; const gchar* end; GString *str, *ind; gchar* json_valid; g_return_val_if_fail(json != NULL, NULL); // validate and isolate json_valid = s_json_get(json); if (!json_valid) return NULL; start = json_valid; str = g_string_sized_new(strlen(json) * 2); ind = g_string_sized_new(50); #define PUSH_INDENT() g_string_append_c(ind, '\t') #define POP_INDENT() g_string_truncate(ind, MAX(ind->len - 1, 0)) #define INDENT() g_string_append_len(str, ind->str, ind->len) gint prev_token = TOK_NONE; while (TRUE) { gint token = s_json_get_token(start, &start, &end); if (token == TOK_NONE) break; gint next_token = s_json_get_token(end, NULL, NULL); if ((token == TOK_OBJ_END && prev_token != TOK_OBJ_START) || (token == TOK_ARRAY_END && prev_token != TOK_ARRAY_START && prev_token != TOK_OBJ_END)) { g_string_append_c(str, '\n'); POP_INDENT(); INDENT(); } g_string_append_len(str, start, end - start); if ((token == TOK_OBJ_START && next_token != TOK_OBJ_END) || (token == TOK_ARRAY_START && next_token != TOK_OBJ_START && next_token != TOK_ARRAY_END)) { g_string_append_c(str, '\n'); PUSH_INDENT(); INDENT(); } else if (token == TOK_COMMA) { if ((prev_token == TOK_OBJ_END && next_token == TOK_OBJ_START) || (prev_token == TOK_ARRAY_END && next_token == TOK_ARRAY_START)) { g_string_append_c(str, ' '); } else { g_string_append_c(str, '\n'); INDENT(); } } else if (token == TOK_COLON) { g_string_append_c(str, ' '); } prev_token = token; start = end; } g_string_free(ind, TRUE); g_free(json_valid); return g_string_free(str, FALSE); } const gchar* s_json_path(const gchar* json, const gchar* path) { const guchar* c = (const guchar*)path; const guchar* m = NULL; const guchar* s; const gchar* cur_node = json; g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); #define CHECK_TYPE(type) \ if (cur_node && s_json_get_type(cur_node) == type) \ return cur_node; \ if ((!cur_node || s_json_get_type(cur_node) == S_JSON_TYPE_NULL) && s[0] == '?') \ return "null"; \ return NULL; while (TRUE) { s = c; /*!re2c WS { // skip whitespace continue; } [\$] { // root cur_node = json; continue; } [.] IDENT { if (!cur_node || s_json_get_type(cur_node) != S_JSON_TYPE_OBJECT) return NULL; // zero terminate member name on stack gchar* name = g_alloca((c - s)); memcpy(name, s + 1, c - (s + 1)); name[c - (s + 1)] = '\0'; cur_node = s_json_get_member(cur_node, name); continue; } "[" INT "]" { if (!cur_node || s_json_get_type(cur_node) != S_JSON_TYPE_ARRAY) return NULL; guint index; sscanf(s + 1, "%u", &index); cur_node = s_json_get_element(cur_node, index); continue; } TYPE = [!?]; TYPE "n" "umber"? { CHECK_TYPE(S_JSON_TYPE_NUMBER) } TYPE "s" "tring"? { CHECK_TYPE(S_JSON_TYPE_STRING) } TYPE "i" "nteger"? { if (cur_node && s_json_get_type(cur_node) == S_JSON_TYPE_NUMBER) { const gchar *int_start, *int_end, *i; g_assert(s_json_get_token(cur_node, &int_start, &int_end) == TOK_NUMBER); for (i = int_start; i < int_end; i++) if (*i > '9' || *i < '0') return NULL; return cur_node; } if ((!cur_node || s_json_get_type(cur_node) == S_JSON_TYPE_NULL) && s[0] == '?') return "null"; return NULL; } TYPE "b" "oolean"? { CHECK_TYPE(S_JSON_TYPE_BOOL) } TYPE "o" "bject"? { CHECK_TYPE(S_JSON_TYPE_OBJECT) } TYPE "a" "rray"? { CHECK_TYPE(S_JSON_TYPE_ARRAY) } [\000] { break; } . | "\n" { return NULL; } */ } return cur_node; } gchar* s_json_compact(const gchar* json) { g_return_val_if_fail(json != NULL, NULL); GString* str = g_string_sized_new(strlen(json)); const guchar* c = (const guchar*)json; const guchar* m = NULL; const guchar* s; while (TRUE) { s = c; /*!re2c ("{" | "}" | "[" | "]" | NOESC_STRING | STRING | ":" | "," | NUMBER | "true" | "false" | "null")+ { g_string_append_len(str, s, c - s); continue; } WS { continue; } [\000] { break; } . | "\n" { goto err; } */ } return g_string_free(str, FALSE); err: g_string_free(str, TRUE); return NULL; } megatools-1.9.98/lib/alloc.h0000644000175000001440000000454213006625442012551 00000000000000#ifndef __ALLOC_H__ #define __ALLOC_H__ #include G_BEGIN_DECLS #define DEFINE_CLEANUP_FUNCTION_FULL(Type, func, null_safe, args...) \ static inline void __cleanup_##func (void *v) \ { \ if (null_safe || *(Type*)v) \ func (*(Type*)v, ##args); \ } #define DEFINE_CLEANUP_FUNCTION(Type, func) \ DEFINE_CLEANUP_FUNCTION_FULL(Type, func, TRUE) #define DEFINE_CLEANUP_FUNCTION_NULL(Type, func) \ DEFINE_CLEANUP_FUNCTION_FULL(Type, func, FALSE) #define CLEANUP(func) \ __attribute__ ((cleanup(__cleanup_##func))) DEFINE_CLEANUP_FUNCTION(void*, g_free) #define gc_free CLEANUP(g_free) DEFINE_CLEANUP_FUNCTION(char**, g_strfreev) #define gc_strfreev CLEANUP(g_strfreev) DEFINE_CLEANUP_FUNCTION_NULL(GError*, g_error_free) #define gc_error_free CLEANUP(g_error_free) DEFINE_CLEANUP_FUNCTION_NULL(GArray*, g_array_unref) #define gc_array_unref CLEANUP(g_array_unref) DEFINE_CLEANUP_FUNCTION_NULL(GPtrArray*, g_ptr_array_unref) #define gc_ptr_array_unref CLEANUP(g_ptr_array_unref) DEFINE_CLEANUP_FUNCTION_NULL(GByteArray*, g_byte_array_unref) #define gc_byte_array_unref CLEANUP(g_byte_array_unref) DEFINE_CLEANUP_FUNCTION_NULL(GHashTable*, g_hash_table_unref) #define gc_hash_table_unref CLEANUP(g_hash_table_unref) DEFINE_CLEANUP_FUNCTION_NULL(GVariant*, g_variant_unref) #define gc_variant_unref CLEANUP(g_variant_unref) DEFINE_CLEANUP_FUNCTION_NULL(GVariantIter*, g_variant_iter_free) #define gc_variant_iter_free CLEANUP(g_variant_iter_free) DEFINE_CLEANUP_FUNCTION_NULL(GVariantBuilder*, g_variant_builder_unref) #define gc_variant_builder_unref CLEANUP(g_variant_builder_unref) DEFINE_CLEANUP_FUNCTION_NULL(GBytes*, g_bytes_unref) #define gc_bytes_unref CLEANUP(g_bytes_unref) DEFINE_CLEANUP_FUNCTION_NULL(GRegex*, g_regex_unref) #define gc_regex_unref CLEANUP(g_regex_unref) DEFINE_CLEANUP_FUNCTION_NULL(GMatchInfo*, g_match_info_unref) #define gc_match_info_unref CLEANUP(g_match_info_unref) DEFINE_CLEANUP_FUNCTION_NULL(GKeyFile*, g_key_file_unref) #define gc_key_file_unref CLEANUP(g_key_file_unref) DEFINE_CLEANUP_FUNCTION_NULL(GChecksum*, g_checksum_free) #define gc_checksum_free CLEANUP(g_checksum_free) DEFINE_CLEANUP_FUNCTION_NULL(GObject*, g_object_unref) #define gc_object_unref CLEANUP(g_object_unref) DEFINE_CLEANUP_FUNCTION_FULL(GString*, g_string_free, FALSE, TRUE) #define gc_string_free CLEANUP(g_string_free) G_END_DECLS #endif megatools-1.9.98/lib/sjson.gen.c0000644000175000001440000026012213006625654013361 00000000000000/* Generated by re2c 0.13.5 on Sat Apr 20 16:07:45 2013 */ #line 1 "sjson.c" /** * sjson - fast string based JSON parser/generator library * Copyright (C) 2013 OndÅ™ej Jirman * * WWW: https://github.com/megous/sjson * * 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 3 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 . */ #include #include #include "sjson.h" enum { TOK_NONE = 0, // no more tokens TOK_OBJ_START, TOK_OBJ_END, TOK_ARRAY_START, TOK_ARRAY_END, TOK_COLON, TOK_COMMA, TOK_STRING, TOK_NOESC_STRING, TOK_NUMBER, TOK_FALSE, TOK_TRUE, TOK_NULL, TOK_INVALID }; #line 66 "sjson.c" static gint s_json_get_token(const gchar* json, const gchar** start, const gchar** end) { g_return_val_if_fail(json != NULL, FALSE); const guchar* c = (const guchar*)json; const guchar* m = NULL; const guchar* s; gint token; while (TRUE) { s = c; #line 63 "sjson.gen.c" { guchar yych; unsigned int yyaccept = 0; yych = (guchar)*c; if (yych <= '9') { if (yych <= ' ') { if (yych <= '\n') { if (yych <= 0x00) goto yy25; if (yych <= 0x08) goto yy27; } else { if (yych == '\r') goto yy2; if (yych <= 0x1F) goto yy27; } } else { if (yych <= ',') { if (yych == '"') goto yy12; if (yych <= '+') goto yy27; goto yy16; } else { if (yych <= '-') goto yy18; if (yych <= '/') goto yy27; if (yych <= '0') goto yy19; goto yy21; } } } else { if (yych <= 'm') { if (yych <= '\\') { if (yych <= ':') goto yy14; if (yych == '[') goto yy8; goto yy27; } else { if (yych <= ']') goto yy10; if (yych == 'f') goto yy23; goto yy27; } } else { if (yych <= 'z') { if (yych <= 'n') goto yy24; if (yych == 't') goto yy22; goto yy27; } else { if (yych <= '{') goto yy4; if (yych == '}') goto yy6; goto yy27; } } } yy2: ++c; yych = (guchar)*c; goto yy66; yy3: #line 82 "sjson.c" { continue; } #line 122 "sjson.gen.c" yy4: ++c; #line 86 "sjson.c" { token = TOK_OBJ_START; goto done; } #line 130 "sjson.gen.c" yy6: ++c; #line 91 "sjson.c" { token = TOK_OBJ_END; goto done; } #line 138 "sjson.gen.c" yy8: ++c; #line 96 "sjson.c" { token = TOK_ARRAY_START; goto done; } #line 146 "sjson.gen.c" yy10: ++c; #line 101 "sjson.c" { token = TOK_ARRAY_END; goto done; } #line 154 "sjson.gen.c" yy12: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych >= 0x01) goto yy53; yy13: #line 150 "sjson.c" { return TOK_INVALID; } #line 164 "sjson.gen.c" yy14: ++c; #line 116 "sjson.c" { token = TOK_COLON; goto done; } #line 172 "sjson.gen.c" yy16: ++c; #line 121 "sjson.c" { token = TOK_COMMA; goto done; } #line 180 "sjson.gen.c" yy18: yych = (guchar)*++c; if (yych <= '/') goto yy13; if (yych <= '0') goto yy51; if (yych <= '9') goto yy42; goto yy13; yy19: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych <= 'D') { if (yych == '.') goto yy44; } else { if (yych <= 'E') goto yy45; if (yych == 'e') goto yy45; } yy20: #line 126 "sjson.c" { token = TOK_NUMBER; goto done; } #line 202 "sjson.gen.c" yy21: yyaccept = 1; yych = (guchar)*(m = ++c); goto yy43; yy22: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych == 'r') goto yy38; goto yy13; yy23: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych == 'a') goto yy33; goto yy13; yy24: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych == 'u') goto yy28; goto yy13; yy25: ++c; #line 146 "sjson.c" { return TOK_NONE; } #line 228 "sjson.gen.c" yy27: yych = (guchar)*++c; goto yy13; yy28: yych = (guchar)*++c; if (yych == 'l') goto yy30; yy29: c = m; if (yyaccept <= 0) { goto yy13; } else { goto yy20; } yy30: yych = (guchar)*++c; if (yych != 'l') goto yy29; ++c; #line 141 "sjson.c" { token = TOK_NULL; goto done; } #line 251 "sjson.gen.c" yy33: yych = (guchar)*++c; if (yych != 'l') goto yy29; yych = (guchar)*++c; if (yych != 's') goto yy29; yych = (guchar)*++c; if (yych != 'e') goto yy29; ++c; #line 136 "sjson.c" { token = TOK_FALSE; goto done; } #line 265 "sjson.gen.c" yy38: yych = (guchar)*++c; if (yych != 'u') goto yy29; yych = (guchar)*++c; if (yych != 'e') goto yy29; ++c; #line 131 "sjson.c" { token = TOK_TRUE; goto done; } #line 277 "sjson.gen.c" yy42: yyaccept = 1; m = ++c; yych = (guchar)*c; yy43: if (yych <= '9') { if (yych == '.') goto yy44; if (yych <= '/') goto yy20; goto yy42; } else { if (yych <= 'E') { if (yych <= 'D') goto yy20; goto yy45; } else { if (yych == 'e') goto yy45; goto yy20; } } yy44: yych = (guchar)*++c; if (yych <= '/') goto yy29; if (yych <= '9') goto yy49; goto yy29; yy45: yych = (guchar)*++c; if (yych <= ',') { if (yych != '+') goto yy29; } else { if (yych <= '-') goto yy46; if (yych <= '/') goto yy29; if (yych <= '9') goto yy47; goto yy29; } yy46: yych = (guchar)*++c; if (yych <= '/') goto yy29; if (yych >= ':') goto yy29; yy47: ++c; yych = (guchar)*c; if (yych <= '/') goto yy20; if (yych <= '9') goto yy47; goto yy20; yy49: yyaccept = 1; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '/') goto yy20; if (yych <= '9') goto yy49; goto yy20; } else { if (yych <= 'E') goto yy45; if (yych == 'e') goto yy45; goto yy20; } yy51: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych <= 'D') { if (yych == '.') goto yy44; goto yy20; } else { if (yych <= 'E') goto yy45; if (yych == 'e') goto yy45; goto yy20; } yy52: ++c; yych = (guchar)*c; yy53: if (yych <= '"') { if (yych <= 0x00) goto yy29; if (yych <= '!') goto yy52; goto yy55; } else { if (yych != '\\') goto yy52; } yy54: ++c; yych = (guchar)*c; if (yych <= 'e') { if (yych <= '/') { if (yych == '"') goto yy58; if (yych <= '.') goto yy29; goto yy58; } else { if (yych <= '\\') { if (yych <= '[') goto yy29; goto yy58; } else { if (yych == 'b') goto yy58; goto yy29; } } } else { if (yych <= 'q') { if (yych <= 'f') goto yy58; if (yych == 'n') goto yy58; goto yy29; } else { if (yych <= 's') { if (yych <= 'r') goto yy58; goto yy29; } else { if (yych <= 't') goto yy58; if (yych <= 'u') goto yy57; goto yy29; } } } yy55: ++c; #line 106 "sjson.c" { token = TOK_NOESC_STRING; goto done; } #line 396 "sjson.gen.c" yy57: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy29; if (yych <= '9') goto yy62; goto yy29; } else { if (yych <= 'F') goto yy62; if (yych <= '`') goto yy29; if (yych <= 'f') goto yy62; goto yy29; } yy58: ++c; yych = (guchar)*c; if (yych <= '"') { if (yych <= 0x00) goto yy29; if (yych <= '!') goto yy58; } else { if (yych == '\\') goto yy54; goto yy58; } ++c; #line 111 "sjson.c" { token = TOK_STRING; goto done; } #line 426 "sjson.gen.c" yy62: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy29; if (yych >= ':') goto yy29; } else { if (yych <= 'F') goto yy63; if (yych <= '`') goto yy29; if (yych >= 'g') goto yy29; } yy63: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy29; if (yych >= ':') goto yy29; } else { if (yych <= 'F') goto yy64; if (yych <= '`') goto yy29; if (yych >= 'g') goto yy29; } yy64: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy29; if (yych <= '9') goto yy58; goto yy29; } else { if (yych <= 'F') goto yy58; if (yych <= '`') goto yy29; if (yych <= 'f') goto yy58; goto yy29; } yy65: ++c; yych = (guchar)*c; yy66: if (yych <= '\f') { if (yych <= 0x08) goto yy3; if (yych <= '\n') goto yy65; goto yy3; } else { if (yych <= '\r') goto yy65; if (yych == ' ') goto yy65; goto yy3; } } #line 153 "sjson.c" } done: if (start) *start = s; if (end) *end = c; return token; } static SJsonType token_to_type(gint token) { switch (token) { case TOK_NONE : return S_JSON_TYPE_NONE; case TOK_OBJ_START : return S_JSON_TYPE_OBJECT; case TOK_ARRAY_START : return S_JSON_TYPE_ARRAY; case TOK_STRING : return S_JSON_TYPE_STRING; case TOK_NOESC_STRING: return S_JSON_TYPE_STRING; case TOK_NUMBER : return S_JSON_TYPE_NUMBER; case TOK_FALSE : return S_JSON_TYPE_BOOL; case TOK_TRUE : return S_JSON_TYPE_BOOL; case TOK_NULL : return S_JSON_TYPE_NULL; default : return S_JSON_TYPE_INVALID; } } // public api static gboolean s_json_is_valid_inner(const gchar* json, const gchar** end) { const gchar* next; gint token; g_return_val_if_fail(json != NULL, FALSE); token = s_json_get_token(json, NULL, &next); if (token == TOK_ARRAY_START) { const gchar* array_elem = next; const gchar* array_next = NULL; gboolean expect_comma = FALSE; while (TRUE) { // check end of array token = s_json_get_token(array_elem, NULL, &array_next); if (token == TOK_ARRAY_END) { if (end) *end = array_next; return TRUE; } if (expect_comma) { if (token == TOK_COMMA) array_elem = array_next; // skip comma else return FALSE; } // check element if (!s_json_is_valid_inner(array_elem, &array_elem)) return FALSE; expect_comma = TRUE; } } else if (token == TOK_OBJ_START) { const gchar* obj_next = next; gboolean expect_comma = FALSE; while (TRUE) { // check end of object token = s_json_get_token(obj_next, NULL, &obj_next); if (token == TOK_OBJ_END) { if (end) *end = obj_next; return TRUE; } // eat comma if (expect_comma) { if (token != TOK_COMMA) return FALSE; token = s_json_get_token(obj_next, NULL, &obj_next); } // check member name and colon if (token != TOK_STRING && token != TOK_NOESC_STRING) return FALSE; token = s_json_get_token(obj_next, NULL, &obj_next); if (token != TOK_COLON) return FALSE; // check member value if (!s_json_is_valid_inner(obj_next, &obj_next)) return FALSE; expect_comma = TRUE; } } else if (token == TOK_STRING || token == TOK_NOESC_STRING || token == TOK_NUMBER || token == TOK_FALSE || token == TOK_TRUE || token == TOK_NULL) { if (end) *end = next; return TRUE; } return FALSE; } gboolean s_json_is_valid(const gchar* json) { const gchar* next; g_return_val_if_fail(json != NULL, FALSE); return s_json_is_valid_inner(json, &next) && s_json_get_token(next, NULL, NULL) == TOK_NONE; } gchar* s_json_get(const gchar* json) { const gchar* next; const gchar* start = NULL; g_return_val_if_fail(json != NULL, NULL); if (s_json_is_valid_inner(json, &next)) { s_json_get_token(json, &start, NULL); // must set start return g_strndup(start, next - start); } return NULL; } SJsonType s_json_get_type(const gchar* json) { g_return_val_if_fail(json != NULL, S_JSON_TYPE_INVALID); return token_to_type(s_json_get_token(json, NULL, NULL)); } const gchar* s_json_get_element_first(const gchar* json) { const gchar* next_elem; gint token; g_return_val_if_fail(json != NULL, NULL); token = s_json_get_token(json, NULL, &next_elem); if (token != TOK_ARRAY_START) return NULL; if (s_json_get_token(next_elem, NULL, NULL) == TOK_ARRAY_END) return NULL; return next_elem; } const gchar* s_json_get_element_next(const gchar* iter) { const gchar* next_elem; gint token; g_return_val_if_fail(iter != NULL, NULL); if (!s_json_is_valid_inner(iter, &next_elem)) return NULL; token = s_json_get_token(next_elem, NULL, &next_elem); if (token != TOK_COMMA) return NULL; return next_elem; } const gchar* s_json_get_element(const gchar* json, guint index) { guint current_index = 0; g_return_val_if_fail(json != NULL, NULL); S_JSON_FOREACH_ELEMENT(json, elem) if (current_index == index) return elem; current_index++; S_JSON_FOREACH_END() return NULL; } gchar** s_json_get_elements(const gchar* json) { GPtrArray* arr; g_return_val_if_fail(json != NULL, NULL); arr = g_ptr_array_sized_new(64); S_JSON_FOREACH_ELEMENT(json, elem) g_ptr_array_add(arr, (gchar*)elem); S_JSON_FOREACH_END() g_ptr_array_add(arr, NULL); return (gchar**)g_ptr_array_free(arr, FALSE); } const gchar* s_json_get_member_first(const gchar* json, const gchar** value) { const gchar* key; const gchar* colon; const gchar* val; gint token; g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(value != NULL, NULL); if (s_json_get_token(json, NULL, &key) != TOK_OBJ_START) return NULL; token = s_json_get_token(key, NULL, &colon); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (s_json_get_token(colon, NULL, &val) != TOK_COLON) return NULL; *value = val; return key; } const gchar* s_json_get_member_next(const gchar** value) { const gchar* comma; const gchar* key; const gchar* colon; const gchar* val; gint token; g_return_val_if_fail(value != NULL && *value != NULL, NULL); if (!s_json_is_valid_inner(*value, &comma)) return NULL; if (s_json_get_token(comma, NULL, &key) != TOK_COMMA) return NULL; token = s_json_get_token(key, NULL, &colon); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (s_json_get_token(colon, NULL, &val) != TOK_COLON) return NULL; *value = val; return key; } const gchar* s_json_get_member(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); S_JSON_FOREACH_MEMBER(json, key, value) if (s_json_string_match(key, name)) return value; S_JSON_FOREACH_END() return NULL; } gchar* s_json_get_string(const gchar* json) { const gchar* start; const gchar* end; gint token; g_return_val_if_fail(json != NULL, NULL); token = s_json_get_token(json, &start, &end); if (token != TOK_STRING && token != TOK_NOESC_STRING) return NULL; if (token == TOK_NOESC_STRING) return g_strndup(start + 1, (end - start) - 2); GString* str = g_string_sized_new(end - start); const guchar* c = (const guchar*)start + 1; const guchar* m = NULL; const guchar* s; while (TRUE) { s = c; #line 791 "sjson.gen.c" { guchar yych; yych = (guchar)*c; if (yych <= '"') { if (yych <= 0x00) goto yy75; if (yych >= '"') goto yy73; } else { if (yych == '\\') goto yy71; } ++c; yych = (guchar)*c; goto yy86; yy70: #line 467 "sjson.c" { g_string_append_len(str, s, c - s); continue; } #line 810 "sjson.gen.c" yy71: yych = (guchar)*(m = ++c); if (yych <= 'e') { if (yych <= '/') { if (yych == '"') goto yy78; if (yych >= '/') goto yy78; } else { if (yych <= '\\') { if (yych >= '\\') goto yy78; } else { if (yych == 'b') goto yy78; } } } else { if (yych <= 'q') { if (yych <= 'f') goto yy78; if (yych == 'n') goto yy78; } else { if (yych <= 's') { if (yych <= 'r') goto yy78; } else { if (yych <= 't') goto yy78; if (yych <= 'u') goto yy76; } } } yy72: #line 502 "sjson.c" { g_assert_not_reached(); } #line 842 "sjson.gen.c" yy73: ++c; #line 498 "sjson.c" { return g_string_free(str, FALSE); } #line 849 "sjson.gen.c" yy75: yych = (guchar)*++c; goto yy72; yy76: yych = (guchar)*++c; if (yych <= '@') { if (yych <= '/') goto yy77; if (yych <= '9') goto yy80; } else { if (yych <= 'F') goto yy80; if (yych <= '`') goto yy77; if (yych <= 'f') goto yy80; } yy77: c = m; goto yy72; yy78: ++c; #line 472 "sjson.c" { gchar ch = (gchar)s[1]; if (ch == 'b') g_string_append_c(str, '\b'); else if (ch == 'n') g_string_append_c(str, '\n'); else if (ch == 'r') g_string_append_c(str, '\r'); else if (ch == 't') g_string_append_c(str, '\t'); else if (ch == 'f') g_string_append_c(str, '\f'); else g_string_append_c(str, ch); continue; } #line 887 "sjson.gen.c" yy80: yych = (guchar)*++c; if (yych <= '@') { if (yych <= '/') goto yy77; if (yych >= ':') goto yy77; } else { if (yych <= 'F') goto yy81; if (yych <= '`') goto yy77; if (yych >= 'g') goto yy77; } yy81: yych = (guchar)*++c; if (yych <= '@') { if (yych <= '/') goto yy77; if (yych >= ':') goto yy77; } else { if (yych <= 'F') goto yy82; if (yych <= '`') goto yy77; if (yych >= 'g') goto yy77; } yy82: yych = (guchar)*++c; if (yych <= '@') { if (yych <= '/') goto yy77; if (yych >= ':') goto yy77; } else { if (yych <= 'F') goto yy83; if (yych <= '`') goto yy77; if (yych >= 'g') goto yy77; } yy83: ++c; #line 491 "sjson.c" { guint ch = 0; sscanf(s + 2, "%4x", &ch); g_string_append_unichar(str, ch); continue; } #line 927 "sjson.gen.c" yy85: ++c; yych = (guchar)*c; yy86: if (yych <= '"') { if (yych <= 0x00) goto yy70; if (yych <= '!') goto yy85; goto yy70; } else { if (yych == '\\') goto yy70; goto yy85; } } #line 505 "sjson.c" } return NULL; } gint64 s_json_get_int(const gchar* json, gint64 fallback) { const gchar* start; const gchar* end; g_return_val_if_fail(json != NULL, fallback); if (s_json_get_token(json, &start, &end) != TOK_NUMBER) return fallback; gchar* str = g_alloca(end - start + 1); memcpy(str, start, end - start); str[end - start] = 0; gint64 v = fallback; sscanf(str, "%" G_GINT64_FORMAT, &v); return v; } gdouble s_json_get_double(const gchar* json, gdouble fallback) { const gchar* start; const gchar* end; g_return_val_if_fail(json != NULL, fallback); if (s_json_get_token(json, &start, &end) != TOK_NUMBER) return fallback; gchar* str = g_alloca(end - start + 1); memcpy(str, start, end - start); str[end - start] = 0; gdouble v = fallback; sscanf(str, "%lf", &v); return v; } gboolean s_json_get_bool(const gchar* json) { g_return_val_if_fail(json != NULL, FALSE); gint token = s_json_get_token(json, NULL, NULL); if (token == TOK_TRUE) return TRUE; return FALSE; } gboolean s_json_is_null(const gchar* json) { g_return_val_if_fail(json != NULL, FALSE); gint token = s_json_get_token(json, NULL, NULL); if (token == TOK_NULL) return TRUE; return FALSE; } gboolean s_json_string_match(const gchar* json_str, const gchar* c_str) { const gchar *start, *end; gint token; g_return_val_if_fail(json_str != NULL, FALSE); g_return_val_if_fail(c_str != NULL, FALSE); token = s_json_get_token(json_str, &start, &end); if (token == TOK_NOESC_STRING) { // fast path gsize json_len = ((end - start) - 2); gint rs = strncmp(start + 1, c_str, json_len); return rs == 0 ? strlen(c_str) == json_len : FALSE; } else if (token == TOK_STRING) { // slow path gchar* str = s_json_get_string(json_str); gint rs = strcmp(str, c_str); g_free(str); return rs == 0; } else { return FALSE; } } // helpers gchar* s_json_get_member_string(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_string(member); return NULL; } gint64 s_json_get_member_int(const gchar* json, const gchar* name, gint64 fallback) { g_return_val_if_fail(json != NULL, fallback); g_return_val_if_fail(name != NULL, fallback); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_int(member, fallback); return fallback; } gdouble s_json_get_member_double(const gchar* json, const gchar* name, gdouble fallback) { g_return_val_if_fail(json != NULL, fallback); g_return_val_if_fail(name != NULL, fallback); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_double(member, fallback); return fallback; } gboolean s_json_get_member_bool(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); const gchar* member = s_json_get_member(json, name); if (member) return s_json_get_bool(member); return FALSE; } gboolean s_json_member_is_null(const gchar* json, const gchar* name) { g_return_val_if_fail(json != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); const gchar* member = s_json_get_member(json, name); if (member) return s_json_is_null(member); return TRUE; } // generator api struct _SJsonGen { GString* str; }; SJsonGen* s_json_gen_new(void) { SJsonGen* gen = g_slice_new(SJsonGen); gen->str = g_string_sized_new(512); return gen; } static void strip_comma(SJsonGen* json) { if (json->str->len > 0) { if (json->str->str[json->str->len - 1] == ',') g_string_truncate(json->str, json->str->len - 1); } } void s_json_gen_start_object(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append_c(json->str, '{'); } void s_json_gen_end_object(SJsonGen* json) { g_return_if_fail(json != NULL); strip_comma(json); g_string_append(json->str, "},"); } void s_json_gen_start_array(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append_c(json->str, '['); } void s_json_gen_end_array(SJsonGen* json) { g_return_if_fail(json != NULL); strip_comma(json); g_string_append(json->str, "],"); } static void escape_string(GString* str, const gchar* v) { g_return_if_fail(str != NULL); g_return_if_fail(v != NULL); const guchar* c = (const guchar*)v; const guchar* m = NULL; const guchar* s; g_string_append_c(str, '"'); while (TRUE) { s = c; #line 1173 "sjson.gen.c" { guchar yych; yych = (guchar)*c; if (yych <= '\v') { if (yych <= 0x08) { if (yych <= 0x00) goto yy103; if (yych <= 0x07) goto yy105; goto yy93; } else { if (yych <= '\t') goto yy95; if (yych >= '\v') goto yy105; } } else { if (yych <= '!') { if (yych <= '\f') goto yy97; if (yych <= '\r') goto yy91; goto yy105; } else { if (yych <= '"') goto yy99; if (yych == '\\') goto yy101; goto yy105; } } ++c; #line 736 "sjson.c" { g_string_append(str, "\\n"); continue; } #line 1200 "sjson.gen.c" yy91: ++c; #line 737 "sjson.c" { g_string_append(str, "\\r"); continue; } #line 1205 "sjson.gen.c" yy93: ++c; #line 738 "sjson.c" { g_string_append(str, "\\b"); continue; } #line 1210 "sjson.gen.c" yy95: ++c; #line 739 "sjson.c" { g_string_append(str, "\\t"); continue; } #line 1215 "sjson.gen.c" yy97: ++c; if ((yych = (guchar)*c) <= '\r') { if (yych <= 0x07) { if (yych >= 0x01) goto yy105; } else { if (yych <= '\n') goto yy98; if (yych <= '\f') goto yy105; } } else { if (yych <= '"') { if (yych <= '!') goto yy105; } else { if (yych != '\\') goto yy105; } } yy98: #line 740 "sjson.c" { g_string_append(str, "\\f"); continue; } #line 1235 "sjson.gen.c" yy99: ++c; #line 741 "sjson.c" { g_string_append(str, "\\\""); continue; } #line 1240 "sjson.gen.c" yy101: ++c; #line 742 "sjson.c" { g_string_append(str, "\\\\"); continue; } #line 1245 "sjson.gen.c" yy103: ++c; #line 744 "sjson.c" { break; } #line 1252 "sjson.gen.c" yy105: ++c; yych = (guchar)*c; if (yych <= '\r') { if (yych <= 0x07) { if (yych >= 0x01) goto yy105; } else { if (yych <= '\n') goto yy107; if (yych <= '\f') goto yy105; } } else { if (yych <= '"') { if (yych <= '!') goto yy105; } else { if (yych != '\\') goto yy105; } } yy107: #line 748 "sjson.c" { g_string_append_len(str, (gchar*)s, c - s); continue; } #line 1276 "sjson.gen.c" } #line 752 "sjson.c" } g_string_append_c(str, '"'); } void s_json_gen_build(SJsonGen* json, const gchar* fmt, ...) { va_list args; gchar* v; g_return_if_fail(json != NULL); g_return_if_fail(fmt != NULL); va_start(args, fmt); v = s_json_buildv(fmt, args); va_end(args); s_json_gen_json(json, v); g_free(v); } void s_json_gen_json(SJsonGen* json, const gchar* v) { g_return_if_fail(json != NULL); if (v) { g_string_append(json->str, v); g_string_append_c(json->str, ','); } else s_json_gen_null(json); } void s_json_gen_string(SJsonGen* json, const gchar* v) { g_return_if_fail(json != NULL); if (v) { escape_string(json->str, v); g_string_append_c(json->str, ','); } else s_json_gen_null(json); } void s_json_gen_int(SJsonGen* json, gint64 v) { g_return_if_fail(json != NULL); g_string_append_printf(json->str, "%" G_GINT64_FORMAT ",", v); } void s_json_gen_double(SJsonGen* json, gdouble v) { g_return_if_fail(json != NULL); g_string_append_printf(json->str, "%lg,", v); } void s_json_gen_bool(SJsonGen* json, gboolean v) { g_return_if_fail(json != NULL); g_string_append(json->str, v ? "true," : "false,"); } void s_json_gen_null(SJsonGen* json) { g_return_if_fail(json != NULL); g_string_append(json->str, "null,"); } void s_json_gen_member_build(SJsonGen* json, const gchar* name, const gchar* fmt, ...) { va_list args; gchar* v; g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); g_return_if_fail(fmt != NULL); va_start(args, fmt); v = s_json_buildv(fmt, args); va_end(args); s_json_gen_member_json(json, name, v); g_free(v); } void s_json_gen_member_json(SJsonGen* json, const gchar* name, const gchar* v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_json(json, v); } void s_json_gen_member_string(SJsonGen* json, const gchar* name, const gchar* v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_string(json, v); } void s_json_gen_member_int(SJsonGen* json, const gchar* name, gint64 v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_int(json, v); } void s_json_gen_member_double(SJsonGen* json, const gchar* name, gdouble v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_double(json, v); } void s_json_gen_member_bool(SJsonGen* json, const gchar* name, gboolean v) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_bool(json, v); } void s_json_gen_member_null(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_null(json); } void s_json_gen_member_array(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_start_array(json); } void s_json_gen_member_object(SJsonGen* json, const gchar* name) { g_return_if_fail(json != NULL); g_return_if_fail(name != NULL); s_json_gen_string(json, name); strip_comma(json); g_string_append_c(json->str, ':'); s_json_gen_start_object(json); } gchar* s_json_gen_done(SJsonGen* json) { g_return_val_if_fail(json != NULL, NULL); strip_comma(json); gchar* str = g_string_free(json->str, FALSE); g_slice_free(SJsonGen, json); if (s_json_is_valid(str)) return str; g_free(str); return NULL; } // build // formats: // - % ? format // format: sidbnjSJ gchar* s_json_buildv(const gchar* format, va_list args) { g_return_val_if_fail(format != NULL, NULL); GString* str = g_string_sized_new(strlen(format)); const guchar* c = (const guchar*)format; const guchar* m = NULL; const guchar* s; #define IS_NULLABLE (s[1] == '?') #define FMT_FULL(arg_type, code_format, code_leave) \ gboolean is_null = (IS_NULLABLE ? va_arg(args, gboolean) : FALSE); \ gchar fmt = s[IS_NULLABLE ? 2 : 1]; \ arg_type arg = va_arg(args, arg_type); \ if (is_null) { \ g_string_append(str, "null"); \ } else { \ code_format \ } \ code_leave \ continue; #define FMT(arg_type, code) FMT_FULL(arg_type, code, ) while (TRUE) { s = c; #line 1514 "sjson.gen.c" { guchar yych; unsigned int yyaccept = 0; yych = (guchar)*c; if (yych <= ':') { if (yych <= '"') { if (yych <= '\f') { if (yych <= 0x00) goto yy123; if (yych <= 0x08) goto yy125; if (yych >= '\v') goto yy125; } else { if (yych <= 0x1F) { if (yych >= 0x0E) goto yy125; } else { if (yych <= ' ') goto yy110; if (yych <= '!') goto yy125; goto yy112; } } } else { if (yych <= ',') { if (yych == '%') goto yy122; if (yych <= '+') goto yy125; } else { if (yych <= '/') { if (yych <= '-') goto yy114; goto yy125; } else { if (yych <= '0') goto yy116; if (yych <= '9') goto yy117; } } } } else { if (yych <= 'e') { if (yych <= '\\') { if (yych <= '@') goto yy125; if (yych <= 'Z') goto yy121; if (yych >= '\\') goto yy125; } else { if (yych <= '^') { if (yych >= '^') goto yy125; } else { if (yych == '`') goto yy125; goto yy121; } } } else { if (yych <= 't') { if (yych <= 'm') { if (yych <= 'f') goto yy119; goto yy121; } else { if (yych <= 'n') goto yy120; if (yych <= 's') goto yy121; goto yy118; } } else { if (yych <= '{') { if (yych <= 'z') goto yy121; } else { if (yych != '}') goto yy125; } } } } yy110: yyaccept = 0; yych = (guchar)*(m = ++c); goto yy144; yy111: #line 987 "sjson.c" { g_string_append_len(str, s, c - s); continue; } #line 1591 "sjson.gen.c" yy112: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych >= 0x01) goto yy146; yy113: #line 1034 "sjson.c" { goto err; } #line 1601 "sjson.gen.c" yy114: ++c; if ((yych = (guchar)*c) <= '/') goto yy139; if (yych <= '0') goto yy148; if (yych <= '9') goto yy150; goto yy139; yy115: #line 992 "sjson.c" { g_string_append_c(str, '"'); g_string_append_len(str, s, c - s); g_string_append_c(str, '"'); continue; } #line 1616 "sjson.gen.c" yy116: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= 'D') { if (yych == '.') goto yy161; goto yy144; } else { if (yych <= 'E') goto yy163; if (yych == 'e') goto yy163; goto yy144; } yy117: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= '0') { if (yych == '.') goto yy161; if (yych <= '/') goto yy144; goto yy181; } else { if (yych <= 'E') { if (yych <= 'D') goto yy144; goto yy163; } else { if (yych == 'e') goto yy163; goto yy144; } } yy118: yych = (guchar)*++c; if (yych == 'r') goto yy158; goto yy139; yy119: yych = (guchar)*++c; if (yych == 'a') goto yy155; goto yy139; yy120: yych = (guchar)*++c; if (yych == 'u') goto yy140; goto yy139; yy121: yych = (guchar)*++c; goto yy139; yy122: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych <= 'b') { if (yych <= 'J') { if (yych == '?') goto yy126; if (yych <= 'I') goto yy113; goto yy134; } else { if (yych == 'S') goto yy136; if (yych <= 'a') goto yy113; goto yy128; } } else { if (yych <= 'i') { if (yych == 'd') goto yy130; if (yych <= 'h') goto yy113; goto yy132; } else { if (yych <= 'j') goto yy134; if (yych == 's') goto yy136; goto yy113; } } yy123: ++c; #line 1030 "sjson.c" { break; } #line 1689 "sjson.gen.c" yy125: yych = (guchar)*++c; goto yy113; yy126: yych = (guchar)*++c; if (yych <= 'c') { if (yych <= 'R') { if (yych == 'J') goto yy134; } else { if (yych <= 'S') goto yy136; if (yych == 'b') goto yy128; } } else { if (yych <= 'i') { if (yych <= 'd') goto yy130; if (yych >= 'i') goto yy132; } else { if (yych <= 'j') goto yy134; if (yych == 's') goto yy136; } } yy127: c = m; if (yyaccept <= 1) { if (yyaccept <= 0) { goto yy111; } else { goto yy113; } } else { goto yy115; } yy128: ++c; #line 1026 "sjson.c" { FMT(gboolean, g_string_append(str, arg ? "true" : "false");) } #line 1728 "sjson.gen.c" yy130: ++c; #line 1022 "sjson.c" { FMT(gdouble, g_string_append_printf(str, "%lg" , arg);) } #line 1735 "sjson.gen.c" yy132: ++c; #line 1018 "sjson.c" { FMT(gint64, g_string_append_printf(str, "%" G_GINT64_FORMAT, arg);) } #line 1742 "sjson.gen.c" yy134: ++c; #line 1005 "sjson.c" { FMT_FULL(gchar*, if (arg) { const gchar* end; if (s_json_is_valid_inner(arg, &end)) g_string_append_len(str, arg, end - arg); else g_string_append(str, "null"); } else { g_string_append(str, "null"); }, if (fmt == 'J') g_free(arg);) } #line 1758 "sjson.gen.c" yy136: ++c; #line 1001 "sjson.c" { FMT_FULL(gchar*, if (arg) escape_string(str, arg); else g_string_append(str, "null");, if (fmt == 'S') g_free(arg);) } #line 1765 "sjson.gen.c" yy138: ++c; yych = (guchar)*c; yy139: if (yych <= '@') { if (yych <= '-') { if (yych <= ',') goto yy115; goto yy138; } else { if (yych <= '/') goto yy115; if (yych <= '9') goto yy138; goto yy115; } } else { if (yych <= '_') { if (yych <= 'Z') goto yy138; if (yych <= '^') goto yy115; goto yy138; } else { if (yych <= '`') goto yy115; if (yych <= 'z') goto yy138; goto yy115; } } yy140: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'l') goto yy141; if (yych <= 'z') goto yy138; goto yy115; } } yy141: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'l') goto yy142; if (yych <= 'z') goto yy138; goto yy115; } } yy142: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '/') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy147; goto yy111; } else { if (yych <= '9') { if (yych <= '0') goto yy148; goto yy150; } else { if (yych <= ':') goto yy143; if (yych <= '@') goto yy111; goto yy138; } } } } else { if (yych <= 'f') { if (yych <= '^') { if (yych == '\\') goto yy111; if (yych >= '^') goto yy111; } else { if (yych == '`') goto yy111; if (yych <= 'e') goto yy138; goto yy153; } } else { if (yych <= 't') { if (yych == 'n') goto yy154; if (yych <= 's') goto yy138; goto yy152; } else { if (yych <= '{') { if (yych <= 'z') goto yy138; } else { if (yych != '}') goto yy111; } } } } yy143: yyaccept = 0; m = ++c; yych = (guchar)*c; yy144: if (yych <= ':') { if (yych <= '!') { if (yych <= '\f') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; goto yy111; } else { if (yych <= '\r') goto yy143; if (yych == ' ') goto yy143; goto yy111; } } else { if (yych <= '-') { if (yych <= '"') goto yy145; if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; goto yy164; } else { if (yych <= '/') goto yy111; if (yych <= '0') goto yy179; if (yych <= '9') goto yy181; goto yy143; } } } else { if (yych <= 'm') { if (yych <= '\\') { if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych == 'f') goto yy170; goto yy111; } } else { if (yych <= 'z') { if (yych <= 'n') goto yy171; if (yych == 't') goto yy169; goto yy111; } else { if (yych == '|') goto yy111; if (yych <= '}') goto yy143; goto yy111; } } } yy145: ++c; yych = (guchar)*c; yy146: if (yych <= '"') { if (yych <= 0x00) goto yy127; if (yych <= '!') goto yy145; goto yy143; } else { if (yych == '\\') goto yy195; goto yy145; } yy147: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '0') goto yy148; if (yych <= '9') goto yy150; goto yy115; } } else { if (yych <= '_') { if (yych <= 'Z') goto yy138; if (yych <= '^') goto yy115; goto yy138; } else { if (yych <= '`') goto yy115; if (yych <= 'z') goto yy138; goto yy115; } } yy148: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'E') { if (yych <= '+') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych <= ' ') { if (yych <= 0x1F) goto yy111; goto yy143; } else { if (yych == '"') goto yy145; goto yy111; } } } else { if (yych <= '0') { if (yych <= '-') { if (yych <= ',') goto yy143; goto yy147; } else { if (yych <= '.') goto yy161; if (yych <= '/') goto yy111; goto yy148; } } else { if (yych <= ':') { if (yych >= ':') goto yy143; } else { if (yych <= '@') goto yy111; if (yych <= 'D') goto yy138; goto yy160; } } } } else { if (yych <= 'e') { if (yych <= ']') { if (yych <= 'Z') goto yy138; if (yych == '\\') goto yy111; goto yy143; } else { if (yych <= '_') { if (yych <= '^') goto yy111; goto yy138; } else { if (yych <= '`') goto yy111; if (yych <= 'd') goto yy138; goto yy160; } } } else { if (yych <= 't') { if (yych <= 'm') { if (yych <= 'f') goto yy153; goto yy138; } else { if (yych <= 'n') goto yy154; if (yych <= 's') goto yy138; goto yy152; } } else { if (yych <= '{') { if (yych <= 'z') goto yy138; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy150: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'E') { if (yych <= '+') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych <= ' ') { if (yych <= 0x1F) goto yy111; goto yy143; } else { if (yych == '"') goto yy145; goto yy111; } } } else { if (yych <= '/') { if (yych <= ',') goto yy143; if (yych <= '-') goto yy147; if (yych <= '.') goto yy161; goto yy111; } else { if (yych <= ':') { if (yych <= '9') goto yy150; goto yy143; } else { if (yych <= '@') goto yy111; if (yych <= 'D') goto yy138; goto yy160; } } } } else { if (yych <= 'e') { if (yych <= ']') { if (yych <= 'Z') goto yy138; if (yych == '\\') goto yy111; goto yy143; } else { if (yych <= '_') { if (yych <= '^') goto yy111; goto yy138; } else { if (yych <= '`') goto yy111; if (yych <= 'd') goto yy138; goto yy160; } } } else { if (yych <= 't') { if (yych <= 'm') { if (yych <= 'f') goto yy153; goto yy138; } else { if (yych <= 'n') goto yy154; if (yych <= 's') goto yy138; } } else { if (yych <= '{') { if (yych <= 'z') goto yy138; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy152: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'r') goto yy158; if (yych <= 'z') goto yy138; goto yy115; } } yy153: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych <= 'a') goto yy155; if (yych <= 'z') goto yy138; goto yy115; } } yy154: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'u') goto yy140; if (yych <= 'z') goto yy138; goto yy115; } } yy155: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'l') goto yy156; if (yych <= 'z') goto yy138; goto yy115; } } yy156: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 's') goto yy157; if (yych <= 'z') goto yy138; goto yy115; } } yy157: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'e') goto yy142; if (yych <= 'z') goto yy138; goto yy115; } } yy158: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'u') goto yy159; if (yych <= 'z') goto yy138; goto yy115; } } yy159: ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '/') { if (yych == '-') goto yy138; goto yy115; } else { if (yych <= '9') goto yy138; if (yych <= '@') goto yy115; goto yy138; } } else { if (yych <= '`') { if (yych == '_') goto yy138; goto yy115; } else { if (yych == 'e') goto yy142; if (yych <= 'z') goto yy138; goto yy115; } } yy160: yyaccept = 2; m = ++c; yych = (guchar)*c; if (yych <= '9') { if (yych <= ',') { if (yych == '+') goto yy183; goto yy115; } else { if (yych <= '-') goto yy189; if (yych <= '/') goto yy115; goto yy190; } } else { if (yych <= '^') { if (yych <= '@') goto yy115; if (yych <= 'Z') goto yy138; goto yy115; } else { if (yych == '`') goto yy115; if (yych <= 'z') goto yy138; goto yy115; } } yy161: ++c; yych = (guchar)*c; if (yych <= '/') goto yy127; if (yych >= ':') goto yy127; yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '/') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy111; } else { if (yych <= '0') goto yy165; if (yych <= '9') goto yy167; if (yych <= ':') goto yy143; goto yy111; } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych >= 'f') goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy163: ++c; yych = (guchar)*c; if (yych <= ',') { if (yych == '+') goto yy183; goto yy127; } else { if (yych <= '-') goto yy183; if (yych <= '/') goto yy127; if (yych <= '9') goto yy184; goto yy127; } yy164: ++c; yych = (guchar)*c; if (yych <= '/') goto yy127; if (yych <= '0') goto yy179; if (yych <= '9') goto yy181; goto yy127; yy165: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '0') { if (yych <= '/') goto yy111; goto yy165; } else { if (yych <= '9') goto yy167; if (yych <= ':') goto yy143; goto yy111; } } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy167: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '/') goto yy111; if (yych <= '9') goto yy167; if (yych <= ':') goto yy143; goto yy111; } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy169: ++c; yych = (guchar)*c; if (yych == 'r') goto yy177; goto yy127; yy170: ++c; yych = (guchar)*c; if (yych == 'a') goto yy174; goto yy127; yy171: ++c; yych = (guchar)*c; if (yych != 'u') goto yy127; ++c; yych = (guchar)*c; if (yych != 'l') goto yy127; ++c; yych = (guchar)*c; if (yych == 'l') goto yy143; goto yy127; yy174: ++c; yych = (guchar)*c; if (yych != 'l') goto yy127; ++c; yych = (guchar)*c; if (yych != 's') goto yy127; ++c; yych = (guchar)*c; if (yych == 'e') goto yy143; goto yy127; yy177: ++c; yych = (guchar)*c; if (yych != 'u') goto yy127; ++c; yych = (guchar)*c; if (yych == 'e') goto yy143; goto yy127; yy179: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '0') { if (yych <= '/') goto yy111; goto yy179; } else { if (yych <= '9') goto yy181; if (yych <= ':') goto yy143; goto yy111; } } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy181: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '/') goto yy111; if (yych <= '9') goto yy181; if (yych <= ':') goto yy143; goto yy111; } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy183: ++c; yych = (guchar)*c; if (yych <= '/') goto yy127; if (yych >= ':') goto yy127; yy184: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= ':') { if (yych <= '!') { if (yych <= '\f') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; goto yy111; } else { if (yych <= '\r') goto yy143; if (yych == ' ') goto yy143; goto yy111; } } else { if (yych <= '-') { if (yych <= '"') goto yy145; if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; goto yy164; } else { if (yych <= '/') goto yy111; if (yych <= '0') goto yy185; if (yych <= '9') goto yy187; goto yy143; } } } else { if (yych <= 'm') { if (yych <= '\\') { if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych == 'f') goto yy170; goto yy111; } } else { if (yych <= 'z') { if (yych <= 'n') goto yy171; if (yych == 't') goto yy169; goto yy111; } else { if (yych == '|') goto yy111; if (yych <= '}') goto yy143; goto yy111; } } } yy185: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '0') { if (yych <= '/') goto yy111; goto yy185; } else { if (yych <= '9') goto yy187; if (yych <= ':') goto yy143; goto yy111; } } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy187: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'D') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '.') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy164; goto yy161; } else { if (yych <= '/') goto yy111; if (yych <= '9') goto yy187; if (yych <= ':') goto yy143; goto yy111; } } } else { if (yych <= 'f') { if (yych <= '\\') { if (yych <= 'E') goto yy163; if (yych == '[') goto yy143; goto yy111; } else { if (yych <= ']') goto yy143; if (yych <= 'd') goto yy111; if (yych <= 'e') goto yy163; goto yy170; } } else { if (yych <= 't') { if (yych == 'n') goto yy171; if (yych <= 's') goto yy111; goto yy169; } else { if (yych <= '{') { if (yych <= 'z') goto yy111; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy189: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '-') { if (yych <= ',') goto yy115; goto yy138; } else { if (yych <= '/') goto yy115; if (yych >= ':') goto yy115; } } else { if (yych <= '_') { if (yych <= 'Z') goto yy138; if (yych <= '^') goto yy115; goto yy138; } else { if (yych <= '`') goto yy115; if (yych <= 'z') goto yy138; goto yy115; } } yy190: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'Z') { if (yych <= '"') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych == ' ') goto yy143; if (yych <= '!') goto yy111; goto yy145; } } else { if (yych <= '/') { if (yych <= '+') goto yy111; if (yych <= ',') goto yy143; if (yych <= '-') goto yy147; goto yy111; } else { if (yych <= '9') { if (yych >= '1') goto yy193; } else { if (yych <= ':') goto yy143; if (yych <= '@') goto yy111; goto yy138; } } } } else { if (yych <= 'f') { if (yych <= '^') { if (yych == '\\') goto yy111; if (yych <= ']') goto yy143; goto yy111; } else { if (yych == '`') goto yy111; if (yych <= 'e') goto yy138; goto yy153; } } else { if (yych <= 't') { if (yych == 'n') goto yy154; if (yych <= 's') goto yy138; goto yy152; } else { if (yych <= '{') { if (yych <= 'z') goto yy138; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy191: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'E') { if (yych <= '+') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych <= ' ') { if (yych <= 0x1F) goto yy111; goto yy143; } else { if (yych == '"') goto yy145; goto yy111; } } } else { if (yych <= '0') { if (yych <= '-') { if (yych <= ',') goto yy143; goto yy147; } else { if (yych <= '.') goto yy161; if (yych <= '/') goto yy111; goto yy191; } } else { if (yych <= ':') { if (yych >= ':') goto yy143; } else { if (yych <= '@') goto yy111; if (yych <= 'D') goto yy138; goto yy160; } } } } else { if (yych <= 'e') { if (yych <= ']') { if (yych <= 'Z') goto yy138; if (yych == '\\') goto yy111; goto yy143; } else { if (yych <= '_') { if (yych <= '^') goto yy111; goto yy138; } else { if (yych <= '`') goto yy111; if (yych <= 'd') goto yy138; goto yy160; } } } else { if (yych <= 't') { if (yych <= 'm') { if (yych <= 'f') goto yy153; goto yy138; } else { if (yych <= 'n') goto yy154; if (yych <= 's') goto yy138; goto yy152; } } else { if (yych <= '{') { if (yych <= 'z') goto yy138; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy193: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= 'E') { if (yych <= '+') { if (yych <= '\r') { if (yych <= 0x08) goto yy111; if (yych <= '\n') goto yy143; if (yych <= '\f') goto yy111; goto yy143; } else { if (yych <= ' ') { if (yych <= 0x1F) goto yy111; goto yy143; } else { if (yych == '"') goto yy145; goto yy111; } } } else { if (yych <= '/') { if (yych <= ',') goto yy143; if (yych <= '-') goto yy147; if (yych <= '.') goto yy161; goto yy111; } else { if (yych <= ':') { if (yych <= '9') goto yy193; goto yy143; } else { if (yych <= '@') goto yy111; if (yych <= 'D') goto yy138; goto yy160; } } } } else { if (yych <= 'e') { if (yych <= ']') { if (yych <= 'Z') goto yy138; if (yych == '\\') goto yy111; goto yy143; } else { if (yych <= '_') { if (yych <= '^') goto yy111; goto yy138; } else { if (yych <= '`') goto yy111; if (yych <= 'd') goto yy138; goto yy160; } } } else { if (yych <= 't') { if (yych <= 'm') { if (yych <= 'f') goto yy153; goto yy138; } else { if (yych <= 'n') goto yy154; if (yych <= 's') goto yy138; goto yy152; } } else { if (yych <= '{') { if (yych <= 'z') goto yy138; goto yy143; } else { if (yych == '}') goto yy143; goto yy111; } } } } yy195: ++c; yych = (guchar)*c; if (yych <= 'e') { if (yych <= '/') { if (yych == '"') goto yy197; if (yych <= '.') goto yy127; goto yy197; } else { if (yych <= '\\') { if (yych <= '[') goto yy127; goto yy197; } else { if (yych == 'b') goto yy197; goto yy127; } } } else { if (yych <= 'q') { if (yych <= 'f') goto yy197; if (yych == 'n') goto yy197; goto yy127; } else { if (yych <= 's') { if (yych <= 'r') goto yy197; goto yy127; } else { if (yych <= 't') goto yy197; if (yych >= 'v') goto yy127; } } } ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy127; if (yych <= '9') goto yy199; goto yy127; } else { if (yych <= 'F') goto yy199; if (yych <= '`') goto yy127; if (yych <= 'f') goto yy199; goto yy127; } yy197: ++c; yych = (guchar)*c; if (yych <= '"') { if (yych <= 0x00) goto yy127; if (yych <= '!') goto yy197; goto yy143; } else { if (yych == '\\') goto yy195; goto yy197; } yy199: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy127; if (yych >= ':') goto yy127; } else { if (yych <= 'F') goto yy200; if (yych <= '`') goto yy127; if (yych >= 'g') goto yy127; } yy200: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy127; if (yych >= ':') goto yy127; } else { if (yych <= 'F') goto yy201; if (yych <= '`') goto yy127; if (yych >= 'g') goto yy127; } yy201: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy127; if (yych <= '9') goto yy197; goto yy127; } else { if (yych <= 'F') goto yy197; if (yych <= '`') goto yy127; if (yych <= 'f') goto yy197; goto yy127; } } #line 1037 "sjson.c" } if (s_json_is_valid(str->str)) return g_string_free(str, FALSE); err: g_string_free(str, TRUE); return NULL; } gchar* s_json_build(const gchar* format, ...) { va_list args; gchar* json; g_return_val_if_fail(format != NULL, NULL); va_start(args, format); json = s_json_buildv(format, args); va_end(args); return json; } gchar* s_json_pretty(const gchar* json) { const gchar* start; const gchar* end; GString *str, *ind; gchar* json_valid; g_return_val_if_fail(json != NULL, NULL); // validate and isolate json_valid = s_json_get(json); if (!json_valid) return NULL; start = json_valid; str = g_string_sized_new(strlen(json) * 2); ind = g_string_sized_new(50); #define PUSH_INDENT() g_string_append_c(ind, '\t') #define POP_INDENT() g_string_truncate(ind, MAX(ind->len - 1, 0)) #define INDENT() g_string_append_len(str, ind->str, ind->len) gint prev_token = TOK_NONE; while (TRUE) { gint token = s_json_get_token(start, &start, &end); if (token == TOK_NONE) break; gint next_token = s_json_get_token(end, NULL, NULL); if ((token == TOK_OBJ_END && prev_token != TOK_OBJ_START) || (token == TOK_ARRAY_END && prev_token != TOK_ARRAY_START && prev_token != TOK_OBJ_END)) { g_string_append_c(str, '\n'); POP_INDENT(); INDENT(); } g_string_append_len(str, start, end - start); if ((token == TOK_OBJ_START && next_token != TOK_OBJ_END) || (token == TOK_ARRAY_START && next_token != TOK_OBJ_START && next_token != TOK_ARRAY_END)) { g_string_append_c(str, '\n'); PUSH_INDENT(); INDENT(); } else if (token == TOK_COMMA) { if ((prev_token == TOK_OBJ_END && next_token == TOK_OBJ_START) || (prev_token == TOK_ARRAY_END && next_token == TOK_ARRAY_START)) { g_string_append_c(str, ' '); } else { g_string_append_c(str, '\n'); INDENT(); } } else if (token == TOK_COLON) { g_string_append_c(str, ' '); } prev_token = token; start = end; } g_string_free(ind, TRUE); g_free(json_valid); return g_string_free(str, FALSE); } const gchar* s_json_path(const gchar* json, const gchar* path) { const guchar* c = (const guchar*)path; const guchar* m = NULL; const guchar* s; const gchar* cur_node = json; g_return_val_if_fail(json != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); #define CHECK_TYPE(type) \ if (cur_node && s_json_get_type(cur_node) == type) \ return cur_node; \ if ((!cur_node || s_json_get_type(cur_node) == S_JSON_TYPE_NULL) && s[0] == '?') \ return "null"; \ return NULL; while (TRUE) { s = c; #line 3298 "sjson.gen.c" { guchar yych; unsigned int yyaccept = 0; yych = (guchar)*c; if (yych <= '!') { if (yych <= '\f') { if (yych <= 0x00) goto yy212; if (yych <= 0x08) goto yy214; if (yych >= '\v') goto yy214; } else { if (yych <= '\r') goto yy204; if (yych <= 0x1F) goto yy214; if (yych >= '!') goto yy211; } } else { if (yych <= '.') { if (yych == '$') goto yy206; if (yych <= '-') goto yy214; goto yy208; } else { if (yych <= '?') { if (yych <= '>') goto yy214; goto yy211; } else { if (yych == '[') goto yy210; goto yy214; } } } yy204: ++c; yych = (guchar)*c; goto yy268; yy205: #line 1158 "sjson.c" { // skip whitespace continue; } #line 3338 "sjson.gen.c" yy206: ++c; #line 1163 "sjson.c" { // root cur_node = json; continue; } #line 3347 "sjson.gen.c" yy208: ++c; if ((yych = (guchar)*c) <= 'Z') { if (yych == '-') goto yy264; if (yych >= 'A') goto yy264; } else { if (yych <= '_') { if (yych >= '_') goto yy264; } else { if (yych <= '`') goto yy209; if (yych <= 'z') goto yy264; } } yy209: #line 1236 "sjson.c" { return NULL; } #line 3366 "sjson.gen.c" yy210: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= '/') goto yy209; if (yych <= '0') goto yy259; if (yych <= '9') goto yy260; goto yy209; yy211: yych = (guchar)*++c; switch (yych) { case 'a': goto yy215; case 'b': goto yy219; case 'i': goto yy221; case 'n': goto yy225; case 'o': goto yy217; case 's': goto yy223; default: goto yy209; } yy212: ++c; #line 1232 "sjson.c" { break; } #line 3391 "sjson.gen.c" yy214: yych = (guchar)*++c; goto yy209; yy215: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych == 'r') goto yy255; yy216: #line 1228 "sjson.c" { CHECK_TYPE(S_JSON_TYPE_ARRAY) } #line 3404 "sjson.gen.c" yy217: yyaccept = 2; yych = (guchar)*(m = ++c); if (yych == 'b') goto yy250; yy218: #line 1224 "sjson.c" { CHECK_TYPE(S_JSON_TYPE_OBJECT) } #line 3414 "sjson.gen.c" yy219: yyaccept = 3; yych = (guchar)*(m = ++c); if (yych == 'o') goto yy244; yy220: #line 1220 "sjson.c" { CHECK_TYPE(S_JSON_TYPE_BOOL) } #line 3424 "sjson.gen.c" yy221: yyaccept = 4; yych = (guchar)*(m = ++c); if (yych == 'n') goto yy238; yy222: #line 1203 "sjson.c" { if (cur_node && s_json_get_type(cur_node) == S_JSON_TYPE_NUMBER) { const gchar *int_start, *int_end, *i; g_assert(s_json_get_token(cur_node, &int_start, &int_end) == TOK_NUMBER); for (i = int_start; i < int_end; i++) if (*i > '9' || *i < '0') return NULL; return cur_node; } if ((!cur_node || s_json_get_type(cur_node) == S_JSON_TYPE_NULL) && s[0] == '?') return "null"; return NULL; } #line 3447 "sjson.gen.c" yy223: yyaccept = 5; yych = (guchar)*(m = ++c); if (yych == 't') goto yy233; yy224: #line 1199 "sjson.c" { CHECK_TYPE(S_JSON_TYPE_STRING) } #line 3457 "sjson.gen.c" yy225: yyaccept = 6; yych = (guchar)*(m = ++c); if (yych == 'u') goto yy227; yy226: #line 1195 "sjson.c" { CHECK_TYPE(S_JSON_TYPE_NUMBER) } #line 3467 "sjson.gen.c" yy227: yych = (guchar)*++c; if (yych == 'm') goto yy229; yy228: c = m; if (yyaccept <= 3) { if (yyaccept <= 1) { if (yyaccept <= 0) { goto yy209; } else { goto yy216; } } else { if (yyaccept <= 2) { goto yy218; } else { goto yy220; } } } else { if (yyaccept <= 5) { if (yyaccept <= 4) { goto yy222; } else { goto yy224; } } else { goto yy226; } } yy229: yych = (guchar)*++c; if (yych != 'b') goto yy228; yych = (guchar)*++c; if (yych != 'e') goto yy228; yych = (guchar)*++c; if (yych != 'r') goto yy228; yych = (guchar)*++c; goto yy226; yy233: yych = (guchar)*++c; if (yych != 'r') goto yy228; yych = (guchar)*++c; if (yych != 'i') goto yy228; yych = (guchar)*++c; if (yych != 'n') goto yy228; yych = (guchar)*++c; if (yych != 'g') goto yy228; yych = (guchar)*++c; goto yy224; yy238: yych = (guchar)*++c; if (yych != 't') goto yy228; yych = (guchar)*++c; if (yych != 'e') goto yy228; yych = (guchar)*++c; if (yych != 'g') goto yy228; yych = (guchar)*++c; if (yych != 'e') goto yy228; yych = (guchar)*++c; if (yych != 'r') goto yy228; yych = (guchar)*++c; goto yy222; yy244: yych = (guchar)*++c; if (yych != 'o') goto yy228; yych = (guchar)*++c; if (yych != 'l') goto yy228; yych = (guchar)*++c; if (yych != 'e') goto yy228; yych = (guchar)*++c; if (yych != 'a') goto yy228; yych = (guchar)*++c; if (yych != 'n') goto yy228; yych = (guchar)*++c; goto yy220; yy250: yych = (guchar)*++c; if (yych != 'j') goto yy228; yych = (guchar)*++c; if (yych != 'e') goto yy228; yych = (guchar)*++c; if (yych != 'c') goto yy228; yych = (guchar)*++c; if (yych != 't') goto yy228; yych = (guchar)*++c; goto yy218; yy255: yych = (guchar)*++c; if (yych != 'r') goto yy228; yych = (guchar)*++c; if (yych != 'a') goto yy228; yych = (guchar)*++c; if (yych != 'y') goto yy228; yych = (guchar)*++c; goto yy216; yy259: yych = (guchar)*++c; if (yych == ']') goto yy262; goto yy228; yy260: ++c; yych = (guchar)*c; if (yych <= '/') goto yy228; if (yych <= '9') goto yy260; if (yych != ']') goto yy228; yy262: ++c; #line 1182 "sjson.c" { if (!cur_node || s_json_get_type(cur_node) != S_JSON_TYPE_ARRAY) return NULL; guint index; sscanf(s + 1, "%u", &index); cur_node = s_json_get_element(cur_node, index); continue; } #line 3587 "sjson.gen.c" yy264: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '-') { if (yych >= '-') goto yy264; } else { if (yych <= '/') goto yy266; if (yych <= '9') goto yy264; } } else { if (yych <= '_') { if (yych <= 'Z') goto yy264; if (yych >= '_') goto yy264; } else { if (yych <= '`') goto yy266; if (yych <= 'z') goto yy264; } } yy266: #line 1169 "sjson.c" { if (!cur_node || s_json_get_type(cur_node) != S_JSON_TYPE_OBJECT) return NULL; // zero terminate member name on stack gchar* name = g_alloca((c - s)); memcpy(name, s + 1, c - (s + 1)); name[c - (s + 1)] = '\0'; cur_node = s_json_get_member(cur_node, name); continue; } #line 3621 "sjson.gen.c" yy267: ++c; yych = (guchar)*c; yy268: if (yych <= '\f') { if (yych <= 0x08) goto yy205; if (yych <= '\n') goto yy267; goto yy205; } else { if (yych <= '\r') goto yy267; if (yych == ' ') goto yy267; goto yy205; } } #line 1239 "sjson.c" } return cur_node; } gchar* s_json_compact(const gchar* json) { g_return_val_if_fail(json != NULL, NULL); GString* str = g_string_sized_new(strlen(json)); const guchar* c = (const guchar*)json; const guchar* m = NULL; const guchar* s; while (TRUE) { s = c; #line 3657 "sjson.gen.c" { guchar yych; unsigned int yyaccept = 0; yych = (guchar)*c; if (yych <= '9') { if (yych <= ' ') { if (yych <= '\n') { if (yych <= 0x00) goto yy283; if (yych <= 0x08) goto yy285; goto yy281; } else { if (yych == '\r') goto yy281; if (yych <= 0x1F) goto yy285; goto yy281; } } else { if (yych <= ',') { if (yych == '"') goto yy273; if (yych <= '+') goto yy285; } else { if (yych <= '-') goto yy275; if (yych <= '/') goto yy285; if (yych <= '0') goto yy276; goto yy277; } } } else { if (yych <= 'm') { if (yych <= '\\') { if (yych <= ':') goto yy271; if (yych != '[') goto yy285; } else { if (yych <= ']') goto yy271; if (yych == 'f') goto yy279; goto yy285; } } else { if (yych <= 'z') { if (yych <= 'n') goto yy280; if (yych == 't') goto yy278; goto yy285; } else { if (yych == '|') goto yy285; if (yych >= '~') goto yy285; } } } yy271: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= '\\') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; } } else { if (yych <= ':') { if (yych <= '0') goto yy296; if (yych <= '9') goto yy298; goto yy291; } else { if (yych == '[') goto yy291; } } } else { if (yych <= 's') { if (yych <= 'f') { if (yych <= ']') goto yy291; if (yych >= 'f') goto yy301; } else { if (yych == 'n') goto yy302; } } else { if (yych <= '{') { if (yych <= 't') goto yy300; if (yych >= '{') goto yy291; } else { if (yych == '}') goto yy291; } } } yy272: #line 1259 "sjson.c" { g_string_append_len(str, s, c - s); continue; } #line 3748 "sjson.gen.c" yy273: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych >= 0x01) goto yy294; yy274: #line 1272 "sjson.c" { goto err; } #line 3758 "sjson.gen.c" yy275: yych = (guchar)*++c; if (yych <= '/') goto yy274; if (yych <= '9') goto yy297; goto yy274; yy276: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= '[') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; if (yych <= '.') goto yy308; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy296; if (yych <= '9') goto yy298; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy277: yyaccept = 0; yych = (guchar)*(m = ++c); if (yych <= '[') { if (yych <= '.') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy308; } } else { if (yych <= ':') { if (yych <= '/') goto yy272; if (yych <= '9') goto yy298; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy278: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych == 'r') goto yy306; goto yy274; yy279: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych == 'a') goto yy303; goto yy274; yy280: yyaccept = 1; yych = (guchar)*(m = ++c); if (yych == 'u') goto yy288; goto yy274; yy281: ++c; yych = (guchar)*c; goto yy287; yy282: #line 1264 "sjson.c" { continue; } #line 3881 "sjson.gen.c" yy283: ++c; #line 1268 "sjson.c" { break; } #line 3888 "sjson.gen.c" yy285: yych = (guchar)*++c; goto yy274; yy286: ++c; yych = (guchar)*c; yy287: if (yych <= '\f') { if (yych <= 0x08) goto yy282; if (yych <= '\n') goto yy286; goto yy282; } else { if (yych <= '\r') goto yy286; if (yych == ' ') goto yy286; goto yy282; } yy288: ++c; yych = (guchar)*c; if (yych == 'l') goto yy290; yy289: c = m; if (yyaccept <= 0) { goto yy272; } else { goto yy274; } yy290: ++c; yych = (guchar)*c; if (yych != 'l') goto yy289; yy291: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '\\') { if (yych <= '/') { if (yych <= '+') { if (yych != '"') goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy296; if (yych <= '9') goto yy298; goto yy291; } else { if (yych == '[') goto yy291; goto yy272; } } } else { if (yych <= 's') { if (yych <= 'f') { if (yych <= ']') goto yy291; if (yych <= 'e') goto yy272; goto yy301; } else { if (yych == 'n') goto yy302; goto yy272; } } else { if (yych <= '{') { if (yych <= 't') goto yy300; if (yych <= 'z') goto yy272; goto yy291; } else { if (yych == '}') goto yy291; goto yy272; } } } yy293: ++c; yych = (guchar)*c; yy294: if (yych <= '"') { if (yych <= 0x00) goto yy289; if (yych <= '!') goto yy293; goto yy291; } else { if (yych == '\\') goto yy321; goto yy293; } yy295: ++c; yych = (guchar)*c; if (yych <= '/') goto yy289; if (yych <= '0') goto yy296; if (yych <= '9') goto yy298; goto yy289; yy296: yyaccept = 0; m = ++c; yych = (guchar)*c; yy297: if (yych <= '[') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; if (yych <= '.') goto yy308; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy296; if (yych >= ':') goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy298: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '.') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy308; } } else { if (yych <= ':') { if (yych <= '/') goto yy272; if (yych <= '9') goto yy298; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych != 't') goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy300: ++c; yych = (guchar)*c; if (yych == 'r') goto yy306; goto yy289; yy301: ++c; yych = (guchar)*c; if (yych == 'a') goto yy303; goto yy289; yy302: ++c; yych = (guchar)*c; if (yych == 'u') goto yy288; goto yy289; yy303: ++c; yych = (guchar)*c; if (yych != 'l') goto yy289; ++c; yych = (guchar)*c; if (yych != 's') goto yy289; ++c; yych = (guchar)*c; if (yych == 'e') goto yy291; goto yy289; yy306: ++c; yych = (guchar)*c; if (yych != 'u') goto yy289; ++c; yych = (guchar)*c; if (yych == 'e') goto yy291; goto yy289; yy308: ++c; yych = (guchar)*c; if (yych <= '/') goto yy289; if (yych <= '9') goto yy316; goto yy289; yy309: ++c; yych = (guchar)*c; if (yych <= ',') { if (yych != '+') goto yy289; } else { if (yych <= '-') goto yy310; if (yych <= '/') goto yy289; if (yych <= '9') goto yy311; goto yy289; } yy310: ++c; yych = (guchar)*c; if (yych <= '/') goto yy289; if (yych >= ':') goto yy289; yy311: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '\\') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy312; if (yych <= '9') goto yy314; goto yy291; } else { if (yych == '[') goto yy291; goto yy272; } } } else { if (yych <= 's') { if (yych <= 'f') { if (yych <= ']') goto yy291; if (yych <= 'e') goto yy272; goto yy301; } else { if (yych == 'n') goto yy302; goto yy272; } } else { if (yych <= '{') { if (yych <= 't') goto yy300; if (yych <= 'z') goto yy272; goto yy291; } else { if (yych == '}') goto yy291; goto yy272; } } } yy312: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; if (yych <= '.') goto yy308; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy312; if (yych >= ':') goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy314: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '.') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy308; } } else { if (yych <= ':') { if (yych <= '/') goto yy272; if (yych <= '9') goto yy314; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy316: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy317; if (yych <= '9') goto yy319; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy317: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '/') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; if (yych <= '.') goto yy308; goto yy272; } } else { if (yych <= ':') { if (yych <= '0') goto yy317; if (yych >= ':') goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy319: yyaccept = 0; m = ++c; yych = (guchar)*c; if (yych <= '[') { if (yych <= '.') { if (yych <= '+') { if (yych == '"') goto yy293; goto yy272; } else { if (yych <= ',') goto yy291; if (yych <= '-') goto yy295; goto yy308; } } else { if (yych <= ':') { if (yych <= '/') goto yy272; if (yych <= '9') goto yy319; goto yy291; } else { if (yych == 'E') goto yy309; if (yych <= 'Z') goto yy272; goto yy291; } } } else { if (yych <= 'n') { if (yych <= 'd') { if (yych == ']') goto yy291; goto yy272; } else { if (yych <= 'e') goto yy309; if (yych <= 'f') goto yy301; if (yych <= 'm') goto yy272; goto yy302; } } else { if (yych <= 'z') { if (yych == 't') goto yy300; goto yy272; } else { if (yych == '|') goto yy272; if (yych <= '}') goto yy291; goto yy272; } } } yy321: ++c; yych = (guchar)*c; if (yych <= 'e') { if (yych <= '/') { if (yych == '"') goto yy323; if (yych <= '.') goto yy289; goto yy323; } else { if (yych <= '\\') { if (yych <= '[') goto yy289; goto yy323; } else { if (yych == 'b') goto yy323; goto yy289; } } } else { if (yych <= 'q') { if (yych <= 'f') goto yy323; if (yych == 'n') goto yy323; goto yy289; } else { if (yych <= 's') { if (yych <= 'r') goto yy323; goto yy289; } else { if (yych <= 't') goto yy323; if (yych >= 'v') goto yy289; } } } ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy289; if (yych <= '9') goto yy325; goto yy289; } else { if (yych <= 'F') goto yy325; if (yych <= '`') goto yy289; if (yych <= 'f') goto yy325; goto yy289; } yy323: ++c; yych = (guchar)*c; if (yych <= '"') { if (yych <= 0x00) goto yy289; if (yych <= '!') goto yy323; goto yy291; } else { if (yych == '\\') goto yy321; goto yy323; } yy325: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy289; if (yych >= ':') goto yy289; } else { if (yych <= 'F') goto yy326; if (yych <= '`') goto yy289; if (yych >= 'g') goto yy289; } yy326: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy289; if (yych >= ':') goto yy289; } else { if (yych <= 'F') goto yy327; if (yych <= '`') goto yy289; if (yych >= 'g') goto yy289; } yy327: ++c; yych = (guchar)*c; if (yych <= '@') { if (yych <= '/') goto yy289; if (yych <= '9') goto yy323; goto yy289; } else { if (yych <= 'F') goto yy323; if (yych <= '`') goto yy289; if (yych <= 'f') goto yy323; goto yy289; } } #line 1275 "sjson.c" } return g_string_free(str, FALSE); err: g_string_free(str, TRUE); return NULL; } megatools-1.9.98/lib/tools.c0000644000175000001440000003612113006630754012612 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include "config.h" #include "tools.h" #ifdef G_OS_WIN32 #include #else #include #include #include #endif #ifdef G_OS_WIN32 #define MEGA_RC_FILENAME "mega.ini" #else #define MEGA_RC_FILENAME ".megarc" #endif static GOptionContext* opt_context; static gchar* opt_username; static gchar* opt_password; static gchar* opt_config; static gboolean opt_reload_files; static gboolean opt_version; static gboolean opt_no_config; static gboolean opt_no_ask_password; static gint opt_speed_limit = -1; /* -1 means limit not set */ static gchar* opt_proxy; static gchar* proxy; static gint upload_speed_limit; static gint download_seed_limit; static gint cache_timout = 10 * 60; static gboolean opt_debug_callback(const gchar *option_name, const gchar *value, gpointer data, GError **error) { if (value) { gchar** opts = g_strsplit(value, ",", 0); gchar** opt = opts; while (*opt) { if (g_ascii_strcasecmp(*opt, "api") == 0) mega_debug |= MEGA_DEBUG_API; else if (g_ascii_strcasecmp(*opt, "fs") == 0) mega_debug |= MEGA_DEBUG_FS; else if (g_ascii_strcasecmp(*opt, "cache") == 0) mega_debug |= MEGA_DEBUG_CACHE; opt++; } } else { mega_debug = MEGA_DEBUG_API; } return TRUE; } static GOptionEntry basic_options[] = { { "config", '\0', 0, G_OPTION_ARG_FILENAME, &opt_config, "Load configuration from a file", "PATH" }, { "ignore-config-file", '\0', 0, G_OPTION_ARG_NONE, &opt_no_config, "Disable loading " MEGA_RC_FILENAME, NULL }, { "debug", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, opt_debug_callback, "Enable debugging output", "OPTS" }, { "version", '\0', 0, G_OPTION_ARG_NONE, &opt_version, "Show version information", NULL }, { NULL } }; static GOptionEntry auth_options[] = { { "username", 'u', 0, G_OPTION_ARG_STRING, &opt_username, "Account username (email)", "USERNAME" }, { "password", 'p', 0, G_OPTION_ARG_STRING, &opt_password, "Account password", "PASSWORD" }, { "no-ask-password", '\0', 0, G_OPTION_ARG_NONE, &opt_no_ask_password, "Never ask interactively for a password", NULL }, { "reload", '\0', 0, G_OPTION_ARG_NONE, &opt_reload_files, "Reload filesystem cache", NULL }, { NULL } }; static GOptionEntry network_options[] = { { "limit-speed", '\0', 0, G_OPTION_ARG_INT, &opt_speed_limit, "Limit transfer speed (KiB/s)", "SPEED" }, { "proxy", '\0', 0, G_OPTION_ARG_STRING, &opt_proxy, "Proxy setup string", "PROXY" }, { NULL } }; #if OPENSSL_VERSION_NUMBER >= 0x10100004L static void init_openssl_locking() { // OpenSSL >= 1.1.0-pre4 doesn't require specific callback setup } #else #if GLIB_CHECK_VERSION(2, 32, 0) static GMutex* openssl_mutexes = NULL; static void openssl_locking_callback(int mode, int type, const char *file, int line) { if (mode & CRYPTO_LOCK) g_mutex_lock(openssl_mutexes + type); else g_mutex_unlock(openssl_mutexes + type); } static unsigned long openssl_thread_id_callback() { unsigned long ret; ret = (unsigned long)g_thread_self(); return ret; } static void init_openssl_locking() { gint i; // initialize OpenSSL locking for multi-threaded operation openssl_mutexes = g_new(GMutex, CRYPTO_num_locks()); for (i = 0; i < CRYPTO_num_locks(); i++) g_mutex_init(openssl_mutexes + i); SSL_library_init(); CRYPTO_set_id_callback(openssl_thread_id_callback); CRYPTO_set_locking_callback(openssl_locking_callback); } #else static GMutex** openssl_mutexes = NULL; static void openssl_locking_callback(int mode, int type, const char *file, int line) { if (mode & CRYPTO_LOCK) g_mutex_lock(openssl_mutexes[type]); else g_mutex_unlock(openssl_mutexes[type]); } static unsigned long openssl_thread_id_callback() { unsigned long ret; ret = (unsigned long)g_thread_self(); return ret; } static void init_openssl_locking() { gint i; // initialize OpenSSL locking for multi-threaded operation openssl_mutexes = g_new(GMutex*, CRYPTO_num_locks()); for (i = 0; i < CRYPTO_num_locks(); i++) openssl_mutexes[i] = g_mutex_new(); SSL_library_init(); CRYPTO_set_id_callback(openssl_thread_id_callback); CRYPTO_set_locking_callback(openssl_locking_callback); } #endif #endif #ifdef G_OS_WIN32 static gchar* get_tools_dir(void) { gchar *path = NULL; wchar_t *wpath; DWORD len = PATH_MAX; HMODULE handle = GetModuleHandleW(NULL); wpath = g_new0(wchar_t, len); if (GetModuleFileNameW(handle, wpath, len) < len) path = g_utf16_to_utf8(wpath, -1, NULL, NULL, NULL); g_free(wpath); if (path == NULL) path = g_strdup(""); gchar* dir = g_path_get_dirname(path); g_free(path); return dir; } #endif static void init(void) { #if !GLIB_CHECK_VERSION(2, 32, 0) if (!g_thread_supported()) g_thread_init(NULL); #endif setlocale(LC_ALL, ""); #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); #endif g_setenv("GSETTINGS_BACKEND", "memory", TRUE); #ifndef G_OS_WIN32 signal(SIGPIPE, SIG_IGN); #endif init_openssl_locking(); #ifdef G_OS_WIN32 gchar* tools_dir = get_tools_dir(); gchar* tmp = g_build_filename(tools_dir, "gio", NULL); g_setenv("GIO_EXTRA_MODULES", tmp, TRUE); g_free(tmp); gchar* certs = g_build_filename(tools_dir, "ca-certificates.crt", NULL); g_setenv("CA_CERT_PATH", certs, TRUE); g_free(certs); g_free(tools_dir); #endif } void tool_show_progress(const gchar* file, const mega_status_data *data) { if (data->progress.total <= 0) return; gc_free gchar* done_str = g_format_size_full(data->progress.done, G_FORMAT_SIZE_IEC_UNITS | G_FORMAT_SIZE_LONG_FORMAT); gc_free gchar* total_str = g_format_size_full(data->progress.total, G_FORMAT_SIZE_IEC_UNITS); const guint64 rate = (data->progress.done - data->progress.last) * 1e6 / data->progress.span; gc_free gchar* rate_str = g_format_size_full(rate, G_FORMAT_SIZE_IEC_UNITS); const double percentage = (double)(data->progress.done * 100 * 1000 / data->progress.total) / 1000.0; g_print( ESC_WHITE "%s" ESC_NORMAL ": " ESC_YELLOW "%.2f%%" ESC_NORMAL " - " ESC_GREEN "%s" ESC_BLUE " of %s" ESC_NORMAL " (%s/s)" ESC_CLREOL "\r", file, percentage, done_str, total_str, rate_str ); } static gchar* input_password(void) { gint tries = 3; gchar buf[1025]; gchar* password = NULL; #ifdef G_OS_WIN32 HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD mode = 0; GetConsoleMode(hStdin, &mode); SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); #else struct termios oldt; tcgetattr(STDIN_FILENO, &oldt); struct termios newt = oldt; newt.c_lflag &= ~ECHO; tcsetattr(STDIN_FILENO, TCSANOW, &newt); #endif again: g_print("Enter password for (%s): ", opt_username); if (fgets(buf, 1024, stdin)) { if (strlen(buf) > 1) { password = g_strndup(buf, strcspn(buf, "\r\n")); } else { if (--tries > 0) { g_print("\n"); goto again; } g_print("\nYou need to provide non-empty password!\n"); exit(1); } } else { g_printerr("\nERROR: Can't read password from the input!\n"); exit(1); } #ifdef G_OS_WIN32 SetConsoleMode(hStdin, mode); #else tcsetattr(STDIN_FILENO, TCSANOW, &oldt); #endif g_print("\nGood, signing in...\n"); return password; } static void print_version(void) { if (opt_version) { g_print("megatools " VERSION " - command line tools for Mega.nz\n\n"); g_print("Written by OndÅ™ej Jirman , 2013\n"); g_print("Go to http://megatools.megous.com for more information\n"); exit(0); } } gchar* tool_convert_filename(const gchar* path, gboolean local) { gchar* locale_path; #ifdef G_OS_WIN32 locale_path = g_locale_to_utf8(path, -1, NULL, NULL, NULL); #else if (local) locale_path = g_strdup(path); else locale_path = g_locale_to_utf8(path, -1, NULL, NULL, NULL); #endif if (locale_path == NULL) { g_printerr("ERROR: Invalid filename locale, can't convert file names specified on the command line to UTF-8.\n"); exit(1); } return locale_path; } void tool_init(gint* ac, gchar*** av, const gchar* tool_name, GOptionEntry* tool_entries, ToolInitFlags flags) { GError *local_err = NULL; init(); opt_context = g_option_context_new(tool_name); if (tool_entries) g_option_context_add_main_entries(opt_context, tool_entries, NULL); GOptionGroup* basic_group = g_option_group_new("basic", "Basic Options:", "Show basic options", NULL, NULL); g_option_group_add_entries(basic_group, basic_options); g_option_context_add_group(opt_context, basic_group); GOptionGroup* network_group = g_option_group_new("network", "Network Options:", "Show network options", NULL, NULL); g_option_group_add_entries(network_group, network_options); g_option_context_add_group(opt_context, network_group); if (flags & TOOL_INIT_AUTH) { GOptionGroup* auth_group = g_option_group_new("auth", "Authentication Options:", "Show authentication options", NULL, NULL); g_option_group_add_entries(auth_group, auth_options); g_option_context_add_group(opt_context, auth_group); } if (!g_option_context_parse(opt_context, ac, av, &local_err)) { g_printerr("ERROR: Option parsing failed: %s\n", local_err->message); g_clear_error(&local_err); exit(1); } print_version(); if (!opt_no_config || opt_config) { gboolean status = TRUE; gc_key_file_unref GKeyFile* kf = g_key_file_new(); if (opt_config) { if (!g_key_file_load_from_file(kf, opt_config, 0, &local_err)) { g_printerr("ERROR: Failed to open config file: %s: %s\n", opt_config, local_err->message); g_clear_error(&local_err); exit(1); } } else { status = g_key_file_load_from_file(kf, MEGA_RC_FILENAME, 0, NULL); if (!status) { gc_free gchar* tmp = g_build_filename(g_get_home_dir(), MEGA_RC_FILENAME, NULL); status = g_key_file_load_from_file(kf, tmp, 0, NULL); } } if (status) { // load username/password from ini file if (!opt_username) opt_username = g_key_file_get_string(kf, "Login", "Username", NULL); if (!opt_password) opt_password = g_key_file_get_string(kf, "Login", "Password", NULL); gint to = g_key_file_get_integer(kf, "Cache", "Timeout", &local_err); if (local_err == NULL) cache_timout = to; else g_clear_error(&local_err); // Load speed limits from settings file if (g_key_file_has_key(kf, "Network", "SpeedLimit", NULL)) { download_seed_limit = upload_speed_limit = g_key_file_get_integer(kf, "Network", "SpeedLimit", &local_err); if (local_err) { g_printerr("WARNING: Invalid speed limit set in the config file: %s\n", local_err->message); g_clear_error(&local_err); } } if (g_key_file_has_key(kf, "Network", "UploadSpeedLimit", NULL)) { upload_speed_limit = g_key_file_get_integer(kf, "Network", "UploadSpeedLimit", &local_err); if (local_err) { g_printerr("WARNING: Invalid upload speed limit set in the config file: %s\n", local_err->message); g_clear_error(&local_err); } } if (g_key_file_has_key(kf, "Network", "DownloadSpeedLimit", NULL)) { download_seed_limit = g_key_file_get_integer(kf, "Network", "DownloadSpeedLimit", &local_err); if (local_err) { g_printerr("WARNING: Invalid download speed limit set in the config file: %s\n", local_err->message); g_clear_error(&local_err); } } proxy = g_key_file_get_string(kf, "Network", "Proxy", NULL); } } if (opt_speed_limit >= 0) { upload_speed_limit = opt_speed_limit; download_seed_limit = opt_speed_limit; } if (opt_proxy) { if (!strcmp(opt_proxy, "none")) proxy = NULL; else proxy = opt_proxy; } if (!(flags & TOOL_INIT_AUTH)) return; if (!opt_username) { g_printerr("ERROR: You must specify your mega.nz username (email)\n"); exit(1); } if (!opt_password && opt_no_ask_password) { g_printerr("ERROR: You must specify your mega.nz password\n"); exit(1); } if (!opt_password) opt_password = input_password(); } mega_session* tool_start_session(ToolSessionFlags flags) { GError *local_err = NULL; gchar* sid = NULL; gboolean loaded = FALSE; mega_session* s = mega_session_new(); mega_session_set_speed(s, upload_speed_limit, download_seed_limit); if (proxy) mega_session_set_proxy(s, proxy); mega_session_enable_previews(s, TRUE); if (!(flags & TOOL_SESSION_OPEN)) return s; // try to load cached session data (they are valid for 10 minutes since last // user_get or refresh) if (!mega_session_load(s, opt_username, opt_password, cache_timout, &sid, &local_err)) { g_clear_error(&local_err); if (!mega_session_open(s, opt_username, opt_password, sid, &local_err)) { g_printerr("ERROR: Can't login to mega.nz: %s\n", local_err->message); goto err; } if (!mega_session_refresh(s, &local_err)) { g_printerr("ERROR: Can't read filesystem info from mega.nz: %s\n", local_err->message); goto err; } loaded = TRUE; mega_session_save(s, NULL); } if (opt_reload_files && !loaded) { if (!mega_session_refresh(s, &local_err)) { g_printerr("ERROR: Can't read filesystem info from mega.nz: %s\n", local_err->message); goto err; } mega_session_save(s, NULL); } g_free(sid); return s; err: mega_session_free(s); g_clear_error(&local_err); g_free(sid); return NULL; } void tool_fini(mega_session* s) { if (s) mega_session_free(s); g_option_context_free(opt_context); curl_global_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); #if OPENSSL_VERSION_NUMBER < 0x10100004L CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); #endif } megatools-1.9.98/lib/tools.h0000644000175000001440000000365213006625442012620 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __TOOLS_H #define __TOOLS_H #include #include #include #include #include #include "mega.h" #include "alloc.h" typedef enum { TOOL_SESSION_OPEN = 1 } ToolSessionFlags; typedef enum { TOOL_INIT_AUTH = 1 } ToolInitFlags; void tool_init (gint* ac, gchar*** av, const gchar* tool_name, GOptionEntry* tool_entries, ToolInitFlags flags); mega_session* tool_start_session (ToolSessionFlags flags); void tool_fini (mega_session* s); void tool_show_progress (const gchar* file, const mega_status_data *data); gchar* tool_convert_filename (const gchar* path, gboolean local); #ifdef G_OS_WIN32 #define ESC_CLREOL "" #define ESC_WHITE "" #define ESC_GREEN "" #define ESC_YELLOW "" #define ESC_BLUE "" #define ESC_GRAY "" #define ESC_NORMAL "" #else #define ESC_CLREOL "\x1b[0K" #define ESC_WHITE "\x1b[37;1m" #define ESC_GREEN "\x1b[32;1m" #define ESC_YELLOW "\x1b[33;1m" #define ESC_BLUE "\x1b[34;1m" #define ESC_GRAY "\x1b[30;1m" #define ESC_NORMAL "\x1b[0m" #endif #endif megatools-1.9.98/lib/mega.h0000644000175000001440000001421513006625442012366 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __OLD_MEGA_H #define __OLD_MEGA_H #include // API error domain #define MEGA_ERROR mega_error_quark() enum { MEGA_ERROR_OTHER }; // forward typedefs typedef struct _mega_sesssion mega_session; typedef struct _mega_node mega_node; typedef struct _mega_share_key mega_share_key; typedef struct _mega_user_quota mega_user_quota; typedef struct _mega_status_data mega_status_data; typedef struct _mega_reg_state mega_reg_state; // status callback enum { MEGA_STATUS_PROGRESS = 1, MEGA_STATUS_FILEINFO, MEGA_STATUS_DATA }; struct _mega_status_data { gint type; union { struct { guint64 total; guint64 done; guint64 last; gint64 span; } progress; struct { gchar* name; guint64 size; } fileinfo; struct { guchar* buf; guint64 size; } data; }; }; typedef gboolean (*mega_status_callback)(mega_status_data* data, gpointer userdata); // session data types enum { MEGA_NODE_FILE = 0, MEGA_NODE_FOLDER = 1, MEGA_NODE_ROOT = 2, MEGA_NODE_INBOX = 3, MEGA_NODE_TRASH = 4, MEGA_NODE_NETWORK = 9, MEGA_NODE_CONTACT = 8 }; struct _mega_share_key { gchar* node_handle; guchar* key; }; struct _mega_node { gchar* name; gchar* handle; gchar* parent_handle; gchar* user_handle; gchar* su_handle; gsize key_len; guchar* key; gint type; guint64 size; glong timestamp; // call addlinks after refresh to get links populated gchar* link; mega_session* s; mega_node* parent; }; struct _mega_user_quota { guint64 total; guint64 used; }; struct _mega_reg_state { gchar* user_handle; guchar password_key[16]; guchar challenge[16]; }; #define MEGA_DEBUG_API 0x01 #define MEGA_DEBUG_CACHE 0x02 #define MEGA_DEBUG_FS 0x04 extern gint mega_debug; GQuark mega_error_quark (void); mega_session* mega_session_new (void); void mega_session_free (mega_session* s); void mega_session_set_speed (mega_session* s, gint ul, gint dl); void mega_session_set_proxy (mega_session* s, const gchar* proxy); void mega_session_watch_status (mega_session* s, mega_status_callback cb, gpointer userdata); void mega_session_enable_previews (mega_session* s, gboolean enable); // this has side effect of the current session being closed gboolean mega_session_open (mega_session* s, const gchar* un, const gchar* pw, const gchar* sid, GError** err); void mega_session_close (mega_session* s); const gchar* mega_session_get_sid (mega_session* s); gboolean mega_session_save (mega_session* s, GError** err); // this has side effect of the current session being closed gboolean mega_session_load (mega_session* s, const gchar* un, const gchar* pw, gint max_age, gchar** last_sid, GError** err); gboolean mega_session_get_user (mega_session* s, GError** err); gboolean mega_session_refresh (mega_session* s, GError** err); gboolean mega_session_addlinks (mega_session* s, GSList* nodes, GError** err); mega_user_quota* mega_session_user_quota (mega_session* s, GError** err); GSList* mega_session_ls_all (mega_session* s); GSList* mega_session_ls (mega_session* s, const gchar* path, gboolean recursive); GSList* mega_session_get_node_chilren (mega_session* s, mega_node* node); mega_node* mega_session_stat (mega_session* s, const gchar* path); mega_node* mega_session_mkdir (mega_session* s, const gchar* path, GError** err); gboolean mega_session_rm (mega_session* s, const gchar* path, GError** err); mega_node* mega_session_put (mega_session* s, const gchar* remote_path, const gchar* local_path, GError** err); gchar* mega_session_new_node_attribute (mega_session* s, const guchar* data, gsize len, const gchar* type, const guchar* key, GError** err); gboolean mega_session_get (mega_session* s, const gchar* local_path, const gchar* remote_path, GError** err); gboolean mega_session_open_exp_folder (mega_session* s, const gchar* n, const gchar* key, GError** err); gboolean mega_session_dl (mega_session* s, const gchar* handle, const gchar* key, const gchar* local_path, GError** err); gboolean mega_node_is_writable (mega_session* s, mega_node* n); gboolean mega_node_is_container (mega_node* n); gchar* mega_node_get_link (mega_node* n, gboolean include_key); gchar* mega_node_get_key (mega_node* n); gboolean mega_node_get_path (mega_node* n, gchar* buf, gsize len); gchar* mega_node_get_path_dup (mega_node* n); gboolean mega_session_register (mega_session* s, const gchar* email, const gchar* password, const gchar* name, mega_reg_state** state, GError** err); gboolean mega_session_register_verify (mega_session* s, mega_reg_state* state, const gchar* signup_key, GError** err); #endif megatools-1.9.98/lib/http.h0000644000175000001440000000417513006625442012440 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __MEGA_HTTP_H #define __MEGA_HTTP_H #include #define HTTP_ERROR http_error_quark() enum { HTTP_ERROR_NO_RESPONSE, HTTP_ERROR_SERVER_BUSY, HTTP_ERROR_OTHER }; typedef struct _http http; typedef gsize (*http_data_fn)(gpointer buf, gsize len, gpointer user_data); typedef gboolean (*http_progress_fn)(goffset total, goffset now, gpointer user_data); // functions http* http_new(void); void http_set_referer(http* h, const gchar* referer); void http_set_user_agent(http* h, const gchar* ua); void http_set_content_type(http* h, const gchar* type); void http_set_content_length(http* h, goffset len); void http_no_expect(http* h); void http_set_header(http* h, const gchar* name, const gchar* value); void http_set_progress_callback(http* h, http_progress_fn cb, gpointer data); void http_set_speed(http* h, gint max_ul, gint max_dl); void http_set_proxy(http* h, const gchar* proxy); GString* http_post(http* h, const gchar* url, const gchar* body, gssize body_len, GError** err); GString* http_post_stream_upload(http* h, const gchar* url, goffset len, http_data_fn read_cb, gpointer user_data, GError** err); gboolean http_post_stream_download(http* h, const gchar* url, http_data_fn write_cb, gpointer user_data, GError** err); void http_free(http* h); GQuark http_error_quark(void); #endif megatools-1.9.98/lib/mega.c0000644000175000001440000032256613006637606012401 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include "mega.h" #include "http.h" #include "sjson.h" #include "alloc.h" #include #include #include #include #include #include #include #include #include #include #include DEFINE_CLEANUP_FUNCTION(http*, http_free) #define gc_http_free CLEANUP(http_free) DEFINE_CLEANUP_FUNCTION_NULL(BN_CTX*, BN_CTX_free) #define gc_bn_ctx_free CLEANUP(BN_CTX_free) DEFINE_CLEANUP_FUNCTION_NULL(BIGNUM*, BN_free) #define gc_bn_free CLEANUP(BN_free) #define CACHE_FORMAT_VERSION 3 #define PROGRESS_FREQUENCY ((gint64)2e6) #define PROGRESS_ONESEC ((gint64)1e6) gint mega_debug = 0; // Data structures and enums // {{{ SRV_E* enum { SRV_EINTERNAL = -1, SRV_EARGS = -2, SRV_EAGAIN = -3, SRV_ERATELIMIT = -4, SRV_EFAILED = -5, SRV_ETOOMANY = -6, SRV_ERANGE = -7, SRV_EEXPIRED = -8, // FS access errors SRV_ENOENT = -9, SRV_ECIRCULAR = -10, SRV_EACCESS = -11, SRV_EEXIST = -12, SRV_EINCOMPLETE = -13, // crypto errors SRV_EKEY = -14, // user errors SRV_ESID = -15, SRV_EBLOCKED = -16, SRV_EOVERQUOTA = -17, SRV_ETEMPUNAVAIL = -18, SRV_ETOOMANYCONNECTIONS = -19 }; // }}} // {{{ rsa_key typedef struct _rsa_key rsa_key; struct _rsa_key { // priv BIGNUM* p; BIGNUM* q; BIGNUM* d; BIGNUM* u; // p^-1 mod q // pub BIGNUM* m; BIGNUM* e; }; // }}} // {{{ mega_session struct _mega_sesssion { http* http; gint max_ul; gint max_dl; gchar* proxy; gint id; gchar* sid; gchar* sid_param_name; gchar* rid; guchar* password_key; guchar* master_key; rsa_key rsa_key; gchar* user_handle; gchar* user_name; gchar* user_email; GHashTable* share_keys; GSList* fs_nodes; // progress reporting mega_status_callback status_callback; mega_status_data status_data; gpointer status_userdata; gint64 last_refresh; gint64 last_progress; guint64 last_progress_bytes; gboolean create_preview; }; // }}} // JSON helpers // {{{ print_node static void print_node(const gchar* n, const gchar* prefix) { gc_free gchar* pretty = s_json_pretty(n); g_printerr("%s%s\n", prefix, pretty); } // }}} // {{{ s_json_get_bytes static guchar* s_json_get_bytes(const gchar* node, gsize* out_len) { g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(out_len != NULL, NULL); gc_free gchar* data = s_json_get_string(node); if (data) { gchar* b64 = g_base64_decode(data, out_len); return b64; } return NULL; } // }}} // {{{ s_json_get_member_bytes static guchar* s_json_get_member_bytes(const gchar* node, const gchar* name, gsize* out_len) { g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); g_return_val_if_fail(out_len != NULL, NULL); const gchar* v = s_json_get_member(node, name); if (v) return s_json_get_bytes(v, out_len); return NULL; } // }}} // {{{ s_json_get_member_bn static BIGNUM* s_json_get_member_bn(const gchar* node, const gchar* name) { g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); gc_free gchar* data = s_json_get_member_string(node, name); if (data) { BIGNUM* n = NULL; if (BN_dec2bn(&n, data)) return n; } return NULL; } void s_json_get_member_rsa_key(const gchar* node, const gchar* name, rsa_key* key) { g_return_if_fail(node != NULL); g_return_if_fail(name != NULL); g_return_if_fail(key != NULL); const gchar* member = s_json_get_member(node, name); if (!member || s_json_get_type(member) != S_JSON_TYPE_OBJECT) return; #define READ_COMPONENT(c) \ key->c = s_json_get_member_bn(member, #c) READ_COMPONENT(p); READ_COMPONENT(q); READ_COMPONENT(d); READ_COMPONENT(u); READ_COMPONENT(m); READ_COMPONENT(e); #undef READ_COMPONENT } // }}} // {{{ s_json_gen_member_bytes static void s_json_gen_member_bytes(SJsonGen* gen, const gchar* name, guchar* data, gsize len) { if (data) { gc_free gchar* tmp = g_base64_encode(data, len); s_json_gen_member_string(gen, name, tmp); } else { s_json_gen_member_null(gen, name); } } // }}} // {{{ s_json_gen_member_rsa_key static void s_json_gen_member_bn(SJsonGen* gen, const gchar* name, BIGNUM* n) { gchar* tmp = BN_bn2dec(n); s_json_gen_member_string(gen, name, tmp); OPENSSL_free(tmp); } static void s_json_gen_member_rsa_key(SJsonGen* gen, const gchar* name, rsa_key* key) { s_json_gen_member_object(gen, name); #define ADD_COMPONENT(name) \ if (key->name) \ s_json_gen_member_bn(gen, #name, key->name); ADD_COMPONENT(p) ADD_COMPONENT(q) ADD_COMPONENT(d) ADD_COMPONENT(u) ADD_COMPONENT(m) ADD_COMPONENT(e) #undef ADD_COMPONENT s_json_gen_end_object(gen); } // }}} // Crypto utilities #define DW(p, n) (*((guint32*)(p) + (n))) // {{{ multi-precision integer macros #define MPI_BITS(ptr) GUINT16_FROM_BE(*(guint16*)(ptr)) #define MPI_BYTES(ptr) ((MPI_BITS(ptr) + 7) / 8) #define MPI_SIZE(ptr) (MPI_BYTES(ptr) + MPI_HDRSIZE) #define MPI_HDRSIZE 2 #define MPI2BN(ptr) \ BN_bin2bn((ptr) + MPI_HDRSIZE, MPI_BYTES(ptr), NULL) // }}} // {{{ base64urlencode static gchar* base64urlencode(const guchar* data, gsize len) { gint i, shl; gchar *she, *p; g_return_val_if_fail(data != NULL, NULL); g_return_val_if_fail(len > 0, NULL); gc_free gchar* sh = g_base64_encode(data, len); shl = strlen(sh); she = g_malloc0(shl + 1), p = she; for (i = 0; i < shl; i++) { if (sh[i] == '+') *p = '-'; else if (sh[i] == '/') *p = '_'; else if (sh[i] == '=') continue; else *p = sh[i]; p++; } *p = '\0'; return she; } // }}} // {{{ base64urldecode static guchar* base64urldecode(const gchar* str, gsize* len) { gint i; g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(len != NULL, NULL); gc_string_free GString* s = g_string_new(str); for (i = 0; i < s->len; i++) { if (s->str[i] == '-') s->str[i] = '+'; else if (s->str[i] == '_') s->str[i] = '/'; } gint eqs = (s->len * 3) & 0x03; for (i = 0; i < eqs; i++) g_string_append_c(s, '='); return g_base64_decode(s->str, len); } // }}} // {{{ aes128_decrypt G_GNUC_UNUSED static gboolean aes128_decrypt(guchar* out, const guchar* in, gsize len, const guchar* key) { AES_KEY k; gsize off; g_return_val_if_fail(out != NULL, FALSE); g_return_val_if_fail(in != NULL, FALSE); g_return_val_if_fail(len % 16 == 0, FALSE); g_return_val_if_fail(key != NULL, FALSE); AES_set_decrypt_key(key, 128, &k); for (off = 0; off < len; off += 16) AES_decrypt(in + off, out + off, &k); return TRUE; } // }}} // {{{ aes128_encrypt static gboolean aes128_encrypt(guchar* out, const guchar* in, gsize len, const guchar* key) { AES_KEY k; gsize off; g_return_val_if_fail(out != NULL, FALSE); g_return_val_if_fail(in != NULL, FALSE); g_return_val_if_fail(len % 16 == 0, FALSE); g_return_val_if_fail(key != NULL, FALSE); AES_set_encrypt_key(key, 128, &k); for (off = 0; off < len; off += 16) AES_encrypt(in + off, out + off, &k); return TRUE; } // }}} // {{{ b64_aes128_decrypt static guchar* b64_aes128_decrypt(const gchar* str, const guchar* key, gsize* outlen) { AES_KEY k; gsize cipherlen = 0; gsize off; gc_free guchar* cipher = NULL; guchar* data; g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); AES_set_decrypt_key(key, 128, &k); cipher = base64urldecode(str, &cipherlen); if (cipher == NULL) return NULL; if (cipherlen % 16 != 0) return NULL; data = g_malloc0(cipherlen); for (off = 0; off < cipherlen; off += 16) AES_decrypt(cipher + off, data + off, &k); if (outlen) *outlen = cipherlen; return data; } // }}} // {{{ b64_aes128_encrypt static gchar* b64_aes128_encrypt(const guchar* data, gsize len, const guchar* key) { AES_KEY k; gsize off; gc_free guchar* cipher = NULL; gchar* str; g_return_val_if_fail(data != NULL, NULL); g_return_val_if_fail((len % 16) == 0, NULL); g_return_val_if_fail(key != NULL, NULL); AES_set_encrypt_key(key, 128, &k); cipher = g_malloc0(len); for (off = 0; off < len; off += 16) AES_encrypt(data + off, cipher + off, &k); return base64urlencode(cipher, len); } // }}} // {{{ b64_aes128_cbc_decrypt static guchar* b64_aes128_cbc_decrypt(const gchar* str, const guchar* key, gsize* outlen) { AES_KEY k; gsize cipherlen = 0; gc_free guchar* cipher = NULL; guchar* data; g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); AES_set_decrypt_key(key, 128, &k); cipher = base64urldecode(str, &cipherlen); if (cipher == NULL) return NULL; if (cipherlen % 16 != 0) return NULL; data = g_malloc0(cipherlen + 1); guchar iv[AES_BLOCK_SIZE] = {0}; AES_cbc_encrypt(cipher, data, cipherlen, &k, iv, 0); if (outlen) *outlen = cipherlen; return data; } // }}} // {{{ b64_aes128_cbc_encrypt static gchar* b64_aes128_cbc_encrypt(const guchar* data, gsize len, const guchar* key) { AES_KEY k; gc_free guchar* cipher = NULL; gchar* str; guchar iv[AES_BLOCK_SIZE] = {0}; g_return_val_if_fail(data != NULL, NULL); g_return_val_if_fail((len % 16) == 0, NULL); g_return_val_if_fail(key != NULL, NULL); AES_set_encrypt_key(key, 128, &k); cipher = g_malloc0(len); AES_cbc_encrypt(data, cipher, len, &k, iv, 1); return base64urlencode(cipher, len); } // }}} // {{{ b64_aes128_cbc_encrypt_str static gchar* b64_aes128_cbc_encrypt_str(const gchar* str, const guchar* key) { gsize len = 0; gc_free guchar* data = NULL; gchar* out; g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); len = strlen(str) + 1; if (len % 16) len += 16 - (len % 16); data = g_malloc0(len); memcpy(data, str, len - 1); return b64_aes128_cbc_encrypt(data, len, key); } // }}} // {{{ b64_aes128_decrypt_privk static gboolean b64_aes128_decrypt_privk(const gchar* str, const guchar* key, rsa_key* rsa) { gsize data_len = 0; gc_free guchar *data = NULL; guchar *p, *e; g_return_val_if_fail(str != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(rsa != NULL, FALSE); data = b64_aes128_decrypt(str, key, &data_len); if (!data) return FALSE; p = data; e = p + data_len; if (p + MPI_SIZE(p) > e) return FALSE; rsa->p = MPI2BN(p); p += MPI_SIZE(p); if (p + MPI_SIZE(p) > e) return FALSE; rsa->q = MPI2BN(p); p += MPI_SIZE(p); if (p + MPI_SIZE(p) > e) return FALSE; rsa->d = MPI2BN(p); p += MPI_SIZE(p); if (p + MPI_SIZE(p) > e) return FALSE; rsa->u = MPI2BN(p); return TRUE; } // }}} // {{{ b64_decode_pubk static gboolean b64_decode_pubk(const gchar* str, rsa_key* rsa) { gsize data_len = 0; gc_free guchar *data = NULL; guchar *p, *e; g_return_val_if_fail(str != NULL, FALSE); g_return_val_if_fail(rsa != NULL, FALSE); data = base64urldecode(str, &data_len); if (data == NULL) return FALSE; p = data; e = p + data_len; if (p + MPI_SIZE(p) > e) return FALSE; rsa->m = MPI2BN(p); p += MPI_SIZE(p); if (p + MPI_SIZE(p) > e) return FALSE; rsa->e = MPI2BN(p); return TRUE; } // }}} // {{{ b64_aes128_encrypt_privk static void append_mpi_from_bn(GString* buf, BIGNUM* n) { g_return_if_fail(buf != NULL); g_return_if_fail(n != NULL); gsize size = BN_num_bytes(n); gsize off = buf->len; g_string_set_size(buf, buf->len + size + MPI_HDRSIZE); *(guint16*)(buf->str + off) = GUINT16_TO_BE(BN_num_bits(n)); BN_bn2bin(n, buf->str + off + MPI_HDRSIZE); } static gchar* b64_aes128_encrypt_privk(const guchar* key, rsa_key* rsa) { g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(rsa != NULL, FALSE); gc_string_free GString* data = g_string_sized_new(128 * 7); append_mpi_from_bn(data, rsa->p); append_mpi_from_bn(data, rsa->q); append_mpi_from_bn(data, rsa->d); append_mpi_from_bn(data, rsa->u); gsize off = data->len; gsize pad = data->len % 16 ? 16 - (data->len % 16) : 0; if (pad) { g_string_set_size(data, data->len + pad); while (off < data->len) data->str[off++] = 0; } return b64_aes128_encrypt(data->str, data->len, key); } // }}} // {{{ b64_encode_pubk static gchar* b64_encode_pubk(rsa_key* rsa) { g_return_val_if_fail(rsa != NULL, FALSE); gc_string_free GString* data = g_string_sized_new(128 * 3); append_mpi_from_bn(data, rsa->m); append_mpi_from_bn(data, rsa->e); return base64urlencode(data->str, data->len); } // }}} // {{{ rsa_decrypt static BIGNUM* rsa_decrypt(BIGNUM* m, BIGNUM* d, BIGNUM* p, BIGNUM* q, BIGNUM* u) { g_return_val_if_fail(m != NULL, NULL); g_return_val_if_fail(d != NULL, NULL); g_return_val_if_fail(p != NULL, NULL); g_return_val_if_fail(q != NULL, NULL); g_return_val_if_fail(u != NULL, NULL); gc_bn_ctx_free BN_CTX* ctx = BN_CTX_new(); gc_bn_free BIGNUM* xp = BN_new(); gc_bn_free BIGNUM* xq = BN_new(); gc_bn_free BIGNUM* mod_mp = BN_new(); gc_bn_free BIGNUM* mod_mq = BN_new(); gc_bn_free BIGNUM* mod_dp1 = BN_new(); gc_bn_free BIGNUM* mod_dq1 = BN_new(); gc_bn_free BIGNUM* p1 = BN_new(); gc_bn_free BIGNUM* q1 = BN_new(); gc_bn_free BIGNUM* t = BN_new(); BIGNUM* x = BN_new(); // var xp = bmodexp(bmod(m,p), bmod(d,bsub(p,[1])), p); BN_mod(mod_mp, m, p, ctx); BN_sub(p1, p, BN_value_one()); BN_mod(mod_dp1, d, p1, ctx); BN_mod_exp(xp, mod_mp, mod_dp1, p, ctx); // var xq = bmodexp(bmod(m,q), bmod(d,bsub(q,[1])), q); BN_mod(mod_mq, m, q, ctx); BN_sub(q1, q, BN_value_one()); BN_mod(mod_dq1, d, q1, ctx); BN_mod_exp(xq, mod_mq, mod_dq1, q, ctx); // var t = bsub(xq,xp); if (BN_ucmp(xq, xp) <= 0) { BN_sub(t, xp, xq); BN_mul(x, t, u, ctx); BN_mod(t, x, q, ctx); BN_sub(t, q, t); } else { BN_sub(t, xq, xp); BN_mul(x, t, u, ctx); BN_mod(t, x, q, ctx); } BN_mul(x, t, p, ctx); BN_add(x, x, xp); return x; } // }}} // {{{ rsa_encrypt /* static BIGNUM* rsa_encrypt(BIGNUM* s, BIGNUM* e, BIGNUM* m) { BN_CTX* ctx; BIGNUM *r; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(e != NULL, NULL); g_return_val_if_fail(m != NULL, NULL); ctx = BN_CTX_new(); r = BN_new(); BN_mod_exp(r, s, e, m, ctx); BN_CTX_free(ctx); return r; } */ // }}} // {{{ b64_rsa_decrypt static guchar* b64_rsa_decrypt(const gchar* str, rsa_key* key, gsize* outlen) { gsize cipherlen = 0; gc_free guchar* cipher = NULL; guchar* data; gc_bn_free BIGNUM *c = NULL, *m = NULL; g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); cipher = base64urldecode(str, &cipherlen); if (cipher == NULL) return NULL; if (MPI_SIZE(cipher) > cipherlen) return NULL; c = MPI2BN(cipher); m = rsa_decrypt(c, key->d, key->p, key->q, key->u); if (!m) return NULL; data = g_malloc0(BN_num_bytes(m) + 1); BN_bn2bin(m, data); if (outlen) *outlen = BN_num_bytes(m); return data; } // }}} // {{{ rsa_key_gen static gboolean rsa_key_gen(rsa_key* k) { RSA* key; g_return_val_if_fail(k != NULL, FALSE); g_return_val_if_fail(k->p == NULL, FALSE); g_return_val_if_fail(k->m == NULL, FALSE); key = RSA_new(); if (!key) return FALSE; BIGNUM* e = BN_new(); if (!e) { RSA_free(key); return FALSE; } BN_set_word(e, RSA_3); if (!RSA_generate_key_ex(key, 2048, e, NULL)) return FALSE; if (RSA_check_key(key) != 1) { RSA_free(key); return FALSE; } #if OPENSSL_VERSION_NUMBER >= 0x10100000L RSA_get0_key(key, &k->m, &k->e, &k->d); RSA_get0_factors(key, &k->q, &k->p); RSA_get0_crt_params(key, NULL, NULL, &k->u); k->p = BN_dup(k->p); k->q = BN_dup(k->q); k->d = BN_dup(k->d); k->u = BN_dup(k->u); k->m = BN_dup(k->m); k->e = BN_dup(k->e); #else // private part k->p = BN_dup(key->q); k->q = BN_dup(key->p); k->d = BN_dup(key->d); k->u = BN_dup(key->iqmp); // public part k->m = BN_dup(key->n); k->e = BN_dup(key->e); #endif RSA_free(key); BN_free(e); return TRUE; } // }}} // {{{ rsa_key_free static void rsa_key_free(rsa_key* k) { if (!k) return; if (k->p) BN_free(k->p); if (k->q) BN_free(k->q); if (k->d) BN_free(k->d); if (k->u) BN_free(k->u); if (k->m) BN_free(k->m); if (k->e) BN_free(k->e); memset(k, 0, sizeof(rsa_key)); } // }}} // {{{ make_random_key static guchar* make_random_key(void) { guchar k[16]; //XXX: error check RAND_bytes(k, sizeof(k)); return g_memdup(k, 16); } // }}} // {{{ make_password_key static guchar* make_password_key(const gchar* password) { guchar pkey[16] = {0x93, 0xC4, 0x67, 0xE3, 0x7D, 0xB0, 0xC7, 0xA4, 0xD1, 0xBE, 0x3F, 0x81, 0x01, 0x52, 0xCB, 0x56}; gint i, r; gint len; g_return_val_if_fail(password != NULL, NULL); len = strlen(password); for (r = 65536; r--; ) { for (i = 0; i < len; i += 16) { AES_KEY k; guchar key[16] = {0}, pkey_tmp[16]; strncpy(key, password + i, 16); AES_set_encrypt_key(key, 128, &k); AES_encrypt(pkey, pkey_tmp, &k); memcpy(pkey, pkey_tmp, 16); } } return g_memdup(pkey, 16); } // }}} // {{{ make_username_hash static gchar* make_username_hash(const gchar* un, const guchar* key) { AES_KEY k; gint l, i; guchar hash[16] = {0}, hash_tmp[16], oh[8]; g_return_val_if_fail(un != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); AES_set_encrypt_key(key, 128, &k); for (i = 0, l = strlen(un); i < l; i++) hash[i % 16] ^= un[i]; for (i = 16384; i--; ) { AES_encrypt(hash, hash_tmp, &k); memcpy(hash, hash_tmp, 16); } memcpy(oh, hash, 4); memcpy(oh + 4, hash + 8, 4); return base64urlencode(oh, 8); } // }}} // {{{ make_request_id static guchar* make_request_id(void) { const gchar chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; gchar k[11] = {0}; gint i; for (i = 0; i < 10; i++) k[i] = chars[rand() % sizeof(chars)]; return g_strdup(k); } // }}} // {{{ chunked CBC-MAC static guint64 get_chunk_size(gsize idx) { return (idx < 8 ? idx + 1 : 8) * 1024 * 128; } /* static gsize get_chunk_off(gint idx) { gsize p = 0; gint i = 0; for (i = 0; i < idx; i++) p += get_chunk_size(i); return p; } */ typedef struct { AES_KEY k; gsize chunk_idx; guint64 next_boundary; guint64 position; guchar chunk_mac_iv[16]; guchar chunk_mac[16]; guchar meta_mac[16]; } chunked_cbc_mac; static void chunked_cbc_mac_init(chunked_cbc_mac* mac, guchar key[16], guchar iv[16]) { g_return_if_fail(mac != NULL); g_return_if_fail(key != NULL); memset(mac, 0, sizeof(*mac)); memcpy(mac->chunk_mac_iv, iv, 16); memcpy(mac->chunk_mac, mac->chunk_mac_iv, 16); AES_set_encrypt_key(key, 128, &mac->k); mac->next_boundary = get_chunk_size(mac->chunk_idx); } static void chunked_cbc_mac_init8(chunked_cbc_mac* mac, guchar key[16], guchar iv[8]) { g_return_if_fail(iv != NULL); guchar mac_iv[16]; memcpy(mac_iv, iv, 8); memcpy(mac_iv + 8, iv, 8); chunked_cbc_mac_init(mac, key, mac_iv); } static void chunked_cbc_mac_close_chunk(chunked_cbc_mac* mac) { gint i; guchar tmp[16]; for (i = 0; i < 16; i++) mac->meta_mac[i] ^= mac->chunk_mac[i]; AES_encrypt(mac->meta_mac, tmp, &mac->k); memcpy(mac->meta_mac, tmp, 16); memcpy(mac->chunk_mac, mac->chunk_mac_iv, 16); mac->next_boundary += get_chunk_size(++mac->chunk_idx); } static void chunked_cbc_mac_update(chunked_cbc_mac* mac, const guchar* data, gsize len) { gsize i; g_return_if_fail(mac != NULL); g_return_if_fail(data != NULL); for (i = 0; i < len; i++) { mac->chunk_mac[mac->position % 16] ^= data[i]; mac->position++; if (G_UNLIKELY((mac->position % 16) == 0)) { guchar tmp[16]; AES_encrypt(mac->chunk_mac, tmp, &mac->k); memcpy(mac->chunk_mac, tmp, 16); } // add chunk mac to the chunk macs list if we are at the chunk boundary if (G_UNLIKELY(mac->position == mac->next_boundary)) chunked_cbc_mac_close_chunk(mac); } } static void chunked_cbc_mac_finish(chunked_cbc_mac* mac, guchar mac_out[16]) { g_return_if_fail(mac != NULL); // finish buffer if necessary if (mac->position % 16) { while (mac->position % 16) { mac->chunk_mac[mac->position % 16] ^= 0; mac->position++; } guchar tmp[16]; AES_encrypt(mac->chunk_mac, tmp, &mac->k); memcpy(mac->chunk_mac, tmp, 16); } // if there last chunk is unfinished, finish it if (mac->position > (mac->next_boundary - get_chunk_size(mac->chunk_idx))) chunked_cbc_mac_close_chunk(mac); if (mac_out) memcpy(mac_out, mac->meta_mac, 16); memset(mac, 0, sizeof(*mac)); } static void chunked_cbc_mac_finish8(chunked_cbc_mac* mac, guchar mac_out[8]) { guchar buf[16]; gint i; g_return_if_fail(mac_out != NULL); chunked_cbc_mac_finish(mac, buf); for (i = 0; i < 4; i++) mac_out[i] = buf[i] ^ buf[i + 4]; for (i = 0; i < 4; i++) mac_out[i + 4] = buf[i + 8] ^ buf[i + 12]; } // }}} // {{{ unpack_node_key static void unpack_node_key(guchar node_key[32], guchar aes_key[16], guchar nonce[8], guchar meta_mac_xor[8]) { if (aes_key) { DW(aes_key, 0) = DW(node_key, 0) ^ DW(node_key, 4); DW(aes_key, 1) = DW(node_key, 1) ^ DW(node_key, 5); DW(aes_key, 2) = DW(node_key, 2) ^ DW(node_key, 6); DW(aes_key, 3) = DW(node_key, 3) ^ DW(node_key, 7); } if (nonce) { DW(nonce, 0) = DW(node_key, 4); DW(nonce, 1) = DW(node_key, 5); } if (meta_mac_xor) { DW(meta_mac_xor, 0) = DW(node_key, 6); DW(meta_mac_xor, 1) = DW(node_key, 7); } } // }}} // {{{ pack_node_key static void pack_node_key(guchar node_key[32], guchar aes_key[16], guchar nonce[8], guchar meta_mac[16]) { DW(node_key, 0) = DW(aes_key, 0) ^ DW(nonce, 0); DW(node_key, 1) = DW(aes_key, 1) ^ DW(nonce, 1); DW(node_key, 2) = DW(aes_key, 2) ^ DW(meta_mac, 0) ^ DW(meta_mac, 1); DW(node_key, 3) = DW(aes_key, 3) ^ DW(meta_mac, 2) ^ DW(meta_mac, 3); DW(node_key, 4) = DW(nonce, 0); DW(node_key, 5) = DW(nonce, 1); DW(node_key, 6) = DW(meta_mac, 0) ^ DW(meta_mac, 1); DW(node_key, 7) = DW(meta_mac, 2) ^ DW(meta_mac, 3); } // }}} // {{{ encode_node_attrs static gchar* encode_node_attrs(const gchar* name) { g_return_val_if_fail(name != NULL, NULL); SJsonGen* gen = s_json_gen_new(); s_json_gen_start_object(gen); s_json_gen_member_string(gen, "n", name); s_json_gen_end_object(gen); gc_free gchar* attrs_json = s_json_gen_done(gen); return g_strdup_printf("MEGA%s", attrs_json); } // }}} // {{{ decode_node_attrs static gboolean decode_node_attrs(const gchar* attrs, gchar** name) { g_return_val_if_fail(attrs != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); // parse attributes if (!attrs || !g_str_has_prefix(attrs, "MEGA{")) return FALSE; // decode JSON if (!s_json_is_valid(attrs + 4)) return FALSE; *name = s_json_get_member_string(attrs + 4, "n"); return TRUE; } // }}} // {{{ decrypt_node_attrs static gboolean decrypt_node_attrs(const gchar* encrypted_attrs, const guchar* key, gchar** name) { g_return_val_if_fail(encrypted_attrs != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); gc_free guchar* attrs = b64_aes128_cbc_decrypt(encrypted_attrs, key, NULL); return decode_node_attrs(attrs, name); } // }}} // {{{ handle_auth gboolean handle_auth(const gchar* handle, const gchar* b64_ha, const guchar* master_key) { gsize ha_len = 0; g_return_val_if_fail(handle != NULL, FALSE); g_return_val_if_fail(b64_ha != NULL, FALSE); g_return_val_if_fail(master_key != NULL, FALSE); gc_free guchar* ha = b64_aes128_decrypt(b64_ha, master_key, &ha_len); if (!ha || ha_len != 16) return FALSE; return !memcmp(ha, handle, 8) && !memcmp(ha + 8, handle, 8); } // }}} // Server API helpers // {{{ srv_error_to_string static const gchar* srv_error_to_string(gint code) { switch (code) { case SRV_EINTERNAL : return "EINTERNAL"; case SRV_EARGS : return "EARGS"; case SRV_EAGAIN : return "EAGAIN"; case SRV_ERATELIMIT : return "ERATELIMIT"; case SRV_EFAILED : return "EFAILED"; case SRV_ETOOMANY : return "ETOOMANY"; case SRV_ERANGE : return "ERANGE"; case SRV_EEXPIRED : return "EEXPIRED"; case SRV_ENOENT : return "ENOENT"; case SRV_ECIRCULAR : return "ECIRCULAR"; case SRV_EACCESS : return "EACCESS"; case SRV_EEXIST : return "EEXIST"; case SRV_EINCOMPLETE : return "EINCOMPLETE"; case SRV_EKEY : return "EKEY"; case SRV_ESID : return "ESID"; case SRV_EBLOCKED : return "EBLOCKED"; case SRV_EOVERQUOTA : return "EOVERQUOTA"; case SRV_ETEMPUNAVAIL : return "ETEMPUNAVAIL"; case SRV_ETOOMANYCONNECTIONS : return "ETOOMANYCONNECTIONS"; default : return "EUNKNOWN"; } } // }}} // {{{ api_request_unsafe static gchar* api_request_unsafe(mega_session* s, const gchar* req_node, GError** err) { GError* local_err = NULL; gc_free gchar* url = NULL; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(req_node != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); if (mega_debug & MEGA_DEBUG_API) print_node(req_node, "-> "); // prepare URL s->id++; if (s->sid) url = g_strdup_printf("https://eu.api.mega.co.nz/cs?id=%u&%s=%s", s->id, s->sid_param_name ? s->sid_param_name : "sid", s->sid); else url = g_strdup_printf("https://eu.api.mega.co.nz/cs?id=%u", s->id); GString* res_str = http_post(s->http, url, req_node, strlen(req_node), &local_err); // handle http errors if (!res_str) { if (local_err->domain == HTTP_ERROR && (local_err->code == HTTP_ERROR_NO_RESPONSE || local_err->code == HTTP_ERROR_SERVER_BUSY)) { // simulate SRV_EAGAIN response if server drops connection return g_strdup_printf("%d", SRV_EAGAIN); } else { g_propagate_prefixed_error(err, local_err, "HTTP POST failed: "); return NULL; } } // decode JSON if (!s_json_is_valid(res_str->str)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response JSON"); g_string_free(res_str, TRUE); return NULL; } gchar* res_node = g_string_free(res_str, FALSE); if (mega_debug & MEGA_DEBUG_API && res_node) print_node(res_node, "<- "); return res_node; } // }}} // {{{ api_request static gchar* api_request(mega_session* s, const gchar* req_node, GError** err) { GError* local_err = NULL; gchar* response; gint delay = 250000; // repeat after 250ms 500ms 1s ... g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(req_node != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); // some default rate limiting g_usleep(20000); again: response = api_request_unsafe(s, req_node, &local_err); if (!response) { g_propagate_error(err, local_err); return NULL; } // if we are asked to repeat the call, do it with exponential backoff if (s_json_get_type(response) == S_JSON_TYPE_NUMBER && s_json_get_int(response, SRV_EINTERNAL) == SRV_EAGAIN) { g_free(response); g_usleep(delay); delay = delay * 2; if (delay > 4 * 64 * 1000 * 1000) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Server keeps asking us for EAGAIN, giving up"); return NULL; } goto again; } return response; } // }}} // {{{ api_response_check // check that we have and array with a response value (object or error code) static const gchar* api_response_check(const gchar* response, gchar expects, gint* error_code, GError** err) { // there was already an error returned by api_request if (*err) return NULL; // null response without an error, it shouldn't happen, but handle it to be sure if (!response) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Null response"); return NULL; } if (error_code) *error_code = 0; SJsonType response_type = s_json_get_type(response); // request level error if (response_type == S_JSON_TYPE_NUMBER) { gint v = s_json_get_int(response, 0); // if it's negative, it's error status if (v < 0) { if (error_code) *error_code = v; g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Server returned error %s", srv_error_to_string(v)); return NULL; } } // check that we have and array with a response value else if (response_type == S_JSON_TYPE_ARRAY) { const gchar* node = s_json_get_element(response, 0); if (node) { SJsonType node_type = s_json_get_type(node); // we got object if (node_type == S_JSON_TYPE_OBJECT) { if (expects == 'o') return node; } else if (node_type == S_JSON_TYPE_ARRAY) { if (expects == 'a') return node; } else if (node_type == S_JSON_TYPE_NUMBER) { // we got int number gint v = s_json_get_int(node, 0); // if it's negative, it's error status if (v < 0) { if (error_code) *error_code = v; g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Server returned error %s", srv_error_to_string(v)); return NULL; } if (expects == 'i') return node; } else if (node_type == S_JSON_TYPE_BOOL) { if (expects == 'b') return node; } else if (node_type == S_JSON_TYPE_STRING) { if (expects == 's') return node; } else if (node_type == S_JSON_TYPE_NULL) { if (expects == 'n') return node; } } } g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Unexpected response"); return NULL; } // }}} // {{{ api_call static gchar* api_call(mega_session* s, gchar expects, gint* error_code, GError** err, const gchar* format, ...) { const gchar* node; va_list args; g_return_val_if_fail(err != NULL && *err == NULL, NULL); g_return_val_if_fail(format != NULL, NULL); va_start(args, format); gc_free gchar* request = s_json_buildv(format, args); va_end(args); if (request == NULL) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid request format: %s", format); return NULL; } gc_free gchar* response = api_request(s, request, err); node = api_response_check(response, expects, error_code, err); if (*err) { const gchar* method_node = s_json_path(request, "$[0].a!string"); if (method_node) { gc_free gchar* method = s_json_get_string(method_node); g_prefix_error(err, "API call '%s' failed: ", method); } else g_prefix_error(err, "API call failed: "); return NULL; } return s_json_get(node); } // }}} // Remote filesystem helpers // {{{ update_pathmap static void mega_node_free(mega_node* n); static void update_pathmap(mega_session* s) { GSList *i, *next; g_return_if_fail(s != NULL); // node handles are assumed to be unique GHashTable* handle_map = g_hash_table_new(g_str_hash, g_str_equal); for (i = s->fs_nodes; i; i = i->next) { mega_node* n = i->data; #if GLIB_CHECK_VERSION(2, 40, 0) if (!g_hash_table_insert(handle_map, n->handle, n)) g_printerr("WARNING: Dup node handle detected %s\n", n->handle); #else if (g_hash_table_lookup(handle_map, n->handle)) g_printerr("WARNING: Dup node handle detected %s\n", n->handle); else g_hash_table_insert(handle_map, n->handle, n); #endif } for (i = s->fs_nodes; i;) { mega_node* n = i->data; next = i->next; if (n->type == MEGA_NODE_CONTACT) { if (n->su_handle) n->parent = g_hash_table_lookup(handle_map, n->su_handle); } else { if (n->parent_handle) n->parent = g_hash_table_lookup(handle_map, n->parent_handle); } /* // remove parentless non-root nodes from the list if (!n->parent && (n->type == MEGA_NODE_FILE || n->type == MEGA_NODE_FOLDER || n->type == MEGA_NODE_CONTACT)) { // remove current node if (prev) prev->next = next; else s->fs_nodes = next; g_slist_free_1(i); mega_node_free(n); } else prev = i; */ i = next; } g_hash_table_unref(handle_map); } // }}} // {{{ path manipulation utils static gchar* path_sanitize_slashes(const gchar* path) { g_return_val_if_fail(path != NULL, NULL); gchar* sanepath = g_malloc(strlen(path) + 1); gchar* tmp = sanepath; gboolean previous_was_slash = 0; while (*path != '\0') { if (*path != '/' || !previous_was_slash) *(tmp++) = *path; previous_was_slash = *path == '/'?1:0; path++; } *tmp = '\0'; if (tmp > (sanepath + 1) && *(tmp - 1) == '/') *(tmp-1) = '\0'; return sanepath; } static gchar** path_get_elements(const gchar* path) { g_return_val_if_fail(path != NULL, NULL); gc_free gchar* sane_path = path_sanitize_slashes(path); /* always succeeds */ return g_strsplit(sane_path, "/", 0); } static gchar* path_simplify(const gchar* path) { guint i, j = 0, pathv_len, subroot = 0; gboolean absolute; g_return_val_if_fail(path != NULL, NULL); gc_strfreev gchar** pathv = path_get_elements(path); /* should free */ pathv_len = g_strv_length(pathv); gc_free gchar** sane_pathv = (gchar**)g_malloc0((pathv_len + 1) * sizeof(gchar*)); absolute = (pathv_len > 1 && **pathv == '\0'); for (i = 0; i < pathv_len; i++) { if (!strcmp(pathv[i], ".")) continue; /* ignore curdirs in path */ else if (!strcmp(pathv[i], "..")) { if (absolute) { if (j > 1) { j--; } } else { if (subroot && !strcmp(sane_pathv[j - 1], "..")) /* if we are off base and last item is .. */ { sane_pathv[j++] = pathv[i]; } else { if (j > subroot) { j--; } else { subroot++; sane_pathv[j++] = pathv[i]; } } } } else { sane_pathv[j++] = pathv[i]; } } sane_pathv[j] = 0; return g_strjoinv("/", sane_pathv); } // }}} // Public API helpers // {{{ send_status static void init_status(mega_session* s, gint type) { memset(&s->status_data, 0, sizeof(s->status_data)); s->status_data.type = type; } // true to interrupt static gboolean send_status(mega_session* s) { if (s->status_callback) return s->status_callback(&s->status_data, s->status_userdata); return FALSE; } // }}} // {{{ add_share_key void add_share_key(mega_session* s, const gchar* handle, const guchar* key) { g_return_if_fail(s != NULL); g_return_if_fail(handle != NULL); g_return_if_fail(key != NULL); g_hash_table_insert(s->share_keys, g_strdup(handle), g_memdup(key, 16)); } // }}} // {{{ mega_node_parse static mega_node* mega_node_parse(mega_session* s, const gchar* node) { gchar* tmp; gc_free gchar* node_h = s_json_get_member_string(node, "h"); gc_free gchar* node_p = s_json_get_member_string(node, "p"); gc_free gchar* node_u = s_json_get_member_string(node, "u"); gc_free gchar* node_k = s_json_get_member_string(node, "k"); gc_free gchar* node_a = s_json_get_member_string(node, "a"); gc_free gchar* node_sk = s_json_get_member_string(node, "sk"); gc_free gchar* node_su = s_json_get_member_string(node, "su"); gint node_t = s_json_get_member_int(node, "t", -1); gint64 node_ts = s_json_get_member_int(node, "ts", 0); gint64 node_s = s_json_get_member_int(node, "s", 0); // sanity check parsed values if (!node_h || strlen(node_h) == 0) { g_printerr("WARNING: Skipping FS node without handle\n"); return NULL; } // return special nodes if (node_t == MEGA_NODE_ROOT) { mega_node* n = g_new0(mega_node, 1); n->name = g_strdup("Root"); n->handle = g_strdup(node_h); n->timestamp = node_ts; n->type = node_t; return n; } else if (node_t == MEGA_NODE_INBOX) { mega_node* n = g_new0(mega_node, 1); n->name = g_strdup("Inbox"); n->handle = g_strdup(node_h); n->timestamp = node_ts; n->type = node_t; return n; } else if (node_t == MEGA_NODE_TRASH) { mega_node* n = g_new0(mega_node, 1); n->name = g_strdup("Trash"); n->handle = g_strdup(node_h); n->timestamp = node_ts; n->type = node_t; return n; } // allow only file and dir nodes if (node_t != MEGA_NODE_FOLDER && node_t != MEGA_NODE_FILE) { g_printerr("WARNING: Skipping FS node %s with unknown type %d\n", node_h, node_t); return NULL; } // node has to have attributes if (!node_a || strlen(node_a) == 0) { g_printerr("WARNING: Skipping FS node %s without attributes\n", node_h); return NULL; } // node has to have a key if (!node_k || strlen(node_k) == 0) { g_printerr("WARNING: Skipping FS node %s because of missing node key\n", node_h); return NULL; } // process sk if available if (node_sk && strlen(node_sk) > 0) { gsize share_key_len; gc_free guchar* share_key = NULL; if (strlen(node_sk) > 22) { share_key = b64_rsa_decrypt(node_sk, &s->rsa_key, &share_key_len); if (share_key && share_key_len >= 16) add_share_key(s, node_h, share_key); } else { share_key = b64_aes128_decrypt(node_sk, s->master_key, &share_key_len); if (share_key && share_key_len == 16) add_share_key(s, node_h, share_key); } } gchar* node_share_key = NULL; gc_free gchar* encrypted_node_key = NULL; gc_strfreev gchar** parts = g_strsplit(node_k, "/", 0); gint i; for (i = 0; parts[i]; i++) { // split node keys gchar* key_value = strchr(parts[i], ':'); if (key_value) { gchar* key_handle = parts[i]; *key_value = '\0'; key_value++; if (s->user_handle && !strcmp(s->user_handle, key_handle)) { // we found a key encrypted by me encrypted_node_key = g_strdup(key_value); node_share_key = s->master_key; break; } node_share_key = g_hash_table_lookup(s->share_keys, key_handle); if (node_share_key) { encrypted_node_key = g_strdup(key_value); } } } if (!encrypted_node_key) { g_printerr("WARNING: Skipping FS node %s because node key wasn't found\n", node_h); return NULL; } // keys longer than 45 chars are RSA keys if (strlen(encrypted_node_key) >= 46) { g_printerr("WARNING: Skipping FS node %s because it has RSA key\n", node_h); return NULL; } // decrypt node key gsize node_key_len = 0; gc_free guchar* node_key = b64_aes128_decrypt(encrypted_node_key, node_share_key, &node_key_len); if (!node_key) { g_printerr("WARNING: Skipping FS node %s because key can't be decrypted %s\n", node_h, encrypted_node_key); return NULL; } if (node_t == MEGA_NODE_FILE && node_key_len != 32) { g_printerr("WARNING: Skipping FS node %s because file key doesn't have 32 bytes\n", node_h); return NULL; } if (node_t == MEGA_NODE_FOLDER && node_key_len != 16) { g_printerr("WARNING: Skipping FS node %s because folder key doesn't have 16 bytes\n", node_h); return NULL; } // decrypt attributes with node key guchar aes_key[16]; if (node_t == MEGA_NODE_FILE) unpack_node_key(node_key, aes_key, NULL, NULL); else memcpy(aes_key, node_key, 16); gc_free gchar* node_name = NULL; if (!decrypt_node_attrs(node_a, aes_key, &node_name)) { g_printerr("WARNING: Skipping FS node %s because it has malformed attributes\n", node_h); return NULL; } if (!node_name) { g_printerr("WARNING: Skipping FS node %s because it is missing name\n", node_h); return NULL; } // check for invalid characters in the name #ifdef G_OS_WIN32 if (strpbrk(node_name, "/\\<>:\"|?*") || !strcmp(node_name, ".") || !strcmp(node_name, "..")) #else if (strpbrk(node_name, "/") || !strcmp(node_name, ".") || !strcmp(node_name, "..")) #endif { g_printerr("WARNING: Skipping FS node %s because it's name is invalid '%s'\n", node_h, node_name); return NULL; } #define TAKE(n) (tmp = n, n = NULL, tmp) mega_node* n = g_new0(mega_node, 1); n->s = s; n->name = TAKE(node_name); n->handle = TAKE(node_h); n->parent_handle = TAKE(node_p); n->user_handle = TAKE(node_u); n->su_handle = TAKE(node_su); n->key_len = node_key_len; n->key = TAKE(node_key); n->size = node_s; n->timestamp = node_ts; n->type = node_t; return n; } // }}} // {{{ mega_node_parse_user static mega_node* mega_node_parse_user(mega_session* s, const gchar* node) { gc_free gchar* node_u = s_json_get_member_string(node, "u"); gc_free gchar* node_m = s_json_get_member_string(node, "m"); gint64 node_ts = s_json_get_member_int(node, "ts", 0); // sanity check parsed values if (!node_u || strlen(node_u) == 0) return NULL; if (!node_m || strlen(node_m) == 0) return NULL; mega_node* n = g_new0(mega_node, 1); n->s = s; n->name = node_m; n->handle = node_u; n->parent_handle = g_strdup("NETWORK"); n->user_handle = g_strdup(node_u); n->timestamp = node_ts; n->type = MEGA_NODE_CONTACT; node_u = node_m = NULL; return n; } // }}} // {{{ mega_node_is_writable gboolean mega_node_is_writable(mega_session* s, mega_node* n) { g_return_val_if_fail(n != NULL, FALSE); return n->type == MEGA_NODE_CONTACT || ((n->type == MEGA_NODE_FILE || n->type == MEGA_NODE_FOLDER) && !strcmp(s->user_handle, n->user_handle)) || n->type == MEGA_NODE_ROOT || n->type == MEGA_NODE_NETWORK || n->type == MEGA_NODE_TRASH; } // }}} // {{{ mega_node_free static void mega_node_free(mega_node* n) { if (n) { g_free(n->name); g_free(n->handle); g_free(n->parent_handle); g_free(n->user_handle); g_free(n->su_handle); g_free(n->key); g_free(n->link); memset(n, 0, sizeof(mega_node)); g_free(n); } } // }}} // Public API // {{{ mega_error_quark GQuark mega_error_quark(void) { return g_quark_from_static_string("mega-error-quark"); } // }}} // {{{ mega_session_new mega_session* mega_session_new(void) { mega_session* s = g_new0(mega_session, 1); s->http = http_new(); http_set_content_type(s->http, "application/json"); s->id = time(NULL); s->rid = make_request_id(); s->share_keys = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); return s; } // }}} // {{{ mega_session_set_speed void mega_session_set_speed(mega_session* s, gint ul, gint dl) { s->max_ul = ul; s->max_dl = dl; } // }}} // {{{ mega_session_set_proxy void mega_session_set_proxy(mega_session* s, const gchar* proxy) { g_free(s->proxy); s->proxy = g_strdup(proxy); http_set_proxy(s->http, s->proxy); } // }}} // {{{ mega_session_free void mega_session_free(mega_session* s) { if (s) { http_free(s->http); g_slist_free_full(s->fs_nodes, (GDestroyNotify)mega_node_free); g_hash_table_destroy(s->share_keys); g_free(s->sid); g_free(s->rid); g_free(s->password_key); g_free(s->master_key); rsa_key_free(&s->rsa_key); g_free(s->user_handle); g_free(s->user_name); g_free(s->user_email); memset(s, 0, sizeof(mega_session)); g_free(s); } } // }}} // {{{ mega_session_watch_status void mega_session_watch_status(mega_session* s, mega_status_callback cb, gpointer userdata) { g_return_if_fail(s != NULL); s->status_callback = cb; s->status_userdata = userdata; } // }}} // {{{ mega_session_enable_previews void mega_session_enable_previews(mega_session* s, gboolean enable) { g_return_if_fail(s != NULL); s->create_preview = enable; } // }}} // {{{ mega_session_open_exp_folder gboolean mega_session_open_exp_folder(mega_session* s, const gchar* n, const gchar* key, GError** err) { GError* local_err = NULL; gsize len, i, l; GSList* list = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(n != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); mega_session_close(s); s->sid_param_name = "n"; s->sid = g_strdup(n); s->master_key = base64urldecode(key, &len); if (len != 16) return FALSE; // login user gc_free gchar* f_node = api_call(s, 'o', NULL, &local_err, "[{a:f, c:1, r:1}]"); if (!f_node) { g_propagate_error(err, local_err); return FALSE; } const gchar* ff_node = s_json_get_member(f_node, "f"); if (ff_node && s_json_get_type(ff_node) == S_JSON_TYPE_ARRAY) { const gchar* node; gint i = 0; while ((node = s_json_get_element(ff_node, i++))) { if (s_json_get_type(node) == S_JSON_TYPE_OBJECT) { // first node is the root folder if (i == 1) { gc_free gchar* node_h = s_json_get_member_string(node, "h"); add_share_key(s, node_h, s->master_key); } // import nodes into the fs mega_node* n = mega_node_parse(s, node); if (n) { if (i == 1) { g_free(n->parent_handle); n->parent_handle = NULL; } list = g_slist_prepend(list, n); } } } } s->fs_nodes = g_slist_reverse(list); update_pathmap(s); return TRUE; } // }}} // {{{ mega_session_open gboolean mega_session_open(mega_session* s, const gchar* un, const gchar* pw, const gchar* sid, GError** err) { GError* local_err = NULL; gboolean is_loggedin = FALSE; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(un != NULL, FALSE); g_return_val_if_fail(pw != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); mega_session_close(s); //g_print("%s %s %s\n", un, pw, sid); // make password key g_free(s->password_key); s->password_key = make_password_key(pw); // if we have existing session id, just check with the server if session is // active, and download keys and user info if (sid) { g_free(s->sid); s->sid = g_strdup(sid); is_loggedin = mega_session_get_user(s, NULL); } if (!is_loggedin) { gc_free gchar* un_lower = g_ascii_strdown(un, -1); gc_free gchar* uh = make_username_hash(un_lower, s->password_key); g_free(s->sid); s->sid = NULL; // login user gc_free gchar* login_node = api_call(s, 'o', NULL, &local_err, "[{a:us, user:%s, uh:%s}]", un_lower, uh); if (!login_node) { g_propagate_error(err, local_err); return FALSE; } gc_free gchar* login_k = s_json_get_member_string(login_node, "k"); gc_free gchar* login_privk = s_json_get_member_string(login_node, "privk"); gc_free gchar* login_csid = s_json_get_member_string(login_node, "csid"); // decrypt master key gc_free guchar* master_key = b64_aes128_decrypt(login_k, s->password_key, NULL); if (!master_key) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read master key during login"); return FALSE; } // decrypt private key with master key rsa_key privk; memset(&privk, 0, sizeof(privk)); if (!b64_aes128_decrypt_privk(login_privk, master_key, &privk)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read private key during login"); rsa_key_free(&privk); return FALSE; } // decrypt session id gsize sid_len = 0; gc_free guchar* sid = b64_rsa_decrypt(login_csid, &privk, &sid_len); if (!sid || sid_len < 43) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read session id during login"); rsa_key_free(&privk); return FALSE; } // save session id g_free(s->sid); s->sid = base64urlencode(sid, 43); // cleanup rsa_key_free(&privk); return mega_session_get_user(s, err); } return TRUE; } // }}} // {{{ mega_session_close void mega_session_close(mega_session* s) { g_return_if_fail(s != NULL); g_free(s->password_key); g_free(s->master_key); g_free(s->sid); rsa_key_free(&s->rsa_key); g_free(s->user_handle); g_free(s->user_name); g_free(s->user_email); g_slist_free_full(s->fs_nodes, (GDestroyNotify)mega_node_free); g_hash_table_remove_all(s->share_keys); s->password_key = NULL; s->master_key = NULL; s->sid = NULL; s->user_handle = NULL; s->user_email = NULL; s->user_name = NULL; s->fs_nodes = NULL; s->last_refresh = 0; s->status_callback = NULL; } // }}} // {{{ mega_session_get_sid const gchar* mega_session_get_sid(mega_session* s) { g_return_val_if_fail(s != NULL, NULL); return s->sid; } // }}} // {{{ mega_session_get_user gboolean mega_session_get_user(mega_session* s, GError** err) { GError* local_err = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(s->sid != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); // prepare request gc_free gchar* user_node = api_call(s, 'o', NULL, &local_err, "[{a:ug}]"); if (!user_node) { g_propagate_error(err, local_err); return FALSE; } // store information about the user g_free(s->user_handle); s->user_handle = s_json_get_member_string(user_node, "u"); if (!s->user_handle) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read user's handle"); return FALSE; } g_free(s->user_email); s->user_email = s_json_get_member_string(user_node, "email"); g_free(s->user_name); s->user_name = s_json_get_member_string(user_node, "name"); gc_free gchar* user_privk = s_json_get_member_string(user_node, "privk"); gc_free gchar* user_pubk = s_json_get_member_string(user_node, "pubk"); gc_free gchar* user_k = s_json_get_member_string(user_node, "k"); // load master key g_free(s->master_key); s->master_key = b64_aes128_decrypt(user_k, s->password_key, NULL); if (!s->master_key) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read master key"); return FALSE; } rsa_key_free(&s->rsa_key); // decrypt private key with master key if (!b64_aes128_decrypt_privk(user_privk, s->master_key, &s->rsa_key)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read private key"); return FALSE; } // load public key if (!b64_decode_pubk(user_pubk, &s->rsa_key)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't read public key"); return FALSE; } s->last_refresh = time(NULL); return TRUE; } // }}} // {{{ mega_session_refresh gboolean mega_session_refresh(mega_session* s, GError** err) { GError* local_err = NULL; GSList* list = NULL; gint i, l; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); // prepare request gc_free gchar* f_node = api_call(s, 'o', NULL, &local_err, "[{a:f, c:1}]"); if (!f_node) { g_propagate_error(err, local_err); return FALSE; } if (mega_debug & MEGA_DEBUG_FS) print_node(f_node, "FS: "); // process 'ok' array const gchar* ok_node = s_json_get_member(f_node, "ok"); if (ok_node && s_json_get_type(ok_node) == S_JSON_TYPE_ARRAY) { gc_free gchar** oks = s_json_get_elements(ok_node); for (i = 0, l = g_strv_length(oks); i < l; i++) { const gchar* ok = oks[i]; if (s_json_get_type(ok) != S_JSON_TYPE_OBJECT) continue; gc_free gchar* ok_h = s_json_get_member_string(ok, "h"); // h.8 gc_free gchar* ok_ha = s_json_get_member_string(ok, "ha"); // b64(aes(h.8 h.8, master_key)) gc_free gchar* ok_k = s_json_get_member_string(ok, "k"); // b64(aes(share_key_for_h, master_key)) if (!ok_h || !ok_ha ||!ok_k) { g_printerr("WARNING: Skipping import of a key %s because it's missing required attributes\n", ok_h); continue; } if (!handle_auth(ok_h, ok_ha, s->master_key)) { g_printerr("WARNING: Skipping import of a key %s because it's authentication failed\n", ok_h); continue; } //g_print("Importing key %s:%s\n", ok_h, ok_k); gc_free guchar* key = b64_aes128_decrypt(ok_k, s->master_key, NULL); add_share_key(s, ok_h, key); } } // process 'f' array const gchar* ff_node = s_json_get_member(f_node, "f"); if (!ff_node || s_json_get_type(ff_node) != S_JSON_TYPE_ARRAY) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Remote filesystem 'f' node is invalid"); return FALSE; } gc_free gchar** ff_arr = s_json_get_elements(ff_node); for (i = 0, l = g_strv_length(ff_arr); i < l; i++) { const gchar* f = ff_arr[i]; if (s_json_get_type(f) != S_JSON_TYPE_OBJECT) continue; mega_node* n = mega_node_parse(s, f); if (n) list = g_slist_prepend(list, n); } // import special root node for contacts mega_node* n = g_new0(mega_node, 1); n->s = s; n->name = g_strdup("Contacts"); n->handle = g_strdup("NETWORK"); n->type = MEGA_NODE_NETWORK; list = g_slist_prepend(list, n); // process 'u' array const gchar* u_node = s_json_get_member(f_node, "u"); if (u_node && s_json_get_type(u_node) == S_JSON_TYPE_ARRAY) { gc_free gchar** u_arr = s_json_get_elements(u_node); for (i = 0, l = g_strv_length(u_arr); i < l; i++) { const gchar* u = u_arr[i]; if (s_json_get_type(u) != S_JSON_TYPE_OBJECT) continue; gint64 u_c = s_json_get_member_int(u, "c", 0); // skip self and removed if (u_c != 1) continue; mega_node* n = mega_node_parse_user(s, u); if (n) list = g_slist_prepend(list, n); } } // replace existing nodes g_slist_free_full(s->fs_nodes, (GDestroyNotify)mega_node_free); s->fs_nodes = g_slist_reverse(list); update_pathmap(s); s->last_refresh = time(NULL); return TRUE; } // }}} // {{{ mega_session_addlinks gboolean mega_session_addlinks(mega_session* s, GSList* nodes, GError** err) { GError* local_err = NULL; GSList* i; gc_ptr_array_unref GPtrArray* rnodes = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); if (g_slist_length(nodes) == 0) return TRUE; rnodes = g_ptr_array_sized_new(g_slist_length(nodes)); // prepare request SJsonGen *gen = s_json_gen_new(); s_json_gen_start_array(gen); for (i = nodes; i; i = i->next) { mega_node* n = i->data; if (n->type == MEGA_NODE_FILE) { s_json_gen_start_object(gen); s_json_gen_member_string(gen, "a", "l"); s_json_gen_member_string(gen, "n", n->handle); s_json_gen_end_object(gen); g_ptr_array_add(rnodes, n); } } s_json_gen_end_array(gen); gc_free gchar *request = s_json_gen_done(gen); // perform request gc_free gchar* response = api_request(s, request, &local_err); // process response if (!response) { g_propagate_prefixed_error(err, local_err, "API call 'l' failed: "); return FALSE; } if (s_json_get_type(response) == S_JSON_TYPE_ARRAY) { gc_free gchar** nodes_arr = s_json_get_elements(response); gint i, l = g_strv_length(nodes_arr); if (l != rnodes->len) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "API call 'l' results mismatch"); return FALSE; } for (i = 0; i < l; i++) { gchar* link = s_json_get_string(nodes_arr[i]); mega_node* n = g_ptr_array_index(rnodes, i); g_free(n->link); n->link = link; } } return TRUE; } // }}} // {{{ mega_session_user_quota mega_user_quota* mega_session_user_quota(mega_session* s, GError** err) { GError* local_err = NULL; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); // prepare request gc_free gchar* quota_node = api_call(s, 'o', NULL, &local_err, "[{a:uq, strg:1, xfer:1, pro:1}]"); if (!quota_node) { g_propagate_error(err, local_err); return NULL; } mega_user_quota* q = g_new0(mega_user_quota, 1); q->total = s_json_get_member_int(quota_node, "mstrg", 0); q->used = s_json_get_member_int(quota_node, "cstrg", 0); return q; } // }}} // {{{ mega_session_ls_all // free gslist, not the data GSList* mega_session_ls_all(mega_session* s) { GSList* list = NULL; g_return_val_if_fail(s != NULL, NULL); return g_slist_copy(s->fs_nodes); } // }}} // {{{ mega_session_ls struct _ls_data { GSList* list; gchar* path; gboolean recursive; }; static void _ls(mega_node* n, struct _ls_data* data) { gchar path[4096]; if (mega_node_get_path(n, path, sizeof(path))) { if (g_str_has_prefix(path, data->path) && (data->recursive || !strchr(path + strlen(data->path), '/'))) data->list = g_slist_prepend(data->list, n); } } // free gslist, not the data GSList* mega_session_ls(mega_session* s, const gchar* path, gboolean recursive) { struct _ls_data data; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); gc_free gchar* tmp = path_simplify(path); if (!strcmp(tmp, "/")) data.path = g_strdup("/"); else data.path = g_strdup_printf("%s/", tmp); data.recursive = recursive; data.list = NULL; g_slist_foreach(s->fs_nodes, (GFunc)_ls, &data); g_free(data.path); return data.list; } // }}} // {{{ mega_session_stat mega_node* mega_session_stat(mega_session* s, const gchar* path) { g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); gc_free gchar* tmp = path_simplify(path); GSList* iter; gchar n_path[4096]; for (iter = s->fs_nodes; iter; iter = iter->next) { mega_node* n = iter->data; if (mega_node_get_path(n, n_path, sizeof(n_path))) { if (!strcmp(n_path, tmp)) return n; } } return NULL; } // }}} // {{{ mega_session_get_node_chilren GSList* mega_session_get_node_chilren(mega_session* s, mega_node* node) { GSList *list = NULL, *i; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(node != NULL, NULL); g_return_val_if_fail(node->handle != NULL, NULL); for (i = s->fs_nodes; i; i = i->next) { mega_node* child = i->data; if (child->parent_handle && !strcmp(child->parent_handle, node->handle)) list = g_slist_prepend(list, child); } return g_slist_reverse(list); } // }}} // {{{ mega_session_mkdir mega_node* mega_session_mkdir(mega_session* s, const gchar* path, GError** err) { GError* local_err = NULL; mega_node* n = NULL; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(path != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); mega_node* d = mega_session_stat(s, path); if (d) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Directory already exists: %s", path); return NULL; } gc_free gchar* tmp = path_simplify(path); gc_free gchar* parent_path = g_path_get_dirname(tmp); if (!strcmp(parent_path, "/")) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't create toplevel dir: %s", path); return NULL; } mega_node* p = mega_session_stat(s, parent_path); if (!p || p->type == MEGA_NODE_FILE || p->type == MEGA_NODE_INBOX) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Parent directory doesn't exist: %s", parent_path); return NULL; } if (!mega_node_is_writable(s, p)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Parent directory is not writable: %s", parent_path); return NULL; } if (p->type == MEGA_NODE_NETWORK) { // prepare contact add request gc_free gchar* ur_node = api_call(s, 'o', NULL, &local_err, "[{a:ur, u:%S, l:1, i:%s}]", g_path_get_basename(tmp), s->rid); if (!ur_node) { g_propagate_error(err, local_err); return NULL; } // parse response n = mega_node_parse_user(s, ur_node); if (!n) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } } else { gc_free guchar* node_key = make_random_key(); gc_free gchar* basename = g_path_get_basename(tmp); gc_free gchar* attrs = encode_node_attrs(basename); gc_free gchar* dir_attrs = b64_aes128_cbc_encrypt_str(attrs, node_key); gc_free gchar* dir_key = b64_aes128_encrypt(node_key, 16, s->master_key); // prepare request gc_free gchar* mkdir_node = api_call(s, 'o', NULL, &local_err, "[{a:p, t:%s, i:%s, n: [{h:xxxxxxxx, t:1, k:%s, a:%s}]}]", p->handle, s->rid, dir_key, dir_attrs); if (!mkdir_node) { g_propagate_error(err, local_err); return NULL; } const gchar* f_arr = s_json_get_member(mkdir_node, "f"); if (s_json_get_type(f_arr) != S_JSON_TYPE_ARRAY) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } const gchar* f_el = s_json_get_element(f_arr, 0); if (!f_el || s_json_get_type(f_el) != S_JSON_TYPE_OBJECT) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } n = mega_node_parse(s, f_el); if (!n) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } } // add mkdired node to the filesystem s->fs_nodes = g_slist_append(s->fs_nodes, n); update_pathmap(s); return n; } // }}} // {{{ mega_session_rm gboolean mega_session_rm(mega_session* s, const gchar* path, GError** err) { GError* local_err = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(path != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); mega_node* mn = mega_session_stat(s, path); if (!mn) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "File not found: %s", path); return FALSE; } if (!mega_node_is_writable(s, mn)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "File is not removable: %s", path); return FALSE; } if (mn->type == MEGA_NODE_FILE || mn->type == MEGA_NODE_FOLDER) { // prepare request gc_free gchar* rm_node = api_call(s, 'i', NULL, &local_err, "[{a:d, i:%s, n:%s}]", s->rid, mn->handle); if (!rm_node) { g_propagate_error(err, local_err); return FALSE; } } else if (mn->type == MEGA_NODE_CONTACT) { gc_free gchar* ur_node = api_call(s, 'i', NULL, &local_err, "[{a:ur, u:%s, l:0, i:%s}]", mn->handle, s->rid); if (!ur_node) { g_propagate_error(err, local_err); return FALSE; } } else { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't remove system dir %s", path); return FALSE; } // remove node from the filesystem s->fs_nodes = g_slist_remove(s->fs_nodes, mn); mega_node_free(mn); update_pathmap(s); return TRUE; } // }}} // {{{ mega_session_new_node_attribute gchar* mega_session_new_node_attribute(mega_session* s, const guchar* data, gsize len, const gchar* type, const guchar* key, GError** err) { GError* local_err = NULL; AES_KEY k; guchar iv[AES_BLOCK_SIZE] = {0}; gsize pad = len % 16 ? 16 - (len % 16) : 0; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(data != NULL, NULL); g_return_val_if_fail(len > 0, NULL); g_return_val_if_fail(type != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); gc_free gchar* ufa_node = api_call(s, 'o', NULL, &local_err, "[{a:ufa, s:%i, ssl:0}]", (gint64)len + pad); if (!ufa_node) { g_propagate_error(err, local_err); return NULL; } gc_free gchar* p_url = s_json_get_member_string(ufa_node, "p"); // encrypt AES_set_encrypt_key(key, 128, &k); gc_free guchar* plain = g_memdup(data, len); plain = g_realloc(plain, len + pad); memset(plain + len, 0, pad); gc_free guchar* cipher = g_malloc0(len + pad); AES_cbc_encrypt(plain, cipher, len + pad, &k, iv, 1); // upload gc_http_free http* h = http_new(); http_set_proxy(h, s->proxy); http_set_content_type(h, "application/octet-stream"); gc_string_free GString* handle = http_post(h, p_url, cipher, len + pad, &local_err); if (!handle) { g_propagate_prefixed_error(err, local_err, "Node attribute data upload failed: "); return NULL; } if (handle->len != 8) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Node attribute handle is invalid"); return NULL; } gc_free gchar* b64_handle = base64urlencode(handle->str, handle->len); return g_strdup_printf("%s*%s", type, b64_handle); } // }}} // {{{ create_preview static gint has_convert = -1; static gint has_ffmpegthumbnailer = -1; static gchar* create_preview(mega_session* s, const gchar* local_path, const guchar* key, GError** err) { gchar* handle = NULL; #ifndef G_OS_WIN32 GError* local_err = NULL; gc_free gchar *tmp1 = NULL, *tmp2 = NULL; if (has_ffmpegthumbnailer < 0) { gc_free gchar* prg = g_find_program_in_path("ffmpegthumbnailer"); has_ffmpegthumbnailer = prg ? 1 : 0; } if (has_convert < 0) { gc_free gchar* prg = g_find_program_in_path("convert"); has_convert = prg ? 1 : 0; } if (has_ffmpegthumbnailer && g_regex_match_simple("\\.(mpg|mpeg|avi|mkv|flv|rm|mp4|wmv|asf|ram|mov)$", local_path, G_REGEX_CASELESS, 0)) { gchar buf[50] = "/tmp/megatools.XXXXXX"; gchar* dir = g_mkdtemp(buf); if (dir) { gint status = 1; gc_free gchar* thumb_path = g_strdup_printf("%s/thumb.jpg", dir); gc_free gchar* qpath = g_shell_quote(local_path); gc_free gchar* tmp = g_strdup_printf("ffmpegthumbnailer -t 5 -i %s -o %s/thumb.jpg -s 128 -f -a", qpath, dir); if (g_spawn_command_line_sync(tmp, &tmp1, &tmp2, &status, &local_err)) { if (g_file_test(thumb_path, G_FILE_TEST_IS_REGULAR)) { gc_free gchar* thumb_data = NULL; gsize thumb_len; if (g_file_get_contents(thumb_path, &thumb_data, &thumb_len, NULL)) { handle = mega_session_new_node_attribute(s, thumb_data, thumb_len, "0", key, &local_err); if (!handle) g_propagate_error(err, local_err); } g_unlink(thumb_path); } } else { g_propagate_error(err, local_err); } g_rmdir(dir); } } else if (has_convert && g_regex_match_simple("\\.(jpe?g|png|gif|bmp|tiff|svg|pnm|eps|ico|pdf)$", local_path, G_REGEX_CASELESS, 0)) { gchar buf[50] = "/tmp/megatools.XXXXXX"; gchar* dir = g_mkdtemp(buf); if (dir) { gint status = 1; gc_free gchar* thumb_path = g_strdup_printf("%s/thumb.jpg", dir); gc_free gchar* qpath = NULL; if (g_regex_match_simple("\\.pdf$", local_path, G_REGEX_CASELESS, 0)) { gc_free gchar* local_path_page = g_strdup_printf("%s[0]", local_path); qpath = g_shell_quote(local_path_page); } else { qpath = g_shell_quote(local_path); } gc_free gchar* tmp = g_strdup_printf("convert %s -strip -background white -flatten -resize 128x128^ -gravity center -crop 128x128+0+0 +repage %s/thumb.jpg", qpath, dir); if (g_spawn_command_line_sync(tmp, &tmp1, &tmp2, &status, &local_err)) { if (g_file_test(thumb_path, G_FILE_TEST_IS_REGULAR)) { gc_free gchar* thumb_data = NULL; gsize thumb_len; if (g_file_get_contents(thumb_path, &thumb_data, &thumb_len, NULL)) { handle = mega_session_new_node_attribute(s, thumb_data, thumb_len, "0", key, &local_err); if (!handle) g_propagate_error(err, local_err); } g_unlink(thumb_path); } } else { g_propagate_error(err, local_err); } g_rmdir(dir); } } else { return NULL; } if (!handle && err && !*err) g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't create preview"); #endif return handle; } // }}} // {{{ mega_session_put static gboolean progress_generic(goffset total, goffset now, mega_session* s) { const gint64 timenow = g_get_monotonic_time(); if (s->last_progress && s->last_progress + PROGRESS_FREQUENCY > timenow) return TRUE; init_status(s, MEGA_STATUS_PROGRESS); s->status_data.progress.total = total; s->status_data.progress.done = now; s->status_data.progress.last = s->last_progress_bytes; s->status_data.progress.span = timenow - s->last_progress; s->last_progress = timenow; s->last_progress_bytes = now; if (send_status(s)) return FALSE; return TRUE; } struct _put_data { GFileInputStream* stream; AES_KEY k; guchar iv[AES_BLOCK_SIZE]; gint num; guchar ecount[AES_BLOCK_SIZE]; chunked_cbc_mac mac; GByteArray* buffer; }; #if OPENSSL_VERSION_NUMBER >= 0x10100000L void AES_ctr128_encrypt( const unsigned char *in, unsigned char *out, size_t length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE], unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num) { CRYPTO_ctr128_encrypt(in, out, length, key, ivec, ecount_buf, num, (block128_f)AES_encrypt); } #endif static gsize put_process_data(gpointer buffer, gsize size, struct _put_data* data) { gc_error_free GError* local_err = NULL; gsize bytes_read = 0; if (size > data->buffer->len) g_byte_array_set_size(data->buffer, size); if (!g_input_stream_read_all(G_INPUT_STREAM(data->stream), data->buffer->data, size, &bytes_read, NULL, &local_err)) { g_printerr("ERROR: Failed reading from stream: %s\n", local_err->message); return 0; } if (bytes_read > 0) { AES_ctr128_encrypt(data->buffer->data, buffer, bytes_read, &data->k, data->iv, data->ecount, &data->num); chunked_cbc_mac_update(&data->mac, data->buffer->data, bytes_read); } return bytes_read; } mega_node* mega_session_put(mega_session* s, const gchar* remote_path, const gchar* local_path, GError** err) { struct _put_data data; GError* local_err = NULL; mega_node *node, *parent_node; gc_free gchar* file_name = NULL; gc_object_unref GFileInputStream* stream = NULL; gc_byte_array_unref GByteArray* buffer = NULL; g_return_val_if_fail(s != NULL, NULL); g_return_val_if_fail(remote_path != NULL, NULL); g_return_val_if_fail(local_path != NULL, NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); memset(&data, 0, sizeof(data)); // check remote filesystem, and get parent node node = mega_session_stat(s, remote_path); if (node) { if (node->type == MEGA_NODE_FILE) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "File already exists: %s", remote_path); return NULL; } else { // put into a dir parent_node = node; gc_free gchar* basename = g_path_get_basename(local_path); gc_free gchar* tmp = g_strconcat(remote_path, "/", basename, NULL); node = mega_session_stat(s, tmp); if (node) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "File already exists: %s", tmp); return NULL; } if (!mega_node_is_writable(s, parent_node) || parent_node->type == MEGA_NODE_NETWORK || parent_node->type == MEGA_NODE_CONTACT) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Directory is not writable: %s", remote_path); return NULL; } file_name = g_path_get_basename(local_path); } } else { gc_free gchar* tmp = path_simplify(remote_path); gc_free gchar* parent_path = g_path_get_dirname(tmp); if (!strcmp(parent_path, "/")) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't upload to toplevel dir: %s", remote_path); return NULL; } parent_node = mega_session_stat(s, parent_path); if (!parent_node || parent_node->type == MEGA_NODE_FILE) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Parent directory doesn't exist: %s", parent_path); return NULL; } if (!mega_node_is_writable(s, parent_node) || parent_node->type == MEGA_NODE_NETWORK || parent_node->type == MEGA_NODE_CONTACT) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Directory is not writable: %s", parent_path); return NULL; } file_name = g_path_get_basename(tmp); } // open local file for reading, and get file size gc_object_unref GFile* file = g_file_new_for_path(local_path); data.stream = stream = g_file_read(file, NULL, &local_err); if (!stream) { g_propagate_prefixed_error(err, local_err, "Can't read local file %s: ", local_path); return NULL; } gc_object_unref GFileInfo* info = g_file_input_stream_query_info(stream, G_FILE_ATTRIBUTE_STANDARD_SIZE, NULL, &local_err); if (!info) { g_propagate_prefixed_error(err, local_err, "Can't read local file %s: ", local_path); return NULL; } goffset file_size = g_file_info_get_size(info); // ask for upload url - [{"a":"u","ssl":0,"ms":0,"s":,"r":0,"e":0}] gc_free gchar* up_node = api_call(s, 'o', NULL, &local_err, "[{a:u, ssl:0, ms:0, s:%i, r:0, e:0}]", (gint64)file_size); if (!up_node) { g_propagate_error(err, local_err); return NULL; } gc_free gchar* p_url = s_json_get_member_string(up_node, "p"); // setup encryption gc_free guchar* aes_key = make_random_key(); gc_free guchar* nonce = make_random_key(); AES_set_encrypt_key(aes_key, 128, &data.k); memcpy(data.iv, nonce, 8); chunked_cbc_mac_init8(&data.mac, aes_key, nonce); // setup buffer data.buffer = buffer = g_byte_array_new(); // perform upload gc_http_free http* h = http_new(); http_set_content_type(h, "application/octet-stream"); http_set_progress_callback(h, (http_progress_fn)progress_generic, s); http_set_speed(h, s->max_ul, s->max_dl); http_set_proxy(h, s->proxy); gc_string_free GString* up_handle = http_post_stream_upload(h, p_url, file_size, (http_data_fn)put_process_data, &data, &local_err); if (!up_handle) { g_propagate_prefixed_error(err, local_err, "Data upload failed: "); return NULL; } // check for numeric error code if (up_handle->len < 10 && g_regex_match_simple("^-(\\d+)$", up_handle->str, 0, 0)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Server returned error code %s", srv_error_to_string(atoi(up_handle->str))); return NULL; } if (up_handle->len > 100 || !g_regex_match_simple("^[a-zA-Z0-9_+/-]{20,50}$", up_handle->str, 0, 0)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid upload handle"); return NULL; } // create preview gc_free gchar* fa = NULL; if (s->create_preview) fa = create_preview(s, local_path, aes_key, NULL); gc_free gchar* attrs = encode_node_attrs(file_name); gc_free gchar* attrs_enc = b64_aes128_cbc_encrypt_str(attrs, aes_key); guchar meta_mac[16]; guchar node_key[32]; chunked_cbc_mac_finish(&data.mac, meta_mac); pack_node_key(node_key, aes_key, nonce, meta_mac); gc_free gchar* node_key_enc = b64_aes128_encrypt(node_key, 32, s->master_key); // prepare request gc_free gchar* put_node = api_call(s, 'o', NULL, &local_err, "[{a:p, t:%s, n:[{h:%s, t:0, k:%s, a:%s, fa:%s}]}]", parent_node->handle, up_handle->str, node_key_enc, attrs_enc, fa); if (!put_node) { g_propagate_error(err, local_err); return NULL; } const gchar* f_arr = s_json_get_member(put_node, "f"); if (s_json_get_type(f_arr) != S_JSON_TYPE_ARRAY) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } const gchar* f_el = s_json_get_element(f_arr, 0); if (!f_el || s_json_get_type(f_el) != S_JSON_TYPE_OBJECT) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } mega_node* nn = mega_node_parse(s, f_el); if (!nn) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid response"); return NULL; } // add uploaded node to the filesystem s->fs_nodes = g_slist_append(s->fs_nodes, nn); nn->parent = parent_node; return nn; } // }}} // {{{ mega_session_get struct _get_data { mega_session* s; GFileOutputStream* stream; AES_KEY k; guchar iv[AES_BLOCK_SIZE]; gint num; guchar ecount[AES_BLOCK_SIZE]; chunked_cbc_mac mac; GByteArray* buffer; }; static gsize get_process_data(gpointer buffer, gsize size, struct _get_data* data) { gc_error_free GError* local_err = NULL; if (size > data->buffer->len) g_byte_array_set_size(data->buffer, size); AES_ctr128_encrypt(buffer, data->buffer->data, size, &data->k, data->iv, data->ecount, &data->num); chunked_cbc_mac_update(&data->mac, data->buffer->data, size); init_status(data->s, MEGA_STATUS_DATA); data->s->status_data.data.size = size; data->s->status_data.data.buf = data->buffer->data; if (send_status(data->s)) return 0; if (!data->stream) return size; if (!g_output_stream_write_all(G_OUTPUT_STREAM(data->stream), data->buffer->data, size, NULL, NULL, &local_err)) { g_printerr("ERROR: Failed writing to stream: %s\n", local_err->message); return 0; } return size; } gboolean mega_session_get(mega_session* s, const gchar* local_path, const gchar* remote_path, GError** err) { struct _get_data data; GError* local_err = NULL; gc_object_unref GFile* file = NULL; gc_object_unref GFileOutputStream* stream = NULL; gboolean remove_file = FALSE; gc_free gchar* get_node = NULL, *url = NULL; gc_http_free http* h = NULL; gc_byte_array_unref GByteArray* buffer = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(remote_path != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); memset(&data, 0, sizeof(data)); data.s = s; mega_node* n = mega_session_stat(s, remote_path); if (!n) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Remote file not found: %s", remote_path); return FALSE; } init_status(s, MEGA_STATUS_FILEINFO); s->status_data.fileinfo.name = n->name; s->status_data.fileinfo.size = n->size; if (send_status(s)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Operation cancelled from status callback"); return FALSE; } if (local_path) { file = g_file_new_for_path(local_path); if (g_file_query_exists(file, NULL)) { if (g_file_query_file_type(file, 0, NULL) == G_FILE_TYPE_DIRECTORY) { gc_object_unref GFile* child = g_file_get_child(file, n->name); if (g_file_query_exists(child, NULL)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Local file already exists: %s/%s", local_path, n->name); return FALSE; } else { file = child; child = NULL; } } else { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Local file already exists: %s", local_path); return FALSE; } } data.stream = stream = g_file_create(file, 0, NULL, &local_err); if (!data.stream) { g_propagate_prefixed_error(err, local_err, "Can't open local file %s for writing: ", local_path); return FALSE; } } remove_file = TRUE; // initialize decrytpion key/state guchar aes_key[16], meta_mac_xor[8]; unpack_node_key(n->key, aes_key, data.iv, meta_mac_xor); AES_set_encrypt_key(aes_key, 128, &data.k); chunked_cbc_mac_init8(&data.mac, aes_key, data.iv); // prepare request get_node = api_call(s, 'o', NULL, &local_err, "[{a:g, g:1, ssl:0, n:%s}]", n->handle); if (!get_node) { g_propagate_error(err, local_err); goto err; } gint64 file_size = s_json_get_member_int(get_node, "s", -1); if (file_size < 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't determine file size"); goto err; } url = s_json_get_member_string(get_node, "g"); if (!url) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't determine download url"); goto err; } // setup buffer data.buffer = buffer = g_byte_array_new(); // perform download h = http_new(); http_set_progress_callback(h, (http_progress_fn)progress_generic, s); http_set_speed(h, s->max_ul, s->max_dl); http_set_proxy(h, s->proxy); if (!http_post_stream_download(h, url, (http_data_fn)get_process_data, &data, &local_err)) { g_propagate_prefixed_error(err, local_err, "Data download failed: "); goto err; } if (file) { if (!g_output_stream_close(G_OUTPUT_STREAM(data.stream), NULL, &local_err)) { g_propagate_prefixed_error(err, local_err, "Can't close downloaded file: "); goto err; } } // check mac of the downloaded file guchar meta_mac_xor_calc[8]; chunked_cbc_mac_finish8(&data.mac, meta_mac_xor_calc); if (memcmp(meta_mac_xor, meta_mac_xor_calc, 8) != 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "MAC mismatch"); goto err; } return TRUE; err: if (file && remove_file) g_file_delete(file, NULL, NULL); return FALSE; } // }}} // {{{ mega_session_dl struct _dl_data { mega_session* s; GFileOutputStream* stream; AES_KEY k; guchar iv[AES_BLOCK_SIZE]; gint num; guchar ecount[AES_BLOCK_SIZE]; chunked_cbc_mac mac; GByteArray* buffer; }; static gsize dl_process_data(gpointer buffer, gsize size, struct _dl_data* data) { gc_error_free GError* local_err = NULL; if (size > data->buffer->len) g_byte_array_set_size(data->buffer, size); AES_ctr128_encrypt(buffer, data->buffer->data, size, &data->k, data->iv, data->ecount, &data->num); chunked_cbc_mac_update(&data->mac, data->buffer->data, size); init_status(data->s, MEGA_STATUS_DATA); data->s->status_data.data.size = size; data->s->status_data.data.buf = data->buffer->data; if (send_status(data->s)) return 0; if (!data->stream) return size; if (!g_output_stream_write_all(G_OUTPUT_STREAM(data->stream), data->buffer->data, size, NULL, NULL, &local_err)) { g_printerr("ERROR: Failed writing to stream: %s\n", local_err->message); return 0; } return size; } gboolean mega_session_dl(mega_session* s, const gchar* handle, const gchar* key, const gchar* local_path, GError** err) { struct _dl_data data; GError* local_err = NULL; gc_object_unref GFile *parent_dir = NULL, *file = NULL; gboolean remove_file = FALSE; gc_free gchar *node_name = NULL, *dl_node = NULL, *url = NULL, *at = NULL; gc_free guchar* node_key = NULL; gc_http_free http* h = NULL; gc_object_unref GFileOutputStream* stream = NULL; gc_byte_array_unref GByteArray* buffer = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(handle != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); memset(&data, 0, sizeof(data)); data.s = s; if (local_path) { // get dir and filename to download to file = g_file_new_for_path(local_path); if (g_file_query_exists(file, NULL)) { if (g_file_query_file_type(file, 0, NULL) != G_FILE_TYPE_DIRECTORY) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "File already exists: %s", local_path); return FALSE; } else { parent_dir = file; file = NULL; } } else { parent_dir = g_file_get_parent(file); if (g_file_query_file_type(parent_dir, 0, NULL) != G_FILE_TYPE_DIRECTORY) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't download file into: %s", g_file_get_path(parent_dir)); return FALSE; } } } // prepare request dl_node = api_call(s, 'o', NULL, &local_err, "[{a:g, g:1, ssl:0, p:%s}]", handle); if (!dl_node) { g_propagate_error(err, local_err); goto err; } // get file size gint64 file_size = s_json_get_member_int(dl_node, "s", -1); if (file_size < 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't determine file size"); goto err; } url = s_json_get_member_string(dl_node, "g"); if (!url) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't determine download url"); goto err; } at = s_json_get_member_string(dl_node, "at"); if (!at) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't get file attributes"); goto err; } // decode node_key gsize node_key_len = 0; node_key = base64urldecode(key, &node_key_len); if (!node_key || node_key_len != 32) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't retrieve file key"); goto err; } // initialize decrytpion key guchar aes_key[16], meta_mac_xor[8]; unpack_node_key(node_key, aes_key, data.iv, meta_mac_xor); // decrypt attributes with aes_key if (!decrypt_node_attrs(at, aes_key, &node_name)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid key"); goto err; } if (!node_name) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't retrieve remote file name"); goto err; } init_status(s, MEGA_STATUS_FILEINFO); s->status_data.fileinfo.name = node_name; s->status_data.fileinfo.size = file_size; if (send_status(s)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Operation cancelled from status callback"); goto err; } // check for invalid characters in filename #ifdef G_OS_WIN32 if (strpbrk(node_name, "/\\<>:\"|?*") || !strcmp(node_name, ".") || !strcmp(node_name, "..")) #else if (strpbrk(node_name, "/") || !strcmp(node_name, ".") || !strcmp(node_name, "..")) #endif { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Remote file name is invalid: '%s'", node_name); goto err; } if (local_path) { if (!file) file = g_file_get_child(parent_dir, node_name); } if (local_path) { // open local file for writing data.stream = stream = g_file_create(file, 0, NULL, &local_err); if (!data.stream) { gc_free gchar* tmp = g_file_get_path(file); g_propagate_prefixed_error(err, local_err, "Can't open local file %s for writing: ", tmp); goto err; } } remove_file = TRUE; // initialize decryption and mac calculation AES_set_encrypt_key(aes_key, 128, &data.k); chunked_cbc_mac_init8(&data.mac, aes_key, data.iv); // setup buffer data.buffer = buffer = g_byte_array_new(); // perform download h = http_new(); http_set_progress_callback(h, (http_progress_fn)progress_generic, s); http_set_speed(h, s->max_ul, s->max_dl); http_set_proxy(h, s->proxy); if (!http_post_stream_download(h, url, (http_data_fn)dl_process_data, &data, &local_err)) { g_propagate_prefixed_error(err, local_err, "Data download failed: "); goto err; } if (data.stream) { if (!g_output_stream_close(G_OUTPUT_STREAM(data.stream), NULL, &local_err)) { g_propagate_prefixed_error(err, local_err, "Can't close downloaded file: "); goto err; } } // check mac of the downloaded file guchar meta_mac_xor_calc[8]; chunked_cbc_mac_finish8(&data.mac, meta_mac_xor_calc); if (memcmp(meta_mac_xor, meta_mac_xor_calc, 8) != 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "MAC mismatch"); goto err; } return TRUE; err: if (file && remove_file) g_file_delete(file, NULL, NULL); return FALSE; } // }}} // {{{ mega_node_get_link gchar* mega_node_get_link(mega_node* n, gboolean include_key) { g_return_val_if_fail(n != NULL, NULL); if (n->link) { if (include_key && n->key) { gc_free gchar* key = mega_node_get_key(n); return g_strdup_printf("https://mega.nz/#!%s!%s", n->link, key); } return g_strdup_printf("https://mega.nz/#!%s", n->link); } return NULL; } // }}} // {{{ mega_node_get_key gchar* mega_node_get_key(mega_node* n) { g_return_val_if_fail(n != NULL, NULL); if (n->key) return base64urlencode(n->key, n->key_len); return NULL; } // }}} // {{{ mega_node_get_path gchar* mega_node_get_path_dup(mega_node* n) { gchar path[4096]; if (mega_node_get_path(n, path, sizeof(path))) return g_strndup(path, sizeof(path)); return NULL; } gboolean mega_node_get_path(mega_node* n, gchar* buf, gsize len) { g_return_val_if_fail(n != NULL, FALSE); // count parents gint n_parents = 0; mega_node* it = n; while (it) { n_parents++; it = it->parent; } // allocate pointer list on stack mega_node** parents = g_alloca(sizeof(mega_node*) * n_parents); // get parents into the pointer list it = n; n_parents = 0; while (it) { parents[n_parents++] = it; it = it->parent; } // reverse iteration gint i; gchar* p = buf; for (i = n_parents - 1; i >= 0; i--) { it = parents[i]; gint name_len = strlen(it->name); gint remaining_buf_len = len - (p - buf); if (remaining_buf_len < name_len + 2) return FALSE; *p = '/'; p += 1; memcpy(p, it->name, name_len); p += name_len; } *p = '\0'; return TRUE; } // }}} // {{{ gboolean mega_node_is_container(mega_node* n) { return n && n->type != MEGA_NODE_FILE; } // }}} // {{{ mega_session_save static void save_share_keys(gchar* handle, gchar* key, SJsonGen* gen) { s_json_gen_start_object(gen); s_json_gen_member_string(gen, "handle", handle); s_json_gen_member_bytes(gen, "key", key, 16); s_json_gen_end_object(gen); } gboolean mega_session_save(mega_session* s, GError** err) { GError* local_err = NULL; GSList* i; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(s->user_email != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); // calculate cache file path gc_free gchar* un = g_ascii_strdown(s->user_email, -1); gc_checksum_free GChecksum* cs = g_checksum_new(G_CHECKSUM_SHA1); g_checksum_update(cs, un, -1); gc_free gchar* filename = g_strconcat(g_checksum_get_string(cs), ".megatools.cache", NULL); gc_free gchar* path = g_build_filename(g_get_tmp_dir(), filename, NULL); SJsonGen *gen = s_json_gen_new(); s_json_gen_start_object(gen); // serialize session object s_json_gen_member_int(gen, "version", CACHE_FORMAT_VERSION); s_json_gen_member_int(gen, "last_refresh", s->last_refresh); s_json_gen_member_string(gen, "sid", s->sid); s_json_gen_member_bytes(gen, "password_key", s->password_key, 16); s_json_gen_member_bytes(gen, "master_key", s->master_key, 16); s_json_gen_member_rsa_key(gen, "rsa_key", &s->rsa_key); s_json_gen_member_string(gen, "user_handle", s->user_handle); s_json_gen_member_string(gen, "user_name", s->user_name); s_json_gen_member_string(gen, "user_email", s->user_email); s_json_gen_member_array(gen, "share_keys"); g_hash_table_foreach(s->share_keys, (GHFunc)save_share_keys, gen); s_json_gen_end_array(gen); s_json_gen_member_array(gen, "fs_nodes"); for (i = s->fs_nodes; i; i = i->next) { mega_node* n = i->data; s_json_gen_start_object(gen); s_json_gen_member_string(gen, "name", n->name); s_json_gen_member_string(gen, "handle", n->handle); s_json_gen_member_string(gen, "parent_handle", n->parent_handle); s_json_gen_member_string(gen, "user_handle", n->user_handle); s_json_gen_member_string(gen, "su_handle", n->su_handle); s_json_gen_member_bytes(gen, "key", n->key, n->key_len); s_json_gen_member_int(gen, "type", n->type); s_json_gen_member_int(gen, "size", n->size); s_json_gen_member_int(gen, "timestamp", n->timestamp); s_json_gen_member_string(gen, "link", n->link); s_json_gen_end_object(gen); } s_json_gen_end_array(gen); s_json_gen_end_object(gen); gc_free gchar *cache_data = s_json_gen_done(gen); if (mega_debug & MEGA_DEBUG_CACHE) print_node(cache_data, "SAVE CACHE: "); gc_free gchar* tmp = g_strconcat("MEGA", cache_data, NULL); gc_free gchar* cipher = b64_aes128_cbc_encrypt_str(tmp, s->password_key); if (!g_file_set_contents(path, cipher, -1, &local_err)) { g_propagate_error(err, local_err); return FALSE; } return TRUE; } // }}} // {{{ mega_session_load gboolean mega_session_load(mega_session* s, const gchar* un, const gchar* pw, gint max_age, gchar** last_sid, GError** err) { GError* local_err = NULL; gc_free gchar* cipher = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(un != NULL, FALSE); g_return_val_if_fail(pw != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); mega_session_close(s); // calculate cache file path gc_free gchar* un_lower = g_ascii_strdown(un, -1); gc_checksum_free GChecksum* cs = g_checksum_new(G_CHECKSUM_SHA1); g_checksum_update(cs, un_lower, -1); gc_free gchar* filename = g_strconcat(g_checksum_get_string(cs), ".megatools.cache", NULL); gc_free gchar* path = g_build_filename(g_get_tmp_dir(), filename, NULL); // load cipher data if (!g_file_get_contents(path, &cipher, NULL, &local_err)) { g_propagate_error(err, local_err); return FALSE; } // calculate password key gc_free guchar* password_key = make_password_key(pw); gsize len = 0; gc_free gchar* data = b64_aes128_cbc_decrypt(cipher, password_key, &len); if (!data || len < 4) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Corrupted cache file"); return FALSE; } if (memcmp(data, "MEGA", 4) != 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Incorrect password"); return FALSE; } if (!s_json_is_valid(data + 4)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Corrupted cache file"); return FALSE; } gc_free gchar* cache_obj = s_json_get(data + 4); if (mega_debug & MEGA_DEBUG_CACHE) print_node(cache_obj, "LOAD CACHE: "); if (s_json_get_type(cache_obj) == S_JSON_TYPE_OBJECT) { gint64 version = s_json_get_member_int(cache_obj, "version", 0); gint64 last_refresh = s_json_get_member_int(cache_obj, "last_refresh", 0); if (version != CACHE_FORMAT_VERSION) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Cache version mismatch"); return FALSE; } // return sid value if available gc_free gchar* sid = s_json_get_member_string(cache_obj, "sid"); if (last_sid && sid) *last_sid = g_strdup(sid); // check max_age if (max_age > 0) { if (!last_refresh || ((last_refresh + max_age) < time(NULL))) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Cache timed out"); return FALSE; } } // cache is valid, load it gsize len; s->last_refresh = last_refresh; s->sid = sid; sid = NULL; s->password_key = s_json_get_member_bytes(cache_obj, "password_key", &len); s->master_key = s_json_get_member_bytes(cache_obj, "master_key", &len); s_json_get_member_rsa_key(cache_obj, "rsa_key", &s->rsa_key); s->user_handle = s_json_get_member_string(cache_obj, "user_handle"); s->user_name = s_json_get_member_string(cache_obj, "user_name"); s->user_email = s_json_get_member_string(cache_obj, "user_email"); if (!s->sid || !s->password_key || !s->master_key || !s->user_handle || !s->user_email || !s->rsa_key.p || !s->rsa_key.q || !s->rsa_key.d || !s->rsa_key.u) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Incomplete cache data"); return FALSE; } const gchar* sk_nodes = s_json_get_member(cache_obj, "share_keys"); if (s_json_get_type(sk_nodes) == S_JSON_TYPE_ARRAY) { S_JSON_FOREACH_ELEMENT(sk_nodes, sk_node) gc_free gchar* handle = s_json_get_member_string(sk_node, "handle"); gc_free guchar* key = s_json_get_member_bytes(sk_node, "key", &len); add_share_key(s, handle, key); S_JSON_FOREACH_END() } const gchar* fs_nodes = s_json_get_member(cache_obj, "fs_nodes"); if (s_json_get_type(fs_nodes) == S_JSON_TYPE_ARRAY) { S_JSON_FOREACH_ELEMENT(fs_nodes, fs_node) mega_node* n = g_new0(mega_node, 1); n->type = -1; S_JSON_FOREACH_MEMBER(fs_node, k, v) if (s_json_string_match(k, "name")) n->name = s_json_get_string(v); else if (s_json_string_match(k, "handle")) n->handle = s_json_get_string(v); else if (s_json_string_match(k, "parent_handle")) n->parent_handle = s_json_get_string(v); else if (s_json_string_match(k, "user_handle")) n->user_handle = s_json_get_string(v); else if (s_json_string_match(k, "su_handle")) n->su_handle = s_json_get_string(v); else if (s_json_string_match(k, "key")) n->key = s_json_get_bytes(v, &n->key_len); else if (s_json_string_match(k, "type")) n->type = s_json_get_int(v, -1); else if (s_json_string_match(k, "size")) n->size = s_json_get_int(v, 0); else if (s_json_string_match(k, "timestamp")) n->timestamp = s_json_get_int(v, 0); else if (s_json_string_match(k, "link")) n->link = s_json_get_string(v); S_JSON_FOREACH_END() s->fs_nodes = g_slist_prepend(s->fs_nodes, n); S_JSON_FOREACH_END() s->fs_nodes = g_slist_reverse(s->fs_nodes); } } else { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Corrupt cache"); return FALSE; } update_pathmap(s); return TRUE; } // }}} // {{{ mega_session_register gboolean mega_session_register(mega_session* s, const gchar* email, const gchar* password, const gchar* name, mega_reg_state** state, GError** err) { GError* local_err = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(email != NULL, FALSE); g_return_val_if_fail(password != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE); g_return_val_if_fail(state != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); // logout mega_session_close(s); // create new master key gc_free guchar* master_key = make_random_key(); // create password key gc_free guchar* password_key = make_password_key(password); // create username hash //gc_free gchar* email_lower = g_ascii_strdown(email, -1); //gc_free gchar* uh = make_username_hash(email_lower, password_key); // create ssc (session self challenge) and ts gc_free guchar* ssc = make_random_key(); guchar ts_data[32]; memcpy(ts_data, ssc, 16); aes128_encrypt(ts_data + 16, ts_data, 16, master_key); // create anon user - [{"a":"up","k":"cHl8JeeSqgBOiURQL_Dvug","ts":"W9fg4kOw8p44KWoWICbgEd3rfMovr5HoSjI1vN7845s"}] -> ["-a1DHeWfguY"] gc_free gchar* node = api_call(s, 's', NULL, &local_err, "[{a:up, k:%S, ts:%S}]", b64_aes128_encrypt(master_key, 16, password_key), base64urlencode(ts_data, 32)); if (!node) { g_propagate_error(err, local_err); return FALSE; } gc_free gchar* user_handle = s_json_get_string(node); // login as an anon user - [{"a":"us","user":"-a1DHeWfguY"}] -> [{"tsid":"W9fg4kOw8p44KWoWICbgES1hMURIZVdmZ3VZ3et8yi-vkehKMjW83vzjmw","k":"cHl8JeeSqgBOiURQL_Dvug"}] g_free(node); node = api_call(s, 'o', NULL, &local_err, "[{a:us, user:%s}]", user_handle); if (!node) { g_propagate_error(err, local_err); return FALSE; } // from now on, tsid is used as session ID s->sid = s_json_get_member_string(node, "tsid"); // get user info - [{"a":"ug"}] -> [{"u":"-a1DHeWfguY","s":1,"n":0,"k":"cHl8JeeSqgBOiURQL_Dvug","c":0,"ts":"W9fg4kOw8p44KWoWICbgEd3rfMovr5HoSjI1vN7845s"}] g_free(node); node = api_call(s, 'o', NULL, &local_err, "[{a:ug}]"); if (!node) { g_propagate_error(err, local_err); return FALSE; } // set user name - [{"a":"up","name":"Bob Brown"}] -> ["-a1DHeWfguY"] g_free(node); node = api_call(s, 's', NULL, &local_err, "[{a:up, name:%s}]", name); if (!node) { g_propagate_error(err, local_err); return FALSE; } // request signup link - [{"a":"uc","c":"ZOB7VJrNXFvCzyZBIcdWhr5l4dJatrWpEjEpAmH17ic","n":"Qm9iIEJyb3du","m":"bWVnb3VzQGVtYWlsLmN6"}] -> [0] guchar c_data[32] = {0}; // aes(master_key, pw_key) + aes(verify, pw_key) memcpy(c_data, master_key, 16); RAND_bytes(c_data + 16, 4); RAND_bytes(c_data + 16 + 12, 4); // this will set new k from the first 16 bytes of c g_free(node); node = api_call(s, 'i', NULL, &local_err, "[{a:uc, c:%S, n:%S, m:%S}]", b64_aes128_encrypt(c_data, 32, password_key), base64urlencode(name, strlen(name)), base64urlencode(email, strlen(email))); if (!node) { g_propagate_error(err, local_err); return FALSE; } // save state mega_reg_state* st = *state = g_new0(mega_reg_state, 1); st->user_handle = user_handle; user_handle = NULL; memcpy(st->password_key, password_key, 16); memcpy(st->challenge, c_data + 16, 16); return TRUE; } // }}} // {{{ mega_session_register_verify gboolean mega_session_register_verify(mega_session* s, mega_reg_state* state, const gchar* signup_key, GError** err) { GError* local_err = NULL; gc_free gchar* node = NULL; g_return_val_if_fail(s != NULL, FALSE); g_return_val_if_fail(state != NULL, FALSE); g_return_val_if_fail(state->user_handle != NULL, FALSE); g_return_val_if_fail(signup_key != NULL, FALSE); g_return_val_if_fail(err == NULL || *err == NULL, FALSE); mega_session_close(s); // generate RSA key rsa_key key; memset(&key, 0, sizeof(key)); if (!rsa_key_gen(&key)) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Can't generate RSA key"); return FALSE; } // u_types: // 0: not registered (!u.email) // 1: not sent confirmation email (!u.c) // 2: not yet set RSA key (!u.privk) // 3: full account // login as an anon user - [{"a":"us","user":"-a1DHeWfguY"}] -> [{"tsid":"W9fg4kOw8p44KWoWICbgES1hMURIZVdmZ3VZ3et8yi-vkehKMjW83vzjmw","k":"cHl8JeeSqgBOiURQL_Dvug"}] node = api_call(s, 'o', NULL, &local_err, "[{a:us, user:%s}]", state->user_handle); if (!node) { g_propagate_error(err, local_err); return FALSE; } // from now on, tsid is used as session ID s->sid = s_json_get_member_string(node, "tsid"); // send confirmation // // https://mega.nz/#confirmZOB7VJrNXFvCzyZBIcdWhr5l4dJatrWpEjEpAmH17ieRRWFjWAUAtSqaVQ_TQKltZWdvdXNAZW1haWwuY3oJQm9iIEJyb3duMhVh8n67rBg // // [{"a":"ud","c":"ZOB7VJrNXFvCzyZBIcdWhr5l4dJatrWpEjEpAmH17ieRRWFjWAUAtSqaVQ_TQKltZWdvdXNAZW1haWwuY3oJQm9iIEJyb3duMhVh8n67rBg"}] // // -> [["bWVnb3VzQGVtYWlsLmN6","Qm9iIEJyb3du","-a1DHeWfguY","ZOB7VJrNXFvCzyZBIcdWhg","vmXh0lq2takSMSkCYfXuJw"]] // ^ ^ ^ ^ ^ // email name handle enc(master_key, pwkey) enc(challenge, pwkey) g_free(node); node = api_call(s, 'a', NULL, &local_err, "[{a:ud, c:%s}]", signup_key); if (!node) { g_propagate_error(err, local_err); return FALSE; } gc_free gchar** arr = s_json_get_elements(node); if (g_strv_length(arr) != 5) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Wrong number of elements in retval from 'ud' (%d)", g_strv_length(arr)); return FALSE; } gc_free gchar* b64_email = s_json_get_string(arr[0]); gc_free gchar* b64_name = s_json_get_string(arr[1]); gc_free gchar* b64_master_key = s_json_get_string(arr[3]); gc_free gchar* b64_challenge = s_json_get_string(arr[4]); if (b64_email == NULL || b64_name == NULL || b64_master_key == NULL || b64_challenge == NULL) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid retval type from 'ud'"); return FALSE; } gsize len; gc_free gchar* email = base64urldecode(b64_email, &len); gc_free gchar* name = base64urldecode(b64_name, &len); gc_free guchar* master_key = b64_aes128_decrypt(b64_master_key, state->password_key, NULL); gc_free guchar* challenge = b64_aes128_decrypt(b64_challenge, state->password_key, NULL); if (email == NULL || name == NULL || master_key == NULL || challenge == NULL) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid retval type from 'ud'"); return FALSE; } // check challenge response if (memcmp(challenge, state->challenge, 16) != 0) { g_set_error(err, MEGA_ERROR, MEGA_ERROR_OTHER, "Invalid challenge response"); return FALSE; } // create username hash gc_free gchar* email_lower = g_ascii_strdown(email, -1); gc_free gchar* uh = make_username_hash(email_lower, state->password_key); // save uh and c // [{"uh":"VcWbhpU9cb0","c":"ZOB7VJrNXFvCzyZBIcdWhr5l4dJatrWpEjEpAmH17ieRRWFjWAUAtSqaVQ_TQKltZWdvdXNAZW1haWwuY3oJQm9iIEJyb3duMhVh8n67rBg","a":"up"}] -> ["-a1DHeWfguY"] g_free(node); node = api_call(s, 's', NULL, &local_err, "[{a:up, c:%s, uh:%s}]", signup_key, uh); if (!node) { g_propagate_error(err, local_err); return FALSE; } // relogin using email + uh // [{"a":"us","user":"megous@email.cz","uh":"VcWbhpU9cb0"}] -> [{"tsid":"W9fg4kOw8p44KWoWICbgES1hMURIZVdmZ3VZ3et8yi-vkehKMjW83vzjmw","k":"ZOB7VJrNXFvCzyZBIcdWhg"}] g_free(node); node = api_call(s, 'o', NULL, &local_err, "[{a:us, user:%s, uh:%s}]", email_lower, uh); if (!node) { g_propagate_error(err, local_err); return FALSE; } g_free(s->sid); s->sid = s_json_get_member_string(node, "tsid"); // set RSA key pair // [{"a":"up", "privk":"...", "pubk":"..."}] -> ["-a1DHeWfguY"] g_free(node); node = api_call(s, 's', NULL, &local_err, "[{a:up, pubk:%S, privk:%S}]", b64_encode_pubk(&key), b64_aes128_encrypt_privk(master_key, &key)); if (!node) { g_propagate_error(err, local_err); return FALSE; } //[{"a":"ug"}] -> [{"u":"-a1DHeWfguY","s":1,"email":"megous@email.cz","name":"Bob Brown","k":"ZOB7VJrNXFvCzyZBIcdWhg","c":1,"ts":"W9fg4kOw8p44KWoWICbgEd3rfMovr5HoSjI1vN7845s"}] //[{"a":"up","privk":"KSUujv7KB8QYL2At2sWeMPi2DQd_e09FwbR2RwileC9NxYw0MxFTKFj7Yxha__borDmBUacxaWXRCnMnAmMlsyWc8zw_ml9tysYHOsL4cQEzpBJtCCIrhnRjwnQk8JUVK--5fyQRS6G2RiOVdeFjkKQyifmXgBsiAlhHKhzSY0VD6ruR9htGfDsgImim_S-MzuWaHQN8TJkBkSZRAgXy6O2tUh0Bk4aEp8NaEV0GHdV7ec1S1jbR9FzwKB7cNkKxk2nd7wRS9rnl_QPz4MTv84dS6qHxahT0ebU5njC2_IkFLxuVlloyO2UTPRPHa9JHaPa3R2BrEmb-eWMmsZ5icNwJl8PLzuc9YlSI09-IR5rHZLm2uW-V05GI1IHIjw9LGzqli6WL7tzlMVhHrsq-xj70iXjVvOXJ3XhwbbW99S8O-3sQ2gG36fSHUcg0WMSD-8KiD-DhmhfqX8iqg-2YDfXrsYUNhq_VHJF83Zm0itPdRIkgUtBR9MFdASSPe_8uxlEBsCATTHNGIWbH0wiKRo2tEqbUTZCJjXhAyTyMhdjbSdS1ARKNr12YHkLKi12uhIJRO73VJGmjZD8De59cPduGihLGt3ipIKVIxsm-Xy6f9p29BtDHE1go_yacqbW1n8d1anN8WhmG8Q_1PwY1h-opagpd-Nf0geFti_3PI8dY75NPAuDyknv0kgn8OZ4ItzO10-4H3_GgLa5m8zb6usk-eeVCo4lkC4Z2YHHlY4YLRIL7rWC0m_kFcsyvVi1-PVNJ8GauLt9PYmW9hj20yJLwCYkEVSQyM4Yxgh55hSa3La3FnUt3Nls_ImOdcDWtYpB0UKJSKN_IYH4NlD60VwvFUifJndRB_JlJGvqzR4s","pubk":"B_9lGyG4ImN-3idVOARGr6dk-4Nn6VwVYxCTSk1nDvXztCNQ-eFwxIJoS3ykODSH_AjHhst_Loj_erSgX-AUOBAjkh5rQuriA4ciT76tIh_IarC5Yf2Zey8Ao_gLPgaqrLTIWPxDhSAmCLd3pa3X9weAuGK_7eiVxmXU4tK_5j7dyn949C4OMNhxp9vRgZqaOzcjouwKm8xH9nWqXTR7F2WKW2BcXxeBkRnFVJz6cd5IqmJENabhDH1-UDf9eCW7GeD2MHU8xnbJk2fXqnru35nxz9OG6VvVDMzrS6dtQU8mC7xnIut_N6eyMRWsHpm8N1bSxHgz1XWCodnOBHFIJSoJAAUR"}] -> ["-a1DHeWfguY"] return TRUE; } // }}} megatools-1.9.98/config.guess0000755000175000001440000012367212575147303013073 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-11-04' # 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 3 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. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # 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 # # Please send patches to . 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 1992-2014 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 case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # 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 ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_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/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` 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 ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *: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-${LIBC}`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/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 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="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${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-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 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-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} 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-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 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 ;; x86_64:Haiku:*:*) echo x86_64-unknown-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 eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then 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 case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi 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 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: megatools-1.9.98/tools/0000755000175000001440000000000013006640511011745 500000000000000megatools-1.9.98/tools/ls.c0000644000175000001440000001122313006625432012453 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gboolean opt_names; static gboolean opt_recursive; static gboolean opt_long; static gboolean opt_human; static gboolean opt_export; //static gboolean opt_color; static gboolean opt_header; static GOptionEntry entries[] = { { "names", 'n', 0, G_OPTION_ARG_NONE, &opt_names, "List names of files only (will be disabled if you specify multiple paths)", NULL }, { "recursive", 'R', 0, G_OPTION_ARG_NONE, &opt_recursive, "List files in subdirectories", NULL }, { "long", 'l', 0, G_OPTION_ARG_NONE, &opt_long, "Use a long listing format", NULL }, { "header", '\0', 0, G_OPTION_ARG_NONE, &opt_header, "Show columns header in long listing", NULL }, { "human", 'h', 0, G_OPTION_ARG_NONE, &opt_human, "Use a long listing format", NULL }, //{ "color", 'c', 0, G_OPTION_ARG_NONE, &opt_color, "Use color highlighting of node types", NULL }, { "export", 'e', 0, G_OPTION_ARG_NONE, &opt_export, "Show mega.nz download links (export)", NULL }, { NULL } }; static gint compare_node(mega_node* a, mega_node* b) { gchar path1[4096]; gchar path2[4096]; if (mega_node_get_path(a, path1, 4096) && mega_node_get_path(b, path2, 4096)) return strcmp(path1, path2); return 0; } int main(int ac, char* av[]) { mega_session* s; gc_error_free GError *local_err = NULL; GSList *l = NULL, *i; gint j; tool_init(&ac, &av, "- list files stored at mega.nz", entries, TOOL_INIT_AUTH); s = tool_start_session(TOOL_SESSION_OPEN); if (!s) return 1; // gather nodes if (ac == 1) { l = mega_session_ls_all(s); opt_names = FALSE; } else { if (ac > 2 || opt_recursive) opt_names = FALSE; for (j = 1; j < ac; j++) { gc_free gchar* path = tool_convert_filename(av[j], FALSE); mega_node* n = mega_session_stat(s, path); if (n && (n->type == MEGA_NODE_FILE || !opt_names)) l = g_slist_append(l, n); l = g_slist_concat(l, mega_session_ls(s, path, opt_recursive)); } } l = g_slist_sort(l, (GCompareFunc)compare_node); // export if requested if (opt_export && !mega_session_addlinks(s, l, &local_err)) { g_printerr("ERROR: Can't read links info from mega.nz: %s\n", local_err->message); g_slist_free(l); tool_fini(s); return 1; } if (l && opt_long && opt_header && !opt_export) { g_print("===================================================================================\n"); g_print("%-11s %-11s %-1s %13s %-19s %s\n", "Handle", "Owner", "T", "Size", "Mod. Date", opt_names ? "Filename" : "Path"); g_print("===================================================================================\n"); } for (i = l; i; i = i->next) { mega_node* n = i->data; gc_free gchar* node_path = mega_node_get_path_dup(n); if (opt_export) g_print("%73s ", n->link ? mega_node_get_link(n, TRUE) : ""); if (opt_long) { GDateTime* dt = g_date_time_new_from_unix_local(n->timestamp); gc_free gchar* time_str = g_date_time_format(dt, "%Y-%m-%d %H:%M:%S"); g_date_time_unref(dt); gc_free gchar* size_str = NULL; if (opt_human) size_str = n->size > 0 ? g_format_size_full(n->size, G_FORMAT_SIZE_IEC_UNITS) : g_strdup("-"); else size_str = n->size > 0 ? g_strdup_printf("%" G_GUINT64_FORMAT, n->size) : g_strdup("-"); g_print("%-11s %-11s %d %13s %19s %s\n", n->handle, n->user_handle ? n->user_handle : "", n->type, size_str, n->timestamp > 0 ? time_str : "", opt_names ? n->name : node_path ); } else g_print("%s\n", opt_names ? n->name : node_path); } g_slist_free(l); tool_fini(s); return 0; } megatools-1.9.98/tools/dl.c0000644000175000001440000001721713006625432012445 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" #ifdef G_OS_WIN32 #include #include #endif static gchar* opt_path = "."; static gboolean opt_stream = FALSE; static gboolean opt_noprogress = FALSE; static gboolean opt_print_names = FALSE; static GOptionEntry entries[] = { { "path", '\0', 0, G_OPTION_ARG_FILENAME, &opt_path, "Local directory or file name, to save data to", "PATH" }, { "no-progress", '\0', 0, G_OPTION_ARG_NONE, &opt_noprogress, "Disable progress bar", NULL }, { "print-names", '\0', 0, G_OPTION_ARG_NONE, &opt_print_names, "Print names of downloaded files", NULL }, { NULL } }; static gchar* cur_file = NULL; static mega_session* s; static gboolean status_callback(mega_status_data* data, gpointer userdata) { if (opt_stream && data->type == MEGA_STATUS_DATA) { fwrite(data->data.buf, data->data.size, 1, stdout); fflush(stdout); } if (data->type == MEGA_STATUS_FILEINFO) { cur_file = g_strdup(data->fileinfo.name); } if (!opt_noprogress && data->type == MEGA_STATUS_PROGRESS) tool_show_progress(cur_file, data); return FALSE; } // download operation static gboolean dl_sync_file(mega_node* node, GFile* file, const gchar* remote_path) { gc_error_free GError *local_err = NULL; gc_free gchar* local_path = g_file_get_path(file); if (g_file_query_exists(file, NULL)) { g_printerr("ERROR: File already exists at %s\n", local_path); return FALSE; } if (!opt_noprogress) g_print("F %s\n", local_path); if (!mega_session_get(s, local_path, remote_path, &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL); g_printerr("ERROR: Download failed for %s: %s\n", remote_path, local_err->message); return FALSE; } if (!opt_noprogress) g_print("\r" ESC_CLREOL); if (opt_print_names) g_print("%s\n", local_path); return TRUE; } static gboolean dl_sync_dir(mega_node* node, GFile* file, const gchar* remote_path) { gc_error_free GError *local_err = NULL; gc_free gchar* local_path = g_file_get_path(file); if (!g_file_query_exists(file, NULL)) { if (!opt_noprogress) g_print("D %s\n", local_path); if (!g_file_make_directory(file, NULL, &local_err)) { g_printerr("ERROR: Can't create local directory %s: %s\n", local_path, local_err->message); return FALSE; } } else { if (g_file_query_file_type(file, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) != G_FILE_TYPE_DIRECTORY) { g_printerr("ERROR: Can't create local directory %s: file exists\n", local_path); return FALSE; } } // sync children GSList* children = mega_session_get_node_chilren(s, node), *i; gboolean status = TRUE; for (i = children; i; i = i->next) { mega_node* child = i->data; gc_free gchar* child_remote_path = g_strconcat(remote_path, "/", child->name, NULL); gc_object_unref GFile* child_file = g_file_get_child(file, child->name); if (child->type == 0) { if (!dl_sync_file(child, child_file, child_remote_path)) status = FALSE; } else { if (!dl_sync_dir(child, child_file, child_remote_path)) status = FALSE; } } g_slist_free(children); return status; } int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; gc_regex_unref GRegex *file_regex = NULL, *folder_regex = NULL; gint i; int status = 0; tool_init(&ac, &av, "- download exported files from mega.nz", entries, 0); if (!strcmp(opt_path, "-")) { opt_noprogress = opt_stream = TRUE; // see https://github.com/megous/megatools/issues/38 #ifdef G_OS_WIN32 setmode(fileno(stdout), O_BINARY); #endif } if (ac < 2) { g_printerr("ERROR: No links specified for download!\n"); tool_fini(NULL); return 1; } if (opt_stream && ac != 2) { g_printerr("ERROR: Can't stream from multiple files!\n"); tool_fini(NULL); return 1; } // prepare link parsers file_regex = g_regex_new("^https?://mega(?:\\.co)?\\.nz/#!([a-z0-9_-]{8})!([a-z0-9_-]{43})$", G_REGEX_CASELESS, 0, NULL); g_assert(file_regex != NULL); folder_regex = g_regex_new("^https?://mega(?:\\.co)?\\.nz/#F!([a-z0-9_-]{8})!([a-z0-9_-]{22})$", G_REGEX_CASELESS, 0, NULL); g_assert(folder_regex != NULL); // create session s = tool_start_session(0); mega_session_watch_status(s, status_callback, NULL); // process links for (i = 1; i < ac; i++) { gc_match_info_unref GMatchInfo* m1 = NULL; gc_match_info_unref GMatchInfo* m2 = NULL; gc_free gchar* key = NULL; gc_free gchar* handle = NULL; gc_free gchar* link = tool_convert_filename(av[i], FALSE); if (g_regex_match(file_regex, link, 0, &m1)) { handle = g_match_info_fetch(m1, 1); key = g_match_info_fetch(m1, 2); // perform download if (!mega_session_dl(s, handle, key, opt_stream ? NULL : opt_path, &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL "\n"); g_printerr("ERROR: Download failed for '%s': %s\n", link, local_err->message); g_clear_error(&local_err); status = 1; } else { if (!opt_noprogress) g_print("\r" ESC_CLREOL "Downloaded %s\n", cur_file); if (opt_print_names) g_print("%s\n", cur_file); } } else if (g_regex_match(folder_regex, link, 0, &m2)) { if (opt_stream) { g_printerr("ERROR: Can't stream from a directory!\n"); tool_fini(s); return 1; } handle = g_match_info_fetch(m2, 1); key = g_match_info_fetch(m2, 2); // perform download if (!mega_session_open_exp_folder(s, handle, key, &local_err)) { g_printerr("ERROR: Can't open folder '%s': %s\n", link, local_err->message); g_clear_error(&local_err); status = 1; } else { mega_session_watch_status(s, status_callback, NULL); GSList* l = mega_session_ls(s, "/", FALSE); if (g_slist_length(l) == 1) { mega_node* root_node = l->data; gc_object_unref GFile* local_dir = g_file_new_for_path(opt_path); if (g_file_query_file_type(local_dir, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) == G_FILE_TYPE_DIRECTORY) { gc_free gchar* node_path = mega_node_get_path_dup(root_node); if (!dl_sync_dir(root_node, local_dir, node_path)) status = 1; } else { g_printerr("ERROR: %s must be a directory\n", opt_path); status = 1; } } else { g_printerr("ERROR: EXP folder fs has multiple toplevel nodes? Weird!\n"); status = 1; } g_slist_free(l); } } else { g_printerr("WARNING: Skipping invalid Mega download link: %s\n", link); } } tool_fini(s); return status; } megatools-1.9.98/tools/mkdir.c0000644000175000001440000000324113006625432013144 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static mega_session* s; static GOptionEntry entries[] = { { NULL } }; int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; tool_init(&ac, &av, "- create directories at mega.nz", entries, TOOL_INIT_AUTH); if (ac < 2) { g_printerr("ERROR: No directories specified!\n"); tool_fini(NULL); return 1; } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) { tool_fini(NULL); return 1; } gint i, status = 0; for (i = 1; i < ac; i++) { gc_free gchar* path = tool_convert_filename(av[i], FALSE); if (!mega_session_mkdir(s, path, &local_err)) { g_printerr("ERROR: Can't create directory %s: %s\n", path, local_err->message); g_clear_error(&local_err); status = 1; } } mega_session_save(s, NULL); tool_fini(s); return status; } megatools-1.9.98/tools/reg.c0000644000175000001440000001343513006625432012621 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gchar* opt_name; static gchar* opt_email; static gchar* opt_password; static gboolean opt_register; static gchar* opt_verify; static gboolean opt_script; static GOptionEntry entries[] = { { "name", 'n', 0, G_OPTION_ARG_STRING, &opt_name, "Your real name", "NAME" }, { "email", 'e', 0, G_OPTION_ARG_STRING, &opt_email, "Your email (will be your username)", "EMAIL" }, { "password", 'p', 0, G_OPTION_ARG_STRING, &opt_password, "Your password", "PASSWORD" }, { "register", '\0', 0, G_OPTION_ARG_NONE, &opt_register, "Perform registration", NULL }, { "verify", '\0', 0, G_OPTION_ARG_STRING, &opt_verify, "Finish registration (pass verification link)", "STATE" }, { "scripted", '\0', 0, G_OPTION_ARG_NONE, &opt_script, "Return script friendly output from --register", NULL }, { NULL } }; static gchar* serialize_reg_state(mega_reg_state* state) { gc_free gchar* pk = g_base64_encode(state->password_key, 16); gc_free gchar* ch = g_base64_encode(state->challenge, 16); return g_strdup_printf("%s:%s:%s", pk, ch, state->user_handle); } static mega_reg_state* unserialize_reg_state(const gchar* str) { gc_match_info_unref GMatchInfo* m = NULL; gc_regex_unref GRegex* r = g_regex_new("^([a-z0-9/+=]{24}):([a-z0-9/+=]{24}):(.*)$", G_REGEX_CASELESS, 0, NULL); gsize len; if (!r) return NULL; if (!g_regex_match(r, str, 0, &m)) return NULL; gc_free gchar* pk = g_match_info_fetch(m, 1); gc_free gchar* ch = g_match_info_fetch(m, 2); gc_free guchar* decoded_ch = NULL; gc_free guchar* decoded_pk = NULL; mega_reg_state* state = g_new0(mega_reg_state, 1); state->user_handle = g_match_info_fetch(m, 3);; decoded_pk = g_base64_decode(pk, &len); if (!decoded_pk) goto err; if (len != 16) goto err; memcpy(state->password_key, decoded_pk, 16); decoded_ch = g_base64_decode(ch, &len); if (!decoded_ch) goto err; if (len != 16) goto err; memcpy(state->challenge, decoded_ch, 16); return state; err: g_free(state->user_handle); g_free(state); return NULL; } int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; mega_reg_state* state = NULL; gc_free gchar* signup_key = NULL; mega_session* s; tool_init(&ac, &av, "LINK - register a new mega.nz account", entries, 0); if (opt_verify && opt_register) { g_printerr("ERROR: You must specify either --register or --verify option\n"); return 1; } if (opt_register) { if (!opt_name) { g_printerr("ERROR: You must specify name for your new mega.nz account\n"); return 1; } if (!opt_email) { g_printerr("ERROR: You must specify email for your new mega.nz account\n"); return 1; } if (!opt_password) { g_printerr("ERROR: You must specify password for your new mega.nz account\n"); return 1; } } else if (opt_verify) { if (ac != 2) { g_printerr("ERROR: You must specify signup key and a link from the verification email\n"); return 1; } gc_regex_unref GRegex* r = g_regex_new("^(?:https?://mega(?:\\.co)?\\.nz/#confirm)?([a-z0-9_-]{80,512})$", G_REGEX_CASELESS, 0, NULL); gc_match_info_unref GMatchInfo* m = NULL; g_assert(r != NULL); if (!g_regex_match(r, av[1], 0, &m)) { g_printerr("ERROR: Invalid verification link or key: '%s'\n", av[1]); return 1; } signup_key = g_match_info_fetch(m, 1); state = unserialize_reg_state(opt_verify); if (!state) { g_printerr("ERROR: Failed to decode registration state parameter, make sure you copied it correctly\n"); return 1; } } else { g_printerr("ERROR: You must specify either --register or --verify option\n"); return 1; } s = mega_session_new(); if (opt_register) { if (!mega_session_register(s, opt_email, opt_password, opt_name, &state, &local_err)) { g_printerr("ERROR: Registration failed: %s\n", local_err ? local_err->message : "Unknown error"); goto err; } gc_free gchar* serialized_state = serialize_reg_state(state); if (opt_script) g_print("%s --verify %s @LINK@\n", av[0], serialized_state); else g_print( "Registration email was sent to %s. To complete registration, you must run:\n\n" " %s --verify %s @LINK@\n\n" "(Where @LINK@ is registration link from the 'MEGA Signup' email)\n", opt_email, g_get_prgname(), serialized_state ); } if (opt_verify) { if (!mega_session_register_verify(s, state, signup_key, &local_err)) { g_printerr("ERROR: Verification failed: %s\n", local_err ? local_err->message : "Unknown error"); goto err; } if (!opt_script) g_print("Account registered successfully!\n"); } tool_fini(s); return 0; err: tool_fini(s); return 1; } megatools-1.9.98/tools/copy.c0000644000175000001440000002021413006625432013007 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gchar* opt_remote_path; static gchar* opt_local_path; static gboolean opt_download; static gboolean opt_noprogress; static gboolean opt_dryrun; static gboolean opt_no_previews; static mega_session* s; static GOptionEntry entries[] = { { "remote", 'r', 0, G_OPTION_ARG_STRING, &opt_remote_path, "Remote directory", "PATH" }, { "local", 'l', 0, G_OPTION_ARG_STRING, &opt_local_path, "Local directory", "PATH" }, { "download", 'd', 0, G_OPTION_ARG_NONE, &opt_download, "Download files from mega", NULL }, { "no-progress", '\0', 0, G_OPTION_ARG_NONE, &opt_noprogress, "Disable progress bar", NULL }, { "dryrun", 'n', 0, G_OPTION_ARG_NONE, &opt_dryrun, "Don't perform any actual changes", NULL }, { "disable-previews", '\0', 0, G_OPTION_ARG_NONE, &opt_no_previews, "Don't generate previews", NULL }, { NULL } }; static gboolean status_callback(mega_status_data* data, gpointer userdata) { if (!opt_noprogress && data->type == MEGA_STATUS_PROGRESS) tool_show_progress("copying...", data); return FALSE; } // upload operation static gboolean up_sync_file(GFile* root, GFile* file, const gchar* remote_path) { GError *local_err = NULL; mega_node* node = mega_session_stat(s, remote_path); if (node) { g_printerr("ERROR: File already exists at %s\n", remote_path); return FALSE; } g_print("F %s\n", remote_path); if (!opt_dryrun) { if (!mega_session_put(s, remote_path, g_file_get_path(file), &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL); g_printerr("ERROR: Upload failed for %s: %s\n", remote_path, local_err->message); g_clear_error(&local_err); return FALSE; } if (!opt_noprogress) g_print("\r" ESC_CLREOL); } return TRUE; } static gboolean up_sync_dir(GFile* root, GFile* file, const gchar* remote_path) { GError *local_err = NULL; GFileInfo* i; if (root != file) { mega_node* node = mega_session_stat(s, remote_path); if (node && node->type == MEGA_NODE_FILE) { g_printerr("ERROR: File already exists at %s\n", remote_path); return FALSE; } if (!node) { g_print("D %s\n", remote_path); if (!opt_dryrun) { if (!mega_session_mkdir(s, remote_path, &local_err)) { g_printerr("ERROR: Can't create remote directory %s: %s\n", remote_path, local_err->message); g_clear_error(&local_err); return FALSE; } } } } // sync children GFileEnumerator* e = g_file_enumerate_children(file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &local_err); if (!e) { g_printerr("ERROR: Can't read local directory %s: %s\n", g_file_get_relative_path(root, file), local_err->message); g_clear_error(&local_err); return FALSE; } gboolean status = TRUE; while ((i = g_file_enumerator_next_file(e, NULL, NULL))) { const gchar* name = g_file_info_get_name(i); GFile* child = g_file_get_child(file, name); GFileType type = g_file_query_file_type(child, 0, NULL); gchar* child_remote_path = g_strconcat(remote_path, "/", name, NULL); if (type == G_FILE_TYPE_DIRECTORY) { if (!up_sync_dir(root, child, child_remote_path)) status = FALSE; } else if (type == G_FILE_TYPE_REGULAR) { if (!up_sync_file(root, child, child_remote_path)) status = FALSE; } else { g_printerr("WARNING: Skipping special file %s\n", g_file_get_relative_path(root, file)); } g_free(child_remote_path); g_object_unref(child); g_object_unref(i); } g_object_unref(e); return status; } // download operation static gboolean dl_sync_file(mega_node* node, GFile* file, const gchar* remote_path) { GError *local_err = NULL; gchar* local_path = g_file_get_path(file); if (g_file_query_exists(file, NULL)) { g_printerr("ERROR: File already exists at %s\n", local_path); return FALSE; } g_print("F %s\n", local_path); if (!opt_dryrun) { if (!mega_session_get(s, g_file_get_path(file), remote_path, &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL); g_printerr("ERROR: Download failed for %s: %s\n", remote_path, local_err->message); g_clear_error(&local_err); return FALSE; } if (!opt_noprogress) g_print("\r" ESC_CLREOL); } return TRUE; } static gboolean dl_sync_dir(mega_node* node, GFile* file, const gchar* remote_path) { GError *local_err = NULL; gchar* local_path = g_file_get_path(file); if (!g_file_query_exists(file, NULL)) { g_print("D %s\n", local_path); if (!opt_dryrun) { if (!g_file_make_directory(file, NULL, &local_err)) { g_printerr("ERROR: Can't create local directory %s: %s\n", local_path, local_err->message); g_clear_error(&local_err); return FALSE; } } } else { if (g_file_query_file_type(file, 0, NULL) != G_FILE_TYPE_DIRECTORY) { g_printerr("ERROR: Can't create local directory %s: file exists\n", local_path); return FALSE; } } // sync children gboolean status = TRUE; GSList* children = mega_session_get_node_chilren(s, node), *i; for (i = children; i; i = i->next) { mega_node* child = i->data; gchar* child_remote_path = g_strconcat(remote_path, "/", child->name, NULL); GFile* child_file = g_file_get_child(file, child->name); if (child->type == MEGA_NODE_FILE) { if (!dl_sync_file(child, child_file, child_remote_path)) status = FALSE; } else { if (!dl_sync_dir(child, child_file, child_remote_path)) status = FALSE; } g_object_unref(child_file); g_free(child_remote_path); } g_slist_free(children); return status; } // main program int main(int ac, char* av[]) { tool_init(&ac, &av, "- synchronize local and remote mega.nz directories", entries, TOOL_INIT_AUTH); if (!opt_local_path || !opt_remote_path) { g_printerr("ERROR: You must specify local and remote paths\n"); return 1; } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) { tool_fini(NULL); return 1; } mega_session_enable_previews(s, !opt_no_previews); mega_session_watch_status(s, status_callback, NULL); // check remote dir existence mega_node* remote_dir = mega_session_stat(s, opt_remote_path); if (!remote_dir) { g_printerr("ERROR: Remote directory not found %s\n", opt_remote_path); goto err0; } else if (!mega_node_is_container(remote_dir)) { g_printerr("ERROR: Remote path must be a folder: %s\n", opt_remote_path); goto err0; } // check local dir existence GFile* local_file = g_file_new_for_path(opt_local_path); gint status = 0; if (opt_download) { if (!dl_sync_dir(remote_dir, local_file, opt_remote_path)) status = 1; } else { if (g_file_query_file_type(local_file, 0, NULL) != G_FILE_TYPE_DIRECTORY) { g_printerr("ERROR: Local directory not found %s\n", opt_local_path); goto err1; } if (!up_sync_dir(local_file, local_file, opt_remote_path)) status = 1; mega_session_save(s, NULL); } g_object_unref(local_file); tool_fini(s); return status; err1: g_object_unref(local_file); err0: tool_fini(s); return 1; } megatools-1.9.98/tools/put.c0000644000175000001440000000550513006625432012653 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gchar* opt_path = "/Root"; static gboolean opt_noprogress = FALSE; static gboolean opt_no_previews; static GOptionEntry entries[] = { { "path", '\0', 0, G_OPTION_ARG_STRING, &opt_path, "Remote path to save files to", "PATH" }, { "no-progress", '\0', 0, G_OPTION_ARG_NONE, &opt_noprogress, "Disable progress bar", NULL }, { "disable-previews", '\0', 0, G_OPTION_ARG_NONE, &opt_no_previews, "Don't generate previews", NULL }, { NULL } }; static gchar* cur_file = NULL; static gboolean status_callback(mega_status_data* data, gpointer userdata) { if (data->type == MEGA_STATUS_FILEINFO) { g_free(cur_file); cur_file = g_strdup(data->fileinfo.name); } if (!opt_noprogress && data->type == MEGA_STATUS_PROGRESS) tool_show_progress(cur_file, data); return FALSE; } int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; mega_session* s; tool_init(&ac, &av, "- upload files to mega.nz", entries, TOOL_INIT_AUTH); if (ac < 2) { g_printerr("ERROR: No files specified for upload!\n"); tool_fini(NULL); return 1; } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) return 1; mega_session_enable_previews(s, !opt_no_previews); mega_session_watch_status(s, status_callback, NULL); gint status = 0; gint i; for (i = 1; i < ac; i++) { gc_free gchar* path = tool_convert_filename(av[i], TRUE); g_free(cur_file); cur_file = g_path_get_basename(path); // perform download if (!mega_session_put(s, opt_path, path, &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL "\n"); g_printerr("ERROR: Upload failed for '%s': %s\n", path, local_err->message); g_clear_error(&local_err); status = 1; } else { if (!opt_noprogress) g_print("\r" ESC_CLREOL "Uploaded %s\n", cur_file); } } mega_session_save(s, NULL); tool_fini(s); return status; } megatools-1.9.98/tools/get.c0000644000175000001440000000563113006625432012622 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gchar* opt_path = "."; static gboolean opt_stream = FALSE; static gboolean opt_noprogress = FALSE; static GOptionEntry entries[] = { { "path", '\0', 0, G_OPTION_ARG_FILENAME, &opt_path, "Local directory or file name, to save data to", "PATH" }, { "no-progress", '\0', 0, G_OPTION_ARG_NONE, &opt_noprogress, "Disable progress bar", NULL}, { NULL } }; static gchar* cur_file = NULL; static gboolean status_callback(mega_status_data* data, gpointer userdata) { if (opt_stream && data->type == MEGA_STATUS_DATA) { fwrite(data->data.buf, data->data.size, 1, stdout); fflush(stdout); } if (data->type == MEGA_STATUS_FILEINFO) { cur_file = g_strdup(data->fileinfo.name); } if (!opt_noprogress && data->type == MEGA_STATUS_PROGRESS) tool_show_progress(cur_file, data); return FALSE; } int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; mega_session* s; tool_init(&ac, &av, "- download individual files from mega.nz", entries, TOOL_INIT_AUTH); if (!strcmp(opt_path, "-")) opt_noprogress = opt_stream = TRUE; if (ac < 2) { g_printerr("ERROR: No files specified for download!\n"); tool_fini(NULL); return 1; } if (opt_stream && ac != 2) { g_printerr("ERROR: Can't stream from multiple files!\n"); tool_fini(NULL); return 1; } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) { tool_fini(NULL); return 1; } mega_session_watch_status(s, status_callback, NULL); gint i, status = 0; for (i = 1; i < ac; i++) { gc_free gchar* path = tool_convert_filename(av[i], FALSE); // perform download if (!mega_session_get(s, opt_stream ? NULL : opt_path, path, &local_err)) { if (!opt_noprogress) g_print("\r" ESC_CLREOL "\n"); g_printerr("ERROR: Download failed for '%s': %s\n", path, local_err->message); g_clear_error(&local_err); status = 1; } else { if (!opt_noprogress) g_print("\r" ESC_CLREOL "Downloaded %s\n", cur_file); } } tool_fini(s); return status; } megatools-1.9.98/tools/rm.c0000644000175000001440000000322713006625432012460 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static GOptionEntry entries[] = { { NULL } }; int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; static mega_session* s; tool_init(&ac, &av, "- remove files from mega.nz", entries, TOOL_INIT_AUTH); if (ac < 2) { g_printerr("ERROR: No files specified for removal!\n"); tool_fini(NULL); return 1; } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) { tool_fini(NULL); return 1; } gint i, status = 0; for (i = 1; i < ac; i++) { gc_free gchar* path = tool_convert_filename(av[i], FALSE); if (!mega_session_rm(s, path, &local_err)) { g_printerr("ERROR: Can't remove %s: %s\n", path, local_err->message); g_clear_error(&local_err); status = 1; } } mega_session_save(s, NULL); tool_fini(s); return status; } megatools-1.9.98/tools/df.c0000644000175000001440000000712313006625432012432 00000000000000/* * megatools - Mega.nz client library and tools * Copyright (C) 2013 OndÅ™ej Jirman * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tools.h" static gboolean opt_human; static gboolean opt_mb; static gboolean opt_gb; static gboolean opt_total; static gboolean opt_free; static gboolean opt_used; static GOptionEntry entries[] = { { "human", 'h', 0, G_OPTION_ARG_NONE, &opt_human, "Use human readable formatting", NULL }, { "mb", '\0', 0, G_OPTION_ARG_NONE, &opt_mb, "Show numbers in MiB", NULL }, { "gb", '\0', 0, G_OPTION_ARG_NONE, &opt_gb, "Show numbers in GiB", NULL }, { "total", '\0', 0, G_OPTION_ARG_NONE, &opt_total, "Show only total available space", NULL }, { "used", '\0', 0, G_OPTION_ARG_NONE, &opt_used, "Show only used space", NULL }, { "free", '\0', 0, G_OPTION_ARG_NONE, &opt_free, "Show only available free space", NULL }, { NULL } }; static gchar* format_size(guint64 size) { if (opt_human) return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS); else if (opt_mb) size /= 1024 * 1024; else if (opt_gb) size /= 1024 * 1024 * 1024; return g_strdup_printf("%" G_GUINT64_FORMAT, size); } int main(int ac, char* av[]) { GError *local_err = NULL; mega_session* s; tool_init(&ac, &av, "- display mega.nz storage quotas/usage", entries, TOOL_INIT_AUTH); if (opt_total || opt_free || opt_used) { gint opts_used = 0; opts_used += opt_total ? 1 : 0; opts_used += opt_free ? 1 : 0; opts_used += opt_used ? 1 : 0; if (opt_used > 1) { g_printerr("ERROR: Options conflict, you should use either --total, --used, or --free.\n"); return 1; } } if (opt_human || opt_mb || opt_gb) { gint opts_used = 0; opts_used += opt_human ? 1 : 0; opts_used += opt_mb ? 1 : 0; opts_used += opt_gb ? 1 : 0; if (opt_used > 1) { g_printerr("ERROR: Options conflict, you should use either --human, --mb, or --gb.\n"); return 1; } } s = tool_start_session(TOOL_SESSION_OPEN); if (!s) return 1; mega_user_quota* q = mega_session_user_quota(s, &local_err); if (!q) { g_printerr("ERROR: Can't determine disk usage: %s\n", local_err->message); g_clear_error(&local_err); goto err; } guint64 free = q->total >= q->used ? q->total - q->used : 0; if (opt_total) g_print("%s\n", format_size(q->total)); else if (opt_used) g_print("%s\n", format_size(q->used)); else if (opt_free) g_print("%s\n", format_size(free)); else { g_print("Total: %s\n", format_size(q->total)); g_print("Used: %s\n", format_size(q->used)); g_print("Free: %s\n", format_size(free)); } g_free(q); tool_fini(s); return 0; err: tool_fini(s); return 1; } megatools-1.9.98/TODO0000644000175000001440000000000013006640447011213 00000000000000megatools-1.9.98/HACKING0000644000175000001440000000124312131600372011513 00000000000000How to contribute to megatools ============================== If you want to contribute code to megatools, you can fork official git repository at: https://github.com/megous/megatools To contribute bug reports and feature requests, use issue tracker at github: https://github.com/megous/megatools/issues If you're developing application that uses libmega, be aware that libmega API is still experimental, and may change in the future. When megatools 2.0.0 will be released, libmega API will become stable, and backward comaptibility will be properly maintained. I will not be working on improving the tools themselves until I finish the new libmega library. megatools-1.9.98/Makefile.in0000644000175000001440000012050513006623037012601 00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 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@ # {{{ global flags VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 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 = : bin_PROGRAMS = megadf$(EXEEXT) megadl$(EXEEXT) megaget$(EXEEXT) \ megals$(EXEEXT) megamkdir$(EXEEXT) megaput$(EXEEXT) \ megareg$(EXEEXT) megarm$(EXEEXT) megacopy$(EXEEXT) @ENABLE_DOCS_TRUE@am__append_1 = $(MANS_ALL) @ENABLE_DOCS_TRUE@am__append_2 = $(MANS_ALL) @ENABLE_DOCS_TRUE@am__append_3 = $(MANS_ALL) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) 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 = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru AM_V_AR = $(am__v_AR_@AM_V@) am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) am__v_AR_0 = @echo " AR " $@; am__v_AR_1 = libmega_a_AR = $(AR) $(ARFLAGS) libmega_a_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp am_libmega_a_OBJECTS = lib/sjson.gen.$(OBJEXT) lib/http.$(OBJEXT) \ lib/mega.$(OBJEXT) lib/tools.$(OBJEXT) libmega_a_OBJECTS = $(am_libmega_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man7dir)" \ "$(DESTDIR)$(docdir)" PROGRAMS = $(bin_PROGRAMS) am_megacopy_OBJECTS = tools/copy.$(OBJEXT) megacopy_OBJECTS = $(am_megacopy_OBJECTS) megacopy_LDADD = $(LDADD) am__DEPENDENCIES_1 = megacopy_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megadf_OBJECTS = tools/df.$(OBJEXT) megadf_OBJECTS = $(am_megadf_OBJECTS) megadf_LDADD = $(LDADD) megadf_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megadl_OBJECTS = tools/dl.$(OBJEXT) megadl_OBJECTS = $(am_megadl_OBJECTS) megadl_LDADD = $(LDADD) megadl_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megaget_OBJECTS = tools/get.$(OBJEXT) megaget_OBJECTS = $(am_megaget_OBJECTS) megaget_LDADD = $(LDADD) megaget_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megals_OBJECTS = tools/ls.$(OBJEXT) megals_OBJECTS = $(am_megals_OBJECTS) megals_LDADD = $(LDADD) megals_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megamkdir_OBJECTS = tools/mkdir.$(OBJEXT) megamkdir_OBJECTS = $(am_megamkdir_OBJECTS) megamkdir_LDADD = $(LDADD) megamkdir_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megaput_OBJECTS = tools/put.$(OBJEXT) megaput_OBJECTS = $(am_megaput_OBJECTS) megaput_LDADD = $(LDADD) megaput_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megareg_OBJECTS = tools/reg.$(OBJEXT) megareg_OBJECTS = $(am_megareg_OBJECTS) megareg_LDADD = $(LDADD) megareg_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_megarm_OBJECTS = tools/rm.$(OBJEXT) megarm_OBJECTS = $(am_megarm_OBJECTS) megarm_LDADD = $(LDADD) megarm_DEPENDENCIES = libmega.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = 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) 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_CC_1 = CCLD = $(CC) 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_CCLD_1 = SOURCES = $(libmega_a_SOURCES) $(megacopy_SOURCES) $(megadf_SOURCES) \ $(megadl_SOURCES) $(megaget_SOURCES) $(megals_SOURCES) \ $(megamkdir_SOURCES) $(megaput_SOURCES) $(megareg_SOURCES) \ $(megarm_SOURCES) DIST_SOURCES = $(libmega_a_SOURCES) $(megacopy_SOURCES) \ $(megadf_SOURCES) $(megadl_SOURCES) $(megaget_SOURCES) \ $(megals_SOURCES) $(megamkdir_SOURCES) $(megaput_SOURCES) \ $(megareg_SOURCES) $(megarm_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac 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; }; \ } man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 man7dir = $(mandir)/man7 NROFF = nroff MANS = $(man1_MANS) $(man5_MANS) $(man7_MANS) DATA = $(doc_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope AM_RECURSIVE_TARGETS = cscope am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in INSTALL \ NEWS README TODO compile config.guess config.sub depcomp \ install-sh ltmain.sh missing 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 am__post_remove_distdir = $(am__remove_distdir) DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print A2X = @A2X@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GOBJECT_QUERY = @GOBJECT_QUERY@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ LIBCURL_LIBS = @LIBCURL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MEGA_REQUIRES = @MEGA_REQUIRES@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ 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@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ 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_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ 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@ BUILT_SOURCES = $(am__append_1) CLEANFILES = # }}} # {{{ tools # }}} # {{{ tests EXTRA_DIST = lib/sjson.c docs/asciidoc.conf docs/footer.txt \ docs/remote-paths.txt docs/basic-options.txt \ docs/auth-options.txt $(addprefix docs/,$(addsuffix .txt, \ $(MAN1) $(MAN5) $(MAN7))) $(am__append_3) LICENSE HACKING DISTCLEANFILES = $(am__append_2) AM_CFLAGS = \ $(GLIB_CFLAGS) \ $(OPENSSL_CFLAGS) \ $(LIBCURL_CFLAGS) \ -DG_LOG_DOMAIN=\"Mega\" \ -I$(srcdir)/lib \ -I$(srcdir) # }}} # {{{ libmega noinst_LIBRARIES = libmega.a libmega_a_SOURCES = \ lib/sjson.gen.c \ lib/sjson.h \ lib/http.c \ lib/http.h \ lib/mega.c \ lib/mega.h \ lib/tools.c \ lib/tools.h \ lib/alloc.h \ lib/mega.h LDADD = \ libmega.a \ $(GLIB_LIBS) \ $(OPENSSL_LIBS) \ $(LIBCURL_LIBS) megadf_SOURCES = tools/df.c megadl_SOURCES = tools/dl.c megaget_SOURCES = tools/get.c megals_SOURCES = tools/ls.c megamkdir_SOURCES = tools/mkdir.c megaput_SOURCES = tools/put.c megareg_SOURCES = tools/reg.c megarm_SOURCES = tools/rm.c megacopy_SOURCES = tools/copy.c # }}} # {{{ docs MAN1 = megadf megadl megaget megals megamkdir megaput megareg megarm megacopy MAN5 = megarc MAN7 = megatools @ENABLE_DOCS_TRUE@man1_MANS = $(addprefix docs/,$(addsuffix .1, $(MAN1))) @ENABLE_DOCS_TRUE@man5_MANS = $(addprefix docs/,$(addsuffix .5, $(MAN5))) @ENABLE_DOCS_TRUE@man7_MANS = $(addprefix docs/,$(addsuffix .7, $(MAN7))) @ENABLE_DOCS_TRUE@MANS_ALL = $(man1_MANS) $(man5_MANS) $(man7_MANS) doc_DATA = LICENSE NEWS TODO README INSTALL HACKING ACLOCAL_AMFLAGS = -I m4 all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .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 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 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 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 clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) lib/$(am__dirstamp): @$(MKDIR_P) lib @: > lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) lib/$(DEPDIR) @: > lib/$(DEPDIR)/$(am__dirstamp) lib/sjson.gen.$(OBJEXT): lib/$(am__dirstamp) \ lib/$(DEPDIR)/$(am__dirstamp) lib/http.$(OBJEXT): lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp) lib/mega.$(OBJEXT): lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp) lib/tools.$(OBJEXT): lib/$(am__dirstamp) lib/$(DEPDIR)/$(am__dirstamp) libmega.a: $(libmega_a_OBJECTS) $(libmega_a_DEPENDENCIES) $(EXTRA_libmega_a_DEPENDENCIES) $(AM_V_at)-rm -f libmega.a $(AM_V_AR)$(libmega_a_AR) libmega.a $(libmega_a_OBJECTS) $(libmega_a_LIBADD) $(AM_V_at)$(RANLIB) libmega.a install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; 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) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || 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)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) tools/$(am__dirstamp): @$(MKDIR_P) tools @: > tools/$(am__dirstamp) tools/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) tools/$(DEPDIR) @: > tools/$(DEPDIR)/$(am__dirstamp) tools/copy.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megacopy$(EXEEXT): $(megacopy_OBJECTS) $(megacopy_DEPENDENCIES) $(EXTRA_megacopy_DEPENDENCIES) @rm -f megacopy$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megacopy_OBJECTS) $(megacopy_LDADD) $(LIBS) tools/df.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megadf$(EXEEXT): $(megadf_OBJECTS) $(megadf_DEPENDENCIES) $(EXTRA_megadf_DEPENDENCIES) @rm -f megadf$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megadf_OBJECTS) $(megadf_LDADD) $(LIBS) tools/dl.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megadl$(EXEEXT): $(megadl_OBJECTS) $(megadl_DEPENDENCIES) $(EXTRA_megadl_DEPENDENCIES) @rm -f megadl$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megadl_OBJECTS) $(megadl_LDADD) $(LIBS) tools/get.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megaget$(EXEEXT): $(megaget_OBJECTS) $(megaget_DEPENDENCIES) $(EXTRA_megaget_DEPENDENCIES) @rm -f megaget$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megaget_OBJECTS) $(megaget_LDADD) $(LIBS) tools/ls.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megals$(EXEEXT): $(megals_OBJECTS) $(megals_DEPENDENCIES) $(EXTRA_megals_DEPENDENCIES) @rm -f megals$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megals_OBJECTS) $(megals_LDADD) $(LIBS) tools/mkdir.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megamkdir$(EXEEXT): $(megamkdir_OBJECTS) $(megamkdir_DEPENDENCIES) $(EXTRA_megamkdir_DEPENDENCIES) @rm -f megamkdir$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megamkdir_OBJECTS) $(megamkdir_LDADD) $(LIBS) tools/put.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megaput$(EXEEXT): $(megaput_OBJECTS) $(megaput_DEPENDENCIES) $(EXTRA_megaput_DEPENDENCIES) @rm -f megaput$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megaput_OBJECTS) $(megaput_LDADD) $(LIBS) tools/reg.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megareg$(EXEEXT): $(megareg_OBJECTS) $(megareg_DEPENDENCIES) $(EXTRA_megareg_DEPENDENCIES) @rm -f megareg$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megareg_OBJECTS) $(megareg_LDADD) $(LIBS) tools/rm.$(OBJEXT): tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) megarm$(EXEEXT): $(megarm_OBJECTS) $(megarm_DEPENDENCIES) $(EXTRA_megarm_DEPENDENCIES) @rm -f megarm$(EXEEXT) $(AM_V_CCLD)$(LINK) $(megarm_OBJECTS) $(megarm_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f lib/*.$(OBJEXT) -rm -f tools/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/http.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/mega.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/sjson.gen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@lib/$(DEPDIR)/tools.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/copy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/df.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/dl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/get.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/ls.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/mkdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/put.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/reg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/rm.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) '$<'` install-man1: $(man1_MANS) @$(NORMAL_INSTALL) @list1='$(man1_MANS)'; \ list2=''; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man5: $(man5_MANS) @$(NORMAL_INSTALL) @list1='$(man5_MANS)'; \ list2=''; \ test -n "$(man5dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.5[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \ done; } uninstall-man5: @$(NORMAL_UNINSTALL) @list='$(man5_MANS)'; test -n "$(man5dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) install-man7: $(man7_MANS) @$(NORMAL_INSTALL) @list1='$(man7_MANS)'; \ list2=''; \ test -n "$(man7dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man7dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man7dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.7[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list='$(man7_MANS)'; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ 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)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ 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-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ 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" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files 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) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_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*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(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*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(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/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(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__post_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 check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS) $(DATA) config.h installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man7dir)" "$(DESTDIR)$(docdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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 lib/$(DEPDIR)/$(am__dirstamp) -rm -f lib/$(am__dirstamp) -rm -f tools/$(DEPDIR)/$(am__dirstamp) -rm -f tools/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 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 "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf lib/$(DEPDIR) tools/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-docDATA install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man5 install-man7 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 lib/$(DEPDIR) tools/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-docDATA uninstall-man uninstall-man: uninstall-man1 uninstall-man5 uninstall-man7 .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ clean-binPROGRAMS clean-cscope clean-generic \ clean-noinstLIBRARIES cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ dist-xz dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-binPROGRAMS install-data \ install-data-am install-docDATA install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-man5 install-man7 install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-docDATA \ uninstall-man uninstall-man1 uninstall-man5 uninstall-man7 .PRECIOUS: Makefile @ENABLE_DOCS_TRUE@%.1 %.5 %.7: %.txt docs/auth-options.txt docs/basic-options.txt docs/remote-paths.txt docs/footer.txt docs/asciidoc.conf @ENABLE_DOCS_TRUE@ $(AM_V_GEN)mkdir -p "$(top_builddir)/docs" @ENABLE_DOCS_TRUE@ $(AM_V_GEN)a2x --asciidoc-opts="-f $(top_srcdir)/docs/asciidoc.conf -o $@" --destination-dir $(top_builddir)/docs -f manpage $< @ENABLE_DOCS_TRUE@ @sed -i 's/\[FIXME: manual]/Megatools Manual/' $@ @ENABLE_DOCS_TRUE@ @sed -i 's/\[FIXME: source]/megatools $(VERSION)/' $@ # }}} export MAKEFLAGS += --no-print-directory -s # 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: megatools-1.9.98/ltmain.sh0000644000175000001440000117077112575147277012410 00000000000000#! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2014-01-03.01 # libtool (GNU libtool) 2.4.6 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2015 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 this program. If not, see . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.6 package_revision=2.4.6 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2015-01-20.17; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2015 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. # 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 3 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES 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 . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! 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 # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are apparently some retarded systems that use ';' as a PATH separator! 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 ## ------------------------- ## ## Locate command utilities. ## ## ------------------------- ## # func_executable_p FILE # ---------------------- # Check that FILE is an executable regular file. func_executable_p () { test -f "$1" && test -x "$1" } # func_path_progs PROGS_LIST CHECK_FUNC [PATH] # -------------------------------------------- # Search for either a program that responds to --version with output # containing "GNU", or else returned by CHECK_FUNC otherwise, by # trying all the directories in PATH with each of the elements of # PROGS_LIST. # # CHECK_FUNC should accept the path to a candidate program, and # set $func_check_prog_result if it truncates its output less than # $_G_path_prog_max characters. func_path_progs () { _G_progs_list=$1 _G_check_func=$2 _G_PATH=${3-"$PATH"} _G_path_prog_max=0 _G_path_prog_found=false _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} for _G_dir in $_G_PATH; do IFS=$_G_save_IFS test -z "$_G_dir" && _G_dir=. for _G_prog_name in $_G_progs_list; do for _exeext in '' .EXE; do _G_path_prog=$_G_dir/$_G_prog_name$_exeext func_executable_p "$_G_path_prog" || continue case `"$_G_path_prog" --version 2>&1` in *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; *) $_G_check_func $_G_path_prog func_path_progs_result=$func_check_prog_result ;; esac $_G_path_prog_found && break 3 done done done IFS=$_G_save_IFS test -z "$func_path_progs_result" && { echo "no acceptable sed could be found in \$PATH" >&2 exit 1 } } # We want to be able to use the functions in this file before configure # has figured out where the best binaries are kept, which means we have # to search for them ourselves - except when the results are already set # where we skip the searches. # Unless the user overrides by setting SED, search the path for either GNU # sed, or the sed that truncates its output the least. test -z "$SED" && { _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for _G_i in 1 2 3 4 5 6 7; do _G_sed_script=$_G_sed_script$nl$_G_sed_script done echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed _G_sed_script= func_check_prog_sed () { _G_path_prog=$1 _G_count=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo '' >> conftest.nl "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin rm -f conftest.sed SED=$func_path_progs_result } # Unless the user overrides by setting GREP, search the path for either GNU # grep, or the grep that truncates its output the least. test -z "$GREP" && { func_check_prog_grep () { _G_path_prog=$1 _G_count=0 _G_path_prog_max=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo 'GREP' >> conftest.nl "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin GREP=$func_path_progs_result } ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="printf %s\n"} : ${EGREP="$GREP -E"} : ${FGREP="$GREP -F"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_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 # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_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 '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. 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. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # 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 # The name of this program. progname=`$ECHO "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$ECHO $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # 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" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_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 "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # 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. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # 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 "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_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 "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_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_append 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_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || 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_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd 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 -z "$func_relative_path_tlibdir"; 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 -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # 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 () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_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. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # 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). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet 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 () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet 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 () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" 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 () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd printf '%s\n%s\n' "$1" "$2" \ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n } # func_lt_ver PREV CURR # --------------------- # Return true if PREV and CURR are in the correct order according to # func_sort_ver, otherwise false. Use it like this: # # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." func_lt_ver () { $debug_cmd test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2014-01-07.03; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2015 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. # 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 3 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 . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do eval $_G_hook '"$@"' # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift done func_quote_for_eval ${1+"$@"} func_run_hooks_result=$func_quote_for_eval_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, remove any # options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # func_quote_for_eval ${1+"$@"} # my_options_prep_result=$func_quote_for_eval_result # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # ;; # *) set dummy "$_G_opt" "$*"; shift; break ;; # esac # done # # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # func_quote_for_eval ${1+"$@"} # my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # # You'll alse need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd func_options_prep ${1+"$@"} eval func_parse_options \ ${func_options_prep_result+"$func_options_prep_result"} eval func_validate_options \ ${func_parse_options_result+"$func_parse_options_result"} eval func_run_hooks func_options \ ${func_validate_options_result+"$func_validate_options_result"} # save modified positional parameters for caller func_options_result=$func_run_hooks_result } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propogate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning. func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} # Adjust func_parse_options positional parameters to match eval set dummy "$func_run_hooks_result"; shift # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) test $# = 0 && func_missing_arg $_G_opt && break case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result } ## ----------------- ## ## Helper functions. ## ## ----------------- ## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$ECHO \""Usage: $usage"\" eval \$ECHO \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # 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. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $ECHO "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$ECHO \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$ECHO \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.6' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --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 --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. func_help () { $debug_cmd func_usage_message $ECHO "$long_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) version: $progname (GNU libtool) 2.4.6 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." exit 0 } # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "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 yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; 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 } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= # 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 # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) # 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 test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; 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." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. 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= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_generated_by_libtool # True iff stdin has been generated by Libtool. This function is only # a basic sanity check; it will hardly flush out determined imposters. func_generated_by_libtool_p () { $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # 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 | func_generated_by_libtool_p } # 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 yes = "$lalib_p" } # 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 () { test -f "$1" && $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # 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 () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs 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 () { $debug_cmd 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 () { $debug_cmd 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 yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; 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 "$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 () { $debug_cmd # 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 () { $debug_cmd 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 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd $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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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 () { $debug_cmd 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_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # 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 yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot 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 yes = "$build_old_libs"; 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 no = "$pic_mode" && test pass_all != "$deplibs_check_method"; 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 no = "$compiler_c_o"; 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 yes = "$need_locks"; 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 warn = "$need_locks"; 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 yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; 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 warn = "$need_locks" && 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 yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; 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 warn = "$need_locks" && 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 no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && 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 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -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 () { $debug_cmd # 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 $opt_dry_run; then # 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 else 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 fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd 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_quiet && 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 finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # 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=false 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=: ;; -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-m = "X$prev" && 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=: if $isdir; 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 ;; os2*) 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 yes = "$build_old_libs"; 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=: 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'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; 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_quiet || { 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 install = "$opt_mode" && 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 () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; 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) $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 can'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 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; 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 func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 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[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi 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" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; 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" "${nlist}I"' # 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_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 () { $debug_cmd 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 () { $debug_cmd 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_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 () { $debug_cmd 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 case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) 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 } }'` ;; esac 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 () { $debug_cmd 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 () { $debug_cmd 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 that possess that section. Heuristic: eliminate # all those that 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_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 () { $debug_cmd 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 () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; 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 yes = "$lock_old_archive_extraction"; 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 () { $debug_cmd 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` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result 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 "$sed_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 where 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) $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/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that 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) $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 yes = "$fast_install"; 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 yes = "$shlibpath_overrides_runpath" && 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 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* 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_platform || defined ... */ #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 #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 (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]; size_t 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 = (size_t) (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 (STREQ (str, pat)) *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 size_t 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) { size_t orig_value_len = strlen (orig_value); size_t 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 #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\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 () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_suncc_cstd_abi # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! # Several compiler flags select an ABI that is incompatible with the # Cstd library. Avoid specifying it if any are in CXXFLAGS. func_suncc_cstd_abi () { $debug_cmd case " $compile_command " in *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) suncc_use_cstd_abi=no ;; *) suncc_use_cstd_abi=yes ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd 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 # what 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 that 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= os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false 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 yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && 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) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; 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 ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. 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 none = "$pic_object" && test none = "$non_pic_object"; 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 none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; 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 dlprefiles = "$prev"; 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 none != "$non_pic_object"; 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 none = "$pic_object"; 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 ;; os2dllname) os2dllname=$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 rpath = "$prev"; 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-export-symbols = "X$arg"; 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-lc = "X$arg" || test X-lm = "X$arg"; 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-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && 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-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm 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 ;; -os2dllname) prev=os2dllname 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 # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -stdlib=* select c++ std lib with clang -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*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 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 ;; -Z*) if test os2 = "`expr $host : '.*\(os2\)'`"; then # OS/2 uses -Zxxx to specify OS/2-specific options compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case $arg in -Zlinker | -Zstack) prev=xcompiler ;; esac continue else # Otherwise treat like 'Some other compiler flag' below func_quote_for_eval "$arg" arg=$func_quote_for_eval_result fi ;; # 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 none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; 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 dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; 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 none = "$pic_object"; 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 dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; 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 yes = "$export_dynamic" && 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\" # Definition is injected by LT_CONFIG during libtool generation. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 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 lib = "$linkmode"; 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=false 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 lib,link = "$linkmode,$pass"; 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 lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; 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 dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; 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 .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # 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 yes = "$allow_libtool_libs_with_static_runtimes"; 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=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; 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 conv = "$pass" && 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 conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; 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 link = "$pass"; 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 conv = "$pass"; 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=false 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=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else 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." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; 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=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # 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 lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; 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" elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi 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 continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; 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 dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" 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 yes = "$installed"; 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 yes = "$hardcode_automatic" && 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 dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; 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 lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; 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 prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: 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 $linkalldeplibs; 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 prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || 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 $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && 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 built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; 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 yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; 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 lib = "$linkmode" && test yes = "$hardcode_into_libs"; 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* | *os2*) 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 prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; 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 cannot # 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 no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; 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 yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; 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 prog = "$linkmode"; 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 yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; 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 prog = "$linkmode"; 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 prog = "$linkmode"; 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 unsupported != "$hardcode_direct"; 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 yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; 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 cannot 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 yes = "$module"; 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 no = "$build_old_libs"; 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 lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; 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 no = "$link_static" && 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 no != "$link_all_deplibs"; 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 link = "$pass"; then if test prog = "$linkmode"; 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 dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # 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= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=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 # Add Sun CC postdeps if required: test CXX = "$tagname" && { case $host_os in linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; solaris*) func_cc_basename "$CC" case $func_cc_basename_result in CC* | sunCC*) func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; esac } # 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 prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; 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 no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; 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 pass_all != "$deplibs_check_method"; 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 no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; 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 # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|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 ;; 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" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; irix | nonstopux) if test no = "$lt_irix_increment"; 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 0 -ne "$loop"; 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 0 -ne "$loop"; 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 ;; sco) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. 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 no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; 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 -n "$precious_files_regex"; 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 yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; 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 yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; 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 yes = "$build_libtool_libs"; 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 yes = "$build_libtool_need_lc"; 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 yes = "$allow_libtool_libs_with_static_runtimes"; 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 yes = "$allow_libtool_libs_with_static_runtimes"; 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 none = "$deplibs_check_method"; 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 yes = "$droppeddeps"; then if test yes = "$module"; 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 no = "$build_old_libs"; 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 no = "$allow_undefined"; 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 no = "$build_old_libs"; 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 yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || 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 relink = "$opt_mode" || 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 func_dll_def_p "$export_symbols" || { # 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 ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || 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 yes = "$try_normal_branch" \ && { 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 : != "$skipped_export"; 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 : != "$skipped_export" && 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 yes = "$compiler_needs_object" && 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 yes = "$thread_safe" && 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 relink = "$opt_mode"; 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 yes = "$module" && 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 : != "$skipped_export" && 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 : != "$skipped_export" && test yes = "$with_gnu_ld"; 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 : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; 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 -z "$objlist" || 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 1 -eq "$k"; 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 ${skipped_export-false} && { 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 } 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_quiet || { 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 relink = "$opt_mode"; 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 ${skipped_export-false} && { 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 } 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 yes = "$module" && 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=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { 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 relink = "$opt_mode"; 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 relink = "$opt_mode"; 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 yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; 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= # if reload_cmds runs $LD directly, get rid of -Wl from # whole_archive_flag_spec and hope we can get by with turning comma # into space. case $reload_cmds in *\$LD[\ \$]*) wl= ;; esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 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 yes = "$build_libtool_libs" || 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 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 test yes = "$build_libtool_libs" || { 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 } if test -n "$pic_flag" || test default != "$pic_mode"; 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" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && 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 CXX = "$tagname"; 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 yes = "$build_old_libs"; 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@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # 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 } 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 yes = "$no_install"; 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 case $hardcode_action,$fast_install in relink,*) # 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" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # 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 case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac 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 yes = "$build_libtool_libs"; 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 -z "$oldobjs"; 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 yes = "$build_old_libs" && 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 yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; 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 -n "$bindir"; 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) $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 cannot 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 no,yes = "$installed,$need_relink"; 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 } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false 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=: ;; -*) 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 . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; 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 $rmforce; 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" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || 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 none != "$pic_object"; 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 none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; 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 yes = "$fast_install" && 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 } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi 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 # where 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: megatools-1.9.98/config.sub0000755000175000001440000010622312575147303012527 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2014 Free Software Foundation, Inc. timestamp='2014-12-03' # 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 3 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. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # 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 1992-2014 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-musl* | 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*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -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 | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | 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 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | 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 \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | 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 \ | visium \ | 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 ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | 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-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | 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-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | 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-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | 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-* \ | visium-* \ | 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 ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; 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 ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-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 ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-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 | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) 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* | -plan9* \ | -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* \ | -bitrig* | -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* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -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* | -tirtos*) # 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 ;; -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 ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; 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: megatools-1.9.98/INSTALL0000644000175000001440000003660512333135155011575 00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. 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. Some packages provide this 'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. 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, generally using the just-built uninstalled binaries. 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the 'make install' phase executed with root privileges. 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. 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. 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. 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 '..'. This is known as a "VPATH" build. 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. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple '-arch' options to the compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the 'lipo' tool if you have problems. 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', where PREFIX must be an absolute file name. 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. In general, the default for these options is expressed in terms of '${prefix}', so that specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the 'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of '${prefix}'. Any directories that were specified during 'configure', but not in terms of '${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the 'DESTDIR' variable. For example, 'make install DESTDIR=/alternate/directory' will prepend '/alternate/directory' before all installation names. The approach of 'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of '${prefix}' at 'configure' time. Optional Features ================= 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'. 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. Some packages offer the ability to configure how verbose the execution of 'make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with 'make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with 'make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX 'make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its '' header file. The option '-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in '/usr/bin'. So, if you need '/usr/ucb' in your 'PATH', put it _after_ '/usr/bin'. On Haiku, software installed for all users goes in '/boot/common', not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common 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 limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/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 all of the options to 'configure', and exit. '--help=short' '--help=recursive' Print a summary of the options unique to this package's 'configure', and exit. The 'short' variant lists options used only in the top level, while the 'recursive' variant lists options also present in any nested packages. '--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. '--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. '--no-create' '-n' Run the configure checks, but stop before creating any output files. 'configure' also accepts some other, not widely useful, options. Run 'configure --help' for more details. megatools-1.9.98/README0000644000175000001440000001217013006627553011421 00000000000000megatools - command line client application for Mega ==================================================== Megatools is a collection of programs for accessing Mega service from a command line of your desktop or server. Megatools allow you to copy individual files as well as entire directory trees to and from the cloud. You can also perform streaming downloads for example to preview videos and audio files, without needing to download the entire file. Megatools are robust and optimized for fast operation - as fast as Mega servers allow. Memory requirements and CPU utilization are kept at minimum. You can register account using a 'megareg' tool, with the benefit of having true control of your encryption keys. Mega website can be found at http://mega.nz. Megatools can be downloaded at http://megatools.megous.com Tools ===== megareg Register and verify a new mega account megadf Show your cloud storage space usage/quota megals List all remote files megamkdir Create remote directory megarm Remove remote file or directory megaput Upload individual files megaget Download individual files megadl Download file from a "public" Mega link (doesn't require login) megastream Streaming download of a file (can be used to preview videos or music) megacopy Upload or download a directory tree All of these tools do: - Local caching of remote session/filesystem information for faster execution. Cache is encrypted with your password key. - Support loading login credentials from a configuration file Usage ===== See man pages for how to use individual tools and how to configure them: man megatools Windows Quirks ============== On Windows, if you see weird characters in your megals output, you'll need to set correct CHARSET environment variable. For example on Czech Windows this would mean executing this command in cmd before using the tools: set CHARSET=CP852 This is just a cosmetic issue. Internally, megatools always work with UTF-8 file names, and even if the tool's terminal output is corrupted, files names of downloaded/uploaded files will be correct. Installation on Mac OS X (Mountain Lion) ======================================== Thanks to Carl Moden, megatools is available in Homebrew (http://brew.sh/). You can therefrore install megatools with: brew install megatools To install megatools by hand you need to: 1. Install glib-networking with a ca-bundle: export BUNDLE=/usr/local/share/ca-bundle.crt curl http://curl.haxx.se/ca/cacert.pem -o $BUNDLE /usr/bin/sed -ie "s|--without-ca-certificates|--with-ca-certificates=$BUNDLE|" \ /usr/local/Library/Formula/glib-networking.rb brew install glib-networking 2. Make the pkgconfig (.pc) file for libcurl findable by megatools configure script: export PKG_CONFIG_PATH=/usr/local/Library/ENV/pkgconfig/10.8 3. Untar megatools, run `./configure`, `make` and `make install` as usual. Installation on Gentoo ====================== There is official ebuild available: https://packages.gentoo.org/packages/net-misc/megatools Installation on Debian ====================== Megatools is available in sid thanks to Alberto Garcia: https://packages.debian.org/unstable/megatools Installation on FreeBSD ======================= Megatools is available in freshports thanks to Maxim V. Kostikov: http://www.freshports.org/net/megatools/ Building megatools from source code =================================== You will need to install dependnencies first, to be able to do the build from the official source code tarball, which is available only at http://megatools.megous.com. You can also check that the code was released by me, using GPG signatures provided alongside the code. Please don't report build issues against code that you downloaded from github. These reports will be closed without explanation, with reference to this README file. It is not expected to work on all distributions. Use the official tarball. On Debian, Ubuntu: apt-get -y install build-essential libglib2.0-dev libssl-dev \ libcurl4-openssl-dev libgirepository1.0-dev Note: when you run into missing .so files, try building with `./configure --disable-shared --enable-static` instead of plain `./configure`. On Fedora: yum -y install gcc make glib2-devel libcurl-devel openssl-devel gmp-devel tar On OpenSUSE: zypper -n install gcc make glib2-devel libcurl-devel openssl-devel gmp-devel On Arch Linux: pacman -Sy --noconfirm --needed pkg-config gcc make glib2 curl gmp nettle Author ====== Megatools were written by OndÅ™ej Jirman , 2014 Webiste: http://megatools.megous.com Contributors ============ - RealDolos - Tom Maneiro Support and bug reports ======================= If you think you've found bug in megatools, send a report including enough information for recreating the issue to: megous@megous.com License ======= Megatools are licensed under GPLv2 with OpenSSL exemption, see LICENSE file for details. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/) megatools-1.9.98/docs/0000755000175000001440000000000013006640511011535 500000000000000megatools-1.9.98/docs/megatools.70000644000175000001440000001336013006630364013547 00000000000000'\" t .\" Title: megatools .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGATOOLS" "7" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megatools \- Mega\&.nz command line tools .SH "SYNOPSIS" .sp .nf \fImegadf\fR [\-\-free|\-\-total|\-\-used] [\-\-mb|\-\-gb|\-h] \fImegals\fR [\-e] [\-h] [\-\-header] [\-l] [\-R] [\-n] [\&...] \fImegaput\fR [\-\-no\-progress] [\-\-path ] \&... \fImegamkdir\fR \&... \fImegamkdir\fR /Contacts/ \fImegaget\fR [\-\-no\-progress] [\-\-path ] \&... \fImegaget\fR \-\-path \- \fImegarm\fR \&... \fImegarm\fR /Contacts/ \fImegadl\fR [\-\-no\-progress] [\-\-path ] \&... \fImegadl\fR \-\-path \- \fImegareg\fR [\-\-scripted] \-\-register \-\-email \-\-name \-\-password \fImegareg\fR [\-\-scripted] \-\-verify .fi .SH "DESCRIPTION" .sp Megatools is a collection of programs for accessing Mega service from a command line of your desktop or server\&. .sp Megatools allow you to copy individual files as well as entire directory trees to and from the cloud\&. You can also perform streaming downloads for example to preview videos and audio files, without needing to download the entire file\&. .sp Megatools are robust and optimized for fast operation \- as fast as Mega servers allow\&. Memory requirements and CPU utilization are kept at minimum\&. .sp You can register account using a \fBmegareg\fR(1) tool, with the benefit of having true control of your encryption keys\&. .sp Mega website can be found at http://mega\&.nz\&. .sp Megatools can be downloaded at http://megatools\&.megous\&.com .SH "TOOLS OVERVIEW" .PP \fBmegareg\fR(1) .RS 4 Register and verify a new mega account .RE .PP \fBmegadf\fR(1) .RS 4 Show your cloud storage space usage/quota .RE .PP \fBmegals\fR(1) .RS 4 List all remote files .RE .PP \fBmegamkdir\fR(1) .RS 4 Create remote directory .RE .PP \fBmegarm\fR(1) .RS 4 Remove remote file or directory .RE .PP \fBmegaput\fR(1) .RS 4 Upload individual files .RE .PP \fBmegaget\fR(1) .RS 4 Download individual files .RE .PP \fBmegadl\fR(1) .RS 4 Download file from a "public" Mega link (doesn\(cqt require login) .RE .PP \fBmegacopy\fR(1) .RS 4 Upload or download a directory tree .RE .SH "CONFIGURATION FILES" .sp See \fBmegarc\fR(5) for information about mega configuration file\&. .sp Each of the individual tools have help that can be accessed using \-\-help parameter\&. .SH "SESSION CACHE" .sp If you modify cloud filesystem from the Mega\&.nz website or from another computer, you\(cqll need to refresh your session cache\&. This can be done by using the \-\-reload option to any tool, or by waiting for a cache timeout (default timeout is set to 10 minutes)\&. .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megamkdir.10000644000175000001440000001367413006630361013514 00000000000000'\" t .\" Title: megamkdir .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGAMKDIR" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megamkdir \- Create remote folder under your Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegamkdir\fR \&... \fImegamkdir\fR /Contacts/ .fi .SH "DESCRIPTION" .sp Creates folders on Mega\&.nz\&. .sp As a special case, by creating a new folder under /Contacts, you\(cqre adding a to your contacts list\&. .SH "OPTIONS" .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 One or more remote directories to create\&. .RE .PP .RS 4 Valid email address of a contact you want to add\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Create new folder: .sp .if n \{\ .RS 4 .\} .nf $ megamkdir /Root/MyNewFolder $ megals /Root /Root /Root/MyNewFolder .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Add new contact to your contacts list: .sp .if n \{\ .RS 4 .\} .nf $ megamkdir /Contacts/some@email\&.com .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megacopy.10000644000175000001440000001471313006630363013355 00000000000000'\" t .\" Title: megacopy .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGACOPY" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megacopy \- Upload/download entire directories to/from your Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegacopy\fR [\-n] [\-\-no\-progress] \-\-local \-\-remote \fImegacopy\fR [\-n] [\-\-no\-progress] \-\-download \-\-local \-\-remote .fi .SH "DESCRIPTION" .sp Sync remote and local directories\&. No files are ever overwritten or removed\&. .sp Default direction is to upload files to the cloud\&. If you want to download files, you have to add \-\-download option\&. .SH "OPTIONS" .PP \-r , \-\-remote .RS 4 Remote directory path\&. .RE .PP \-l , \-\-local .RS 4 Local directory path\&. .RE .PP \-d, \-\-download .RS 4 Download files from the Mega\&.nz\&. The default is to upload\&. .RE .PP \-n, \-\-dryrun .RS 4 Don\(cqt perform any actual changes, just print what would be done\&. .RE .PP \-\-no\-progress .RS 4 Disable upload progress reporting\&. .RE .PP \-\-disable\-previews .RS 4 Never generate and upload file previews, when uploading new files .RE .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upload directory\&. .sp .if n \{\ .RS 4 .\} .nf $ megacopy \-\-local MyBackups \-\-remote /Root/Backups .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Download directory\&. .sp .if n \{\ .RS 4 .\} .nf $ megacopy \-\-local MyBackups \-\-remote /Root/Backups \-\-download .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megals.10000644000175000001440000002036613006630360013017 00000000000000'\" t .\" Title: megals .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGALS" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megals \- List files stored in the cloud .SH "SYNOPSIS" .sp .nf \fImegals\fR [\-e] [\-h] [\-\-header] [\-l] [\-R] [\-n] [\&...] .fi .SH "DESCRIPTION" .sp Lists files stored on Mega\&.nz, exports public download links\&. .SH "OPTIONS" .PP \-\-export, \-e .RS 4 For all files that are going to be listed, also display public download link with file key\&. .sp \fBNOTE\fR: Folders export doesn\(cqt work yet\&. .RE .PP \-\-human, \-h .RS 4 Display file sizes in a human readable format\&. .RE .PP \-\-header .RS 4 For long list format, display header describing all listed columns\&. .RE .PP \-\-long, \-l .RS 4 List additional information about listed filesystem nodes\&. Node handle, owner, node type, file size, and the last modification date\&. .RE .PP \-\-recursive, \-R .RS 4 List directories recursively\&. This is the default if no paths are specified\&. .RE .PP \-\-names, \-n .RS 4 Show only names of nodes within the directory\&. This option has effect only if you specified a single path on a command line\&. .RE .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 One or more remote filesystem paths to list\&. If path points to a directory, contents of the directory and the directory itself is listed\&. When \-\-names is given, only the contents of the directory is listed\&. .sp .if n \{\ .RS 4 .\} .nf If path points to a file, the file itself is listed\&. .fi .if n \{\ .RE .\} .sp .if n \{\ .RS 4 .\} .nf If ommited, the entire remote filesystem is listed recursively\&. .fi .if n \{\ .RE .\} .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} List all files: .sp .if n \{\ .RS 4 .\} .nf $ megals /Contacts /Inbox /Root /Root/README /Root/bigfile /Trash .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} List all files in the /Root, recursively and with details: .sp .if n \{\ .RS 4 .\} .nf $ megals \-l /Root 3RsS2QwJ 2 \- 2013\-01\-22 12:31:06 /Root 2FFSiaKZ Xz2tWWB5Dmo 0 2686 2013\-04\-15 08:33:47 /Root/README udtDgR7I Xz2tWWB5Dmo 0 4405067776 2013\-04\-10 19:16:02 /Root/bigfile .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} List all files in the /Root, recursively and with details, show only file names: .sp .if n \{\ .RS 4 .\} .nf $ megals \-ln /Root 2FFSiaKZ Xz2tWWB5Dmo 0 2686 2013\-04\-15 08:33:47 README udtDgR7I Xz2tWWB5Dmo 0 4405067776 2013\-04\-10 19:16:02 bigfile .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Export download links: .sp .if n \{\ .RS 4 .\} .nf $ megals \-e /Root/README https://mega\&.nz/#!OFFRlbgR!k5rWmLp3mxB0gsq07Ii67PLd9L0wq4KondFLDlfH3Uw /Root/README .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} List files in a more human readable format: .sp .if n \{\ .RS 4 .\} .nf $ megals \-hnl \-\-header /Root/README =================================================================================== Handle Owner T Size Mod\&. Date Filename =================================================================================== 2FFSiaKZ Xz2tWWB5Dmo 0 2\&.6 KiB 2013\-04\-15 08:33:47 README .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/auth-options.txt0000644000175000001440000000033113006622223014645 00000000000000-u :: --username :: Account username (email) -p :: --password :: Account password --no-ask-password:: Never ask interactively for a password --reload:: Reload filesystem cache megatools-1.9.98/docs/megareg.txt0000644000175000001440000000371613006622056013640 00000000000000megareg(1) ========= NAME ---- megareg - Register new Mega.nz account SYNOPSIS -------- [verse] 'megareg' [--scripted] --register --email --name --password 'megareg' [--scripted] --verify DESCRIPTION ----------- Registers new Mega.nz account. Registration is split into two steps: . `--register`: Creates a new non-verified account . `--verify`: Verifies account with the link that was sent to `` See example of registration below. OPTIONS ------- --register:: Create new non-verified account. --verify :: Verify account previously created by `megareg --register`. You need to pass `` that was returned from `megareg --register` and a verification link from the email that was sent to ``. --email :: Email serves as your new account username, that you'll be using to sign in. + *NOTES*: Beware that ATM, email format is not validated by megatools. --name :: Your real (or fake) name. --password :: Plaintext password. No strength checking is done, so make sure you pick a strong password yourself. --scripted:: After registration, print the command that can be used to finish the registration in a format suitable for scripting purposes. include::basic-options.txt[] EXAMPLE ------- First create an non-verified account: ------------ $ megareg --register --email your@email.com --name "Your Name" --password "Your Password" Registration email was sent to test@megous.com. To complete registration, you must run: megareg --verify vbFFFv7AFM25etzkFXLs9A==:Z7FFbgAAAAAAAAAArL33eA==:inEONh3tmwY @LINK@ (Where @LINK@ is registration link from the 'MEGA Signup' email) ------------ Now wait for a verification mail and run the command as asked: ------------ $ megareg --verify vbFFFv7AFM25etzkFXLs9A==:Z7FFbgAAAAAAAAAArL33eA==:inEONh3tmwY \ 'https://mega.nz/#confirmciyfWXRGFNcM...' Account registered successfully! ------------ include::footer.txt[] megatools-1.9.98/docs/remote-paths.txt0000644000175000001440000000245212641715440014641 00000000000000REMOTE FILESYSTEM ----------------- Mega.nz filesystem is represented as a tree of nodes of various types. Nodes are identified by a 8 character node handles (eg. `7Fdi3ZjC`). Structure of the filesystem is not encrypted. Megatools maps node tree structure to a traditional filesystem paths (eg. `/Root/SomeFile.DAT`). *NOTE*: By the nature of Mega.nz storage, several files in the directory can have the same name. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: --------- /Root/conflictingfile /Root/conflictingfile.7Fdi3ZjC /Root/conflictingfile.mEU23aSD --------- You need to be aware of several special folders: /Root:: Writable directory representing the root of the filesystem. /Trash:: Trash directory where Mega.nz web client moves deleted files. This directory is not used by megatools when removing files. /Inbox:: Not sure. /Contacts:: Directory containing subdirectories representing your contacts list. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add. /Contacts/:: Directories representing individual contacts in your contacts list. These directories contain folders that others shared with you. All shared files are read-only, at the moment. megatools-1.9.98/docs/megareg.10000644000175000001440000001306713006630362013160 00000000000000'\" t .\" Title: megareg .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGAREG" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megareg \- Register new Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegareg\fR [\-\-scripted] \-\-register \-\-email \-\-name \-\-password \fImegareg\fR [\-\-scripted] \-\-verify .fi .SH "DESCRIPTION" .sp Registers new Mega\&.nz account\&. Registration is split into two steps: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} \-\-register: Creates a new non\-verified account .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} \-\-verify: Verifies account with the link that was sent to .RE .sp See example of registration below\&. .SH "OPTIONS" .PP \-\-register .RS 4 Create new non\-verified account\&. .RE .PP \-\-verify .RS 4 Verify account previously created by megareg \-\-register\&. You need to pass that was returned from megareg \-\-register and a verification link from the email that was sent to \&. .RE .PP \-\-email .RS 4 Email serves as your new account username, that you\(cqll be using to sign in\&. .sp \fBNOTES\fR: Beware that ATM, email format is not validated by megatools\&. .RE .PP \-\-name .RS 4 Your real (or fake) name\&. .RE .PP \-\-password .RS 4 Plaintext password\&. No strength checking is done, so make sure you pick a strong password yourself\&. .RE .PP \-\-scripted .RS 4 After registration, print the command that can be used to finish the registration in a format suitable for scripting purposes\&. .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .SH "EXAMPLE" .sp First create an non\-verified account: .sp .if n \{\ .RS 4 .\} .nf $ megareg \-\-register \-\-email your@email\&.com \-\-name "Your Name" \-\-password "Your Password" Registration email was sent to test@megous\&.com\&. To complete registration, you must run: megareg \-\-verify vbFFFv7AFM25etzkFXLs9A==:Z7FFbgAAAAAAAAAArL33eA==:inEONh3tmwY @LINK@ (Where @LINK@ is registration link from the \*(AqMEGA Signup\*(Aq email) .fi .if n \{\ .RE .\} .sp Now wait for a verification mail and run the command as asked: .sp .if n \{\ .RS 4 .\} .nf $ megareg \-\-verify vbFFFv7AFM25etzkFXLs9A==:Z7FFbgAAAAAAAAAArL33eA==:inEONh3tmwY \e \*(Aqhttps://mega\&.nz/#confirmciyfWXRGFNcM\&.\&.\&.\*(Aq Account registered successfully! .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megarc.txt0000644000175000001440000000436513006630352013466 00000000000000megarc(5) ========= NAME ---- megarc - Configuration file for megatools SYNOPSIS -------- [verse] '~/.megarc' './.megarc' DESCRIPTION ----------- Megatools use INI configuration file to store commonly used login credentials. This makes it less bothersome to use the tools, as you can simply write -------- $ megadf -------- instead of -------- $ megadf --username my@email.com --password mypass -------- when using the tools. Configuration file is read either from the current directory or user's home directory. Exceptions are when `--ignore-config-file` was passed to the tool, or when explicit path to the config file was given via `--config `. CONFIG FILE SECTIONS -------------------- All sections are optional. All names are case sensitive, thus you must write [Login], and not [login], and so on. [Login] Section ~~~~~~~~~~~~~~~ Username:: Your username. Password:: Your password. Be aware that back slashes have special meaning. If you have back slash in your password, you must escape it with another backslash. For example: my\nice\password would be written as my\\nice\\password in the config file. [Cache] Section ~~~~~~~~~~~~~~~ Timeout:: Cache timeout in seconds (default is 10 minutes). [Network] Section ~~~~~~~~~~~~~~~ DownloadSpeedLimit:: Set maximum allowed download speed in KiB/s. 0 means no limit. Overrides SpeedLimit setting. UploadSpeedLimit:: Set maximum allowed upload speed in KiB/s. 0 means no limit. Overrides SpeedLimit setting. SpeedLimit:: Set maximum allowed upload and download speed in KiB/s. 0 means no limit. Proxy:: Use proxy server to connect to mega.nz. More information can be found in libcurl documentation at link:https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html[]. Some acceptable values are: * `socks5://localhost:9050` : Local SOCKSv5 proxy server * `socks5h://localhost:9050` : Local SOCKSv5 proxy server with DNS handled by the proxy EXAMPLE ------- Create ~/.megarc (on linux) or mega.ini file containing these 3 lines: ------------ [Login] Username = your@email Password = yourpassword [Network] ; 1MiB/s SpeedLimit = 1024 ; Use over TOR Proxy = socks5://127.0.0.1:9050 ------------ Run man:megadf[1] to check that megatools are able to login to your account. include::footer.txt[] megatools-1.9.98/docs/megaput.txt0000644000175000001440000000223613006622223013663 00000000000000megaput(1) ========= NAME ---- megaput - upload files to your Mega.nz account SYNOPSIS -------- [verse] 'megaput' [--no-progress] [--path ] ... DESCRIPTION ----------- Uploads files to your Mega.nz account. *NOTE*: If you want to upload entire directories, use man:megacopy[1]. OPTIONS ------- --path :: Remote path to upload to. If this path is a directory, files are placed into the directory. If this path doesn't exist, and it's parent directory does, the file will be uploaded to a specified path (this only works if you specify exactly one file). --no-progress:: Disable upload progress reporting. --disable-previews:: Never generate and upload file previews, when uploading new files include::auth-options.txt[] include::basic-options.txt[] :: One or more local files to upload. EXAMPLES -------- * Upload file to the /Root: + ------------ $ megaput README $ megals /Root /Root /Root/README ------------ * Upload file, while naming it differently: + ------------ $ megaput --path /Root/README.TXT README $ megals /Root /Root /Root/README.TXT ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megamkdir.txt0000644000175000001440000000154513006622071014164 00000000000000megamkdir(1) ============ NAME ---- megamkdir - Create remote folder under your Mega.nz account SYNOPSIS -------- [verse] 'megamkdir' ... 'megamkdir' /Contacts/ DESCRIPTION ----------- Creates folders on Mega.nz. As a special case, by creating a new folder under /Contacts, you're adding a `` to your contacts list. OPTIONS ------- include::auth-options.txt[] include::basic-options.txt[] :: One or more remote directories to create. :: Valid email address of a contact you want to add. EXAMPLES -------- * Create new folder: + ------------ $ megamkdir /Root/MyNewFolder $ megals /Root /Root /Root/MyNewFolder ------------ * Add new contact to your contacts list: + ------------ $ megamkdir /Contacts/some@email.com ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megals.txt0000644000175000001440000000526413006622033013474 00000000000000megals(1) ========= NAME ---- megals - List files stored in the cloud SYNOPSIS -------- [verse] 'megals' [-e] [-h] [--header] [-l] [-R] [-n] [...] DESCRIPTION ----------- Lists files stored on Mega.nz, exports public download links. OPTIONS ------- --export:: -e:: For all files that are going to be listed, also display public download link with file key. + *NOTE*: Folders export doesn't work yet. --human:: -h:: Display file sizes in a human readable format. --header:: For long list format, display header describing all listed columns. --long:: -l:: List additional information about listed filesystem nodes. Node handle, owner, node type, file size, and the last modification date. --recursive:: -R:: List directories recursively. This is the default if no paths are specified. --names:: -n:: Show only names of nodes within the directory. This option has effect only if you specified a single path on a command line. include::auth-options.txt[] include::basic-options.txt[] :: One or more remote filesystem paths to list. If path points to a directory, contents of the directory and the directory itself is listed. When `--names` is given, only the contents of the directory is listed. If path points to a file, the file itself is listed. If ommited, the entire remote filesystem is listed recursively. EXAMPLES -------- * List all files: + ------------ $ megals /Contacts /Inbox /Root /Root/README /Root/bigfile /Trash ------------ * List all files in the /Root, recursively and with details: + ------------ $ megals -l /Root 3RsS2QwJ 2 - 2013-01-22 12:31:06 /Root 2FFSiaKZ Xz2tWWB5Dmo 0 2686 2013-04-15 08:33:47 /Root/README udtDgR7I Xz2tWWB5Dmo 0 4405067776 2013-04-10 19:16:02 /Root/bigfile ------------ * List all files in the /Root, recursively and with details, show only file names: + ------------ $ megals -ln /Root 2FFSiaKZ Xz2tWWB5Dmo 0 2686 2013-04-15 08:33:47 README udtDgR7I Xz2tWWB5Dmo 0 4405067776 2013-04-10 19:16:02 bigfile ------------ * Export download links: + ------------ $ megals -e /Root/README https://mega.nz/#!OFFRlbgR!k5rWmLp3mxB0gsq07Ii67PLd9L0wq4KondFLDlfH3Uw /Root/README ------------ * List files in a more human readable format: + ------------ $ megals -hnl --header /Root/README =================================================================================== Handle Owner T Size Mod. Date Filename =================================================================================== 2FFSiaKZ Xz2tWWB5Dmo 0 2.6 KiB 2013-04-15 08:33:47 README ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megarm.txt0000644000175000001440000000173013006622071013470 00000000000000megarm(1) ========= NAME ---- megarm - Remove files and folders from your Mega.nz account SYNOPSIS -------- [verse] 'megarm' ... 'megarm' /Contacts/ DESCRIPTION ----------- Removes files and folders from your Mega.nz account. *NOTE*: This command removes folders recursively without asking. Be careful. As a special case, by removing a folder under /Contacts, you're removing a `` from your contacts list. OPTIONS ------- include::auth-options.txt[] include::basic-options.txt[] :: One or more remote files or directories to remove. :: Valid email address of a contact you want to remove. EXAMPLES -------- * Remove a folder: + ------------ $ megals /Root /Root /Root/MyNewFolder $ megarm /Root/MyNewFolder $ megals /Root /Root ------------ * Remove contact from your contacts list: + ------------ $ megarm /Contacts/some@email.com ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megadf.txt0000644000175000001440000000202113006621775013447 00000000000000megadf(1) ========= NAME ---- megadf - Show total available, used, or free space in the cloud SYNOPSIS -------- [verse] 'megadf' [--free|--total|--used] [--mb|--gb|-h] DESCRIPTION ----------- Shows available, used and free space in the cloud in machine or human readable formats. OPTIONS ------- --total:: Show only total available space (free + used). --free:: Show only free space. --used:: Show only used space. --human:: -h:: Display file sizes in a human readable format. --mb:: Show in MiB units. --gb:: Show in GiB units. include::auth-options.txt[] include::basic-options.txt[] EXAMPLES -------- * Show overall human readable space usage information: + ------------ $ megadf -h Total: 50.0 GiB Used: 6.4 GiB Free: 43.6 GiB ------------ * Check free space from a script: + ------------ $ test `megadf --free --gb` -lt 1 && \ echo "You have less than 1 GiB of available free space" ------------ KNOWN BUGS ---------- Megadf can't determine available space for premium accounts. include::footer.txt[] megatools-1.9.98/docs/megarm.10000644000175000001440000001407413006630363013021 00000000000000'\" t .\" Title: megarm .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGARM" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megarm \- Remove files and folders from your Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegarm\fR \&... \fImegarm\fR /Contacts/ .fi .SH "DESCRIPTION" .sp Removes files and folders from your Mega\&.nz account\&. .sp \fBNOTE\fR: This command removes folders recursively without asking\&. Be careful\&. .sp As a special case, by removing a folder under /Contacts, you\(cqre removing a from your contacts list\&. .SH "OPTIONS" .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 One or more remote files or directories to remove\&. .RE .PP .RS 4 Valid email address of a contact you want to remove\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove a folder: .sp .if n \{\ .RS 4 .\} .nf $ megals /Root /Root /Root/MyNewFolder $ megarm /Root/MyNewFolder $ megals /Root /Root .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Remove contact from your contacts list: .sp .if n \{\ .RS 4 .\} .nf $ megarm /Contacts/some@email\&.com .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megadl.txt0000644000175000001440000000273013006622022013446 00000000000000megadl(1) ========= NAME ---- megadl - download exported files and directories from Mega.nz SYNOPSIS -------- [verse] 'megadl' [--no-progress] [--path ] ... 'megadl' --path - DESCRIPTION ----------- Downloads exported files and folders from Mega.nz. Handles links like: * https://mega.nz/#!7YVWhCzZ!bauBlAkKKvv8hIm-8-qFmGOYS289ToQWN7rGFPzXB_w * https://mega.nz/#F!HIlFDajT!HLiVvQQkSe1d0ogxZuaOJg When downloading individual files, these are placed into ``. When downloading folders, the contents of the folder are placed into directory specified by ``. To export files, you can use Mega.nz web application, or man:megals[1]'s `--export` option. OPTIONS ------- --path :: Local directory to download to. Defaults to the current working directory. + If `` is `-`, remote file will be streamed to stdout. --no-progress:: Disable download progress reporting. This is implied when streaming. --print-names:: Print names/paths of successfully downloaded files (one per line). include::basic-options.txt[] :: File and folder links to download from. :: Link to exported file to stream. EXAMPLES -------- * Download exported file: + ------------ $ megadl 'https://mega.nz/#!7YVWhCzZ!bauBlAkKKvv8hIm-8-qFmGOYS289ToQWN7rGFPzXB_w' ------------ * Download exported folder: + ------------ $ megadl 'https://mega.nz/#F!HIlFDajT!HLiVvQQkSe1d0ogxZuaOJg' ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megaput.10000644000175000001440000001444413006630361013212 00000000000000'\" t .\" Title: megaput .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGAPUT" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megaput \- upload files to your Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegaput\fR [\-\-no\-progress] [\-\-path ] \&... .fi .SH "DESCRIPTION" .sp Uploads files to your Mega\&.nz account\&. .sp \fBNOTE\fR: If you want to upload entire directories, use \fBmegacopy\fR(1)\&. .SH "OPTIONS" .PP \-\-path .RS 4 Remote path to upload to\&. If this path is a directory, files are placed into the directory\&. If this path doesn\(cqt exist, and it\(cqs parent directory does, the file will be uploaded to a specified path (this only works if you specify exactly one file)\&. .RE .PP \-\-no\-progress .RS 4 Disable upload progress reporting\&. .RE .PP \-\-disable\-previews .RS 4 Never generate and upload file previews, when uploading new files .RE .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 One or more local files to upload\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upload file to the /Root: .sp .if n \{\ .RS 4 .\} .nf $ megaput README $ megals /Root /Root /Root/README .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Upload file, while naming it differently: .sp .if n \{\ .RS 4 .\} .nf $ megaput \-\-path /Root/README\&.TXT README $ megals /Root /Root /Root/README\&.TXT .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megadl.10000644000175000001440000001507013006630357013002 00000000000000'\" t .\" Title: megadl .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGADL" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megadl \- download exported files and directories from Mega\&.nz .SH "SYNOPSIS" .sp .nf \fImegadl\fR [\-\-no\-progress] [\-\-path ] \&... \fImegadl\fR \-\-path \- .fi .SH "DESCRIPTION" .sp Downloads exported files and folders from Mega\&.nz\&. Handles links like: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} https://mega\&.nz/#!7YVWhCzZ!bauBlAkKKvv8hIm\-8\-qFmGOYS289ToQWN7rGFPzXB_w .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} https://mega\&.nz/#F!HIlFDajT!HLiVvQQkSe1d0ogxZuaOJg .RE .sp When downloading individual files, these are placed into \&. When downloading folders, the contents of the folder are placed into directory specified by \&. .sp To export files, you can use Mega\&.nz web application, or \fBmegals\fR(1)\*(Aqs \-\-export option\&. .SH "OPTIONS" .PP \-\-path .RS 4 Local directory to download to\&. Defaults to the current working directory\&. .sp If is \-, remote file will be streamed to stdout\&. .RE .PP \-\-no\-progress .RS 4 Disable download progress reporting\&. This is implied when streaming\&. .RE .PP \-\-print\-names .RS 4 Print names/paths of successfully downloaded files (one per line)\&. .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 File and folder links to download from\&. .RE .PP .RS 4 Link to exported file to stream\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Download exported file: .sp .if n \{\ .RS 4 .\} .nf $ megadl \*(Aqhttps://mega\&.nz/#!7YVWhCzZ!bauBlAkKKvv8hIm\-8\-qFmGOYS289ToQWN7rGFPzXB_w\*(Aq .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Download exported folder: .sp .if n \{\ .RS 4 .\} .nf $ megadl \*(Aqhttps://mega\&.nz/#F!HIlFDajT!HLiVvQQkSe1d0ogxZuaOJg\*(Aq .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/basic-options.txt0000644000175000001440000000211513006630211014763 00000000000000--speed-limit :: Set maximum allowed upload and download speed in KiB/s. This option overrides config file settings. 0 means no limit. --proxy :: Use proxy server to connect to mega.nz. This option overrides config file settings. More information can be found in libcurl documentation at link:https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html[]. Some acceptable values are: * `none` : Disable proxy if it was enabled in the config file. * `socks5://localhost:9050` : Local SOCKSv5 proxy server * `socks5h://localhost:9050` : Local SOCKSv5 proxy server with DNS handled by the proxy --config :: Load configuration from a file --ignore-config-file:: Disable loading .megarc --debug []:: Enable debugging of various aspects of the megatools operation. You may enable multiple debugging options separated by commas. (eg. `--debug api,fs`) + Available options are: * `api`: Dump Mega.nz API calls * `fs`: Dump Mega.nz filesystem (may require `--reload` to actually print something) * `cache`: Dump cache contents --version:: Show version information megatools-1.9.98/docs/asciidoc.conf0000644000175000001440000000161312133064656014115 00000000000000## man: macro # # Usage: man:command[manpage-section] # # Note, {0} is the manpage section, while {target} is the command. # # Show man link as: (
); if section is defined, else just show # the command. [macros] (?su)[\\]?(?Pman):(?P\S*?)\[(?P.*?)\]= ifdef::backend-docbook[] ifdef::doctype-manpage[] [man-inlinemacro] {0%{target}} {0#} {0#{target}{0}} {0#} [header] template::[header-declarations] {mantitle} {manvolnum} {manname} {manpurpose} endif::doctype-manpage[] ifdef::doctype-article[] [man-inlinemacro] {target}{0?({0})} endif::doctype-article[] endif::backend-docbook[] megatools-1.9.98/docs/megarc.50000644000175000001440000001036213006630364013010 00000000000000'\" t .\" Title: megarc .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGARC" "5" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megarc \- Configuration file for megatools .SH "SYNOPSIS" .sp .nf \fI~/\&.megarc\fR \fI\&./\&.megarc\fR .fi .SH "DESCRIPTION" .sp Megatools use INI configuration file to store commonly used login credentials\&. This makes it less bothersome to use the tools, as you can simply write .sp .if n \{\ .RS 4 .\} .nf $ megadf .fi .if n \{\ .RE .\} .sp instead of .sp .if n \{\ .RS 4 .\} .nf $ megadf \-\-username my@email\&.com \-\-password mypass .fi .if n \{\ .RE .\} .sp when using the tools\&. .sp Configuration file is read either from the current directory or user\(cqs home directory\&. Exceptions are when \-\-ignore\-config\-file was passed to the tool, or when explicit path to the config file was given via \-\-config \&. .SH "CONFIG FILE SECTIONS" .sp All sections are optional\&. All names are case sensitive, thus you must write [Login], and not [login], and so on\&. .SS "[Login] Section" .PP Username .RS 4 Your username\&. .RE .PP Password .RS 4 Your password\&. Be aware that back slashes have special meaning\&. If you have back slash in your password, you must escape it with another backslash\&. For example: my\enice\epassword would be written as my\e\enice\e\epassword in the config file\&. .RE .SS "[Cache] Section" .PP Timeout .RS 4 Cache timeout in seconds (default is 10 minutes)\&. .RE .SS "[Network] Section" .PP DownloadSpeedLimit .RS 4 Set maximum allowed download speed in KiB/s\&. 0 means no limit\&. Overrides SpeedLimit setting\&. .RE .PP UploadSpeedLimit .RS 4 Set maximum allowed upload speed in KiB/s\&. 0 means no limit\&. Overrides SpeedLimit setting\&. .RE .PP SpeedLimit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. 0 means no limit\&. .RE .PP Proxy .RS 4 Use proxy server to connect to mega\&.nz\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .SH "EXAMPLE" .sp Create ~/\&.megarc (on linux) or mega\&.ini file containing these 3 lines: .sp .if n \{\ .RS 4 .\} .nf [Login] Username = your@email Password = yourpassword [Network] ; 1MiB/s SpeedLimit = 1024 ; Use over TOR Proxy = socks5://127\&.0\&.0\&.1:9050 .fi .if n \{\ .RE .\} .sp Run \fBmegadf\fR(1) to check that megatools are able to login to your account\&. .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megaget.txt0000644000175000001440000000223413006622026013631 00000000000000megaget(1) ========= NAME ---- megaget - download files from your Mega.nz account SYNOPSIS -------- [verse] 'megaget' [--no-progress] [--path ] ... 'megaget' --path - DESCRIPTION ----------- Downloads files from your Mega.nz account. *NOTE*: If you want to download entire directories, use man:megacopy[1]. OPTIONS ------- --path :: Local path to download to. If this path is a directory, files are placed into the directory. If this path doesn't exist, and it's parent directory does, the file will be downloaded to a specified file (this only works if you specify exactly one remote path). + If `` is `-`, remote file will be streamed to stdout. --no-progress:: Disable download progress reporting. This is implied when streaming. include::auth-options.txt[] include::basic-options.txt[] :: One or more remote files to download. :: Remote path to a single file to stream. EXAMPLES -------- * Download file to the current directory: + ------------ $ megals /Root /Root /Root/README $ megaget /Root/README $ ls README ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/footer.txt0000644000175000001440000000075312676020137013531 00000000000000SEE ALSO -------- man:megatools[7], man:megarc[5], man:megadf[1], man:megadl[1], man:megaget[1], man:megals[1], man:megamkdir[1], man:megaput[1], man:megareg[1], man:megarm[1], man:megacopy[1]. MEGATOOLS --------- Part of the man:megatools[7] suite. BUGS ---- Report bugs at link:https://github.com/megous/megatools[] or megous@megous.com. AUTHOR ------ Megatools was written by Ondrej Jirman , 2013-2016. Official website is link:http://megatools.megous.com[]. megatools-1.9.98/docs/megacopy.txt0000644000175000001440000000242413006622223014024 00000000000000megacopy(1) =========== NAME ---- megacopy - Upload/download entire directories to/from your Mega.nz account SYNOPSIS -------- [verse] 'megacopy' [-n] [--no-progress] --local --remote 'megacopy' [-n] [--no-progress] --download --local --remote DESCRIPTION ----------- Sync remote and local directories. No files are ever overwritten or removed. Default direction is to upload files to the cloud. If you want to download files, you have to add `--download` option. OPTIONS ------- -r :: --remote :: Remote directory path. -l :: --local :: Local directory path. -d:: --download:: Download files from the Mega.nz. The default is to upload. -n:: --dryrun:: Don't perform any actual changes, just print what would be done. --no-progress:: Disable upload progress reporting. --disable-previews:: Never generate and upload file previews, when uploading new files include::auth-options.txt[] include::basic-options.txt[] EXAMPLES -------- * Upload directory. + ------------ $ megacopy --local MyBackups --remote /Root/Backups ------------ * Download directory. + ------------ $ megacopy --local MyBackups --remote /Root/Backups --download ------------ include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megatools.txt0000644000175000001440000000472512676020122014222 00000000000000megatools(7) ============ NAME ---- megatools - Mega.nz command line tools SYNOPSIS -------- [verse] 'megadf' [--free|--total|--used] [--mb|--gb|-h] 'megals' [-e] [-h] [--header] [-l] [-R] [-n] [...] 'megaput' [--no-progress] [--path ] ... 'megamkdir' ... 'megamkdir' /Contacts/ 'megaget' [--no-progress] [--path ] ... 'megaget' --path - 'megarm' ... 'megarm' /Contacts/ 'megadl' [--no-progress] [--path ] ... 'megadl' --path - 'megareg' [--scripted] --register --email --name --password 'megareg' [--scripted] --verify DESCRIPTION ----------- Megatools is a collection of programs for accessing Mega service from a command line of your desktop or server. Megatools allow you to copy individual files as well as entire directory trees to and from the cloud. You can also perform streaming downloads for example to preview videos and audio files, without needing to download the entire file. Megatools are robust and optimized for fast operation - as fast as Mega servers allow. Memory requirements and CPU utilization are kept at minimum. You can register account using a man:megareg[1] tool, with the benefit of having true control of your encryption keys. Mega website can be found at http://mega.nz. Megatools can be downloaded at http://megatools.megous.com TOOLS OVERVIEW -------------- man:megareg[1]:: Register and verify a new mega account man:megadf[1]:: Show your cloud storage space usage/quota man:megals[1]:: List all remote files man:megamkdir[1]:: Create remote directory man:megarm[1]:: Remove remote file or directory man:megaput[1]:: Upload individual files man:megaget[1]:: Download individual files man:megadl[1]:: Download file from a "public" Mega link (doesn't require login) man:megacopy[1]:: Upload or download a directory tree CONFIGURATION FILES ------------------- See man:megarc[5] for information about mega configuration file. Each of the individual tools have help that can be accessed using --help parameter. SESSION CACHE ------------- If you modify cloud filesystem from the Mega.nz website or from another computer, you'll need to refresh your session cache. This can be done by using the --reload option to any tool, or by waiting for a cache timeout (default timeout is set to 10 minutes). include::remote-paths.txt[] include::footer.txt[] megatools-1.9.98/docs/megadf.10000644000175000001440000001145013006630356012771 00000000000000'\" t .\" Title: megadf .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGADF" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megadf \- Show total available, used, or free space in the cloud .SH "SYNOPSIS" .sp .nf \fImegadf\fR [\-\-free|\-\-total|\-\-used] [\-\-mb|\-\-gb|\-h] .fi .SH "DESCRIPTION" .sp Shows available, used and free space in the cloud in machine or human readable formats\&. .SH "OPTIONS" .PP \-\-total .RS 4 Show only total available space (free + used)\&. .RE .PP \-\-free .RS 4 Show only free space\&. .RE .PP \-\-used .RS 4 Show only used space\&. .RE .PP \-\-human, \-h .RS 4 Display file sizes in a human readable format\&. .RE .PP \-\-mb .RS 4 Show in MiB units\&. .RE .PP \-\-gb .RS 4 Show in GiB units\&. .RE .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Show overall human readable space usage information: .sp .if n \{\ .RS 4 .\} .nf $ megadf \-h Total: 50\&.0 GiB Used: 6\&.4 GiB Free: 43\&.6 GiB .fi .if n \{\ .RE .\} .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Check free space from a script: .sp .if n \{\ .RS 4 .\} .nf $ test `megadf \-\-free \-\-gb` \-lt 1 && \e echo "You have less than 1 GiB of available free space" .fi .if n \{\ .RE .\} .RE .SH "KNOWN BUGS" .sp Megadf can\(cqt determine available space for premium accounts\&. .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&. megatools-1.9.98/docs/megaget.10000644000175000001440000001430313006630357013160 00000000000000'\" t .\" Title: megaget .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/03/2016 .\" Manual: Megatools Manual .\" Source: megatools 1.9.98 .\" Language: English .\" .TH "MEGAGET" "1" "11/03/2016" "megatools 1.9.98" "Megatools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" megaget \- download files from your Mega\&.nz account .SH "SYNOPSIS" .sp .nf \fImegaget\fR [\-\-no\-progress] [\-\-path ] \&... \fImegaget\fR \-\-path \- .fi .SH "DESCRIPTION" .sp Downloads files from your Mega\&.nz account\&. .sp \fBNOTE\fR: If you want to download entire directories, use \fBmegacopy\fR(1)\&. .SH "OPTIONS" .PP \-\-path .RS 4 Local path to download to\&. If this path is a directory, files are placed into the directory\&. If this path doesn\(cqt exist, and it\(cqs parent directory does, the file will be downloaded to a specified file (this only works if you specify exactly one remote path)\&. .sp If is \-, remote file will be streamed to stdout\&. .RE .PP \-\-no\-progress .RS 4 Disable download progress reporting\&. This is implied when streaming\&. .RE .PP \-u , \-\-username .RS 4 Account username (email) .RE .PP \-p , \-\-password .RS 4 Account password .RE .PP \-\-no\-ask\-password .RS 4 Never ask interactively for a password .RE .PP \-\-reload .RS 4 Reload filesystem cache .RE .PP \-\-speed\-limit .RS 4 Set maximum allowed upload and download speed in KiB/s\&. This option overrides config file settings\&. 0 means no limit\&. .RE .PP \-\-proxy .RS 4 Use proxy server to connect to mega\&.nz\&. This option overrides config file settings\&. More information can be found in libcurl documentation at https://curl\&.haxx\&.se/libcurl/c/CURLOPT_PROXY\&.html\&. Some acceptable values are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} none : Disable proxy if it was enabled in the config file\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5://localhost:9050 : Local SOCKSv5 proxy server .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} socks5h://localhost:9050 : Local SOCKSv5 proxy server with DNS handled by the proxy .RE .RE .PP \-\-config .RS 4 Load configuration from a file .RE .PP \-\-ignore\-config\-file .RS 4 Disable loading \&.megarc .RE .PP \-\-debug [] .RS 4 Enable debugging of various aspects of the megatools operation\&. You may enable multiple debugging options separated by commas\&. (eg\&. \-\-debug api,fs) .sp Available options are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} api: Dump Mega\&.nz API calls .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} fs: Dump Mega\&.nz filesystem (may require \-\-reload to actually print something) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} cache: Dump cache contents .RE .RE .PP \-\-version .RS 4 Show version information .RE .PP .RS 4 One or more remote files to download\&. .RE .PP .RS 4 Remote path to a single file to stream\&. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Download file to the current directory: .sp .if n \{\ .RS 4 .\} .nf $ megals /Root /Root /Root/README $ megaget /Root/README $ ls README .fi .if n \{\ .RE .\} .RE .SH "REMOTE FILESYSTEM" .sp Mega\&.nz filesystem is represented as a tree of nodes of various types\&. Nodes are identified by a 8 character node handles (eg\&. 7Fdi3ZjC)\&. Structure of the filesystem is not encrypted\&. .sp Megatools maps node tree structure to a traditional filesystem paths (eg\&. /Root/SomeFile\&.DAT)\&. .sp \fBNOTE\fR: By the nature of Mega\&.nz storage, several files in the directory can have the same name\&. To allow access to such files, the names of conflicting files are extended by appending dot and their node handle like this: .sp .if n \{\ .RS 4 .\} .nf /Root/conflictingfile /Root/conflictingfile\&.7Fdi3ZjC /Root/conflictingfile\&.mEU23aSD .fi .if n \{\ .RE .\} .sp You need to be aware of several special folders: .PP /Root .RS 4 Writable directory representing the root of the filesystem\&. .RE .PP /Trash .RS 4 Trash directory where Mega\&.nz web client moves deleted files\&. This directory is not used by megatools when removing files\&. .RE .PP /Inbox .RS 4 Not sure\&. .RE .PP /Contacts .RS 4 Directory containing subdirectories representing your contacts list\&. If you want to add contacts to the list, simply create subdirectory named after the contact you want to add\&. .RE .PP /Contacts/ .RS 4 Directories representing individual contacts in your contacts list\&. These directories contain folders that others shared with you\&. All shared files are read\-only, at the moment\&. .RE .SH "SEE ALSO" .sp \fBmegatools\fR(7), \fBmegarc\fR(5), \fBmegadf\fR(1), \fBmegadl\fR(1), \fBmegaget\fR(1), \fBmegals\fR(1), \fBmegamkdir\fR(1), \fBmegaput\fR(1), \fBmegareg\fR(1), \fBmegarm\fR(1), \fBmegacopy\fR(1)\&. .SH "MEGATOOLS" .sp Part of the \fBmegatools\fR(7) suite\&. .SH "BUGS" .sp Report bugs at https://github\&.com/megous/megatools or megous@megous\&.com\&. .SH "AUTHOR" .sp Megatools was written by Ondrej Jirman , 2013\-2016\&. .sp Official website is http://megatools\&.megous\&.com\&.