diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a39185f6fe..c3e90a9409 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3572,9 +3572,9 @@ static void ffprobe_show_program_version(WriterContext *w)
     av_bprint_finalize(&pbuf, NULL);
 }
 
-#define SHOW_LIB_VERSION(libname, LIBNAME)                              \
-    do {                                                                \
-        if (CONFIG_##LIBNAME) {                                         \
+#define SHOW_LIB_VERSION_0(libname, LIBNAME)
+#define SHOW_LIB_VERSION_1(libname, LIBNAME)                            \
+        {                                                               \
             unsigned int version = libname##_version();                 \
             writer_print_section_header(w, SECTION_ID_LIBRARY_VERSION); \
             print_str("name",    "lib" #libname);                       \
@@ -3584,8 +3584,14 @@ static void ffprobe_show_program_version(WriterContext *w)
             print_int("version", version);                              \
             print_str("ident",   LIB##LIBNAME##_IDENT);                 \
             writer_print_section_footer(w);                             \
-        }                                                               \
-    } while (0)
+        }
+
+#define SHOW_LIB_VERSION_2(cfg, libname, LIBNAME)                       \
+    SHOW_LIB_VERSION_ ## cfg(libname, LIBNAME)
+#define SHOW_LIB_VERSION_3(cfg, libname, LIBNAME)                       \
+    SHOW_LIB_VERSION_2(cfg, libname, LIBNAME)
+#define SHOW_LIB_VERSION(libname, LIBNAME)                              \
+    SHOW_LIB_VERSION_3(CONFIG_ ## LIBNAME, libname, LIBNAME)
 
 static void ffprobe_show_library_versions(WriterContext *w)
 {
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 7c996f140d..5729d656e9 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -153,8 +153,9 @@ static int warned_cfg = 0;
 #define SHOW_CONFIG   4
 #define SHOW_COPYRIGHT 8
 
-#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)                  \
-    if (CONFIG_##LIBNAME) {                                             \
+#define PRINT_LIB_INFO_0(libname, LIBNAME, flags, level)
+#define PRINT_LIB_INFO_1(libname, LIBNAME, flags, level)                \
+    {                                                                   \
         const char *indent = flags & INDENT? "  " : "";                 \
         if (flags & SHOW_VERSION) {                                     \
             unsigned int version = libname##_version();                 \
@@ -182,6 +183,13 @@ static int warned_cfg = 0;
         }                                                               \
     }                                                                   \
 
+#define PRINT_LIB_INFO_2(cfg, libname, LIBNAME, flags, level)           \
+    PRINT_LIB_INFO_ ## cfg(libname, LIBNAME, flags, level)
+#define PRINT_LIB_INFO_3(cfg, libname, LIBNAME, flags, level)           \
+    PRINT_LIB_INFO_2(cfg, libname, LIBNAME, flags, level)
+#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)                  \
+    PRINT_LIB_INFO_3(CONFIG_ ## LIBNAME, libname, LIBNAME, flags, level)
+
 static void print_all_libs_info(int flags, int level)
 {
     PRINT_LIB_INFO(avutil,     AVUTIL,     flags, level);
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index f0ef223f05..6d84fcf34f 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -1222,7 +1222,8 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
     for (i = 9; i <= RTMP_HANDSHAKE_PACKET_SIZE; i++)
         tosend[i] = av_lfg_get(&rnd) >> 24;
 
-    if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+    if (rt->encrypted) {
         /* When the client wants to use RTMPE, we have to change the command
          * byte to 0x06 which means to use encrypted data and we have to set
          * the flash version to at least 9.0.115.0. */
@@ -1237,6 +1238,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
         if ((ret = ff_rtmpe_gen_pub_key(rt->stream, tosend + 1)) < 0)
             return ret;
     }
+#endif
 
     client_pos = rtmp_handshake_imprint_with_digest(tosend + 1, rt->encrypted);
     if (client_pos < 0)
@@ -1300,7 +1302,8 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
         if (ret < 0)
             return ret;
 
-        if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+        if (rt->encrypted) {
             /* Compute the shared secret key sent by the server and initialize
              * the RC4 encryption. */
             if ((ret = ff_rtmpe_compute_secret_key(rt->stream, serverdata + 1,
@@ -1310,6 +1313,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
             /* Encrypt the signature received by the server. */
             ff_rtmpe_encrypt_sig(rt->stream, signature, digest, serverdata[0]);
         }
+#endif
 
         if (memcmp(signature, clientdata + RTMP_HANDSHAKE_PACKET_SIZE - 32, 32)) {
             av_log(s, AV_LOG_ERROR, "Signature mismatch\n");
@@ -1330,25 +1334,30 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
         if (ret < 0)
             return ret;
 
-        if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+        if (rt->encrypted) {
             /* Encrypt the signature to be send to the server. */
             ff_rtmpe_encrypt_sig(rt->stream, tosend +
                                  RTMP_HANDSHAKE_PACKET_SIZE - 32, digest,
                                  serverdata[0]);
         }
+#endif
 
         // write reply back to the server
         if ((ret = ffurl_write(rt->stream, tosend,
                                RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
             return ret;
 
-        if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+        if (rt->encrypted) {
             /* Set RC4 keys for encryption and update the keystreams. */
             if ((ret = ff_rtmpe_update_keystream(rt->stream)) < 0)
                 return ret;
         }
+#endif
     } else {
-        if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+        if (rt->encrypted) {
             /* Compute the shared secret key sent by the server and initialize
              * the RC4 encryption. */
             if ((ret = ff_rtmpe_compute_secret_key(rt->stream, serverdata + 1,
@@ -1361,16 +1370,19 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
                                      serverdata[0]);
             }
         }
+#endif
 
         if ((ret = ffurl_write(rt->stream, serverdata + 1,
                                RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
             return ret;
 
-        if (CONFIG_FFRTMPCRYPT_PROTOCOL && rt->encrypted) {
+#if CONFIG_FFRTMPCRYPT_PROTOCOL
+        if (rt->encrypted) {
             /* Set RC4 keys for encryption and update the keystreams. */
             if ((ret = ff_rtmpe_update_keystream(rt->stream)) < 0)
                 return ret;
         }
+#endif
     }
 
     return 0;
