From 0eb707fdcf1b87e71bb3a9eaa8472d0b05799a3d Mon Sep 17 00:00:00 2001 From: Terry Dawson VK2KTJ Date: Wed, 12 Sep 2001 13:18:43 +0000 Subject: updated libtool, uniformly indented source, corrected small ax25mond Makefile bug --- Makefile.in | 10 +- aclocal.m4 | 3382 +++++++++++++++++++++++++++++++++++++-- ax25ipd/Makefile.in | 25 +- ax25ipd/ax25ipd.c | 190 +-- ax25ipd/ax25ipd.h | 3 + ax25ipd/config.c | 325 ++-- ax25ipd/crc.c | 141 +- ax25ipd/io.c | 850 ++++++---- ax25ipd/kiss.c | 92 +- ax25ipd/process.c | 192 ++- ax25ipd/routing.c | 164 +- ax25mond/ax25mond.c | 614 ++++---- ax25rtd/Makefile.in | 33 +- ax25rtd/ax25rtctl.c | 400 +++-- ax25rtd/ax25rtd.c | 96 +- ax25rtd/cache_ctl.c | 184 +-- ax25rtd/cache_dump.c | 96 +- ax25rtd/config.c | 491 +++--- ax25rtd/listener.c | 332 ++-- call/Makefile.in | 24 +- call/call.c | 3491 ++++++++++++++++++++++------------------- call/crc.c | 37 +- call/dostime.c | 79 +- call/menu.c | 275 ++-- call/yapp.c | 844 +++++----- config.guess | 776 +++++---- config.h.in | 5 +- config.sub | 372 +++-- configure | 4268 ++++++++++++++++++++++++++++++++++++++++++++++---- configure.in | 1 + listen/Makefile.in | 29 +- listen/arpdump.c | 48 +- listen/ax25dump.c | 335 ++-- listen/flexnetdump.c | 61 +- listen/icmpdump.c | 28 +- listen/ipdump.c | 59 +- listen/kissdump.c | 17 +- listen/listen.c | 171 +- listen/nrdump.c | 81 +- listen/ripdump.c | 217 ++- listen/rosedump.c | 252 ++- listen/rspfdump.c | 91 +- listen/tcpdump.c | 54 +- listen/udpdump.c | 31 +- listen/utils.c | 35 +- ltmain.sh | 2655 +++++++++++++++++++++---------- 46 files changed, 15352 insertions(+), 6604 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7eca57a..7040b6f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -64,15 +64,17 @@ AWK = @AWK@ AX25_LIB = @AX25_LIB@ CC = @CC@ DLLTOOL = @DLLTOOL@ -LD = @LD@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAKEINFO = @MAKEINFO@ NCURSES_LIB = @NCURSES_LIB@ -NM = @NM@ OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STRIP = @STRIP@ VERSION = @VERSION@ SUBDIRS = ax25ipd ax25rtd call listen ax25mond @@ -110,7 +112,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) -config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) +config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) diff --git a/aclocal.m4 b/aclocal.m4 index ee15744..3d8b358 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4-p4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -125,130 +125,2875 @@ for am_file in <<$1>>; do done<<>>dnl>>) changequote([,]))]) +# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- -# serial 40 AC_PROG_LIBTOOL -AC_DEFUN(AC_PROG_LIBTOOL, +# serial 46 AC_PROG_LIBTOOL + +builtin([undefine],[symbols]) + +AC_DEFUN([AC_PROG_LIBTOOL], [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -# Save cache, so that ltconfig can load it -AC_CACHE_SAVE +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +]) + +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +_LT_AC_PROG_ECHO_BACKSLASH +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_SAVE + AC_LANG_C + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_RESTORE]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one + AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, + [AC_TRY_LINK([], + [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); + DllMain (0, 0, 0);], + [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) + + case $host/$CC in + *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) + # old mingw systems require "-dll" to link a DLL, while more recent ones + # require "-mdll" + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdll" + AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, + [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) + CFLAGS="$SAVE_CFLAGS" ;; + *-*-cygwin* | *-*-pw32*) + # cygwin systems need to pass --dll to the linker, and not link + # crt.o which will require a WinMain@16 definition. + lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; + esac + ;; + ]) +esac + +_LT_AC_LTCONFIG_HACK + +]) + +# _LT_AC_CHECK_DLFCN +# -------------------- +AC_DEFUN(_LT_AC_CHECK_DLFCN, +[AC_CHECK_HEADERS(dlfcn.h) +])# _LT_AC_CHECK_DLFCN + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +[symcode='[BCDEGRST]'] + +# Regexp to match symbols that can be accessed directly from C. +[sympat='\([_A-Za-z][_A-Za-z0-9]*\)'] + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + [symcode='[BCDT]'] + ;; +cygwin* | mingw* | pw32*) + [symcode='[ABCDGISTW]'] + ;; +hpux*) # Its linker distinguishes data from code symbols + lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix*) + [symcode='[BCDEGRST]'] + ;; +solaris* | sysv5*) + [symcode='[BDT]'] + ;; +sysv4) + [symcode='[DFNSTU]'] + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $host_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + [symcode='[ABCDGISTW]'] +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. +[lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"] + + # Check to see that the pipe works correctly. + pipe_works=no + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +[lt_preloaded_symbols[] =] +{ +EOF + sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if AC_TRY_EVAL(ac_link) && test -s conftest; then + pipe_works=yes + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AC_FD_CC + fi + else + echo "cannot find nm_test_var in $nlist" >&AC_FD_CC + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC + fi + else + echo "$progname: failed program was:" >&AC_FD_CC + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" +if test -z "$lt_cv_sys_global_symbol_pipe"; then + global_symbol_to_cdecl= + global_symbol_to_c_name_address= +else + global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" + global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" +fi +if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; +then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + +# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR +# --------------------------------- +AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], +[# Find the correct PATH separator. Usually this is `:', but +# DJGPP uses `;' like DOS. +if test "X${PATH_SEPARATOR+set}" != Xset; then + UNAME=${UNAME-`uname 2>/dev/null`} + case X$UNAME in + *-DOS) lt_cv_sys_path_separator=';' ;; + *) lt_cv_sys_path_separator=':' ;; + esac +fi +])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn;t interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +AC_DIVERT_POP +])# _LT_AC_PROG_ECHO_BACKSLASH + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +AC_DEFUN(_LT_AC_TRY_DLOPEN_SELF, +[if test "$cross_compiling" = yes; then : + [$4] +else + AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_unknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +AC_DEFUN(AC_LIBTOOL_DLOPEN_SELF, +[if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + cygwin* | mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + +AC_DEFUN([_LT_AC_LTCONFIG_HACK], +[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" +need_locks="$enable_libtool_lock" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +if test x"$host" != x"$build"; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case $host_os in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="[$]2" + +AC_MSG_CHECKING([for objdir]) +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +AC_MSG_RESULT($objdir) + + +AC_ARG_WITH(pic, +[ --with-pic try to use only PIC/non-PIC objects [default=use both]], +pic_mode="$withval", pic_mode=default) +test -z "$pic_mode" && pic_mode=default + +# We assume here that the value for lt_cv_prog_cc_pic will not be cached +# in isolation, and that seeing it set (from the cache) indicates that +# the associated values are set (in the cache) correctly too. +AC_MSG_CHECKING([for $compiler option to produce PIC]) +AC_CACHE_VAL(lt_cv_prog_cc_pic, +[ lt_cv_prog_cc_pic= + lt_cv_prog_cc_shlib= + lt_cv_prog_cc_wl= + lt_cv_prog_cc_static= + lt_cv_prog_cc_no_builtin= + lt_cv_prog_cc_can_build_shared=$can_build_shared + + if test "$GCC" = yes; then + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-static' + + case $host_os in + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # not sure about C++ programs. + lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_cv_prog_cc_pic='-fno-common' + ;; + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_cv_prog_cc_pic=-Kconform_pic + fi + ;; + *) + lt_cv_prog_cc_pic='-fPIC' + ;; + esac + else + # PORTME Check for PIC flags for the system compiler. + case $host_os in + aix3* | aix4* | aix5*) + lt_cv_prog_cc_wl='-Wl,' + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_cv_prog_cc_static='-Bstatic' + else + lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better lt_cv_prog_cc_static that works with the bundled CC? + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" + lt_cv_prog_cc_pic='+Z' + ;; + + irix5* | irix6*) + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + + newsos6) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + ;; + + sco3.2v5*) + lt_cv_prog_cc_pic='-Kpic' + lt_cv_prog_cc_static='-dn' + lt_cv_prog_cc_shlib='-belf' + ;; + + solaris*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Wl,' + ;; + + sunos4*) + lt_cv_prog_cc_pic='-PIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + if test "x$host_vendor" = xsni; then + lt_cv_prog_cc_wl='-LD' + else + lt_cv_prog_cc_wl='-Wl,' + fi + ;; + + uts4*) + lt_cv_prog_cc_pic='-pic' + lt_cv_prog_cc_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_cv_prog_cc_pic='-Kconform_pic' + lt_cv_prog_cc_static='-Bstatic' + fi + ;; + + *) + lt_cv_prog_cc_can_build_shared=no + ;; + esac + fi +]) +if test -z "$lt_cv_prog_cc_pic"; then + AC_MSG_RESULT([none]) +else + AC_MSG_RESULT([$lt_cv_prog_cc_pic]) + + # Check to make sure the pic_flag actually works. + AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works]) + AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" + AC_TRY_COMPILE([], [], [dnl + case $host_os in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then + # they create non-PIC objects. So, if there were any warnings, we + # assume that PIC is not supported. + if test -s conftest.err; then + lt_cv_prog_cc_pic_works=no + else + lt_cv_prog_cc_pic_works=yes + fi + ;; + *) + lt_cv_prog_cc_pic_works=yes + ;; + esac + ], [dnl + lt_cv_prog_cc_pic_works=no + ]) + CFLAGS="$save_CFLAGS" + ]) + + if test "X$lt_cv_prog_cc_pic_works" = Xno; then + lt_cv_prog_cc_pic= + lt_cv_prog_cc_can_build_shared=no + else + lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" + fi + + AC_MSG_RESULT([$lt_cv_prog_cc_pic_works]) +fi + +# Check for any special shared library compilation flags. +if test -n "$lt_cv_prog_cc_shlib"; then + AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) + if echo "$old_CC $old_CFLAGS " | [egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]"] >/dev/null; then : + else + AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) + lt_cv_prog_cc_can_build_shared=no + fi +fi + +AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works]) +AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl + lt_cv_prog_cc_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" + AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes]) + LDFLAGS="$save_LDFLAGS" +]) + +# Belt *and* braces to stop my trousers falling down: +test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= +AC_MSG_RESULT([$lt_cv_prog_cc_static_works]) + +pic_flag="$lt_cv_prog_cc_pic" +special_shlib_compile_flags="$lt_cv_prog_cc_shlib" +wl="$lt_cv_prog_cc_wl" +link_static_flag="$lt_cv_prog_cc_static" +no_builtin_flag="$lt_cv_prog_cc_no_builtin" +can_build_shared="$lt_cv_prog_cc_can_build_shared" + + +# Check to see if options -o and -c are simultaneously supported by compiler +AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext]) +AC_CACHE_VAL([lt_cv_compiler_c_o], [ +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +echo "int some_variable = 0;" > conftest.$ac_ext +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" +compiler_c_o=no +if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + lt_cv_compiler_c_o=no + else + lt_cv_compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&AC_FD_CC + lt_cv_compiler_c_o=no +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null +]) +compiler_c_o=$lt_cv_compiler_c_o +AC_MSG_RESULT([$compiler_c_o]) + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + AC_MSG_CHECKING([if $compiler supports -c -o file.lo]) + AC_CACHE_VAL([lt_cv_compiler_o_lo], [ + lt_cv_compiler_o_lo=no + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + save_objext="$ac_objext" + ac_objext=lo + AC_TRY_COMPILE([], [int some_variable = 0;], [dnl + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + lt_cv_compiler_o_lo=no + else + lt_cv_compiler_o_lo=yes + fi + ]) + ac_objext="$save_objext" + CFLAGS="$save_CFLAGS" + ]) + compiler_o_lo=$lt_cv_compiler_o_lo + AC_MSG_RESULT([$compiler_o_lo]) +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi + +if test "$GCC" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions]) + echo "int some_variable = 0;" > conftest.$ac_ext + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" + compiler_rtti_exceptions=no + AC_TRY_COMPILE([], [int some_variable = 0;], [dnl + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + compiler_rtti_exceptions=no + else + compiler_rtti_exceptions=yes + fi + ]) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT([$compiler_rtti_exceptions]) + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi +fi + +# See if the linker supports building shared libraries. +AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries]) + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +old_archive_from_expsyms_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_into_libs=no +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +link_all_deplibs=unknown +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. +extract_expsyms_cmds= + +case $host_os in +cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; +openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX, the GNU linker is very broken + # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ + sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ + test -f $output_objdir/impgen.exe || (cd $output_objdir && \ + if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ + else $CC -o impgen impgen.c ; fi)~ + $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' + + old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' + + # cygwin and mingw dlls have different entry points and sets of symbols + # to exclude. + # FIXME: what about values for MSVC? + dll_entry=__cygwin_dll_entry@12 + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ + case $host_os in + mingw*) + # mingw values + dll_entry=_DllMainCRTStartup@12 + dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ + ;; + esac + + # mingw and cygwin differ, and it's simplest to just exclude the union + # of the two symbol sets. + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one (in ltdll.c) + if test "x$lt_cv_need_dllmain" = "xyes"; then + ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " + ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < [$]0 > $output_objdir/$soname-ltdll.c~ + test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' + else + ltdll_obj= + ltdll_cmds= + fi + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left be newer dlltools. + export_symbols_cmds="$ltdll_cmds"' + $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ + [sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//"] < $output_objdir/$soname-def > $export_symbols' + + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is. + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname-def; + else + echo EXPORTS > $output_objdir/$soname-def; + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \[$]# in + 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; + *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done; + fi~ + '"$ltdll_cmds"' + $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ + $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ + $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw* | pw32*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + hardcode_direct=yes + archive_cmds='' + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + shared_flag='${wl}-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall can do strange things, so it is better to + # generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='${wl}-berok' + # This is a bit strange, but is similar to how AIX traditionally builds + # it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[[012]]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + esac + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. + archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' + # We need to add '_' to the symbols in $export_symbols first + #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' + hardcode_direct=yes + hardcode_shlibpath_var=no + whole_archive_flag_spec='-all_load $convenience' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case $host_os in + hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case "$host_os" in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + #Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + export_dynamic_flag_spec='${wl}-Bexport' + ;; + + solaris*) + no_undefined_flag=' -z defs' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + [solaris2.[0-5] | solaris2.[0-5].*]) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + if test "x$host_vendor" = xsno; then + archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + else + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5uw7* | unixware7*) + no_undefined_flag='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +AC_MSG_RESULT([$ld_shlibs]) +test "$ld_shlibs" = no && can_build_shared=no + +# Check hardcoding attributes. +AC_MSG_CHECKING([how to hardcode library paths into programs]) +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +AC_MSG_RESULT([$hardcode_action]) + +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +reload_cmds='$LD$reload_flag -o $output$reload_objs' +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +# PORTME Fill in your ld.so characteristics +AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4* | aix5*) + version_type=linux + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + [ aix4 | aix4.[01] | aix4.[01].*)] + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can + # not hardcode correct soname into executable. Probably we can + # add versioning support to collect2, so additional links can + # be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}.so$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | [$Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\'']`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + need_version=no + need_lib_prefix=no + case $GCC,$host_os in + yes,cygwin*) + library_names_spec='$libname.dll.a' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll' + postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog .libs/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + ;; + yes,mingw*) + library_names_spec='${libname}`echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` + ;; + yes,pw32*) + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' + ;; + *) + library_names_spec='${libname}`echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. + library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' + soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + *) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' + case $host_os in + irix5*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case "$host_os" in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +AC_LIBTOOL_DLOPEN_SELF + +if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + AC_CACHE_VAL([lt_cv_archive_cmds_need_lc], + [$rm conftest* + echo 'static int dummy;' > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile); then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_cv_prog_cc_wl + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi]) + AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc]) + ;; + esac +fi +need_lc=${lt_cv_archive_cmds_need_lc-yes} + +# The second clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + : +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + test -f Makefile && make "$ltmain" +fi + +if test -f "$ltmain"; then + trap "$rm \"${ofile}T\"; exit 1" 1 2 15 + $rm -f "${ofile}T" + + echo creating $ofile + + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS \ + AR AR_FLAGS CC LD LN_S NM SHELL \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ + postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ + old_striplib striplib file_magic_cmd export_symbols_cmds \ + deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + global_symbol_to_c_name_address \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case $var in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + cat <<__EOF__ > "${ofile}T" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996-2000 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 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 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL -# Actually configure libtool. ac_aux_dir is where install-sh is found. -CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ -LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ -LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ -DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ -${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ -|| AC_MSG_ERROR([libtool configure failed]) +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared -# Reload cache, that may have been modified by ltconfig -AC_CACHE_LOAD +# Whether or not to build static libraries. +build_old_libs=$enable_static -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$need_lc -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install -# Redirect the config.log output again, so that the ltconfig log is not -# clobbered by the next message. -exec 5>>./config.log -]) +# The host system. +host_alias=$host_alias +host=$host -AC_DEFUN(AC_LIBTOOL_SETUP, -[AC_PREREQ(2.13)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_RANLIB])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_NM])dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -dnl +# An echo program that does not interpret backslashes. +echo=$lt_echo -# Check for any special flags to pass to ltconfig. -libtool_flags="--cache-file=$cache_file" -test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" -test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" -test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" -test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" -test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" -ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], -[libtool_flags="$libtool_flags --enable-dlopen"]) -ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], -[libtool_flags="$libtool_flags --enable-win32-dll"]) -AC_ARG_ENABLE(libtool-lock, - [ --disable-libtool-lock avoid locking (might break parallel builds)]) -test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" -test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case "$host" in -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case "`/usr/bin/file conftest.o`" in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - rm -rf conftest* - ;; +# The default C compiler. +CC=$lt_CC -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; +# Is the compiler the GNU C compiler? +with_gcc=$GCC -ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -]) -esac -]) +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_pic_flag +pic_mode=$pic_mode + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$lt_compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + case $host_os in + aix3*) + cat <<\EOF >> "${ofile}T" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + case $host_os in + cygwin* | mingw* | pw32* | os2*) + cat <<'EOF' >> "${ofile}T" + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# /* O_BINARY isn't required (or even defined sometimes) under Unix */ +# #ifndef O_BINARY +# #define O_BINARY 0 +# #endif +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (dll < 1) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) + + mv -f "${ofile}T" "$ofile" || \ + (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") + chmod +x "$ofile" +fi + +])# _LT_AC_LTCONFIG_HACK # AC_LIBTOOL_DLOPEN - enable checks for dlopen support -AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) +AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's -AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) # AC_ENABLE_SHARED - implement the --enable-shared flag # Usage: AC_ENABLE_SHARED[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. -AC_DEFUN(AC_ENABLE_SHARED, [dnl -define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(shared, changequote(<<, >>)dnl << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) @@ -267,21 +3012,22 @@ enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl ]) # AC_DISABLE_SHARED - set the default shared flag to --disable-shared -AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_SHARED(no)]) # AC_ENABLE_STATIC - implement the --enable-static flag # Usage: AC_ENABLE_STATIC[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. -AC_DEFUN(AC_ENABLE_STATIC, [dnl -define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(static, changequote(<<, >>)dnl << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) @@ -300,7 +3046,8 @@ enable_static=AC_ENABLE_STATIC_DEFAULT)dnl ]) # AC_DISABLE_STATIC - set the default static flag to --disable-static -AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_STATIC(no)]) @@ -308,14 +3055,14 @@ AC_ENABLE_STATIC(no)]) # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. -AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl -define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(fast-install, changequote(<<, >>)dnl << --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) @@ -333,12 +3080,98 @@ esac], enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl ]) -# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install -AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_FAST_INSTALL(no)]) +# AC_LIBTOOL_PICMODE - implement the --with-pic flag +# Usage: AC_LIBTOOL_PICMODE[(MODE)] +# Where MODE is either `yes' or `no'. If omitted, it defaults to +# `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default)]) + + +# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in + /*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; + ?:/*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. + ;; + *) + ac_save_MAGIC_CMD="$MAGIC_CMD" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$ac_save_ifs" + MAGIC_CMD="$ac_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +]) + + +# AC_PATH_MAGIC - find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl +AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH) + else + MAGIC_CMD=: + fi +fi +]) + + # AC_PROG_LD - find the path to the GNU or non-GNU linker -AC_DEFUN(AC_PROG_LD, +AC_DEFUN([AC_PROG_LD], [AC_ARG_WITH(gnu-ld, [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) @@ -346,16 +3179,20 @@ AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl ac_prog=ld -if test "$ac_cv_prog_gcc" = yes; then +if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) - ac_prog=`($CC -print-prog-name=ld) 2>&5` - case "$ac_prog" in + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in # Accept absolute paths. -changequote(,)dnl - [\\/]* | [A-Za-z]:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' -changequote([,])dnl + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do @@ -377,17 +3214,17 @@ elif test "$with_gnu_ld" = yes; then else AC_MSG_CHECKING([for non-GNU ld]) fi -AC_CACHE_VAL(ac_cv_path_LD, +AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - ac_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" != no && break else test "$with_gnu_ld" != yes && break @@ -396,70 +3233,263 @@ AC_CACHE_VAL(ac_cv_path_LD, done IFS="$ac_save_ifs" else - ac_cv_path_LD="$LD" # Let the user override the test with a path. + lt_cv_path_LD="$LD" # Let the user override the test with a path. fi]) -LD="$ac_cv_path_LD" +LD="$lt_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -AC_SUBST(LD) AC_PROG_LD_GNU ]) -AC_DEFUN(AC_PROG_LD_GNU, -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +# AC_PROG_LD_GNU - +AC_DEFUN([AC_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. if $LD -v 2>&1 &5; then - ac_cv_prog_gnu_ld=yes + lt_cv_prog_gnu_ld=yes else - ac_cv_prog_gnu_ld=no + lt_cv_prog_gnu_ld=no fi]) +with_gnu_ld=$lt_cv_prog_gnu_ld +]) + +# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker +# -- PORTME Some linkers may need a different reload flag. +AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], +[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag, +[lt_cv_ld_reload_flag='-r']) +reload_flag=$lt_cv_ld_reload_flag +test -n "$reload_flag" && reload_flag=" $reload_flag" +]) + +# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], +[AC_CACHE_CHECK([how to recognise dependant libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# ['file_magic [regex]'] -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi4*) + [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'] + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin* | mingw* | pw32*) + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' + lt_cv_file_magic_cmd='/usr/bin/file -L' + case "$host_os" in + rhapsody* | darwin1.[[012]]) + lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` + ;; + *) # Darwin 1.3 on + lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' + ;; + esac + ;; + +freebsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + [lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'] + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20*|hpux11*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'] + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + +irix5* | irix6*) + case $host_os in + irix5*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + # this will be overridden with pass_all, but let us keep it just in case + [lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"] + ;; + esac + lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux-gnu*) + case $host_cpu in + alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* ) + lt_cv_deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;;] + esac + lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'] + else + [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'] + fi + ;; + +newos6*) + [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'] + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' + lt_cv_file_magic_test_file=/shlib/libc.so + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + lt_cv_file_magic_test_file=/lib/libc.so + ;; + +[sysv5uw[78]* | sysv4*uw2*)] + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'] + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'] + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + [lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"] + lt_cv_file_magic_test_file=/lib/libc.so + ;; + esac + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method ]) + # AC_PROG_NM - find the path to a BSD-compatible name lister -AC_DEFUN(AC_PROG_NM, +AC_DEFUN([AC_PROG_NM], [AC_MSG_CHECKING([for BSD-compatible nm]) -AC_CACHE_VAL(ac_cv_path_NM, +AC_CACHE_VAL(lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. - ac_cv_path_NM="$NM" + lt_cv_path_NM="$NM" else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + tmp_nm=$ac_dir/${ac_tool_prefix}nm + if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored - if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - ac_cv_path_NM="$ac_dir/nm -B" + # Tru64's nm complains that /dev/null is an invalid object file + if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then + lt_cv_path_NM="$tmp_nm -B" break - elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - ac_cv_path_NM="$ac_dir/nm -p" + elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + lt_cv_path_NM="$tmp_nm -p" break else - ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags fi fi done IFS="$ac_save_ifs" - test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi]) -NM="$ac_cv_path_NM" +NM="$lt_cv_path_NM" AC_MSG_RESULT([$NM]) -AC_SUBST(NM) ]) # AC_CHECK_LIBM - check for math library -AC_DEFUN(AC_CHECK_LIBM, +AC_DEFUN([AC_CHECK_LIBM], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= -case "$host" in -*-*-beos* | *-*-cygwin*) +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32*) # These system don't have libm ;; *-ncr-sysv4.3*) @@ -473,33 +3503,39 @@ esac ]) # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl convenience library, adds --enable-ltdl-convenience to -# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor -# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed -# to be `${top_builddir}/libltdl'. Make sure you start DIR with -# '${top_builddir}/' (note the single quotes!) if your package is not -# flat, and, if you're not using automake, define top_builddir as -# appropriate in the Makefiles. -AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - case "$enable_ltdl_convenience" in +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac - LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la - INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) ]) # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl installable library, and adds --enable-ltdl-install to -# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor -# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed -# to be `${top_builddir}/libltdl'. Make sure you start DIR with -# '${top_builddir}/' (note the single quotes!) if your package is not -# flat, and, if you're not using automake, define top_builddir as -# appropriate in the Makefiles. +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. # In the future, this macro may have to be called after AC_PROG_LIBTOOL. -AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_CHECK_LIB(ltdl, main, [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], [if test x"$enable_ltdl_install" = xno; then @@ -510,8 +3546,8 @@ AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la - INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl" @@ -519,15 +3555,15 @@ AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl fi ]) -dnl old names -AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl -AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl -AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl -AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl -AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl -AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl -AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl - -dnl This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL])dnl +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) diff --git a/ax25ipd/Makefile.in b/ax25ipd/Makefile.in index 513d44d..d2c6d30 100644 --- a/ax25ipd/Makefile.in +++ b/ax25ipd/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -64,15 +64,17 @@ AWK = @AWK@ AX25_LIB = @AX25_LIB@ CC = @CC@ DLLTOOL = @DLLTOOL@ -LD = @LD@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAKEINFO = @MAKEINFO@ NCURSES_LIB = @NCURSES_LIB@ -NM = @NM@ OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STRIP = @STRIP@ VERSION = @VERSION@ sbin_PROGRAMS = ax25ipd @@ -101,6 +103,7 @@ INCLUDES = -DAX25_SYSCONFDIR=\""$(AX25_SYSCONFDIR)"\" -DAX25_LOCALSTATEDIR=\ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = +sbin_PROGRAMS = ax25ipd$(EXEEXT) PROGRAMS = $(sbin_PROGRAMS) @@ -108,8 +111,8 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -ax25ipd_OBJECTS = config.o crc.o io.o kiss.o ax25ipd.o process.o \ -routing.o +ax25ipd_OBJECTS = config.$(OBJEXT) crc.$(OBJEXT) io.$(OBJEXT) \ +kiss.$(OBJEXT) ax25ipd.$(OBJEXT) process.$(OBJEXT) routing.$(OBJEXT) ax25ipd_DEPENDENCIES = ax25ipd_LDFLAGS = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -135,7 +138,7 @@ OBJECTS = $(ax25ipd_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .lo .o .s +.SUFFIXES: .S .c .lo .o .obj .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps ax25ipd/Makefile @@ -172,6 +175,11 @@ uninstall-sbinPROGRAMS: .c.o: $(COMPILE) -c $< +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + .s.o: $(COMPILE) -c $< @@ -180,6 +188,7 @@ uninstall-sbinPROGRAMS: mostlyclean-compile: -rm -f *.o core *.core + -rm -f *.$(OBJEXT) clean-compile: @@ -207,8 +216,8 @@ distclean-libtool: maintainer-clean-libtool: -ax25ipd: $(ax25ipd_OBJECTS) $(ax25ipd_DEPENDENCIES) - @rm -f ax25ipd +ax25ipd$(EXEEXT): $(ax25ipd_OBJECTS) $(ax25ipd_DEPENDENCIES) + @rm -f ax25ipd$(EXEEXT) $(LINK) $(ax25ipd_LDFLAGS) $(ax25ipd_OBJECTS) $(ax25ipd_LDADD) $(LIBS) install-man5: diff --git a/ax25ipd/ax25ipd.c b/ax25ipd/ax25ipd.c index e73f36b..45e59fa 100644 --- a/ax25ipd/ax25ipd.c +++ b/ax25ipd/ax25ipd.c @@ -33,16 +33,16 @@ int opt_help = 0; char opt_configfile[1024]; struct option options[] = { - "version", 0, &opt_version, 1, - "loglevel", 1, &opt_loglevel, 1, - "help", 0, &opt_help, 1, - "configfile", 1, NULL, 0, - 0,0,0,0 }; - -int -main(int argc, char **argv) + "version", 0, &opt_version, 1, + "loglevel", 1, &opt_loglevel, 1, + "help", 0, &opt_help, 1, + "configfile", 1, NULL, 0, + 0, 0, 0, 0 +}; + +int main(int argc, char **argv) { - if(setjmp(restart_env)==0) { + if (setjmp(restart_env) == 0) { signal(SIGHUP, hupper); } @@ -51,58 +51,65 @@ main(int argc, char **argv) signal(SIGINT, int_handler); signal(SIGTERM, term_handler); - while(1) { - int option_index = 0; - int c; - - c = getopt_long(argc, argv, "c:hl:v", options, &option_index); - if (c == -1) - break; - - switch (c) { - case 0: - break; - switch(option_index) { - case 0: case 2: - break; - case 1: - opt_loglevel = atoi(optarg); - break; - case 3: - strncpy(opt_configfile, optarg, 1023); - break; - - } - break; - case 'c' : - strncpy(opt_configfile, optarg, 1023); - break; - case 'v': - opt_version = 1; - break; - case 'l': - opt_loglevel = atoi(optarg); - break; - } - } - - if (optind < argc) { printf ("config %s\n", argv[optind++]); } - - if (opt_version == 1) { - greet_world(); - exit(0); - } - if (opt_help == 1) { - greet_world(); - printf ("Usage:\n"); - printf ("%s [flags]\n",argv[0]); - printf ("\nFlags:\n"); - printf (" --version, -v Print version of program\n"); - printf (" --help, -h This help screen\n"); - printf (" --loglevel NUM, -l NUM Set logging level to NUM\n"); - printf (" --configfile FILE, -c FILE Set confgiuration file to FILE\n"); - exit(0); - } + while (1) { + int option_index = 0; + int c; + + c = getopt_long(argc, argv, "c:hl:v", options, + &option_index); + if (c == -1) + break; + + switch (c) { + case 0: + break; + switch (option_index) { + case 0: + case 2: + break; + case 1: + opt_loglevel = atoi(optarg); + break; + case 3: + strncpy(opt_configfile, optarg, 1023); + break; + + } + break; + case 'c': + strncpy(opt_configfile, optarg, 1023); + break; + case 'v': + opt_version = 1; + break; + case 'l': + opt_loglevel = atoi(optarg); + break; + } + } + + if (optind < argc) { + printf("config %s\n", argv[optind++]); + } + + if (opt_version == 1) { + greet_world(); + exit(0); + } + if (opt_help == 1) { + greet_world(); + printf("Usage:\n"); + printf("%s [flags]\n", argv[0]); + printf("\nFlags:\n"); + printf + (" --version, -v Print version of program\n"); + printf(" --help, -h This help screen\n"); + printf + (" --loglevel NUM, -l NUM Set logging level to NUM\n"); + printf + (" --configfile FILE, -c FILE Set confgiuration file to FILE\n"); + exit(0); + } /* Initialize all routines */ config_init(); @@ -131,21 +138,21 @@ main(int argc, char **argv) /* and let the games begin */ io_start(); - return(0); + return (0); } -void -greet_world() +void greet_world() { printf("\nax25ipd %s / %s\n", VERS2, VERSION); - printf("Copyright 1991, Michael Westerhof, Sun Microsystems, Inc.\n"); - printf("This software may be freely used, distributed, or modified, providing\nthis header is not removed\n\n"); + printf + ("Copyright 1991, Michael Westerhof, Sun Microsystems, Inc.\n"); + printf + ("This software may be freely used, distributed, or modified, providing\nthis header is not removed\n\n"); fflush(stdout); } -void -do_stats() +void do_stats() { int save_loglevel; @@ -162,24 +169,24 @@ do_stats() dump_params(); printf("\nInput stats:\n"); - printf("KISS input packets: %d\n",stats.kiss_in); - printf(" too big: %d\n",stats.kiss_toobig); - printf(" bad type: %d\n",stats.kiss_badtype); - printf(" too short: %d\n",stats.kiss_tooshort); - printf(" not for me: %d\n",stats.kiss_not_for_me); - printf(" I am destination: %d\n",stats.kiss_i_am_dest); - printf(" no route found: %d\n",stats.kiss_no_ip_addr); - printf("UDP input packets: %d\n",stats.udp_in); - printf("IP input packets: %d\n",stats.ip_in); - printf(" failed CRC test: %d\n",stats.ip_failed_crc); - printf(" too short: %d\n",stats.ip_tooshort); - printf(" not for me: %d\n",stats.ip_not_for_me); - printf(" I am destination: %d\n",stats.ip_i_am_dest); + printf("KISS input packets: %d\n", stats.kiss_in); + printf(" too big: %d\n", stats.kiss_toobig); + printf(" bad type: %d\n", stats.kiss_badtype); + printf(" too short: %d\n", stats.kiss_tooshort); + printf(" not for me: %d\n", stats.kiss_not_for_me); + printf(" I am destination: %d\n", stats.kiss_i_am_dest); + printf(" no route found: %d\n", stats.kiss_no_ip_addr); + printf("UDP input packets: %d\n", stats.udp_in); + printf("IP input packets: %d\n", stats.ip_in); + printf(" failed CRC test: %d\n", stats.ip_failed_crc); + printf(" too short: %d\n", stats.ip_tooshort); + printf(" not for me: %d\n", stats.ip_not_for_me); + printf(" I am destination: %d\n", stats.ip_i_am_dest); printf("\nOutput stats:\n"); - printf("KISS output packets: %d\n",stats.kiss_out); - printf(" beacons: %d\n",stats.kiss_beacon_outs); - printf("UDP output packets: %d\n",stats.udp_out); - printf("IP output packets: %d\n",stats.ip_out); + printf("KISS output packets: %d\n", stats.kiss_out); + printf(" beacons: %d\n", stats.kiss_beacon_outs); + printf("UDP output packets: %d\n", stats.udp_out); + printf("IP output packets: %d\n", stats.ip_out); printf("\n"); fflush(stdout); @@ -188,33 +195,28 @@ do_stats() loglevel = save_loglevel; } -void -hupper(int i) +void hupper(int i) { printf("\nSIGHUP!\n"); longjmp(restart_env, 1); } -void -usr1_handler(int i) +void usr1_handler(int i) { printf("\nSIGUSR1!\n"); do_stats(); } -void -int_handler(int i) +void int_handler(int i) { printf("\nSIGINT!\n"); do_stats(); exit(1); } -void -term_handler(int i) +void term_handler(int i) { printf("\nSIGTERM!\n"); do_stats(); exit(1); } - diff --git a/ax25ipd/ax25ipd.h b/ax25ipd/ax25ipd.h index eeaf183..76a25b6 100644 --- a/ax25ipd/ax25ipd.h +++ b/ax25ipd/ax25ipd.h @@ -20,6 +20,9 @@ * added route flags, it's a little ugly, but is extensible fairly easily. * provided a mechanism for handling broadcast traffic * Terry Dawson, VK2KTJ, July 1997. + * + * Minor bug fixes. + * Terry Dawson, VK2KTJ, September 2001. */ /* Define the current version number diff --git a/ax25ipd/config.c b/ax25ipd/config.c index 243b82c..b80d113 100644 --- a/ax25ipd/config.c +++ b/ax25ipd/config.c @@ -23,21 +23,24 @@ #include "ax25ipd.h" /* Initialize the config table */ -void -config_init() +void config_init() { int i; *ttydevice = '\0'; - for(i=0;i<7;i++)mycallsign[i]='\0'; - for(i=0;i<7;i++)myalias[i]='\0'; - for(i=0;i<7;i++)mycallsign2[i]='\0'; - for(i=0;i<7;i++)myalias2[i]='\0'; + for (i = 0; i < 7; i++) + mycallsign[i] = '\0'; + for (i = 0; i < 7; i++) + myalias[i] = '\0'; + for (i = 0; i < 7; i++) + mycallsign2[i] = '\0'; + for (i = 0; i < 7; i++) + myalias2[i] = '\0'; digi = 1; ttyspeed = 9600; loglevel = 0; bc_interval = 0; - bc_text[0]='\0'; + bc_text[0] = '\0'; bc_every = 0; my_udp = htons(0); udp_mode = 0; @@ -65,8 +68,7 @@ config_init() /* Open and read the config file */ -void -config_read(f) +void config_read(f) char *f; { FILE *cf; @@ -74,252 +76,287 @@ char *f; int errflag, e, lineno; char *fname; - if (f) fname = f; - else fname = CONF_AX25IPD_FILE; + if (f) + fname = f; + else + fname = CONF_AX25IPD_FILE; - if((cf = fopen(fname,"r"))==NULL) { - fprintf(stderr,"Config file %s not found or could not be opened\n",fname); + if ((cf = fopen(fname, "r")) == NULL) { + fprintf(stderr, + "Config file %s not found or could not be opened\n", + fname); exit(1); } errflag = 0; lineno = 0; - while(fgets(buf, 255, cf)!=NULL) { + while (fgets(buf, 255, cf) != NULL) { strcpy(cbuf, buf); lineno++; - if((e = parse_line(buf)) < 0) { - fprintf(stderr,"Config error at line %d: ",lineno); - if(e==-1)fprintf(stderr,"Missing argument\n"); - else if(e==-2)fprintf(stderr,"Bad callsign format\n"); - else if(e==-3)fprintf(stderr,"Bad option - on/off\n"); - else if(e==-4)fprintf(stderr,"Bad option - tnc/digi\n"); - else if(e==-5)fprintf(stderr,"Host not known\n"); - else if(e==-6)fprintf(stderr,"Unknown command\n"); - else if(e==-7)fprintf(stderr,"Text string too long\n"); - else if(e==-8)fprintf(stderr,"Bad option - every/after\n"); - else if(e==-9)fprintf(stderr,"Bad option - ip/udp\n"); - else fprintf(stderr,"Unknown error\n"); - fprintf(stderr,"%s",cbuf); + if ((e = parse_line(buf)) < 0) { + fprintf(stderr, "Config error at line %d: ", + lineno); + if (e == -1) + fprintf(stderr, "Missing argument\n"); + else if (e == -2) + fprintf(stderr, "Bad callsign format\n"); + else if (e == -3) + fprintf(stderr, "Bad option - on/off\n"); + else if (e == -4) + fprintf(stderr, "Bad option - tnc/digi\n"); + else if (e == -5) + fprintf(stderr, "Host not known\n"); + else if (e == -6) + fprintf(stderr, "Unknown command\n"); + else if (e == -7) + fprintf(stderr, "Text string too long\n"); + else if (e == -8) + fprintf(stderr, + "Bad option - every/after\n"); + else if (e == -9) + fprintf(stderr, "Bad option - ip/udp\n"); + else + fprintf(stderr, "Unknown error\n"); + fprintf(stderr, "%s", cbuf); errflag++; } } - if(errflag)exit(1); + if (errflag) + exit(1); - if(strlen(ttydevice)==0) { - fprintf(stderr,"No device specified in config file\n"); + if (strlen(ttydevice) == 0) { + fprintf(stderr, "No device specified in config file\n"); exit(1); } - if((udp_mode == 0) && (ip_mode == 0)) { - fprintf(stderr,"Must specify ip and/or udp sockets\n"); + if ((udp_mode == 0) && (ip_mode == 0)) { + fprintf(stderr, "Must specify ip and/or udp sockets\n"); exit(1); } - if(digi) { - if(mycallsign[0]=='\0') { - fprintf(stderr,"No mycall line in config file\n"); + if (digi) { + if (mycallsign[0] == '\0') { + fprintf(stderr, "No mycall line in config file\n"); exit(1); } } - if((digi) && (dual_port)) { - if(mycallsign2[0]=='\0') { - fprintf(stderr,"No mycall2 line in config file\n"); + if ((digi) && (dual_port)) { + if (mycallsign2[0] == '\0') { + fprintf(stderr, + "No mycall2 line in config file\n"); exit(1); } } } /* Process each line from the config file. The return value is encoded. */ -int -parse_line(buf) +int parse_line(buf) char *buf; { char *p, *q; unsigned char tcall[7], tip[4]; struct hostent *he; - int i,j, uport; + int i, j, uport; unsigned int flags; p = strtok(buf, " \t\n\r"); - if(p==NULL)return 0; - if(*p=='#')return 0; + if (p == NULL) + return 0; + if (*p == '#') + return 0; - if(strcmp(p,"mycall")==0) { + if (strcmp(p, "mycall") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; - if(a_to_call(q, mycallsign)!=0)return -2; + if (q == NULL) + return -1; + if (a_to_call(q, mycallsign) != 0) + return -2; return 0; - } else if(strcmp(p,"mycall2")==0) { + } else if (strcmp(p, "mycall2") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; - if(a_to_call(q, mycallsign2)!=0)return -2; + if (q == NULL) + return -1; + if (a_to_call(q, mycallsign2) != 0) + return -2; return 0; - } else if(strcmp(p,"myalias")==0) { + } else if (strcmp(p, "myalias") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; - if(a_to_call(q, myalias)!=0)return -2; + if (q == NULL) + return -1; + if (a_to_call(q, myalias) != 0) + return -2; dual_port = 1; - if(mycallsign2[0]=='\0') { - dual_port = 0; + if (mycallsign2[0] == '\0') { + dual_port = 0; } return 0; - } else if(strcmp(p,"myalias2")==0) { + } else if (strcmp(p, "myalias2") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; - if(a_to_call(q, myalias2)!=0)return -2; + if (q == NULL) + return -1; + if (a_to_call(q, myalias2) != 0) + return -2; return 0; - } else if(strcmp(p,"device")==0) { + } else if (strcmp(p, "device") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; + if (q == NULL) + return -1; strcpy(ttydevice, q); return 0; - } else if(strcmp(p,"mode")==0) { + } else if (strcmp(p, "mode") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; - if(strcmp(q,"digi")==0) digi = 1; - else if(strcmp(q,"tnc")==0) digi = 0; - else return -4; + if (q == NULL) + return -1; + if (strcmp(q, "digi") == 0) + digi = 1; + else if (strcmp(q, "tnc") == 0) + digi = 0; + else + return -4; return 0; - } else if(strcmp(p,"speed")==0) { + } else if (strcmp(p, "speed") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; + if (q == NULL) + return -1; ttyspeed = atoi(q); return 0; - } else if(strcmp(p,"socket")==0) { + } else if (strcmp(p, "socket") == 0) { q = strtok(NULL, " \t\n\r"); - if (q==NULL) + if (q == NULL) return -1; - if (strcmp(q,"ip")==0) { + if (strcmp(q, "ip") == 0) { ip_mode = 1; - } - else if(strcmp(q,"udp")==0) { + } else if (strcmp(q, "udp") == 0) { udp_mode = 1; my_udp = htons(DEFAULT_UDP_PORT); q = strtok(NULL, " \t\n\r"); - if (q!=NULL) { + if (q != NULL) { i = atoi(q); - if (i>0) + if (i > 0) my_udp = htons(i); } - } - else + } else return -9; return 0; - } else if(strcmp(p,"beacon")==0) { + } else if (strcmp(p, "beacon") == 0) { q = strtok(NULL, " \t\n\r"); - if (q==NULL) + if (q == NULL) return -1; - if (strcmp(q,"every")==0) + if (strcmp(q, "every") == 0) bc_every = 1; - else if (strcmp(q,"after")==0) + else if (strcmp(q, "after") == 0) bc_every = 0; else return -8; q = strtok(NULL, " \t\n\r"); - if (q==NULL) + if (q == NULL) return -1; bc_interval = atoi(q); return 0; /* This next one is a hack!!!!!! watch out!!!! */ - } else if(strcmp(p,"btext")==0) { + } else if (strcmp(p, "btext") == 0) { q = p + strlen(p) + 1; - if(strlen(q) < 2) return -1; /* line ends with a \n */ - if(strlen(q) > sizeof bc_text)return -7; - q[strlen(q)-1]='\0'; + if (strlen(q) < 2) + return -1; /* line ends with a \n */ + if (strlen(q) > sizeof bc_text) + return -7; + q[strlen(q) - 1] = '\0'; strcpy(bc_text, q); return 0; - } else if(strcmp(p,"loglevel")==0) { + } else if (strcmp(p, "loglevel") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; + if (q == NULL) + return -1; loglevel = atoi(q); return 0; - } else if(strcmp(p,"route")==0) { + } else if (strcmp(p, "route") == 0) { uport = 0; flags = 0; q = strtok(NULL, " \t\n\r"); - if(q==NULL) + if (q == NULL) return -1; - if(a_to_call(q, tcall)!=0) + if (a_to_call(q, tcall) != 0) return -2; q = strtok(NULL, " \t\n\r"); - if(q==NULL) + if (q == NULL) return -1; he = gethostbyname(q); - if(he!=NULL) { + if (he != NULL) { memcpy(tip, he->h_addr_list[0], 4); - } else { /* maybe user specified a numeric addr? */ + } else { /* maybe user specified a numeric addr? */ j = inet_addr(q); - if(j==-1) - return -5; /* if -1, bad deal! */ - memcpy(tip, (char *)&j, 4); + if (j == -1) + return -5; /* if -1, bad deal! */ + memcpy(tip, (char *) &j, 4); } - while((q = strtok(NULL, " \t\n\r"))!=NULL) { - if(strcmp(q,"udp")==0) { + while ((q = strtok(NULL, " \t\n\r")) != NULL) { + if (strcmp(q, "udp") == 0) { uport = DEFAULT_UDP_PORT; q = strtok(NULL, " \t\n\r"); - if(q!=NULL) { + if (q != NULL) { i = atoi(q); - if(i>0) + if (i > 0) uport = i; } } else { /* Test for broadcast flag */ - if (strchr(q,'b')) { - flags|=AXRT_BCAST; + if (strchr(q, 'b')) { + flags |= AXRT_BCAST; } /* Test for Default flag */ - if (strchr(q,'d')) { - flags|=AXRT_DEFAULT; + if (strchr(q, 'd')) { + flags |= AXRT_DEFAULT; } } } route_add(tip, tcall, uport, flags); return 0; - } else if(strcmp(p,"broadcast")==0) { + } else if (strcmp(p, "broadcast") == 0) { - while ((q = strtok(NULL, " \t\n\r"))!=NULL) { - if (a_to_call(q, tcall)!=0) + while ((q = strtok(NULL, " \t\n\r")) != NULL) { + if (a_to_call(q, tcall) != 0) return -2; bcast_add(tcall); } return 0; - } else if(strcmp(p,"param")==0) { + } else if (strcmp(p, "param") == 0) { q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; + if (q == NULL) + return -1; i = atoi(q); q = strtok(NULL, " \t\n\r"); - if(q==NULL)return -1; + if (q == NULL) + return -1; j = atoi(q); - param_add(i,j); + param_add(i, j); return 0; } return -999; } /* Convert ascii callsign to internal format */ -int -a_to_call(text, tcall) +int a_to_call(text, tcall) char *text; unsigned char *tcall; { @@ -327,32 +364,35 @@ unsigned char *tcall; int ssid; unsigned char c; - if(strlen(text)==0)return -1; + if (strlen(text) == 0) + return -1; ssid = 0; - for(i=0;i<6;i++) { - tcall[i]=(' '<<1); + for (i = 0; i < 6; i++) { + tcall[i] = (' ' << 1); } tcall[6] = '\0'; - for(i=0;i15)return -1; - tcall[6] = (ssid<<1); + if (c == '-') { + ssid = atoi(&text[i + 1]); + if (ssid > 15) + return -1; + tcall[6] = (ssid << 1); return 0; } - if(islower(c))c = toupper(c); - if(i>5)return -1; - tcall[i]=(c<<1); + if (islower(c)) + c = toupper(c); + if (i > 5) + return -1; + tcall[i] = (c << 1); } return 0; } /* Convert internal callsign to printable format */ -char * -call_to_a(tcall) +char *call_to_a(tcall) unsigned char *tcall; { int i; @@ -360,17 +400,18 @@ unsigned char *tcall; char *tptr; static char t[10]; - for(i=0,tptr=t;i<6;i++) { - if(tcall[i]==(' '<<1))break; - *tptr = tcall[i]>>1; + for (i = 0, tptr = t; i < 6; i++) { + if (tcall[i] == (' ' << 1)) + break; + *tptr = tcall[i] >> 1; tptr++; } - ssid = (tcall[6]>>1)&0x0f; - if(ssid>0) { + ssid = (tcall[6] >> 1) & 0x0f; + if (ssid > 0) { *tptr = '-'; tptr++; - if(ssid>9) { + if (ssid > 9) { *tptr = '1'; tptr++; ssid -= 10; @@ -384,21 +425,25 @@ unsigned char *tcall; } /* print the configuration data out */ -void -dump_config() +void dump_config() { LOGL1("\nCurrent configuration:\n"); - if(ip_mode) LOGL1(" socket ip\n"); - if(udp_mode)LOGL1(" socket udp on port %d\n", ntohs(my_udp)); + if (ip_mode) + LOGL1(" socket ip\n"); + if (udp_mode) + LOGL1(" socket udp on port %d\n", ntohs(my_udp)); LOGL1(" mode %s\n", digi ? "digi" : "tnc"); LOGL1(" device %s\n", ttydevice); LOGL1(" speed %d\n", ttyspeed); - if(digi)LOGL1(" mycall %s\n", call_to_a(mycallsign)); - if(digi && myalias[0])LOGL1(" myalias %s\n", call_to_a(myalias)); - if(bc_interval>0) { - LOGL1(" beacon %s %d\n", bc_every ? "every" : "after", bc_interval); + if (digi) + LOGL1(" mycall %s\n", call_to_a(mycallsign)); + if (digi && myalias[0]) + LOGL1(" myalias %s\n", call_to_a(myalias)); + if (bc_interval > 0) { + LOGL1(" beacon %s %d\n", bc_every ? "every" : "after", + bc_interval); LOGL1(" btext %s\n", bc_text); } LOGL1(" loglevel %d\n", loglevel); - (void)fflush(stdout); + (void) fflush(stdout); } diff --git a/ax25ipd/crc.c b/ax25ipd/crc.c index ff07195..f6fc565 100644 --- a/ax25ipd/crc.c +++ b/ax25ipd/crc.c @@ -30,57 +30,57 @@ typedef unsigned short u16; * FCS lookup table as calculated by the table generator in section 2. */ static u16 fcstab[256] = { - 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, - 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, - 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, - 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, - 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, - 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, - 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, - 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, - 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, - 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, - 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, - 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, - 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, - 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, - 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, - 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, - 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, - 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, - 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, - 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, - 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, - 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, - 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, - 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, - 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, - 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, - 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, - 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, - 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, - 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, - 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, - 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 + 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, + 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, + 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, + 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, + 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, + 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, + 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, + 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, + 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, + 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, + 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, + 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, + 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, + 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, + 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, + 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, + 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, + 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, + 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, + 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, + 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, + 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, + 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, + 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, + 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, + 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, + 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, + 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, + 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, + 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, + 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, + 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; -#define PPPINITFCS 0xffff /* Initial FCS value */ -#define PPPGOODFCS 0xf0b8 /* Good final FCS value */ +#define PPPINITFCS 0xffff /* Initial FCS value */ +#define PPPGOODFCS 0xf0b8 /* Good final FCS value */ /* * Calculate a new fcs given the current fcs and the new data. */ u16 pppfcs(fcs, cp, len) - register u16 fcs; - register unsigned char *cp; - register int len; +register u16 fcs; +register unsigned char *cp; +register int len; { /* ASSERT(sizeof (u16) == 2); */ /* ASSERT(((u16) -1) > 0); */ - while (len--) - fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff]; + while (len--) + fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff]; - return (fcs); + return (fcs); } /* @@ -94,8 +94,7 @@ u16 pppfcs(fcs, cp, len) */ /* Return the computed CRC */ -unsigned short int -compute_crc(buf, l) +unsigned short int compute_crc(buf, l) unsigned char *buf; int l; { @@ -108,8 +107,7 @@ int l; } /* Return true if the CRC is correct */ -int -ok_crc(buf, l) +int ok_crc(buf, l) unsigned char *buf; int l; { @@ -127,45 +125,52 @@ int l; */ #ifdef TEST -void -main() +void main() { unsigned char buf[258]; int l, i; unsigned short int f; l = 256; - for(i=0;i>8); + buf[l] = (f & 0xff); + buf[l + 1] = (f >> 8); printf("crc should be good... "); - i = ok_crc(buf, l+2); - if(i)printf("CRC declared OK\n"); - else printf("CRC declared bad\n"); - - buf[l+1]=(f&0xff); - buf[l]=(f>>8); + i = ok_crc(buf, l + 2); + if (i) + printf("CRC declared OK\n"); + else + printf("CRC declared bad\n"); + + buf[l + 1] = (f & 0xff); + buf[l] = (f >> 8); printf("reversed the CRC byte order... CRC should be bad..."); - i = ok_crc(buf, l+2); - if(i)printf("CRC declared OK\n"); - else printf("CRC declared bad\n"); + i = ok_crc(buf, l + 2); + if (i) + printf("CRC declared OK\n"); + else + printf("CRC declared bad\n"); printf("changed the frame length... CRC should be bad..."); - i = ok_crc(buf, l+1); - if(i)printf("CRC declared OK\n"); - else printf("CRC declared bad\n"); + i = ok_crc(buf, l + 1); + if (i) + printf("CRC declared OK\n"); + else + printf("CRC declared bad\n"); - buf[0]-=1; + buf[0] -= 1; printf("corrupted the data... CRC should be bad..."); - i = ok_crc(buf, l+2); - if(i)printf("CRC declared OK\n"); - else printf("CRC declared bad\n"); + i = ok_crc(buf, l + 2); + if (i) + printf("CRC declared OK\n"); + else + printf("CRC declared bad\n"); } #endif diff --git a/ax25ipd/io.c b/ax25ipd/io.c index 88a4923..6371e5e 100644 --- a/ax25ipd/io.c +++ b/ax25ipd/io.c @@ -46,12 +46,12 @@ struct termios nterm; #ifdef USE_TERMIO #include -struct termio nterm; +struct termio nterm; #endif #ifdef USE_SGTTY #include -struct sgttyb nterm; +struct sgttyb nterm; #endif int ttyfd = -1; @@ -88,8 +88,7 @@ time_t last_bc_time; * Initialize the io variables */ -void -io_init() +void io_init() { /* @@ -97,23 +96,22 @@ io_init() * will be able to support a re-initialization if sent a SIGHUP. */ - if(ttyfd>=0){ + if (ttyfd >= 0) { close(ttyfd); ttyfd = -1; } - if(sock>=0){ + if (sock >= 0) { close(sock); sock = -1; } - if(udpsock>=0){ + if (udpsock >= 0) { close(udpsock); udpsock = -1; } - #ifdef USE_ICMP - if(icmpsock>=0){ + if (icmpsock >= 0) { close(icmpsock); icmpsock = -1; } @@ -124,13 +122,13 @@ io_init() * address structure. Since both to and from are static, they are * already clear. */ - bzero( (char *)&to, sizeof(struct sockaddr) ); + bzero((char *) &to, sizeof(struct sockaddr)); to.sin_family = AF_INET; - bzero( (char *)&from, sizeof(struct sockaddr) ); + bzero((char *) &from, sizeof(struct sockaddr)); from.sin_family = AF_INET; - bzero( (char *)&udpbind, sizeof(struct sockaddr) ); + bzero((char *) &udpbind, sizeof(struct sockaddr)); udpbind.sin_family = AF_INET; } @@ -142,9 +140,9 @@ void io_open() { int baudrate; - if(ip_mode){ + if (ip_mode) { sock = socket(AF_INET, SOCK_RAW, IPPROTO_AX25); - if (sock<0) { + if (sock < 0) { perror("opening raw socket"); exit(1); } @@ -152,10 +150,9 @@ void io_open() perror("setting non-blocking I/O on raw socket"); exit(1); } - #ifdef USE_ICMP icmpsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if (icmpsock<0) { + if (icmpsock < 0) { perror("opening raw ICMP socket"); exit(1); } @@ -166,9 +163,9 @@ void io_open() #endif } - if(udp_mode){ + if (udp_mode) { udpsock = socket(AF_INET, SOCK_DGRAM, 0); - if (udpsock<0) { + if (udpsock < 0) { perror("opening udp socket"); exit(1); } @@ -182,14 +179,16 @@ void io_open() */ udpbind.sin_addr.s_addr = INADDR_ANY; udpbind.sin_port = my_udp; - if(bind(udpsock,(struct sockaddr *)&udpbind,sizeof udpbind)<0){ + if (bind + (udpsock, (struct sockaddr *) &udpbind, + sizeof udpbind) < 0) { perror("binding udp socket"); exit(1); } } ttyfd = open(ttydevice, O_RDWR, 0); - if (ttyfd<0) { + if (ttyfd < 0) { perror("opening tty device"); exit(1); } @@ -197,257 +196,416 @@ void io_open() perror("setting non-blocking I/O on tty device"); exit(1); } - #ifdef USE_TERMIOS - if(ioctl(ttyfd, TCGETS, &nterm)<0){ + if (ioctl(ttyfd, TCGETS, &nterm) < 0) { #endif #ifdef USE_TERMIO - if(ioctl(ttyfd, TCGETA, &nterm)<0){ + if (ioctl(ttyfd, TCGETA, &nterm) < 0) { #endif #ifdef USE_SGTTY - if(ioctl(ttyfd, TIOCGETP, &nterm)<0){ + if (ioctl(ttyfd, TIOCGETP, &nterm) < 0) { #endif - perror("fetching tty device parameters"); - exit(1); - } + perror("fetching tty device parameters"); + exit(1); + } - if(ttyspeed==50)baudrate=B50; - else if(ttyspeed==50)baudrate=B50; - else if(ttyspeed==75)baudrate=B75; - else if(ttyspeed==110)baudrate=B110; - else if(ttyspeed==134)baudrate=B134; - else if(ttyspeed==150)baudrate=B150; - else if(ttyspeed==200)baudrate=B200; - else if(ttyspeed==300)baudrate=B300; - else if(ttyspeed==600)baudrate=B600; - else if(ttyspeed==1200)baudrate=B1200; - else if(ttyspeed==1800)baudrate=B1800; - else if(ttyspeed==2400)baudrate=B2400; - else if(ttyspeed==4800)baudrate=B4800; - else if(ttyspeed==9600)baudrate=B9600; + if (ttyspeed == 50) + baudrate = B50; + else if (ttyspeed == 50) + baudrate = B50; + else if (ttyspeed == 75) + baudrate = B75; + else if (ttyspeed == 110) + baudrate = B110; + else if (ttyspeed == 134) + baudrate = B134; + else if (ttyspeed == 150) + baudrate = B150; + else if (ttyspeed == 200) + baudrate = B200; + else if (ttyspeed == 300) + baudrate = B300; + else if (ttyspeed == 600) + baudrate = B600; + else if (ttyspeed == 1200) + baudrate = B1200; + else if (ttyspeed == 1800) + baudrate = B1800; + else if (ttyspeed == 2400) + baudrate = B2400; + else if (ttyspeed == 4800) + baudrate = B4800; + else if (ttyspeed == 9600) + baudrate = B9600; #ifdef B19200 - else if(ttyspeed==19200)baudrate=B19200; + else if (ttyspeed == 19200) + baudrate = B19200; #else #ifdef EXTA - else if(ttyspeed==19200)baudrate=EXTA; + else if (ttyspeed == 19200) + baudrate = EXTA; #endif #endif #ifdef B38400 - else if(ttyspeed==38400)baudrate=B38400; + else if (ttyspeed == 38400) + baudrate = B38400; #else #ifdef EXTB - else if(ttyspeed==38400)baudrate=EXTB; + else if (ttyspeed == 38400) + baudrate = EXTB; #endif #endif - else baudrate = B9600; + else + baudrate = B9600; #ifdef USE_SGTTY - nterm.sg_flags = (RAW | ANYP); - nterm.sg_ispeed = baudrate; - nterm.sg_ospeed = baudrate; + nterm.sg_flags = (RAW | ANYP); + nterm.sg_ispeed = baudrate; + nterm.sg_ospeed = baudrate; #else - nterm.c_iflag = 0; - nterm.c_oflag = 0; - nterm.c_cflag = baudrate | CS8 | CREAD | CLOCAL; - nterm.c_lflag = 0; - nterm.c_cc[VMIN] = 0; - nterm.c_cc[VTIME] = 0; + nterm.c_iflag = 0; + nterm.c_oflag = 0; + nterm.c_cflag = baudrate | CS8 | CREAD | CLOCAL; + nterm.c_lflag = 0; + nterm.c_cc[VMIN] = 0; + nterm.c_cc[VTIME] = 0; #endif #ifdef USE_TERMIOS - if(ioctl(ttyfd, TCSETS, &nterm)<0){ + if (ioctl(ttyfd, TCSETS, &nterm) < 0) { #endif #ifdef USE_TERMIO - if(ioctl(ttyfd, TCSETA, &nterm)<0){ + if (ioctl(ttyfd, TCSETA, &nterm) < 0) { #endif #ifdef USE_SGTTY - if(ioctl(ttyfd, TIOCSETP, &nterm)<0){ + if (ioctl + (ttyfd, TIOCSETP, + &nterm) < 0) { #endif - perror("setting tty device parameters"); - exit(1); - } + perror + ("setting tty device parameters"); + exit(1); + } - if(digi)send_params(); + if (digi) + send_params(); - last_bc_time = 0; /* force immediate id */ -} + last_bc_time = 0; /* force immediate id */ + } /* * Start up and run the I/O mechanisms. * run in a loop, using the select call to handle input. */ -void -io_start() -{ - int n, nb, hdr_len; - fd_set readfds; - unsigned char buf[MAX_FRAME]; - struct timeval wait; - struct iphdr *ipptr; - time_t now; - - for(;;){ - - if((bc_interval>0)&&digi){ - now = time(NULL); - if (last_bc_time + bc_interval < now){ - last_bc_time = now; - LOGL4("iostart: BEACON\n"); - do_beacon(); - } - } - - wait.tv_sec = 10; /* lets us keep the beacon going */ - wait.tv_usec = 0; - - FD_ZERO(&readfds); - - FD_SET(ttyfd, &readfds); - - if(ip_mode){ - FD_SET(sock, &readfds); + void io_start() { + int n, nb, hdr_len; + fd_set readfds; + unsigned char buf[MAX_FRAME]; + struct timeval wait; + struct iphdr *ipptr; + time_t now; + + for (;;) { + + if ((bc_interval > 0) + && digi) { + now = time(NULL); + if (last_bc_time + + bc_interval < + now) { + last_bc_time + = now; + LOGL4 + ("iostart: BEACON\n"); + do_beacon + (); + } + } + + wait.tv_sec = 10; /* lets us keep the beacon going */ + wait.tv_usec = 0; + + FD_ZERO(&readfds); + + FD_SET(ttyfd, &readfds); + + if (ip_mode) { + FD_SET(sock, + &readfds); #ifdef USE_ICMP - FD_SET(icmpsock, &readfds); + FD_SET(icmpsock, + &readfds); #endif - } - - if(udp_mode){ - FD_SET(udpsock, &readfds); - } - - nb = select(FD_SETSIZE,&readfds,(fd_set *)0,(fd_set *)0,&wait); - - if(nb < 0){ - if(errno == EINTR)continue; /* Ignore */ - perror("select"); - exit(1); - } - - if(nb == 0){ - fflush(stdout); - fflush(stderr); - /* just so we go back to the top of the loop! */ - continue; - } - - if(FD_ISSET(ttyfd, &readfds)){ - do { - n = read(ttyfd, buf, MAX_FRAME); - } while(io_error(n, buf, n, READ_MSG, TTY_MODE)); - LOGL4("ttydata l=%d\n",n); - if(n>0)assemble_kiss(buf,n); + } + + if (udp_mode) { + FD_SET(udpsock, + &readfds); + } + + nb = select + (FD_SETSIZE, + &readfds, + (fd_set *) 0, + (fd_set *) 0, &wait); + + if (nb < 0) { + if (errno == EINTR) + continue; /* Ignore */ + perror("select"); + exit(1); + } + + if (nb == 0) { + fflush(stdout); + fflush(stderr); + /* just so we go back to the top of the loop! */ + continue; + } + + if (FD_ISSET + (ttyfd, &readfds)) { + do { + n = read + (ttyfd, + buf, + MAX_FRAME); + } + while (io_error + (n, buf, n, + READ_MSG, + TTY_MODE)); + LOGL4 + ("ttydata l=%d\n", + n); + if (n > 0) + assemble_kiss + (buf, + n); /* * If we are in "beacon after" mode, reset the "last_bc_time" each time * we hear something on the channel. */ - if(!bc_every)last_bc_time = time(NULL); - } - - if(udp_mode){ - if(FD_ISSET(udpsock, &readfds)){ - do { - fromlen = sizeof from; - n = recvfrom(udpsock, buf, MAX_FRAME, 0, - (struct sockaddr *)&from, &fromlen); - } while(io_error(n, buf, n, READ_MSG, UDP_MODE)); - LOGL4("udpdata from=%s port=%d l=%d\n", - (char *)inet_ntoa(from.sin_addr), - ntohs(from.sin_port), n); - stats.udp_in++; - if(n>0)from_ip(buf, n); - } - } /* if udp_mode */ - - if(ip_mode){ - if(FD_ISSET(sock, &readfds)){ - do{ - fromlen = sizeof from; - n = recvfrom(sock, buf, MAX_FRAME, 0, - (struct sockaddr *)&from, &fromlen); - } while(io_error(n, buf, n, READ_MSG, IP_MODE)); - ipptr = (struct iphdr *)buf; - hdr_len = 4 * ipptr->ihl; - LOGL4("ipdata from=%s l=%d, hl=%d\n", - (char *)inet_ntoa(from.sin_addr), - n, hdr_len); - stats.ip_in++; - if(n>hdr_len)from_ip(buf+hdr_len, n-hdr_len); - } - + if (!bc_every) + last_bc_time + = + time + (NULL); + } + + if (udp_mode) { + if (FD_ISSET + (udpsock, + &readfds)) { + do { + fromlen + = + sizeof + from; + n = recvfrom(udpsock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen); + } + while + (io_error + (n, + buf, + n, + READ_MSG, + UDP_MODE)); + LOGL4 + ("udpdata from=%s port=%d l=%d\n", + (char + *) + inet_ntoa + (from. + sin_addr), + ntohs + (from. + sin_port), + n); + stats. + udp_in++; + if (n > 0) + from_ip + (buf, + n); + } + } + /* if udp_mode */ + if (ip_mode) { + if (FD_ISSET + (sock, + &readfds)) { + do { + fromlen + = + sizeof + from; + n = recvfrom(sock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen); + } + while + (io_error + (n, + buf, + n, + READ_MSG, + IP_MODE)); + ipptr = + (struct + iphdr + *) + buf; + hdr_len = + 4 * + ipptr-> + ihl; + LOGL4 + ("ipdata from=%s l=%d, hl=%d\n", + (char + *) + inet_ntoa + (from. + sin_addr), + n, + hdr_len); + stats. + ip_in++; + if (n > + hdr_len) + from_ip + (buf + + + hdr_len, + n + - + hdr_len); + } #ifdef USE_ICMP - if(FD_ISSET(icmpsock, &readfds)){ - do { - fromlen = sizeof from; - n = recvfrom(icmpsock, buf, MAX_FRAME, 0, - (struct sockaddr *)&from, &fromlen); - } while(io_error(n, buf, n, READ_MSG, ICMP_MODE)); - ipptr = (struct iphdr *)buf; - hdr_len = 4 * ipptr->ihl; - LOGL4("icmpdata from=%s l=%d, hl=%d\n", - (char *)inet_ntoa(from.sin_addr), - n, hdr_len); - } + if (FD_ISSET + (icmpsock, + &readfds)) { + do { + fromlen + = + sizeof + from; + n = recvfrom(icmpsock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen); + } + while + (io_error + (n, + buf, + n, + READ_MSG, + ICMP_MODE)); + ipptr = + (struct + iphdr + *) + buf; + hdr_len = + 4 * + ipptr-> + ihl; + LOGL4 + ("icmpdata from=%s l=%d, hl=%d\n", + (char + *) + inet_ntoa + (from. + sin_addr), + n, + hdr_len); + } #endif - } /* if ip_mode */ - - } /* for forever */ -} + } + /* if ip_mode */ + } /* for forever */ + } /* Send an IP frame */ -void -send_ip(buf, l, targetip) -unsigned char *buf; -int l; -unsigned char *targetip; -{ - int n; - - if(l<=0)return; - memcpy((char *)&to.sin_addr, targetip, 4); - memcpy((char *)&to.sin_port, &targetip[4], 2); - LOGL4("sendipdata to=%s %s %d l=%d\n", - (char *)inet_ntoa(to.sin_addr), - to.sin_port ? "udp" : "ip", - ntohs(to.sin_port), l); - if(to.sin_port){ - if(udp_mode){ - stats.udp_out++; - do { - n = sendto(udpsock, buf, l, 0, - (struct sockaddr *)&to, sizeof to); - } while(io_error(n, buf, l, SEND_MSG, UDP_MODE)); - } - } else { - if(ip_mode){ - stats.ip_out++; - do { - n = sendto(sock, buf, l, 0, - (struct sockaddr *)&to, sizeof to); - } while(io_error(n, buf, l, SEND_MSG, IP_MODE)); - } - } -} + void send_ip(buf, l, targetip) + unsigned char *buf; + int l; + unsigned char *targetip; + { + int n; + + if (l <= 0) + return; + memcpy((char *) &to.sin_addr, + targetip, 4); + memcpy((char *) &to.sin_port, + &targetip[4], 2); + LOGL4 + ("sendipdata to=%s %s %d l=%d\n", + (char *) inet_ntoa(to. + sin_addr), + to.sin_port ? "udp" : "ip", + ntohs(to.sin_port), l); + if (to.sin_port) { + if (udp_mode) { + stats.udp_out++; + do { + n = sendto + (udpsock, + buf, + l, 0, + (struct + sockaddr + *) + &to, + sizeof + to); + } + while (io_error + (n, buf, l, + SEND_MSG, + UDP_MODE)); + } + } else { + if (ip_mode) { + stats.ip_out++; + do { + n = sendto + (sock, + buf, + l, 0, + (struct + sockaddr + *) + &to, + sizeof + to); + } + while (io_error + (n, buf, l, + SEND_MSG, + IP_MODE)); + } + } + } /* Send a kiss frame */ -void -send_tty(buf, l) -unsigned char *buf; -int l; -{ - int n; - unsigned char *p; - int nc; + void send_tty(buf, l) + unsigned char *buf; + int l; + { + int n; + unsigned char *p; + int nc; - if(l<=0)return; - LOGL4("sendttydata l=%d\tsent: ",l); - stats.kiss_out++; + if (l <= 0) + return; + LOGL4("sendttydata l=%d\tsent: ", + l); + stats.kiss_out++; - p = buf; - nc = l; - n = 0; + p = buf; + nc = l; + n = 0; /* * we have to loop around here because each call to write may write a few @@ -459,116 +617,158 @@ int l; * compile-time options) by having io_error barf when it detects an EAGAIN * error code. */ - do { - if((n>0)&&(n0){ - if(n!=nc){ - LOGL4("%d ",n); /* no-one said loglevel 4 */ - } else { - LOGL4("%d\n",n); /* was efficient!!! */ - } - } - } while( ((n>0)&&(n 0) + && (n < nc)) { /* did we put only write a bit? */ + p += n; /* point to the new data */ + nc -= n; /* drop the length */ + } + n = write(ttyfd, p, nc); + if (n > 0) { + if (n != nc) { + LOGL4("%d ", n); /* no-one said loglevel 4 */ + } else { + LOGL4("%d\n", n); /* was efficient!!! */ + } + } + } + while (((n > 0) && (n < nc)) + || + (io_error + (n, p, nc, SEND_MSG, + TTY_MODE))); + } /* process an I/O error; return true if a retry is needed */ -int -io_error(oops, buf, bufsize, dir, mode) -int oops; /* the error flag; < 0 indicates a problem */ -unsigned char *buf; /* the data in question */ -int bufsize; /* the size of the data buffer */ -int dir; /* the direction; input or output */ -int mode; /* the fd on which we got the error */ -{ + int io_error(oops, buf, bufsize, dir, mode) int oops; /* the error flag; < 0 indicates a problem */ + unsigned char *buf; /* the data in question */ + int bufsize; /* the size of the data buffer */ + int dir; /* the direction; input or output */ + int mode; /* the fd on which we got the error */ + { - if(oops >= 0) return 0; /* do we have an error ? */ + if (oops >= 0) + return 0; /* do we have an error ? */ #ifdef EAGAIN - if(errno == EAGAIN){ - perror("System 5 I/O error!"); - fprintf(stderr,"A System 5 style I/O error was detected. This program requires BSD 4.2\n"); - fprintf(stderr,"behaviour. This is probably a result of compile-time environment.\n"); - exit(3); - } + if (errno == EAGAIN) { + perror + ("System 5 I/O error!"); + fprintf(stderr, + "A System 5 style I/O error was detected. This program requires BSD 4.2\n"); + fprintf(stderr, + "behaviour. This is probably a result of compile-time environment.\n"); + exit(3); + } #endif - if(dir == READ_MSG){ - if(errno == EINTR) return 0; /* never retry read */ - if(errno == EWOULDBLOCK){ - LOGL4("READ would block (?!), sleeping and retrying!\n"); - usleep(100000); /* sleep a bit */ - return 1; /* and retry */ - } - if(mode == IP_MODE){ - perror("reading from raw ip socket"); - exit(2); - } else if(mode == UDP_MODE){ - perror("reading from udp socket"); - exit(2); - } else if(mode == TTY_MODE){ - perror("reading from tty device"); - exit(2); - } else { - perror("reading from unknown I/O"); - exit(2); - } - } else if(dir == SEND_MSG){ - if(errno == EINTR) return 1; /* always retry on writes */ - if(mode == IP_MODE){ - if(errno == EMSGSIZE){ /* msg too big, drop it */ - perror("message dropped on raw ip socket"); - fprintf(stderr,"message was %d bytes long.\n",bufsize); - return 0; - } - if(errno == ENOBUFS){ /* congestion; sleep + retry */ - LOGL4("send congestion on raw ip, sleeping and retrying!\n"); - usleep(100000); - return 1; - } - if(errno == EWOULDBLOCK){ - LOGL4("send on raw ip would block, sleeping and retrying!\n"); - usleep(100000); /* sleep a bit */ - return 1; /* and retry */ - } - perror("writing to raw ip socket"); - exit(2); - } else if(mode == UDP_MODE){ - if(errno == EMSGSIZE){ /* msg too big, drop it */ - perror("message dropped on udp socket"); - fprintf(stderr,"message was %d bytes long.\n",bufsize); - return 0; - } - if(errno == ENOBUFS){ /* congestion; sleep + retry */ - LOGL4("send congestion on udp, sleeping and retrying!\n"); - usleep(100000); - return 1; - } - if(errno == EWOULDBLOCK){ - LOGL4("send on udp would block, sleeping and retrying!\n"); - usleep(100000); /* sleep a bit */ - return 1; /* and retry */ - } - perror("writing to udp socket"); - exit(2); - } else if(mode == TTY_MODE){ - if(errno == EWOULDBLOCK){ - LOGL4("write to tty would block, sleeping and retrying!\n"); - usleep(100000); /* sleep a bit */ - return 1; /* and retry */ - } - perror("writing to tty device"); - exit(2); - } else { - perror("writing to unknown I/O"); - exit(2); - } - } else { - perror("Unknown direction and I/O"); - exit(2); - } - return 0; -} + if (dir == READ_MSG) { + if (errno == EINTR) + return 0; /* never retry read */ + if (errno == EWOULDBLOCK) { + LOGL4 + ("READ would block (?!), sleeping and retrying!\n"); + usleep(100000); /* sleep a bit */ + return 1; /* and retry */ + } + if (mode == IP_MODE) { + perror + ("reading from raw ip socket"); + exit(2); + } else if (mode == + UDP_MODE) { + perror + ("reading from udp socket"); + exit(2); + } else if (mode == + TTY_MODE) { + perror + ("reading from tty device"); + exit(2); + } else { + perror + ("reading from unknown I/O"); + exit(2); + } + } else if (dir == SEND_MSG) { + if (errno == EINTR) + return 1; /* always retry on writes */ + if (mode == IP_MODE) { + if (errno == EMSGSIZE) { /* msg too big, drop it */ + perror + ("message dropped on raw ip socket"); + fprintf + (stderr, + "message was %d bytes long.\n", + bufsize); + return 0; + } + if (errno == ENOBUFS) { /* congestion; sleep + retry */ + LOGL4 + ("send congestion on raw ip, sleeping and retrying!\n"); + usleep + (100000); + return 1; + } + if (errno == + EWOULDBLOCK) { + LOGL4 + ("send on raw ip would block, sleeping and retrying!\n"); + usleep(100000); /* sleep a bit */ + return 1; /* and retry */ + } + perror + ("writing to raw ip socket"); + exit(2); + } else if (mode == + UDP_MODE) { + if (errno == EMSGSIZE) { /* msg too big, drop it */ + perror + ("message dropped on udp socket"); + fprintf + (stderr, + "message was %d bytes long.\n", + bufsize); + return 0; + } + if (errno == ENOBUFS) { /* congestion; sleep + retry */ + LOGL4 + ("send congestion on udp, sleeping and retrying!\n"); + usleep + (100000); + return 1; + } + if (errno == + EWOULDBLOCK) { + LOGL4 + ("send on udp would block, sleeping and retrying!\n"); + usleep(100000); /* sleep a bit */ + return 1; /* and retry */ + } + perror + ("writing to udp socket"); + exit(2); + } else if (mode == + TTY_MODE) { + if (errno == + EWOULDBLOCK) { + LOGL4 + ("write to tty would block, sleeping and retrying!\n"); + usleep(100000); /* sleep a bit */ + return 1; /* and retry */ + } + perror + ("writing to tty device"); + exit(2); + } else { + perror + ("writing to unknown I/O"); + exit(2); + } + } else { + perror + ("Unknown direction and I/O"); + exit(2); + } + return 0; + } diff --git a/ax25ipd/kiss.c b/ax25ipd/kiss.c index 6042cf0..b43d969 100644 --- a/ax25ipd/kiss.c +++ b/ax25ipd/kiss.c @@ -43,8 +43,7 @@ int param_tbl_top; * Initialize the KISS variables */ -void -kiss_init() +void kiss_init() { ifptr = iframe; ifcount = 0; @@ -60,31 +59,33 @@ kiss_init() * frame has been assembled. */ -void -assemble_kiss(buf, l) +void assemble_kiss(buf, l) unsigned char *buf; int l; { int i; unsigned char c; - for(i=0;i0){ + if (c == FEND) { + if (ifcount > 0) { /* Make sure that the control byte is zero */ - if(*iframe=='\0' || *iframe==0x10) { + if (*iframe == '\0' || *iframe == 0x10) { /* Room for CRC in buffer? */ - if(ifcount < (MAX_FRAME - 2)) { + if (ifcount < (MAX_FRAME - 2)) { stats.kiss_in++; - from_kiss(iframe+1,ifcount-1); + from_kiss(iframe + + 1, ifcount - 1); } else { stats.kiss_toobig++; - LOGL2("assemble_kiss: dumped - frame too large\n"); + LOGL2 + ("assemble_kiss: dumped - frame too large\n"); } } else { stats.kiss_badtype++; - LOGL2("assemble_kiss: dumped - control byte non-zero\n"); + LOGL2 + ("assemble_kiss: dumped - control byte non-zero\n"); } } ifcount = 0; @@ -92,26 +93,27 @@ int l; ifptr = iframe; continue; } - if(c==FESC){ - iescaped=1; + if (c == FESC) { + iescaped = 1; continue; } - if(iescaped){ - if(c==TFEND)c = FEND; - if(c==TFESC)c = FESC; + if (iescaped) { + if (c == TFEND) + c = FEND; + if (c == TFESC) + c = FESC; iescaped = 0; } - if(ifcount < MAX_FRAME){ + if (ifcount < MAX_FRAME) { *ifptr = c; ifptr++; ifcount++; } - } /* for every character in the buffer */ + } /* for every character in the buffer */ } /* convert a standard AX25 frame into a kiss frame */ -void -send_kiss(type, buf, l) +void send_kiss(type, buf, l) unsigned char type; unsigned char *buf; int l; @@ -125,27 +127,27 @@ int l; KISSEMIT(FEND); - if(type==FEND){ + if (type == FEND) { KISSEMIT(FESC); KISSEMIT(TFEND); - }else if (type==FESC){ + } else if (type == FESC) { KISSEMIT(FESC); KISSEMIT(TFESC); - }else { + } else { KISSEMIT(type); } - for(i=0;i= PTABLE_SIZE){ - fprintf(stderr,"param table is full; entry ignored.\n"); + if (param_tbl_top >= PTABLE_SIZE) { + fprintf(stderr, "param table is full; entry ignored.\n"); } - param_tbl[param_tbl_top].parameter = p&0xff; - param_tbl[param_tbl_top].value = v&0xff; + param_tbl[param_tbl_top].parameter = p & 0xff; + param_tbl[param_tbl_top].value = v & 0xff; LOGL4("added param: %d\t%d\n", - param_tbl[param_tbl_top].parameter, - param_tbl[param_tbl_top].value); + param_tbl[param_tbl_top].parameter, + param_tbl[param_tbl_top].value); param_tbl_top++; return; } /* dump the contents of the parameter table */ -void -dump_params() +void dump_params() { int i; - LOGL1("\n%d parameters\n",param_tbl_top); - for(i=0;i2) + if (loglevel > 2) dump_ax25frame("from_kiss: ", buf, l); - if(digi) { /* if we are in digi mode */ + if (digi) { /* if we are in digi mode */ a = next_addr(buf); - if(NOT_ME(a)){ + if (NOT_ME(a)) { stats.kiss_not_for_me++; LOGL4("from_kiss: (digi) dumped - not for me\n"); return; } - if (a==buf) { /* must be a digi */ + if (a == buf) { /* must be a digi */ stats.kiss_i_am_dest++; - LOGL2("from_kiss: (digi) dumped - I am destination!\n"); + LOGL2 + ("from_kiss: (digi) dumped - I am destination!\n"); return; } SETREPEATED(a); a = next_addr(buf); /* find who gets it after us */ - } else { /* must be tnc mode */ + } else { /* must be tnc mode */ a = next_addr(buf); #ifdef TNC_FILTER if (IS_ME(a)) { - LOGL2("from_kiss: (tnc) dumped - addressed to self!\n"); + LOGL2 + ("from_kiss: (tnc) dumped - addressed to self!\n"); return; } #endif - } /* end of tnc mode */ + } /* end of tnc mode */ /* Lookup the IP address for this route */ ipaddr = call_to_ip(a); - if (ipaddr==NULL) { + if (ipaddr == NULL) { if (is_call_bcast(a)) { /* Warning - assuming buffer has room for 2 bytes */ - add_crc(buf, l); l+=2; + add_crc(buf, l); + l += 2; send_broadcast(buf, l); } else { stats.kiss_no_ip_addr++; - LOGL2("from_kiss: dumped - cannot figure out where to send this!\n"); + LOGL2 + ("from_kiss: dumped - cannot figure out where to send this!\n"); } return; } else { /* Warning - assuming buffer has room for 2 bytes */ - add_crc(buf, l); l+=2; + add_crc(buf, l); + l += 2; send_ip(buf, l, ipaddr); if (is_call_bcast(a)) { send_broadcast(buf, l); @@ -144,54 +147,56 @@ int l; * We simply send the packet to the KISS send routine. */ -void -from_ip(buf, l) +void from_ip(buf, l) unsigned char *buf; int l; { int port = 0; unsigned char *a; - if(!ok_crc(buf, l)){ + if (!ok_crc(buf, l)) { stats.ip_failed_crc++; LOGL2("from_ip: dumped - CRC incorrect!\n"); return; } - l = l - 2; /* dump the blasted CRC */ + l = l - 2; /* dump the blasted CRC */ - if(l<15){ + if (l < 15) { stats.ip_tooshort++; LOGL2("from_ip: dumped - length wrong!\n"); return; } - if(loglevel>2)dump_ax25frame("from_ip: ", buf, l); + if (loglevel > 2) + dump_ax25frame("from_ip: ", buf, l); - if(digi){ /* if we are in digi mode */ + if (digi) { /* if we are in digi mode */ a = next_addr(buf); - if(NOT_ME(a)){ + if (NOT_ME(a)) { stats.ip_not_for_me++; LOGL2("from_ip: (digi) dumped - not for me!\n"); return; } - if(a==buf){ /* must be a digi */ + if (a == buf) { /* must be a digi */ stats.ip_i_am_dest++; - LOGL2("from_ip: (digi) dumped - I am destination!\n"); + LOGL2 + ("from_ip: (digi) dumped - I am destination!\n"); return; } - if(dual_port == 1 && FOR_PORT2(a)){ + if (dual_port == 1 && FOR_PORT2(a)) { port = 0x10; } SETREPEATED(a); - } else { /* must be tnc mode */ + } else { /* must be tnc mode */ a = next_addr(buf); #ifdef TNC_FILTER - if(NOT_ME(a)){ - LOGL2("from_ip: (tnc) dumped - I am not destination!\n"); + if (NOT_ME(a)) { + LOGL2 + ("from_ip: (tnc) dumped - I am not destination!\n"); return; } #endif - } /* end of tnc mode */ + } /* end of tnc mode */ send_kiss(port, buf, l); } @@ -199,38 +204,40 @@ int l; * Send an ID frame out the KISS port. */ -void -do_beacon() +void do_beacon() { int i; unsigned char *p; - if(bclen == 0) return; /* nothing to do! */ + if (bclen == 0) + return; /* nothing to do! */ - if(bclen < 0) { /* build the id string */ + if (bclen < 0) { /* build the id string */ p = bcbuf; - *p++ = ('I'<<1); - *p++ = ('D'<<1); - *p++ = (' '<<1); - *p++ = (' '<<1); - *p++ = (' '<<1); - *p++ = (' '<<1); - *p++ = '\0' | 0x60; /* SSID, set reserved bits */ + *p++ = ('I' << 1); + *p++ = ('D' << 1); + *p++ = (' ' << 1); + *p++ = (' ' << 1); + *p++ = (' ' << 1); + *p++ = (' ' << 1); + *p++ = '\0' | 0x60; /* SSID, set reserved bits */ - for(i=0;i<6;i++)*p++=mycallsign[i]; - *p++ = mycallsign[6] | 0x60; /* ensure reserved bits are set */ - SETLAST(bcbuf+7); /* Set the E bit -- last address */ + for (i = 0; i < 6; i++) + *p++ = mycallsign[i]; + *p++ = mycallsign[6] | 0x60; /* ensure reserved bits are set */ + SETLAST(bcbuf + 7); /* Set the E bit -- last address */ - *p++ = 0x03; /* Control field -- UI frame */ + *p++ = 0x03; /* Control field -- UI frame */ - *p++ = 0xf0; /* Protocol ID -- 0xf0 is no protocol */ + *p++ = 0xf0; /* Protocol ID -- 0xf0 is no protocol */ - strcpy(p, bc_text); /* add the text field */ + strcpy(p, bc_text); /* add the text field */ - bclen = 16 + strlen(bc_text); /* adjust the length nicely */ + bclen = 16 + strlen(bc_text); /* adjust the length nicely */ } - if(loglevel>2)dump_ax25frame("do_beacon: ", bcbuf, bclen); + if (loglevel > 2) + dump_ax25frame("do_beacon: ", bcbuf, bclen); stats.kiss_beacon_outs++; send_kiss(0, bcbuf, bclen); } @@ -239,20 +246,28 @@ do_beacon() * return true if the addresses supplied match * modified for wildcarding by vk5xxx */ -int -addrmatch(a,b) +int addrmatch(a, b) unsigned char *a, *b; { - if((*a=='\0') || (*b=='\0'))return 0; - - if((*a++^*b++)&0xfe)return 0; /* "K" */ - if((*a++^*b++)&0xfe)return 0; /* "A" */ - if((*a++^*b++)&0xfe)return 0; /* "9" */ - if((*a++^*b++)&0xfe)return 0; /* "W" */ - if((*a++^*b++)&0xfe)return 0; /* "S" */ - if((*a++^*b++)&0xfe)return 0; /* "B" */ - if(((*b++)&0x1e)==0)return 1; /* ssid 0 matches all ssid's */ - if((*a++^*b)&0x1e)return 0; /* ssid */ + if ((*a == '\0') || (*b == '\0')) + return 0; + + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "K" */ + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "A" */ + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "9" */ + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "W" */ + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "S" */ + if ((*a++ ^ *b++) & 0xfe) + return 0; /* "B" */ + if (((*b++) & 0x1e) == 0) + return 1; /* ssid 0 matches all ssid's */ + if ((*a++ ^ *b) & 0x1e) + return 0; /* ssid */ /* if((*a++^*b++)&0x1e)return 0; ssid (how it was ...) */ return 1; } @@ -260,47 +275,47 @@ unsigned char *a, *b; /* * return pointer to the next station to get this packet */ -unsigned char * -next_addr(f) +unsigned char *next_addr(f) unsigned char *f; { unsigned char *a; /* If no digis, return the destination address */ - if(NO_DIGIS(f))return f; + if (NO_DIGIS(f)) + return f; /* check each digi field. The first one that hasn't seen it is the one */ a = f + 7; do { a += 7; - if(NOTREPEATED(a))return a; - }while(NOT_LAST(a)); + if (NOTREPEATED(a)) + return a; + } + while (NOT_LAST(a)); /* all the digis have seen it. return the destination address */ - return f; + return f; } /* * tack on the CRC for the frame. Note we assume the buffer is long * enough to have the two bytes tacked on. */ -void -add_crc(buf, l) +void add_crc(buf, l) unsigned char *buf; int l; { unsigned short int u; u = compute_crc(buf, l); - buf[l] = u&0xff; /* lsb first */ - buf[l+1] = (u>>8)&0xff; /* msb next */ + buf[l] = u & 0xff; /* lsb first */ + buf[l + 1] = (u >> 8) & 0xff; /* msb next */ } /* * Dump AX25 frame. */ -void -dump_ax25frame(t, buf, l) +void dump_ax25frame(t, buf, l) unsigned char *buf; char *t; int l; @@ -312,28 +327,31 @@ int l; printf("%s AX25: (l=%3d) ", t, l); - if(l<15){ + if (l < 15) { printf("Bogus size...\n"); return; } - printf("%s -> ", call_to_a(buf+7)); + printf("%s -> ", call_to_a(buf + 7)); printf("%s", call_to_a(buf)); - if(ARE_DIGIS(buf)){ + if (ARE_DIGIS(buf)) { printf(" v"); - a = buf+7; - do{ - a+=7; + a = buf + 7; + do { + a += 7; printf(" %s", call_to_a(a)); - if(REPEATED(a))printf("*"); - }while(NOT_LAST(a)); + if (REPEATED(a)) + printf("*"); + } + while (NOT_LAST(a)); } printf("\n"); #ifdef DEBUG - for(i=0;inext) - rl=rl->next; + rl = rl->next; - rn=(struct route_table_entry*)malloc(sizeof(struct route_table_entry)); + rn = (struct route_table_entry *) + malloc(sizeof(struct route_table_entry)); /* Build this entry ... */ - for (i=0; i<6; i++) + for (i = 0; i < 6; i++) rn->callsign[i] = call[i] & 0xfe; rn->callsign[6] = (call[6] & 0x1e) | 0x60; rn->padcall = 0; @@ -83,58 +82,57 @@ unsigned int flags; rn->pad1 = 0; rn->pad2 = 0; rn->flags = flags; - rn->next=NULL; + rn->next = NULL; /* Update the default_route pointer if this is a default route */ if (flags & AXRT_DEFAULT) - default_route=rn; + default_route = rn; - if (rl) /* ... the list is already started add the new route */ - rl->next=rn; - else /* ... start the list off */ - route_tbl=rn; + if (rl) /* ... the list is already started add the new route */ + rl->next = rn; + else /* ... start the list off */ + route_tbl = rn; /* Log this entry ... */ LOGL4("added route: %s\t%s\t%s\t%d\t%d\n", - call_to_a(rn->callsign), - (char *)inet_ntoa(*(struct in_addr *)rn->ip_addr), - rn->udp_port ? "udp" : "ip", - ntohs(rn->udp_port), flags); + call_to_a(rn->callsign), + (char *) inet_ntoa(*(struct in_addr *) rn->ip_addr), + rn->udp_port ? "udp" : "ip", ntohs(rn->udp_port), flags); return; } /* Add a new broadcast address entry */ -void -bcast_add(call) -unsigned char* call; +void bcast_add(call) +unsigned char *call; { struct bcast_table_entry *bl, *bn; int i; /* Check we have a callsign */ - if (call==NULL) + if (call == NULL) return; /* Find the last entry in the list */ - bl=bcast_tbl; + bl = bcast_tbl; if (bcast_tbl) while (bl->next) - bl=bl->next; + bl = bl->next; - bn=(struct bcast_table_entry*)malloc(sizeof(struct bcast_table_entry)); + bn = (struct bcast_table_entry *) + malloc(sizeof(struct bcast_table_entry)); /* Build this entry ... */ - for (i=0; i<6; i++) + for (i = 0; i < 6; i++) bn->callsign[i] = call[i] & 0xfe; bn->callsign[6] = (call[6] & 0x1e) | 0x60; - bn->next=NULL; + bn->next = NULL; - if (bl) /* ... the list is already started add the new route */ - bl->next=bn; - else /* ... start the list off */ - bcast_tbl=bn; + if (bl) /* ... the list is already started add the new route */ + bl->next = bn; + else /* ... start the list off */ + bcast_tbl = bn; /* Log this entry ... */ LOGL4("added broadcast address: %s\n", call_to_a(bn->callsign)); @@ -146,32 +144,32 @@ unsigned char* call; * immediately following the IP address. (UGLY coding; to be fixed later!) */ -unsigned char * -call_to_ip(call) +unsigned char *call_to_ip(call) unsigned char *call; { - struct route_table_entry* rp; + struct route_table_entry *rp; unsigned char mycall[7]; int i; - if(call==NULL) + if (call == NULL) return NULL; - for(i=0; i<6; i++) + for (i = 0; i < 6; i++) mycall[i] = call[i] & 0xfe; mycall[6] = (call[6] & 0x1e) | 0x60; - LOGL4("lookup call %s ",call_to_a(mycall)); + LOGL4("lookup call %s ", call_to_a(mycall)); - rp=route_tbl; + rp = route_tbl; while (rp) { - if (addrmatch(mycall,rp->callsign)) { + if (addrmatch(mycall, rp->callsign)) { LOGL4("found ip addr %s\n", - (char *)inet_ntoa(*(struct in_addr *)rp->ip_addr)); + (char *) inet_ntoa(*(struct in_addr *) + rp->ip_addr)); return rp->ip_addr; } - rp=rp->next; + rp = rp->next; } /* @@ -180,7 +178,8 @@ unsigned char *call; */ if (default_route) { LOGL4("failed, using default ip addr %s\n", - (char *)inet_ntoa(*(struct in_addr *)default_route->ip_addr)); + (char *) inet_ntoa(*(struct in_addr *) + default_route->ip_addr)); return default_route->ip_addr; } @@ -192,73 +191,70 @@ unsigned char *call; * Accept a callsign and return true if it is a broadcast address, or false * if it is not found on the list */ -int -is_call_bcast(call) +int is_call_bcast(call) unsigned char *call; { - struct bcast_table_entry* bp; + struct bcast_table_entry *bp; unsigned char bccall[7]; int i; - if(call==NULL) - return(FALSE); + if (call == NULL) + return (FALSE); - for(i=0; i<6; i++) + for (i = 0; i < 6; i++) bccall[i] = call[i] & 0xfe; bccall[6] = (call[6] & 0x1e) | 0x60; - LOGL4("lookup broadcast %s ",call_to_a(bccall)); + LOGL4("lookup broadcast %s ", call_to_a(bccall)); - bp=bcast_tbl; + bp = bcast_tbl; while (bp) { - if (addrmatch(bccall,bp->callsign)) { - LOGL4("found broadcast %s\n", call_to_a(bp->callsign)); - return(TRUE); + if (addrmatch(bccall, bp->callsign)) { + LOGL4("found broadcast %s\n", + call_to_a(bp->callsign)); + return (TRUE); } - bp=bp->next; + bp = bp->next; } - return(FALSE); + return (FALSE); } /* Traverse the routing table, transmitting the packet to each bcast route */ -void -send_broadcast(buf, l) +void send_broadcast(buf, l) unsigned char *buf; int l; { struct route_table_entry *rp; - rp=route_tbl; + rp = route_tbl; while (rp) { if (rp->flags & AXRT_BCAST) { send_ip(buf, l, rp->ip_addr); } - rp=rp->next; + rp = rp->next; } } /* print out the list of routes */ -void -dump_routes() +void dump_routes() { - struct route_table_entry* rp; + struct route_table_entry *rp; int i; - for (rp=route_tbl, i=0; rp; rp=rp->next) + for (rp = route_tbl, i = 0; rp; rp = rp->next) i++; - LOGL1("\n%d active routes.\n",i); + LOGL1("\n%d active routes.\n", i); - rp=route_tbl; + rp = route_tbl; while (rp) { LOGL1(" %s\t%s\t%s\t%d\t%d\n", - call_to_a(rp->callsign), - (char *)inet_ntoa(*(struct in_addr *)rp->ip_addr), - rp->udp_port ? "udp" : "ip", - ntohs(rp->udp_port), rp->flags); - rp=rp->next; + call_to_a(rp->callsign), + (char *) inet_ntoa(*(struct in_addr *) rp->ip_addr), + rp->udp_port ? "udp" : "ip", + ntohs(rp->udp_port), rp->flags); + rp = rp->next; } fflush(stdout); } - diff --git a/ax25mond/ax25mond.c b/ax25mond/ax25mond.c index 58a932a..928b8ed 100644 --- a/ax25mond/ax25mond.c +++ b/ax25mond/ax25mond.c @@ -49,15 +49,15 @@ // For older kernels #ifndef PF_PACKET - #define PF_PACKET PF_INET +#define PF_PACKET PF_INET #endif /*--------------------------------------------------------------------------*/ static union { - struct sockaddr sa; - struct sockaddr_in si; - struct sockaddr_un su; + struct sockaddr sa; + struct sockaddr_in si; + struct sockaddr_un su; } addr; /*--------------------------------------------------------------------------*/ @@ -65,313 +65,355 @@ static union { int sock_list[MAX_SOCKETS]; char sock_monmode[MAX_SOCKETS]; char sock_filename[MAX_SOCKETS][100]; -int sock_num=0; +int sock_num = 0; int conn_list[MAX_CONNECTS]; struct sockaddr conn_addr[MAX_CONNECTS]; int conn_addrlen[MAX_CONNECTS]; char conn_monmode[MAX_CONNECTS]; -int conn_num=0; +int conn_num = 0; int highest_sock_fd; -int end=0; +int end = 0; /*--------------------------------------------------------------------------*/ /* from buildsaddr.c */ struct sockaddr *build_sockaddr(const char *name, int *addrlen) -{ char *host_name; - char *serv_name; - char buf[1024]; - - memset((char *) &addr, 0, sizeof(addr)); - *addrlen=0; - - host_name=strcpy(buf, name); - serv_name=strchr(buf, ':'); - if(!serv_name) - return 0; - *serv_name++=0; - if(!*host_name || !*serv_name) - return 0; - - if(!strcmp(host_name, "local") || !strcmp(host_name, "unix")) { - addr.su.sun_family=AF_UNIX; - *addr.su.sun_path=0; - strcat(addr.su.sun_path, serv_name); - *addrlen=sizeof(struct sockaddr_un); - return &addr.sa; - } - - addr.si.sin_family=AF_INET; - - if(!strcmp(host_name, "*")) { - addr.si.sin_addr.s_addr=INADDR_ANY; - } else if(!strcmp(host_name, "loopback")) { - addr.si.sin_addr.s_addr=inet_addr("127.0.0.1"); - } else if((addr.si.sin_addr.s_addr=inet_addr(host_name))==-1L) { - struct hostent *hp=gethostbyname(host_name); - endhostent(); - if(!hp) - return 0; - addr.si.sin_addr.s_addr=((struct in_addr *) (hp->h_addr))->s_addr; - } - - if(isdigit(*serv_name & 0xff)) { - addr.si.sin_port=htons(atoi(serv_name)); - } else { - struct servent *sp=getservbyname(serv_name, (char *) 0); - endservent(); - if(!sp) - return 0; - addr.si.sin_port=sp->s_port; - } - - *addrlen=sizeof(struct sockaddr_in); - return &addr.sa; +{ + char *host_name; + char *serv_name; + char buf[1024]; + + memset((char *) &addr, 0, sizeof(addr)); + *addrlen = 0; + + host_name = strcpy(buf, name); + serv_name = strchr(buf, ':'); + if (!serv_name) + return 0; + *serv_name++ = 0; + if (!*host_name || !*serv_name) + return 0; + + if (!strcmp(host_name, "local") || !strcmp(host_name, "unix")) { + addr.su.sun_family = AF_UNIX; + *addr.su.sun_path = 0; + strcat(addr.su.sun_path, serv_name); + *addrlen = sizeof(struct sockaddr_un); + return &addr.sa; + } + + addr.si.sin_family = AF_INET; + + if (!strcmp(host_name, "*")) { + addr.si.sin_addr.s_addr = INADDR_ANY; + } else if (!strcmp(host_name, "loopback")) { + addr.si.sin_addr.s_addr = inet_addr("127.0.0.1"); + } else if ((addr.si.sin_addr.s_addr = inet_addr(host_name)) == -1L) { + struct hostent *hp = gethostbyname(host_name); + endhostent(); + if (!hp) + return 0; + addr.si.sin_addr.s_addr = + ((struct in_addr *) (hp->h_addr))->s_addr; + } + + if (isdigit(*serv_name & 0xff)) { + addr.si.sin_port = htons(atoi(serv_name)); + } else { + struct servent *sp = getservbyname(serv_name, (char *) 0); + endservent(); + if (!sp) + return 0; + addr.si.sin_port = sp->s_port; + } + + *addrlen = sizeof(struct sockaddr_in); + return &addr.sa; } /*--------------------------------------------------------------------------*/ -void add_socket(char *sockname, char monmode) { - struct sockaddr *saddr; - int saddrlen; - - if(sock_num==MAX_SOCKETS-1) { - fprintf(stderr, "WARNING: Too many sockets defined - only %d are " - "allowed\n", MAX_SOCKETS); - return; - } - - if(!(saddr=build_sockaddr(sockname,&saddrlen))) { - fprintf(stderr, "WARNING: Invalid socket name: \"%s\"\n", sockname); - return; - } - - if(saddr->sa_family==AF_UNIX) - strcpy(sock_filename[sock_num], strchr(sockname, ':')+1); - else - sock_filename[sock_num][0]=0; - - if((sock_list[sock_num]=socket(saddr->sa_family,SOCK_STREAM,0))<0) { - fprintf(stderr, "WARNING: Error opening socket \"%s\": %s\n", - sockname, strerror(errno)); - return; - } - - if(bind(sock_list[sock_num],saddr,saddrlen)<0) { - fprintf(stderr, "WARNING: Error binding socket \"%s\": %s\n", - sockname, strerror(errno)); - return; - } - - if(listen(sock_list[sock_num], 5)<0) { - fprintf(stderr, "WARNING: Error listening on socket \"%s\": %s\n", - sockname, strerror(errno)); - return; - } - - fcntl(sock_list[sock_num],F_SETFL,O_NONBLOCK); - - if(sock_list[sock_num] > highest_sock_fd) - highest_sock_fd=sock_list[sock_num]; - - sock_monmode[sock_num]=monmode; - sock_num++; +void add_socket(char *sockname, char monmode) +{ + struct sockaddr *saddr; + int saddrlen; + + if (sock_num == MAX_SOCKETS - 1) { + fprintf(stderr, + "WARNING: Too many sockets defined - only %d are " + "allowed\n", MAX_SOCKETS); + return; + } + + if (!(saddr = build_sockaddr(sockname, &saddrlen))) { + fprintf(stderr, "WARNING: Invalid socket name: \"%s\"\n", + sockname); + return; + } + + if (saddr->sa_family == AF_UNIX) + strcpy(sock_filename[sock_num], strchr(sockname, ':') + 1); + else + sock_filename[sock_num][0] = 0; + + if ((sock_list[sock_num] = + socket(saddr->sa_family, SOCK_STREAM, 0)) < 0) { + fprintf(stderr, + "WARNING: Error opening socket \"%s\": %s\n", + sockname, strerror(errno)); + return; + } + + if (bind(sock_list[sock_num], saddr, saddrlen) < 0) { + fprintf(stderr, + "WARNING: Error binding socket \"%s\": %s\n", + sockname, strerror(errno)); + return; + } + + if (listen(sock_list[sock_num], 5) < 0) { + fprintf(stderr, + "WARNING: Error listening on socket \"%s\": %s\n", + sockname, strerror(errno)); + return; + } + + fcntl(sock_list[sock_num], F_SETFL, O_NONBLOCK); + + if (sock_list[sock_num] > highest_sock_fd) + highest_sock_fd = sock_list[sock_num]; + + sock_monmode[sock_num] = monmode; + sock_num++; } /*--------------------------------------------------------------------------*/ -void close_sockets() { - int i; - - for(i=0;i1) { - if(argc==2 && - (strcmp(argv[1],"-v")==0 || strcmp(argv[1],"--version")==0)) { - printf("%s: Version " VERSION "\n\n", argv[0]); - printf("Copyright (C) 1998-1999 Johann Hanne, DH3MB. All rights reserved.\n" - "This program is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"); - exit(1); - } else { - printf("Usage: %s [-v|--version]\n", argv[0]); - exit(0); - } - } - - // At first, read the configuration file - if(!(conffile=fopen(CONFFILE, "r"))) { - fprintf(stderr, "Unable to open " CONFFILE ".\n"); - exit(1); - } - while(fgets(confline, 100, conffile)) { - if(confline[0]=='#') // Comment - continue; - - confline[strlen(confline)-1]=0; // Cut the LF - - if(!(sockname=strchr(confline, ' '))) { - fprintf(stderr, "WARNING: The following configuration line includes " - "one or more errors:\n%s\n", confline); - continue; - } - - *(sockname++)=0; - mode=confline; - if(strcasecmp(mode, "RX")==0) - add_socket(sockname, 0); - else if(strcasecmp(mode, "RXTX")==0) - add_socket(sockname, 1); - else - fprintf(stderr, "WARNING: Mode \"%s\" not supported\n", mode); - - } - fclose(conffile); - - if(sock_num==0) { - fprintf(stderr, "FATAL: No usable socket found\n"); - exit(1); - } - - // Fork into background - if(fork()) - exit(0); - - // Close stdout, stderr and stdin - fclose(stdout); - fclose(stderr); - fclose(stdin); - - // Set some signal handlers - signal(SIGPIPE, SIG_IGN); - signal(SIGTERM, quit_handler); - - openlog("ax25mond", LOG_PID, LOG_DAEMON); - - // Open AX.25 socket for monitoring RX traffic only - if((monrx_fd=socket(PF_PACKET,SOCK_PACKET,htons(ETH_P_AX25)))<0) { - syslog(LOG_ERR, "Error opening monitor socket: %s\n",strerror(errno)); - exit(1); - } - fcntl(monrx_fd,F_SETFL,O_NONBLOCK); - - // Open AX.25 socket for monitoring RX and TX traffic - if((monrxtx_fd=socket(PF_PACKET,SOCK_PACKET,htons(ETH_P_ALL)))<0) { - syslog(LOG_ERR, "Error opening monitor socket: %s\n",strerror(errno)); - exit(1); - } - fcntl(monrxtx_fd,F_SETFL,O_NONBLOCK); - - while(!end) { - - // Look for incoming connects on all open sockets - FD_ZERO(&conn_request); - for(i=0;i 1) { + if (argc == 2 && + (strcmp(argv[1], "-v") == 0 + || strcmp(argv[1], "--version") == 0)) { + printf("%s: Version " VERSION "\n\n", argv[0]); + printf + ("Copyright (C) 1998-1999 Johann Hanne, DH3MB. All rights reserved.\n" + "This program is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"); + exit(1); + } else { + printf("Usage: %s [-v|--version]\n", argv[0]); + exit(0); + } + } + // At first, read the configuration file + if (!(conffile = fopen(CONFFILE, "r"))) { + fprintf(stderr, "Unable to open " CONFFILE ".\n"); + exit(1); + } + while (fgets(confline, 100, conffile)) { + if (confline[0] == '#') // Comment + continue; + + confline[strlen(confline) - 1] = 0; // Cut the LF + + if (!(sockname = strchr(confline, ' '))) { + fprintf(stderr, + "WARNING: The following configuration line includes " + "one or more errors:\n%s\n", confline); + continue; + } + + *(sockname++) = 0; + mode = confline; + if (strcasecmp(mode, "RX") == 0) + add_socket(sockname, 0); + else if (strcasecmp(mode, "RXTX") == 0) + add_socket(sockname, 1); + else + fprintf(stderr, + "WARNING: Mode \"%s\" not supported\n", + mode); + + } + fclose(conffile); + + if (sock_num == 0) { + fprintf(stderr, "FATAL: No usable socket found\n"); + exit(1); + } + // Fork into background + if (fork()) + exit(0); + + // Close stdout, stderr and stdin + fclose(stdout); + fclose(stderr); + fclose(stdin); + + // Set some signal handlers + signal(SIGPIPE, SIG_IGN); + signal(SIGTERM, quit_handler); + + openlog("ax25mond", LOG_PID, LOG_DAEMON); + + // Open AX.25 socket for monitoring RX traffic only + if ((monrx_fd = + socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_AX25))) < 0) { + syslog(LOG_ERR, "Error opening monitor socket: %s\n", + strerror(errno)); + exit(1); + } + fcntl(monrx_fd, F_SETFL, O_NONBLOCK); + + // Open AX.25 socket for monitoring RX and TX traffic + if ((monrxtx_fd = + socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) { + syslog(LOG_ERR, "Error opening monitor socket: %s\n", + strerror(errno)); + exit(1); + } + fcntl(monrxtx_fd, F_SETFL, O_NONBLOCK); + + while (!end) { + + // Look for incoming connects on all open sockets + FD_ZERO(&conn_request); + for (i = 0; i < sock_num; i++) + FD_SET(sock_list[i], &conn_request); + tv.tv_sec = 0; + tv.tv_usec = 0; + select(highest_sock_fd + 1, &conn_request, 0, 0, &tv); + for (i = 0; i < sock_num; i++) + if (FD_ISSET(sock_list[i], &conn_request)) { + conn_list[conn_num] = accept(sock_list[i], + &conn_addr + [conn_num], + &conn_addrlen + [conn_num]); + conn_monmode[conn_num] = sock_monmode[i]; + conn_num++; + } + // Check if there is new data on the RX-only monitor socket + FD_ZERO(&monavail); + FD_SET(monrx_fd, &monavail); + tv.tv_sec = 0; + tv.tv_usec = 10; + select(monrx_fd + 1, &monavail, 0, 0, &tv); + if (FD_ISSET(monrx_fd, &monavail)) { + monfromlen = sizeof(monfrom); + size = + recvfrom(monrx_fd, buf, sizeof(buf), 0, + &monfrom, &monfromlen); + // Send the packet to all connected sockets + for (i = 0; i < conn_num; i++) { + if (conn_monmode[i] == 0) + if (send + (conn_list[i], buf, size, + 0) < 0) + if (errno != EAGAIN) { + syslog(LOG_ERR, + "Error sending monitor data: %s\n", + strerror + (errno)); + close(conn_list + [i]); + conn_list[i] = + conn_list + [conn_num - 1]; + conn_num--; + } + } + } + // Check if there is new data on the RX+TX monitor socket + FD_ZERO(&monavail); + FD_SET(monrxtx_fd, &monavail); + tv.tv_sec = 0; + tv.tv_usec = 10; + select(monrxtx_fd + 1, &monavail, 0, 0, &tv); + if (FD_ISSET(monrxtx_fd, &monavail)) { + monfromlen = sizeof(monfrom); + size = + recvfrom(monrxtx_fd, buf, sizeof(buf), 0, + &monfrom, &monfromlen); + // Check, if we have received a AX.25-packet + strcpy(ifr.ifr_name, monfrom.sa_data); + ioctl(monrxtx_fd, SIOCGIFHWADDR, &ifr); + if (ifr.ifr_hwaddr.sa_family == AF_AX25) + // Send the packet to all connected sockets + for (i = 0; i < conn_num; i++) { + if (conn_monmode[i] == 1) + if (send + (conn_list[i], buf, + size, 0) < 0) + if (errno != + EAGAIN) { + syslog + (LOG_ERR, + "Error sending monitor data: %s\n", + strerror + (errno)); + close + (conn_list + [i]); + conn_list + [i] = + conn_list + [conn_num + - 1]; + conn_num--; + } + } + } + + } + + for (i = 0; i < conn_num; i++) + close(conn_list[i]); + close_sockets(); + close(monrx_fd); + close(monrxtx_fd); + closelog(); + return 0; } diff --git a/ax25rtd/Makefile.in b/ax25rtd/Makefile.in index 87e7c17..04306cd 100644 --- a/ax25rtd/Makefile.in +++ b/ax25rtd/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -64,15 +64,17 @@ AWK = @AWK@ AX25_LIB = @AX25_LIB@ CC = @CC@ DLLTOOL = @DLLTOOL@ -LD = @LD@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAKEINFO = @MAKEINFO@ NCURSES_LIB = @NCURSES_LIB@ -NM = @NM@ OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STRIP = @STRIP@ VERSION = @VERSION@ etcfiles = ax25rtd.conf @@ -97,6 +99,7 @@ INCLUDES = -DAX25_SYSCONFDIR=\""$(AX25_SYSCONFDIR)"\" -DAX25_LOCALSTATEDIR=\ mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = +sbin_PROGRAMS = ax25rtd$(EXEEXT) ax25rtctl$(EXEEXT) PROGRAMS = $(sbin_PROGRAMS) @@ -104,13 +107,13 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -ax25rtd_OBJECTS = ax25rtd.o cache_ctl.o cache_dump.o config.o \ -listener.o +ax25rtd_OBJECTS = ax25rtd.$(OBJEXT) cache_ctl.$(OBJEXT) \ +cache_dump.$(OBJEXT) config.$(OBJEXT) listener.$(OBJEXT) ax25rtd_LDADD = $(LDADD) ax25rtd_DEPENDENCIES = ax25rtd_LDFLAGS = ax25rtctl_SOURCES = ax25rtctl.c -ax25rtctl_OBJECTS = ax25rtctl.o +ax25rtctl_OBJECTS = ax25rtctl.$(OBJEXT) ax25rtctl_LDADD = $(LDADD) ax25rtctl_DEPENDENCIES = ax25rtctl_LDFLAGS = @@ -129,11 +132,11 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best SOURCES = $(ax25rtd_SOURCES) ax25rtctl.c -OBJECTS = $(ax25rtd_OBJECTS) ax25rtctl.o +OBJECTS = $(ax25rtd_OBJECTS) ax25rtctl.$(OBJEXT) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .lo .o .s +.SUFFIXES: .S .c .lo .o .obj .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps ax25rtd/Makefile @@ -170,6 +173,11 @@ uninstall-sbinPROGRAMS: .c.o: $(COMPILE) -c $< +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + .s.o: $(COMPILE) -c $< @@ -178,6 +186,7 @@ uninstall-sbinPROGRAMS: mostlyclean-compile: -rm -f *.o core *.core + -rm -f *.$(OBJEXT) clean-compile: @@ -205,12 +214,12 @@ distclean-libtool: maintainer-clean-libtool: -ax25rtd: $(ax25rtd_OBJECTS) $(ax25rtd_DEPENDENCIES) - @rm -f ax25rtd +ax25rtd$(EXEEXT): $(ax25rtd_OBJECTS) $(ax25rtd_DEPENDENCIES) + @rm -f ax25rtd$(EXEEXT) $(LINK) $(ax25rtd_LDFLAGS) $(ax25rtd_OBJECTS) $(ax25rtd_LDADD) $(LIBS) -ax25rtctl: $(ax25rtctl_OBJECTS) $(ax25rtctl_DEPENDENCIES) - @rm -f ax25rtctl +ax25rtctl$(EXEEXT): $(ax25rtctl_OBJECTS) $(ax25rtctl_DEPENDENCIES) + @rm -f ax25rtctl$(EXEEXT) $(LINK) $(ax25rtctl_LDFLAGS) $(ax25rtctl_OBJECTS) $(ax25rtctl_LDADD) $(LIBS) install-docDATA: $(doc_DATA) diff --git a/ax25rtd/ax25rtctl.c b/ax25rtd/ax25rtctl.c index 6b40451..222ee61 100644 --- a/ax25rtd/ax25rtctl.c +++ b/ax25rtd/ax25rtctl.c @@ -1,4 +1,4 @@ -/* $Id: ax25rtctl.c,v 1.1 2001/04/10 01:58:38 csmall Exp $ +/* $Id: ax25rtctl.c,v 1.2 2001/09/12 13:18:43 terry Exp $ * * Copyright (c) 1996 Jörg Reuter (jreuter@poboxes.com) * @@ -17,7 +17,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ - + #include #include #include @@ -32,38 +32,40 @@ #include #include "../pathnames.h" -static const struct option lopts[] = { - {"add", 1, 0, 'a'}, - {"del", 1, 0, 'd'}, - {"list", 1, 0, 'l'}, - {"expire", 1, 0, 'e'}, - {"save", 0, 0, 's'}, - {"reload", 0, 0, 'r'}, - {"shutdown", 0, 0, 'q'}, - {"Version", 0, 0, 'V'}, - {"help", 0, 0, 'h'}, - {"debug", 0, 0, 'x'}, - {"version", 0, 0, 'v'}, - {NULL, 0, 0, 0 } +static const struct option lopts[] = { + {"add", 1, 0, 'a'}, + {"del", 1, 0, 'd'}, + {"list", 1, 0, 'l'}, + {"expire", 1, 0, 'e'}, + {"save", 0, 0, 's'}, + {"reload", 0, 0, 'r'}, + {"shutdown", 0, 0, 'q'}, + {"Version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {"debug", 0, 0, 'x'}, + {"version", 0, 0, 'v'}, + {NULL, 0, 0, 0} }; - + static const char *sopts = "a:d:l:e:srqvVh"; static void usage(void) { - fprintf(stderr,"usage:\n"); - fprintf(stderr,"ax25rtctl -a|--add ax25