Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -100,9 +100,6 @@ AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
 
-# Control compiler optimizations
-CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'`
-
 AC_PROG_CC
 AC_C_INLINE
 AC_C_CONST
@@ -169,12 +166,13 @@ AC_DEFUN([SILC_ADD_CFLAGS],
 # Function to check if compiler flag works, destination specifiable
 # Usage: SILC_ADD_CC_FLAGS(VAR, FLAGS, [ACTION-IF-FAILED])
 AC_DEFUN([SILC_ADD_CC_FLAGS],
-[ tmp_CFLAGS="$1_CFLAGS"
-  $1_CFLAGS="${$1_CFLAGS} $2"
+[ tmp_CFLAGS="$CFLAGS"
+  CFLAGS="${$1_CFLAGS} $2"
   AC_MSG_CHECKING(whether $CC accepts $2 flag)
-  AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
-				       $1_CFLAGS="$tmp_CFLAGS"
+  AC_TRY_LINK([], [], [AC_MSG_RESULT(yes)
+       $1_CFLAGS="$CFLAGS"], [AC_MSG_RESULT(no)
 				       $3])
+  CFLAGS="$tmp_CFLAGS"
   unset tmp_CFLAGS
 ])
 
@@ -387,8 +385,7 @@ AC_TRY_COMPILE(
   [
     #include <stdarg.h>
     #include <stdlib.h>
-  ],
-  [
+
     int t(int x, ...)
     {
       va_list va, cp;
@@ -400,12 +397,11 @@ AC_TRY_COMPILE(
       va_end(cp);
       return 0;
     }
-    int main()
-    {
-      return t(0, 0xff11);
-    }
   ],
   [
+    return t(0, 0xff11);
+  ],
+  [
     AC_DEFINE([HAVE_VA_COPY], [], [HAVE_VA_COPY])
     AC_MSG_RESULT(yes)
     va_copy=true
@@ -422,8 +418,7 @@ if test x$va_copy = xfalse; then
   [
     #include <stdarg.h>
     #include <stdlib.h>
-  ],
-  [
+
     int t(int x, ...)
     {
       va_list va, cp;
@@ -435,12 +430,11 @@ if test x$va_copy = xfalse; then
       va_end(cp);
       return 0;
     }
-    int main()
-    {
-      return t(0, 0xff11);
-    }
   ],
   [
+    return t(0, 0xff11);
+  ],
+  [
     AC_DEFINE([HAVE___VA_COPY], [], [HAVE___VA_COPY])
     AC_MSG_RESULT(yes)
     va_copy=true
@@ -485,59 +479,9 @@ fi
 ## Compiler and compiler flag checks
 ##
 
-if test "$GCC"; then
-  # GCC specific options
-  if test "x$summary_debug" = "xyes"; then
-    SILC_ADD_CFLAGS(-g)
-  else
-    SILC_ADD_CFLAGS(-g)
-  fi
-  SILC_ADD_CFLAGS(-Wall -finline-functions)
-  SILC_ADD_CFLAGS(-Wno-pointer-sign)
-else
-  # Other compilers
-  case "$target" in
-    alpha*-dec-osf*)
-      SILC_ADD_CFLAGS(-g3)
-      ;;
-    mips*-sgi-irix*)
-      SILC_ADD_CFLAGS(-g3)
-      ;;
-    *)
-      SILC_ADD_CFLAGS(-g)
-      ;;
-  esac
+SILC_ADD_CFLAGS(-Wall -finline-functions)
+SILC_ADD_CFLAGS(-Wno-pointer-sign)
 
-  # Intel C++ Compiler needs -restrict
-  if test "x$CC" = "xicc"; then
-    SILC_ADD_CFLAGS(-restrict)
-  fi
-fi
-
-if test x$want_cc_optimizations = xtrue; then
-  if test "$GCC"; then
-    # GCC specific options
-    if test "x$summary_debug" = "xyes"; then
-      SILC_ADD_CFLAGS(-O)
-    else
-      SILC_ADD_CFLAGS(-O2)
-    fi
-  else
-    # Other compilers
-    case "$target" in
-      alpha*-dec-osf*)
-        SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
-        ;;
-      mips*-sgi-irix*)
-        SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
-        ;;
-      *)
-        SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
-        ;;
-    esac
-  fi
-fi
-
 #
 # Workaround a bug in GCC 2.x which causes memory exhaustion
 # when compiling sha1 with optimizations on UltraSPARC.
@@ -593,55 +537,6 @@ AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOC
 compile_libs=true
 LIBSUBDIR=lib
 
-AC_ARG_WITH(silc-includes,
-  [  --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
-  [ac_silc_includes="$withval"], [ac_silc_includes="no"])
-AC_ARG_WITH(silc-libs,
-  [  --with-silc-libs=DIR     SILC Toolkit libraries [search in DIR]],
-  [ac_silc_libs="$withval"], [ac_silc_libs="no"])
-
-if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
-
-  # Manually provided libs
-  if test "$ac_silc_includes" != "no"; then
-    compile_libs=false
-    SILC_LIB_INCLUDES="-I$ac_silc_includes"
-    LIBSUBDIR=
-  fi
-  if test "$ac_silc_libs" != "no"; then
-    compile_libs=false
-    LIBSUBDIR=
-    LDFLAGS="-L$ac_silc_libs $LDFLAGS"
-  else
-    LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
-  fi
-
-  # Check libs to link against
-  f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
-  if test -n "$f"; then
-    LIBS="$LIBS -lpthread"
-    check_threads=false
-    has_threads=true
-  fi
-  f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
-  if test -n "$f"; then
-    LIBS="$LIBS -ldl"
-  fi
-
-else
-  # pkg-config check
-  PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true)
-
-  if test x$compile_libs = xfalse; then
-    LIBSUBDIR=
-    LIBS="$SILC_LIBS $LIBS"
-    CFLAGS="$CFLAGS $SILC_CFLAGS"
-  else
-    LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
-  fi
-fi
-
-
 # SOCKS4 support checking
 #
 SAVE_LIBS="$LIBS"
@@ -1311,7 +1206,7 @@ fi
 
 SILC_ADD_CC_FLAGS(SILC_CRYPTO, -fno-regmove)
 if test x$summary_debug = xno -a x$want_cc_optimizations = xtrue; then
-  SILC_ADD_CC_FLAGS(SILC_CRYPTO, -fomit-frame-pointer -O3)
+  SILC_ADD_CC_FLAGS(SILC_CRYPTO, -fomit-frame-pointer)
 fi
 
 AC_SUBST(SILC_CRYPTO_CFLAGS)
@@ -1347,7 +1242,6 @@ if test x$compile_libs = xtrue; then
 AC_MSG_NOTICE([configuring math library])
 
 if test x$want_cc_optimizations = xtrue; then
-  SILC_ADD_CC_FLAGS(MATH, -O3, SILC_ADD_CC_FLAGS(MATH, -O2))
   SILC_ADD_CC_FLAGS(MATH, -funroll-all-loops)
 fi
 if test x$enable_stack_trace != xyes; then
