NetworkManager r4002 - trunk



Author: mbiebl
Date: Fri Aug 22 18:57:23 2008
New Revision: 4002
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4002&view=rev

Log:
Refine check for dhcp client

This commit is based on a patch by Roy Marples <roy marples name>

Refine the detection logic of the dhcp client to not require a installed dhcp
client and be more backwards compatible:
1.) If no argument is given, first search for dhclient, then dhcpcd. If none is
    found, fall back to /sbin/dhclient (old behaviour)
2.) If either dhclient or dhcpcd is used as argument to --with-dhcp-client,
    search for the binary and the correct version. Fail if not found.
3.) If a complete path is given, do no search for the binary.

Finally, check if the backend is either "dhclient" or "dhcpcd" and fail
otherwise.

Modified:
   trunk/configure.in

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Aug 22 18:57:23 2008
@@ -338,7 +338,14 @@
 
 # DHCP client
 AC_ARG_WITH([dhcp-client], AS_HELP_STRING([--with-dhcp-client=dhcpcd|dhclient], [path to the chosen dhcp client]))
-if test "x$with_dhcp_client" = "x" || test x`basename "$with_dhcp_client"` = "xdhclient"; then
+# If a full path is given, use that and do not test if it works or not.
+case "${with_dhcp_client}" in
+	/*)
+		DHCP_CLIENT_PATH="${with_dhcp_client}"
+		AC_MSG_NOTICE(using the DHCP client ${DHCP_CLIENT_PATH})
+		;;
+esac
+if test -z "$DHCP_CLIENT_PATH" -a \( -z "$with_dhcp_client" -o x`basename "$with_dhcp_client"` = "xdhclient" \); then
 	# We only work with ISC dhclient - the FreeBSD and OpenBSD derivatives don't have the same userland.
 	AC_MSG_CHECKING(for dhclient)
 	for client in "$with_dhcp_client" /sbin/dhclient /usr/pkg/sbin/dhclient /usr/local/sbin/dhclient; do
@@ -347,15 +354,17 @@
 			"isc-dhclient-"*) DHCP_CLIENT_PATH="$client"; break;;
 		esac
 	done
-	if test "x$DHCP_CLIENT_PATH" = "x"; then
+	if test -z "$DHCP_CLIENT_PATH"; then
 		AC_MSG_RESULT(no)
-		if test "x$with_dhcp_client" != "x"; then
+		if test -n "$with_dhcp_client"; then
 			AC_MSG_ERROR([Could not find ISC dhclient])
 		fi
+	else
+		AC_MSG_RESULT($DHCP_CLIENT_PATH)
 	fi
-	AC_MSG_RESULT($DHCP_CLIENT_PATH)
 fi
-if test "x$with_dhcp_client" = "x" -a "x$DHCP_CLIENT_PATH" = "x" || test x`basename "$with_dhcp_client"` = "xdhcpcd"; then
+if test -z "$DHCP_CLIENT_PATH" -a \( -z "$with_dhcp_client" -o x`basename "$with_dhcp_client"` = "xdhcpcd" \); then
+	test -n "$DHCP_CLIENT_PATH" && echo bar
 	# We fully work with upstream dhcpcd-4
 	AC_MSG_CHECKING([for dhcpcd])
 	for client in "$with_dhcp_client" /sbin/dhcpcd /usr/pkg/sbin/dhcpcd /usr/local/sbin/dhcpcd; do
@@ -365,19 +374,28 @@
 			"dhcpcd "*) DHCP_CLIENT_PATH="$client"; break;;
 		esac
 	done
-	if test "x$DHCP_CLIENT_PATH" = "x"; then
+	if test -z "$DHCP_CLIENT_PATH"; then
 		AC_MSG_RESULT(no)
-		if test "x$with_dhcp_client" != "x"; then
+		if test -n "$with_dhcp_client"; then
 			AC_MSG_ERROR([Could not find dhcpcd-4 or newer])
 		fi
+	else
+		AC_MSG_RESULT($DHCP_CLIENT_PATH)
 	fi
-	AC_MSG_RESULT($DHCP_CLIENT_PATH)
 fi
-if test "x$DHCP_CLIENT_PATH" = "x"; then
-	AC_MSG_ERROR([Could not find a suitable DHCP client])
+if test -z "$DHCP_CLIENT_PATH"; then
+	# DHCP clients are not a build time dependency, only runtime.
+	# dhclient has been the longtime default for NM and it's in /sbin
+	# in most distros, so use it.
+	AC_MSG_WARN([Could not find a suitable DHCP client])
+	DHCP_CLIENT_PATH=/sbin/dhclient
+	AC_MSG_WARN([Falling back to ISC dhclient, ${DHCP_CLIENT_PATH}])
 fi
 AC_SUBST(DHCP_CLIENT_PATH)
 DHCP_CLIENT=`basename "$DHCP_CLIENT_PATH"`
+if test "$DHCP_CLIENT" != "dhclient" -a "$DHCP_CLIENT" != "dhcpcd"; then
+	AC_MSG_ERROR([No backend for the DHCP client ${DHCP_CLIENT}])
+fi
 AC_SUBST(DHCP_CLIENT)
 
 AC_ARG_ENABLE(more-warnings,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]