diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 36650ad555..3b25da55fe 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -154,7 +154,8 @@ INCLUDE_CFLAGS = -I$(INCLUDE_DIR)
 LIBIBERTY = ../libiberty/libiberty.a
 
 # Where is the CTF library?  Typically in ../libctf.
-LIBCTF = ../libctf/.libs/libctf.a
+LIBCTF = @LIBCTF@
+CTF_DEPS = @CTF_DEPS@
 
 # Where is the BFD library?  Typically in ../bfd.
 BFD_DIR = ../bfd
@@ -591,14 +592,14 @@ INTERNAL_LDFLAGS = \
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
         $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
 	$(LIBIBERTY) $(WIN32LIBS) $(LIBGNU) $(LIBICONV) $(LIBMPFR) \
 	$(SRCHIGH_LIBS)
-CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \
+CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
 	$(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU)
 
 DIST = gdb
diff --git a/gdb/config.in b/gdb/config.in
index 26ca02f6a3..5d6737b874 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -33,6 +33,9 @@
 /* Define to BFD's default target vector. */
 #undef DEFAULT_BFD_VEC
 
+/* Handle .ctf type-info sections */
+#undef ENABLE_LIBCTF
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/gdb/configure b/gdb/configure
index 22a5f6051d..ed30f909a0 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -627,6 +627,9 @@ GCORE_TRANSFORM_NAME
 GDB_TRANSFORM_NAME
 XSLTPROC
 GDB_NM_FILE
+CTF_DEPS
+LIBCTF
+ENABLE_LIBCTF
 LTLIBBABELTRACE
 LIBBABELTRACE
 HAVE_LIBBABELTRACE
@@ -897,6 +900,7 @@ enable_sim
 enable_gdbserver
 with_babeltrace
 with_libbabeltrace_prefix
+enable_libctf
 enable_unit_tests
 '
       ac_precious_vars='build_alias
@@ -1564,6 +1568,7 @@ Optional Features:
   --enable-sim            link gdb with simulator
   --enable-gdbserver      automatically build gdbserver (yes/no/auto, default
                           is auto)
+  --enable-libctf         Handle .ctf type-info sections
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
 
@@ -17556,6 +17561,37 @@ $as_echo "$as_me: WARNING: babeltrace is missing or unusable; GDB is unable to r
   fi
 fi
 
+# Check whether --enable-libctf was given.
+if test "${enable_libctf+set}" = set; then :
+  enableval=$enable_libctf;
+if test "${enableval}" = no; then
+  enable_libctf=no
+else
+  enable_libctf=yes
+fi
+else
+  enable_libctf=yes
+fi
+
+if test x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+
+$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h
+
+else
+    LIBCTF=
+    CTF_DEPS=
+fi
+
+
+
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 9da8818fb5..761e436277 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2217,6 +2217,30 @@ else
   fi
 fi
 
+AC_ARG_ENABLE(libctf,
+[AS_HELP_STRING([--enable-libctf], [Handle .ctf type-info sections])], [
+if test "${enableval}" = no; then
+  enable_libctf=no
+else
+  enable_libctf=yes
+fi], [enable_libctf=yes])
+if test x${enable_static} = xno; then
+  LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so"
+  CTF_DEPS="../libctf/.libs/libctf.so"
+else
+  LIBCTF="../libctf/.libs/libctf.a"
+  CTF_DEPS="$LIBCTF"
+fi
+if test "${enable_libctf}" = yes; then
+    AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
+else
+    LIBCTF=
+    CTF_DEPS=
+fi
+AC_SUBST(ENABLE_LIBCTF)
+AC_SUBST(LIBCTF)
+AC_SUBST(CTF_DEPS)
+
 # If nativefile (NAT_FILE) is not set in configure.nat, we link to an
 # empty version.
 
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 44ccff62ae..ad8446b56c 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -81,6 +81,9 @@
 #include "block.h"
 #include "ctfread.h"
 #include "psympriv.h"
+
+#if ENABLE_LIBCTF
+
 #include "ctf.h"
 #include "ctf-api.h"
 
@@ -1484,3 +1487,18 @@ _initialize_ctfread (void)
   ctf_file_key
     = register_objfile_data_with_cleanup (NULL, ctf_close_objfile);
 }
+
+#else
+
+void
+_initialize_ctfread (void)
+{
+}
+
+void
+elfctf_build_psymtabs (struct objfile *of)
+{
+  /* Nothing to do if CTF is disabled.  */
+}
+
+#endif /* ENABLE_LIBCTF */
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index 2beba053ee..42de3d6f22 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@
 build_canonical = @build@
 host_canonical = @host@
 target_canonical = @target@
+enable_libctf = @enable_libctf@
 
 SHELL = @SHELL@
 EXEEXT = @EXEEXT@
@@ -131,6 +132,7 @@ $(abs_builddir)/site.exp site.exp: ./config.status Makefile
 	@echo "set build_triplet ${build_canonical}" >> ./tmp0
 	@echo "set srcdir ${abs_srcdir}" >> ./tmp0
 	@echo "set tool gdb" >> ./tmp0
+	@echo "set enable_libctf ${enable_libctf}" >> ./tmp0
 	@echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
 	@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
 		@cat ./tmp0 > site.exp
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index cc00f8dfa8..dc4e498855 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -638,6 +638,7 @@ LDFLAGS
 CFLAGS
 CC
 RPATH_ENVVAR
+enable_libctf
 subdirs
 target_noncanonical
 target_os
@@ -694,6 +695,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_gdbtk
+enable_libctf
 enable_shared
 '
       ac_precious_vars='build_alias
@@ -1323,6 +1325,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-gtk            enable gdbtk graphical user interface (GUI)
+  --enable-libctf         Handle .ctf type-info sections
   --enable-shared         build shared libraries deault=yes
 
 Some influential environment variables:
@@ -2189,6 +2192,21 @@ subdirs="$subdirs gdb.gdbtk"
 
 fi
 
+# Check whether --enable-libctf was given.
+if test "${enable_libctf+set}" = set; then :
+  enableval=$enable_libctf;
+if test "${enableval}" = no; then
+  enable_libctf=no
+else
+  enable_libctf=yes
+fi
+else
+  enable_libctf=yes
+fi
+
+
+
+
 # Enable shared libraries.
 # Check whether --enable-shared was given.
 if test "${enable_shared+set}" = set; then :
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 1c4dc99c47..8f7c99084e 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -43,6 +43,16 @@ if test $enable_gdbtk = yes; then
    AC_CONFIG_SUBDIRS(gdb.gdbtk)
 fi
 
+AC_ARG_ENABLE(libctf,
+[AS_HELP_STRING([--enable-libctf], [Handle .ctf type-info sections])], [
+if test "${enableval}" = no; then
+  enable_libctf=no
+else
+  enable_libctf=yes
+fi], [enable_libctf=yes])
+
+AC_SUBST(enable_libctf)
+
 # Enable shared libraries.
 AC_ARG_ENABLE(shared,
 [  --enable-shared         build shared libraries [deault=yes]],,
diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp b/gdb/testsuite/gdb.base/ctf-constvars.exp
index 4a81a94ddb..e7b81edb9e 100644
--- a/gdb/testsuite/gdb.base/ctf-constvars.exp
+++ b/gdb/testsuite/gdb.base/ctf-constvars.exp
@@ -32,6 +32,10 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
 	  [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/gdb.base/ctf-cvexpr.exp b/gdb/testsuite/gdb.base/ctf-cvexpr.exp
index 67ceb21f52..7c97e10446 100644
--- a/gdb/testsuite/gdb.base/ctf-cvexpr.exp
+++ b/gdb/testsuite/gdb.base/ctf-cvexpr.exp
@@ -27,6 +27,10 @@
 standard_testfile cvexpr.c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    return
+}
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested "failed to compile"
      return -1
diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index 9f54582422..7242131a47 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -23,6 +23,10 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
 	  [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/gdb.base/ctf-whatis.exp b/gdb/testsuite/gdb.base/ctf-whatis.exp
index 3f26fc326e..19150ea247 100644
--- a/gdb/testsuite/gdb.base/ctf-whatis.exp
+++ b/gdb/testsuite/gdb.base/ctf-whatis.exp
@@ -23,6 +23,10 @@
 standard_testfile .c
 set opts "additional_flags=-gt"
 
+if {[skip_ctf_tests]} {
+    return
+}
+
 if { [prepare_for_testing "failed to prepare" ${testfile} \
           [list $srcfile] [list $opts nowarnings]] } {
     return 0
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 50db45d1b1..51447c1f91 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2013,6 +2013,23 @@ proc skip_tui_tests {} {
     return 0
 }
 
+# Return 1 if we should skip CTF-related tests.
+
+proc skip_ctf_tests {} {
+    set me "skip_ctf_tests"
+    set src { int main () {return 0;} }
+    set compile_flags "additional_flags=-gt"
+    global enable_libctf
+
+    if {$enable_libctf eq "no"} {
+	return 1
+    }
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+	return 1
+    }
+    return 0
+}
+
 # Test files shall make sure all the test result lines in gdb.sum are
 # unique in a test run, so that comparing the gdb.sum files of two
 # test runs gives correct results.  Test files that exercise
