$NetBSD: patch-an,v 1.7 2006/10/05 01:13:00 rillig Exp $

The '$' while loops expand the variables as long as possible so that no
references to other variables occur. This is necessary because fontpath
may be "${exec_prefix}", which itself may be "${prefix}", and so on. I
don't know how many levels of indirection are possible, therefore the
loop.

I'm also sure that this is not the Right Way to fix it, but at least it
works.

--- config-scripts/cups-directories.m4.orig	2005-01-03 20:29:45.000000000 +0100
+++ config-scripts/cups-directories.m4	2006-10-05 02:58:53.000000000 +0200
@@ -28,6 +28,8 @@ AC_ARG_WITH(fontpath, [  --with-fontpath
 AC_ARG_WITH(docdir, [  --with-docdir           set path for documentation],docdir="$withval",docdir="")
 AC_ARG_WITH(logdir, [  --with-logdir           set path for log files],logdir="$withval",logdir="")
 AC_ARG_WITH(rcdir, [  --with-rcdir            set path for rc scripts],rcdir="$withval",rcdir="")
+AC_ARG_WITH(localedir, [  --with-localedir        set path for locale files],localedir="$withval",localedir="")
+AC_ARG_WITH(serverbindir, [  --with-serverbindir     set path for server helper programs],serverbindir="$withval",serverbindir="")
 
 dnl Fix "prefix" variable if it hasn't been specified...
 if test "$prefix" = "NONE"; then
@@ -162,32 +164,32 @@ dnl Setup default locations...
 CUPS_SERVERROOT="$sysconfdir/cups"
 CUPS_REQUESTS="$localstatedir/spool/cups"
 
-AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups")
-AC_DEFINE_UNQUOTED(CUPS_REQUESTS, "$localstatedir/spool/cups")
+AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT")
+AC_DEFINE_UNQUOTED(CUPS_REQUESTS, "$CUPS_REQUESTS")
 
 if test x$logdir = x; then
 	CUPS_LOGDIR="$localstatedir/log/cups"
-	AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$localstatedir/log/cups")
 else
 	CUPS_LOGDIR="$logdir"
-	AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$logdir")
 fi
+AC_DEFINE_UNQUOTED(CUPS_LOGDIR, "$CUPS_LOGDIR")
 
 dnl See what directory to put server executables...
-case "$uname" in
-	*BSD* | Darwin*)
-		# *BSD and Darwin (MacOS X)
-		INSTALL_SYSV=""
-		CUPS_SERVERBIN="$exec_prefix/libexec/cups"
-		AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$exec_prefix/libexec/cups")
-		;;
-	*)
-		# All others
-		INSTALL_SYSV="install-sysv"
-		CUPS_SERVERBIN="$libdir/cups"
-		AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$libdir/cups")
-		;;
-esac
+if test x$serverbindir = x; then
+	case "$uname" in
+		*BSD* | Darwin*)
+			# *BSD and Darwin (MacOS X)
+			CUPS_SERVERBIN="$exec_prefix/libexec/cups"
+			;;
+		*)
+			# All others
+			CUPS_SERVERBIN="$libdir/cups"
+			;;
+	esac
+else
+	CUPS_SERVERBIN="$serverbindir"
+fi
+AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN")
 
 AC_SUBST(INSTALL_SYSV)
 AC_SUBST(CUPS_SERVERROOT)
@@ -196,29 +198,47 @@ AC_SUBST(CUPS_LOGDIR)
 AC_SUBST(CUPS_REQUESTS)
 
 dnl Set the CUPS_LOCALE directory...
-case "$uname" in
-	Linux | GNU | *BSD* | Darwin*)
-		CUPS_LOCALEDIR="$datadir/locale"
-		AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$datadir/locale")
-		;;
-
-	OSF1* | AIX*)
-		CUPS_LOCALEDIR="$exec_prefix/lib/nls/msg"
-		AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$exec_prefix/lib/nls/msg")
-		;;
-
-	*)
-		# This is the standard System V location...
-		CUPS_LOCALEDIR="$exec_prefix/lib/locale"
-		AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$exec_prefix/lib/locale")
-		;;
-esac
+if test x$localedir = x; then
+	case "$uname" in
+		Linux* | *BSD* | Darwin* | DragonFly*)
+			CUPS_LOCALEDIR="$datadir/locale"
+			;;
+
+		OSF1* | AIX*)
+			CUPS_LOCALEDIR="$exec_prefix/lib/nls/msg"
+			;;
+
+		*)
+			# This is the standard System V location...
+			CUPS_LOCALEDIR="$exec_prefix/lib/locale"
+			;;
+	esac
+else
+	CUPS_LOCALEDIR="$localedir"
+fi
 
+done=no
+while test $done = no; do
+	case "$CUPS_LOCALEDIR" in
+	*'$'*) eval "CUPS_LOCALEDIR=$CUPS_LOCALEDIR";;
+	*) done=yes;;
+	esac
+done
+	
+AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$CUPS_LOCALEDIR")
 AC_SUBST(CUPS_LOCALEDIR)
 
 dnl Set the CUPS_DATADIR directory...
 CUPS_DATADIR="$datadir/cups"
-AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$datadir/cups")
+done=no
+while test $done = no; do
+	case "$CUPS_DATADIR" in
+	*'$'*) eval "CUPS_DATADIR=$CUPS_DATADIR";;
+	*) done=yes;;
+	esac
+done
+
+AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR")
 AC_SUBST(CUPS_DATADIR)
 
 dnl Set the CUPS_DOCROOT directory...
@@ -230,11 +250,27 @@ else
 fi
 
-AC_DEFINE_UNQUOTED(CUPS_DOCROOT, "$docdir")
+done=no
+while test $done = no; do
+	case "$CUPS_DOCROOT" in
+	*'$'*) eval "CUPS_DOCROOT=$CUPS_DOCROOT";;
+	*) done=yes;;
+	esac
+done
+
+AC_DEFINE_UNQUOTED(CUPS_DOCROOT, "$CUPS_DOCROOT")
 AC_SUBST(CUPS_DOCROOT)
 
 dnl Set the CUPS_FONTPATH directory...
 CUPS_FONTPATH="$fontpath"
+done=no
+while test $done = no; do
+	case "$CUPS_FONTPATH" in
+	*'$'*) eval "CUPS_FONTPATH=$CUPS_FONTPATH";;
+	*) done=yes;;
+	esac
+done
+
+AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH")
 AC_SUBST(CUPS_FONTPATH)
-AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$fontpath")
 
 dnl
