From f3d298f0368fcc9e1e64467e7a4d885826fd6501 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 23 Feb 2017 09:35:12 +0800 Subject: [PATCH] Fix #1291 --- configure.ac | 3 ++- src/cache.c | 4 ++++ src/cache.h | 7 ++++++- src/local.h | 7 ++++++- src/manager.h | 7 ++++++- src/redir.h | 14 +++++++++----- src/resolv.c | 10 ++++++++-- src/server.h | 7 ++++++- src/tunnel.h | 5 +++++ src/udprelay.h | 7 ++++++- 10 files changed, 58 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index f8fa1de9..c5134f48 100755 --- a/configure.ac +++ b/configure.ac @@ -225,7 +225,8 @@ AC_DEFINE([HAVE_IPv6], [1], [Enable IPv6 support in libudns]) AC_CHECK_HEADERS([udns.h], [], [AC_MSG_ERROR([Couldn't find libudns. Try installing libudns-dev or udns-devel.])]) AC_CHECK_LIB([udns], [dns_dnlen], [LIBS="-ludns $LIBS"], [AC_MSG_ERROR([Couldn't find libudns. Try installing libudns-dev or udns-devel.])]) -AC_CHECK_HEADERS([ev.h], [], [AC_MSG_ERROR([Couldn't find libev. Try installing libev-dev@<:@el@:>@.])]) + +AC_CHECK_HEADERS([ev.h libev/ev.h], [], []) AC_CHECK_LIB([ev], [ev_loop_destroy], [LIBS="-lev $LIBS"], [AC_MSG_ERROR([Couldn't find libev. Try installing libev-dev@<:@el@:>@.])]) AC_CONFIG_FILES([shadowsocks-libev.pc diff --git a/src/cache.c b/src/cache.c index c7754e50..cca548d5 100644 --- a/src/cache.c +++ b/src/cache.c @@ -25,6 +25,10 @@ * License: This is licensed under the same terms as uthash itself */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/cache.h b/src/cache.h index 9fa27486..7b980ce4 100644 --- a/src/cache.h +++ b/src/cache.h @@ -29,7 +29,12 @@ #define _CACHE_ #include "uthash.h" -#include "ev.h" + +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif /** * A cache entry diff --git a/src/local.h b/src/local.h index 4421a7a1..61eb97b4 100644 --- a/src/local.h +++ b/src/local.h @@ -23,9 +23,14 @@ #ifndef _LOCAL_H #define _LOCAL_H -#include #include +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif + #include "crypto.h" #include "jconf.h" #include "protocol.h" diff --git a/src/manager.h b/src/manager.h index 978bf37e..fc0ee012 100644 --- a/src/manager.h +++ b/src/manager.h @@ -23,10 +23,15 @@ #ifndef _MANAGER_H #define _MANAGER_H -#include #include #include +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif + #include "jconf.h" #include "common.h" diff --git a/src/redir.h b/src/redir.h index 22bf5be1..783121d0 100644 --- a/src/redir.h +++ b/src/redir.h @@ -1,5 +1,4 @@ -/* - * redir.h - Define the redirector's buffers and callbacks +/* * redir.h - Define the redirector's buffers and callbacks * * Copyright (C) 2013 - 2017, Max Lv * @@ -20,10 +19,15 @@ * . */ -#ifndef _LOCAL_H -#define _LOCAL_H +#ifndef _REDIR_H +#define _REDIR_H +#ifdef HAVE_LIBEV_EV_H +#include +#else #include +#endif + #include "crypto.h" #include "jconf.h" @@ -75,4 +79,4 @@ typedef struct remote { uint32_t counter; } remote_t; -#endif // _LOCAL_H +#endif // _REDIR_H diff --git a/src/resolv.c b/src/resolv.c index bc3c7bc8..baa3ab9d 100644 --- a/src/resolv.c +++ b/src/resolv.c @@ -32,14 +32,20 @@ #include #include #include -#include -#include #include #include #include #include +#include + +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif + #include "resolv.h" #include "utils.h" #include "netutils.h" diff --git a/src/server.h b/src/server.h index 8cfff007..a1d74995 100644 --- a/src/server.h +++ b/src/server.h @@ -23,10 +23,15 @@ #ifndef _SERVER_H #define _SERVER_H -#include #include #include +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif + #include "crypto.h" #include "jconf.h" #include "resolv.h" diff --git a/src/tunnel.h b/src/tunnel.h index 93739a4b..45f0cfd5 100644 --- a/src/tunnel.h +++ b/src/tunnel.h @@ -23,7 +23,12 @@ #ifndef _TUNNEL_H #define _TUNNEL_H +#ifdef HAVE_LIBEV_EV_H +#include +#else #include +#endif + #include "crypto.h" #include "jconf.h" diff --git a/src/udprelay.h b/src/udprelay.h index 02050760..20d9dab2 100644 --- a/src/udprelay.h +++ b/src/udprelay.h @@ -23,9 +23,14 @@ #ifndef _UDPRELAY_H #define _UDPRELAY_H -#include #include +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif + #include "crypto.h" #include "jconf.h"