--- ./configure_orig	2017-11-28 01:21:39 -0600
+++ ./configure	2017-11-28 01:34:41 -0600
@@ -760,6 +760,7 @@
 enable_libada
 enable_libssp
 enable_libstdcxx
+enable_staticlib
 enable_liboffloadmic
 enable_static_libjava
 enable_bootstrap
@@ -1487,6 +1488,7 @@
   --enable-libada         build libada directory
   --enable-libssp         build libssp directory
   --disable-libstdcxx     do not build libstdc++-v3 directory
+  --disable-staticlib	  disable static linking of libstdc++ and libgcc 
   --enable-liboffloadmic=ARG
                           build liboffloadmic [ARG={no,host,target}]
   --enable-static-libjava[=ARG]
@@ -3106,6 +3108,14 @@
   ENABLE_LIBSTDCXX=default
 fi
 
+# Check whether --disable-staticlib was given.
+if test "${enable_staticlib+set}" = set; then 
+  enableval=$enable_staticlib; 
+  ENABLE_STATICLIB=$enableval;
+else
+  ENABLE_STATICLIB=yes;
+fi
+
 if test "${ENABLE_LIBSTDCXX}" = "no" ; then
   noconfigdirs="$noconfigdirs target-libstdc++-v3"
 fi
@@ -5111,7 +5121,9 @@
 
 # Check whether -static-libstdc++ -static-libgcc is supported.
 have_static_libs=no
-if test "$GCC" = yes; then
+# If enable_staticlib is set for configuration, check whether -static-libstdc++ -static-libgcc is supported.
+if test "$ENABLE_STATICLIB" = yes; then 
+ if test "$GCC" = yes; then
   saved_LDFLAGS="$LDFLAGS"
 
   LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
@@ -5150,6 +5162,7 @@
 
   LDFLAGS="$saved_LDFLAGS"
 fi
+fi
 
 
 
@@ -5903,6 +5916,9 @@
  # trust that they are doing what they want.
  if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then
    stage1_ldflags="-static-libstdc++ -static-libgcc"
+ else
+  # If static lib is disabled.
+   stage1_ldflags="" 
  fi
 fi
 
@@ -5937,8 +5953,10 @@
  # In stages 2 and 3, default to linking libstdc++ and libgcc
  # statically.  But if the user explicitly specified the libraries to
  # use, trust that they are doing what they want.
- if test "$poststage1_libs" = ""; then
+ if test "$poststage1_libs" = "" -a $ENABLE_STATICLIB = yes; then
    poststage1_ldflags="-static-libstdc++ -static-libgcc"
+ else
+   poststage1_ldflags="" 
  fi
 fi
 
