Build FFmpeg with NVIDIA GPU Hardware Acceleration

Hi,
I’m building FFmpeg with NVIDIA GPU hardware acceleration following here.
I found FFmpeg can find NVIDIA NVENC when building FFmpeg master branch(commit 7aa71ab5c04cbff9ed4eb7c2925ceb33a8e4e970):

ffmpeg -encoders | grep 264
ffmpeg version N-111869-g7aa71ab5c0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared --prefix=/usr/local/ffmpeg --enable-libx264 --enable-libx265 --enable-gpl
  libavutil      58. 17.100 / 58. 17.100
  libavcodec     60. 23.100 / 60. 23.100
  libavformat    60. 10.101 / 60. 10.101
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9. 11.100 /  9. 11.100
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
 V....D libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V....D libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
 V....D h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)

However, if I checkout FFmpeg other tags(n6.0/n5.1.3) and built it with the same command, FFmpeg can’t find NVIDIA NVENC anymore:

ffmpeg -encoders | grep 264
ffmpeg version n5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared --prefix=/usr/local/ffmpeg-5.1.3 --enable-libx264 --enable-libx265 --enable-gpl
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
 V....D libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V....D libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)

But I found nvenc has been built in libavcodec.so:

nm libavcodec.so | grep nvdec
0000000000d5ab60 d ff_av1_nvdec_hwaccel
0000000000d5abe0 d ff_h264_nvdec_hwaccel
0000000000d5ac60 d ff_hevc_nvdec_hwaccel
0000000000d63160 d ff_mjpeg_nvdec_hwaccel
0000000000d5ace0 d ff_mpeg1_nvdec_hwaccel
0000000000d5ad60 d ff_mpeg2_nvdec_hwaccel
0000000000d5ade0 d ff_mpeg4_nvdec_hwaccel
00000000005b1f00 t ff_nvdec_decode_init
00000000005b1e90 t ff_nvdec_decode_uninit
...

So is there anything I missed?
Thanks!