diff -ruN a/AmberTools/src/cpptraj/dat/CMakeLists.txt b/AmberTools/src/cpptraj/dat/CMakeLists.txt
--- a/AmberTools/src/cpptraj/dat/CMakeLists.txt	2026-11-23 06:29:03.384879411 +0300
+++ b/AmberTools/src/cpptraj/dat/CMakeLists.txt	2026-11-23 06:29:23.884977389 +0300
@@ -1,5 +1,5 @@
 if(INSIDE_AMBER)
-  install(DIRECTORY . USE_SOURCE_PERMISSIONS DESTINATION AmberTools/src/cpptraj/dat/)
+  install(DIRECTORY . USE_SOURCE_PERMISSIONS DESTINATION ${DATADIR})
 else()
   install(DIRECTORY . USE_SOURCE_PERMISSIONS DESTINATION dat/)
 endif()
diff -ruN a/AmberTools/src/leap/tleap b/AmberTools/src/leap/tleap
--- a/AmberTools/src/leap/tleap	2026-11-23 06:29:03.388212760 +0300
+++ b/AmberTools/src/leap/tleap	2026-11-23 06:29:23.884977389 +0300
@@ -1,6 +1,11 @@
 #!/bin/sh
 
-export AMBERHOME="$(dirname "$(cd "$(dirname "$0")" && pwd)")"
+# Gentoo: binaries live in /usr/bin (symlinked to $AMBERHOME/bin) and the
+# data tree in /usr/share/ambertools/dat, so the prefix cannot be derived
+# from the script location anymore.  Honor an existing AMBERHOME so users
+# can still point it at a full Amber installation.
+: "${AMBERHOME:=/usr/share/ambertools}"
+export AMBERHOME
 
 "$AMBERHOME/bin/teLeap" \
            -I"$AMBERHOME/dat/leap/prep" \
diff -ruN a/cmake/InstallDirs.cmake b/cmake/InstallDirs.cmake
--- a/cmake/InstallDirs.cmake	2026-11-23 06:29:03.384879411 +0300
+++ b/cmake/InstallDirs.cmake	2026-11-23 06:29:23.884977389 +0300
@@ -30,7 +30,9 @@
 
 set(BINDIR "${CMAKE_INSTALL_POSTFIX}bin") #binary subdirectory in install location
 set(LIBDIR "${CMAKE_INSTALL_POSTFIX}lib") #shared library subdirectory in install location
-set(DATADIR "${CMAKE_INSTALL_POSTFIX}dat") #subdirectory for programs' data files
+# Gentoo: keep the data tree under $(prefix)/share/ambertools/dat so that
+# $AMBERHOME/dat lookups still work with AMBERHOME=/usr/share/ambertools.
+set(DATADIR "${CMAKE_INSTALL_POSTFIX}share/ambertools/dat") #subdirectory for programs' data files
 set(DOCDIR "${CMAKE_INSTALL_POSTFIX}doc") # subdirectory for PDF documentation
 set(INCDIR "${CMAKE_INSTALL_POSTFIX}include") #subdirecvtory for headers
 set(LICENSEDIR "${CMAKE_INSTALL_POSTFIX}licenses") #license file subdir
diff -ruN a/cmake/RPATHConfig.cmake b/cmake/RPATHConfig.cmake
--- a/cmake/RPATHConfig.cmake	2026-11-23 06:29:03.384879411 +0300
+++ b/cmake/RPATHConfig.cmake	2026-11-23 06:29:23.884977389 +0300
@@ -13,6 +13,9 @@
 	
 	# set the RPATH to the absolute install dir.  This enables using many Amber programs without sourcing amber.sh.
 	# If you do move the install tree, then amber.sh will still set LD_LIBRARY_PATH, and it'll will work fine once you've sourced it.
-	set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
+	# Gentoo: use a loader-relative path instead of baking ${CMAKE_INSTALL_PREFIX}/${LIBDIR} into
+	# the binaries, which keeps the FHS layout (/usr/bin -> /usr/lib) relocatable
+	# and free of build-time paths.
+	set(CMAKE_INSTALL_RPATH "$ORIGIN/../${LIBDIR}")
 	set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 endif()
\ В конце файла нет новой строки
diff -ruN a/dat/CMakeLists.txt b/dat/CMakeLists.txt
--- a/dat/CMakeLists.txt	2026-11-23 06:29:03.384879411 +0300
+++ b/dat/CMakeLists.txt	2026-11-23 06:29:23.884977389 +0300
@@ -4,5 +4,12 @@
 install(DIRECTORY . USE_SOURCE_PERMISSIONS DESTINATION ${DATADIR} COMPONENT Data)
 
 if(NOT (HOST_WINDOWS OR TARGET_WINDOWS))
-	installtime_create_symlink(${CMAKE_INSTALL_POSTFIX}dat/leap/cmd/leaprc.protein.ff12polL ${CMAKE_INSTALL_POSTFIX}dat/leap/cmd/leaprc.protein.ff12pol Data)
+	# leaprc.protein.ff12polL is not part of the source tree (it arrives via
+	# update_amber); only create the compatibility symlink when the target
+	# really exists, and keep it relative: installtime_create_symlink bakes
+	# $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX} into the link contents, which
+	# breaks staged (DESTDIR) installs and QA symlink checks.
+	if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/leap/cmd/leaprc.protein.ff12polL)
+		install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink leaprc.protein.ff12polL \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${DATADIR}/leap/cmd/leaprc.protein.ff12pol)" COMPONENT Data)
+	endif()
 endif()
