diff --git a/configure.ac b/configure.ac
index 68bd4a2c37a4440da4796121e27a87b46700bfbb..adb835bac2cc288796b4465932c1afceacfd7354 100644
--- a/configure.ac
+++ b/configure.ac
@@ -605,7 +605,7 @@ AM_CONDITIONAL([HAVE_PARALLEL_NC4], [test "x$have_parallel_nc4" = xyes])
 AS_VAR_IF([enable_borges], [yes],
   [ACX_C_PACKAGE([BORGES], [borges/borges.h],,,
      [AC_MSG_FAILURE([required header borges/borges.h not found or not compilable])],
-     [borges_context_create],[borges], [rt], [],
+     [borges_context_create],[borges], [$LIBRT], [],
      [AC_MSG_FAILURE([cannot link C BORGES programs])])
    AC_DEFINE([HAVE_BORGES], [1],
      [supporting output to BORGES data system])])
diff --git a/src/Makefile.am b/src/Makefile.am
index d2c0d091668c560b3dca80b66db537c94dd59155..e4cd52f3b7edfef646a17f7f2dd1c15065940502 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,7 +62,7 @@ else !with_on_demand_check_programs
 noinst_LTLIBRARIES += libcdiresunpack.la
 endif !with_on_demand_check_programs
 
-AM_CPPFLAGS = $(PPM_CORE_C_INCLUDE) $(YAXT_C_INCLUDE) $(MPI_C_INCLUDE)
+AM_CPPFLAGS = $(BORGES_C_INCLUDE) $(PPM_CORE_C_INCLUDE) $(YAXT_C_INCLUDE) $(MPI_C_INCLUDE)
 if ENABLE_MPI
 # TODO: this needs a refactoring but for now we set this macro here and not in
 # config.h because the macro is used in several files that do not include the
@@ -233,6 +233,8 @@ libcdi_la_SOURCES += \
   stream_gribapi.c
 endif HAVE_LIBGRIB_API
 
+libcdi_la_LIBADD = $(BORGES_C_LIB) $(LIBRT)
+
 libcdi_f2003_la_SOURCES = mo_cdi.f90
 libcdi_f2003_la_LIBADD = libcdi.la