diff --git a/agentfwd.h b/agentfwd.h
index e9824605b3d6d39f825b107705f0ec93d97f74dd..e4a831c6aeae6f766127998cf308a8a40970d75a 100644
--- a/agentfwd.h
+++ b/agentfwd.h
@@ -30,22 +30,19 @@
 #include "auth.h"
 #include "list.h"
 
+#ifdef ENABLE_CLI_AGENTFWD
+
 /* An agent reply can be reasonably large, as it can
  * contain a list of all public keys held by the agent.
  * 10000 is arbitrary */
 #define MAX_AGENT_REPLY  10000
 
-int svr_agentreq(struct ChanSess * chansess);
-void svr_agentcleanup(struct ChanSess * chansess);
-void svr_agentset(struct ChanSess *chansess);
-
 /* client functions */
 void cli_load_agent_keys(m_list * ret_list);
 void agent_buf_sign(buffer *sigblob, sign_key *key, 
     const unsigned char *data, unsigned int len);
 void cli_setup_agent(struct Channel *channel);
 
-
 #ifdef __hpux
 #define seteuid(a)       setresuid(-1, (a), -1)
 #define setegid(a)       setresgid(-1, (a), -1)
@@ -53,4 +50,14 @@ void cli_setup_agent(struct Channel *channel);
 
 extern const struct ChanType cli_chan_agent;
 
+#endif /* ENABLE_CLI_AGENTFWD */
+
+#ifdef ENABLE_SVR_AGENTFWD
+
+int svr_agentreq(struct ChanSess * chansess);
+void svr_agentcleanup(struct ChanSess * chansess);
+void svr_agentset(struct ChanSess *chansess);
+
+#endif /* ENABLE_SVR_AGENTFWD */
+
 #endif /* _AGENTFWD_H_ */
diff --git a/cli-authpubkey.c b/cli-authpubkey.c
index a57fd6b69f6c9f3643e9bd38d12cad6ad6cc72f5..cf506b8c1b2a416b08fb939bf083afc2d32e5c09 100644
--- a/cli-authpubkey.c
+++ b/cli-authpubkey.c
@@ -123,6 +123,7 @@ void recv_msg_userauth_pk_ok() {
 void cli_buf_put_sign(buffer* buf, sign_key *key, int type, 
 			const unsigned char *data, unsigned int len)
 {
+#ifdef ENABLE_CLI_AGENTFWD
 	if (key->source == SIGNKEY_SOURCE_AGENT) {
 		/* Format the agent signature ourselves, as buf_put_sign would. */
 		buffer *sigblob;
@@ -134,8 +135,11 @@ void cli_buf_put_sign(buffer* buf, sign_key *key, int type,
 
 		buf_free(sigblob);
 	} else {
+#endif
 		buf_put_sign(buf, key, type, data, len);
+#ifdef ENABLE_CLI_AGENTFWD
 	}
+#endif
 	
 }
 
@@ -187,11 +191,13 @@ int cli_auth_pubkey() {
 
 	TRACE(("enter cli_auth_pubkey"))
 
+#ifdef ENABLE_CLI_AGENTFWD
 	if (!cli_opts.agent_keys_loaded) {
 		/* get the list of available keys from the agent */
 		cli_load_agent_keys(cli_opts.privkeys);
 		cli_opts.agent_keys_loaded = 1;
 	}
+#endif
 
 	if (cli_opts.privkeys->first) {
 		sign_key * key = (sign_key*)cli_opts.privkeys->first->item;
diff --git a/svr-authpubkeyoptions.c b/svr-authpubkeyoptions.c
index 4490b5849c9db48c166ae65e19b629d6c57a742d..71d7c146ec40b2414d1d07fdbd78b9023f3f4d90 100644
--- a/svr-authpubkeyoptions.c
+++ b/svr-authpubkeyoptions.c
@@ -143,7 +143,7 @@ int svr_add_pubkey_options(buffer *options_buf, int line_num, const char* filena
 			ses.authstate.pubkey_options->no_port_forwarding_flag = 1;
 			goto next_option;
 		}
-#ifdef ENABLE_AGENTFWD
+#ifdef ENABLE_SVR_AGENTFWD
 		if (match_option(options_buf, "no-agent-forwarding") == DROPBEAR_SUCCESS) {
 			dropbear_log(LOG_WARNING, "Agent forwarding disabled.");
 			ses.authstate.pubkey_options->no_agent_forwarding_flag = 1;
diff --git a/svr-chansession.c b/svr-chansession.c
index f31d9f0c940c931743400c58ecc5d38e64c95ab9..b99bf26ce6a5d69b64eacd1ebda6f0479e329387 100644
--- a/svr-chansession.c
+++ b/svr-chansession.c
@@ -243,7 +243,7 @@ static int newchansess(struct Channel *channel) {
 	chansess->x11authcookie = NULL;
 #endif
 
-#ifdef ENABLE_AGENTFWD
+#ifdef ENABLE_SVR_AGENTFWD
 	chansess->agentlistener = NULL;
 	chansess->agentfile = NULL;
 	chansess->agentdir = NULL;
@@ -300,7 +300,7 @@ static void closechansess(struct Channel *channel) {
 	x11cleanup(chansess);
 #endif
 
-#ifdef ENABLE_AGENTFWD
+#ifdef ENABLE_SVR_AGENTFWD
 	svr_agentcleanup(chansess);
 #endif
 
@@ -358,7 +358,7 @@ static void chansessionrequest(struct Channel *channel) {
 	} else if (strcmp(type, "x11-req") == 0) {
 		ret = x11req(chansess);
 #endif
-#ifdef ENABLE_AGENTFWD
+#ifdef ENABLE_SVR_AGENTFWD
 	} else if (strcmp(type, "auth-agent-req@openssh.com") == 0) {
 		ret = svr_agentreq(chansess);
 #endif
@@ -945,7 +945,7 @@ static void execchild(void *user_data) {
 	/* set up X11 forwarding if enabled */
 	x11setauth(chansess);
 #endif
-#ifdef ENABLE_AGENTFWD
+#ifdef ENABLE_SVR_AGENTFWD
 	/* set up agent env variable */
 	svr_agentset(chansess);
 #endif
diff --git a/sysoptions.h b/sysoptions.h
index ee5ff3679d5f6c5201b3510b0814c9bb99370666..e2f53e39d976a3849bc8999ff7e4d66aecbe5a19 100644
--- a/sysoptions.h
+++ b/sysoptions.h
@@ -162,10 +162,6 @@
 #define USING_LISTENERS
 #endif
 
-#if defined(ENABLE_SVR_AGENTFWD) || defined(ENABLE_CLI_LOCALTCPFWD)
-#define ENABLE_AGENTFWD
-#endif
-
 #if defined(ENABLE_CLI_NETCAT) && defined(ENABLE_CLI_PROXYCMD)
 #define ENABLE_CLI_MULTIHOP
 #endif