dnl CF_WITH_X11_RGB version: 3 updated: 2023/10/28 11:59:01
dnl ---------------
dnl Handle configure option "--with-x11-rgb", setting these shell
dnl variables:
dnl
dnl $RGB_PATH is the option value, used for finding the X11 rgb file.
dnl $no_x11_rgb is a "#" (comment) if "--without-x11-rgb" is given.
dnl
dnl Most Linux's use this:
dnl 	/usr/share/X11/rgb.txt
dnl Debian uses this:
dnl 	/etc/X11/rgb.txt
dnl DragonFlyBSD ports uses this:
dnl 	/usr/pkg/lib/X11/rgb.txt
dnl FreeBSD ports use these:
dnl 	/usr/local/lib/X11/rgb.txt
dnl 	/usr/local/share/X11/rgb.txt
dnl Mandriva has these:
dnl 	/usr/lib/X11/rgb.txt
dnl 	/usr/lib64/X11/rgb.txt
dnl NetBSD has these
dnl 	/usr/X11R7/lib/X11/rgb.txt
dnl OpenSolaris uses
dnl 	32-bit:
dnl 	/usr/X11/etc/X11/rgb.txt
dnl 	/usr/X11/share/X11/rgb.txt
dnl 	/usr/X11/lib/X11/rgb.txt
dnl OSX uses
dnl		/opt/local/share/X11/rgb.txt (MacPorts)
dnl		/opt/X11/share/X11/rgb.txt (non-ports)
dnl	64-bit:
dnl 	/usr/X11/etc/X11/rgb.txt
dnl 	/usr/X11/share/X11/rgb.txt (perhaps)
dnl 	/usr/X11/lib/amd64/X11/rgb.txt
dnl Solaris10 uses (in this order):
dnl 	/usr/openwin/lib/X11/rgb.txt
dnl 	/usr/X11/lib/X11/rgb.txt
AC_DEFUN([CF_WITH_X11_RGB],[
AC_MSG_CHECKING(for X11 rgb file)
AC_ARG_WITH(x11-rgb,
	[  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)],
	[RGB_PATH=$withval],
	[RGB_PATH=auto])

if test "x[$]RGB_PATH" = xauto
then
	RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
	for cf_path in \
		/opt/local/share/X11/rgb.txt \
		/opt/X11/share/X11/rgb.txt \
		/usr/share/X11/rgb.txt \
		/usr/X11/share/X11/rgb.txt \
		/usr/X11/lib/X11/rgb.txt \
		/usr/lib/X11/rgb.txt \
		/etc/X11/rgb.txt \
		/usr/pkg/lib/X11/rgb.txt \
		/usr/X11R7/lib/X11/rgb.txt \
		/usr/X11R6/lib/X11/rgb.txt \
		/usr/X11R5/lib/X11/rgb.txt \
		/usr/X11R4/lib/X11/rgb.txt \
		/usr/local/lib/X11/rgb.txt \
		/usr/local/share/X11/rgb.txt \
		/usr/lib64/X11/rgb.txt
	do
		if test -f "$cf_path" ; then
			RGB_PATH="$cf_path"
			break
		fi
	done
else
	cf_path=$RGB_PATH
	CF_PATH_SYNTAX(cf_path)
fi

AC_MSG_RESULT($RGB_PATH)
AC_SUBST(RGB_PATH)
AC_DEFINE_UNQUOTED(RGB_PATH,"$cf_path",[Define to the full pathname of rgb.txt])

no_x11_rgb=
if test "$RGB_PATH" = no
then
	no_x11_rgb="#"
fi
AC_SUBST(no_x11_rgb)
])dnl
