Let configure check libevent version and include according to version

This commit is contained in:
ejurgensen 2014-03-13 23:33:35 +01:00
parent 5c40b2344c
commit 687f349927
25 changed files with 1935 additions and 88 deletions

View File

@ -79,8 +79,8 @@ Libraries:
from <http://libav.org/releases/>
- libconfuse
from <http://www.nongnu.org/confuse/>
- libevent 1.4 (** NOT libevent 2 **)
from <http://www.monkey.org/~provos/libevent/>
- libevent 1.4 or 2.1.4+
from <http://libevent.org/>
- libavl 0.3.5
from <http://ftp.debian.org/debian/pool/main/liba/libavl>
- MiniXML (aka mxml or libmxml)

View File

@ -159,9 +159,24 @@ fi
PKG_CHECK_MODULES(MINIXML, [ mxml ])
AC_CHECK_HEADER(event.h, , AC_MSG_ERROR([event.h not found]))
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found]))
AC_SUBST(LIBEVENT_LIBS)
PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2],
AC_CHECK_LIB([event], [evhttp_request_set_header_cb],
AC_DEFINE(HAVE_LIBEVENT2, 1, [Define to 1 if you have libevent 2 with evhttp_request_set_header_cb()]),
AC_MSG_ERROR([found libevent 2 but without evhttp_request_set_header_cb() - try version >= 2.1.4])
),
try_libevent1=true;
)
if test x$try_libevent1 = xtrue; then
AC_CHECK_HEADER(event.h,
AC_CHECK_LIB([event_core], [event_init], [LIBEVENT_LIBS="-levent_core"], AC_MSG_ERROR([libevent not found])),
AC_MSG_ERROR([event.h not found])
)
AC_SUBST(LIBEVENT_LIBS)
AM_CONDITIONAL(COND_LIBEVENT2, false)
else
AM_CONDITIONAL(COND_LIBEVENT2, true)
fi
AC_CHECK_HEADER(avl.h, , AC_MSG_ERROR([avl.h not found]))
AC_CHECK_LIB([avl], [avl_alloc_tree], [LIBAVL_LIBS="-lavl"], AC_MSG_ERROR([libavl not found]))
@ -191,12 +206,12 @@ fi
if test x$use_spotify = xtrue; then
AC_CHECK_HEADER(libspotify/api.h, , AC_MSG_ERROR([libspotify/api.h not found]))
AC_DEFINE(HAVE_SPOTIFY_H, 1, [Define to 1 if you have the <libspotify/api.h> header file.])
dnl Don't link to libspotify, but instead enable dynamic linking
SPOTIFY_CFLAGS="-rdynamic"
SPOTIFY_LIBS="-ldl"
AC_SUBST(SPOTIFY_CFLAGS)
AC_SUBST(SPOTIFY_LIBS)
AC_DEFINE(HAVE_SPOTIFY_H, 1, [Define to 1 if you have the <libspotify/api.h> header file.])
dnl Don't link to libspotify, but instead enable dynamic linking
SPOTIFY_CFLAGS="-rdynamic"
SPOTIFY_LIBS="-ldl"
AC_SUBST(SPOTIFY_CFLAGS)
AC_SUBST(SPOTIFY_LIBS)
fi
case "$host" in

View File

@ -31,6 +31,13 @@ else
FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h
endif
if COND_LIBEVENT2
RTSP_SRC=evrtsp/rtsp.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
else
EVHTTP_SRC=evhttp/http.c evhttp/evhttp.h evhttp/http-internal.h evhttp/log.h
RTSP_SRC=evrtsp/rtsp-libevent1.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
endif
GPERF_FILES = \
daap_query.gperf \
rsp_query.gperf \
@ -79,8 +86,7 @@ forked_daapd_SOURCES = main.c \
filescanner_ffmpeg.c filescanner_m3u.c filescanner_icy.c $(ITUNESSRC) \
mdns_avahi.c mdns.h \
remote_pairing.c remote_pairing.h \
evhttp/http.c evhttp/evhttp.h \
evhttp/http-internal.h evhttp/log.h \
$(EVHTTP_SRC) \
$(FFURL_SRC) $(AVIO_SRC) \
httpd.c httpd.h \
httpd_rsp.c httpd_rsp.h \
@ -96,10 +102,9 @@ forked_daapd_SOURCES = main.c \
player.c player.h \
$(ALSASRC) $(OSS4SRC) laudio.h \
raop.c raop.h \
evrtsp/rtsp.c evrtp/evrtsp.h \
evrtsp/rtsp-internal.h evrtsp/log.h \
$(RTSP_SRC) \
scan-wma.c \
$(SPOTIFYSRC) \
$(SPOTIFYSRC) \
$(FLACSRC) $(MUSEPACKSRC)
nodist_forked_daapd_SOURCES = \

View File

@ -29,8 +29,6 @@
#include <fcntl.h>
#include <limits.h>
#include <event.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>

View File

@ -8,6 +8,7 @@
#define ART_FMT_PNG 1
#define ART_FMT_JPEG 2
#include <event.h>
int
artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf);

View File

@ -24,8 +24,6 @@
#include <libavformat/avformat.h>
#include <event.h>
#include "logger.h"
#include "avio_evbuffer.h"

View File

@ -2,6 +2,8 @@
#ifndef __AVIO_EVBUFFER_H__
#define __AVIO_EVBUFFER_H__
#include <event.h>
AVIOContext *
avio_evbuffer_open(struct evbuffer *evbuf);

View File

@ -23,9 +23,6 @@
#include <string.h>
#include <stdint.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include "db.h"
#include "misc.h"
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __DMAP_HELPERS_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include "db.h"

1816
src/evrtsp/rtsp-libevent1.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,19 +28,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <event-config.h>
#include <event.h>
#ifdef _EVENT_HAVE_SYS_PARAM_H
#ifdef EVENT__HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef _EVENT_HAVE_SYS_TYPES_H
#ifdef EVENT__HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef _EVENT_HAVE_SYS_TIME_H
#ifdef EVENT__HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef _EVENT_HAVE_SYS_IOCCOM_H
#ifdef EVENT__HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
@ -74,19 +74,17 @@
#endif
#include <signal.h>
#include <time.h>
#ifdef _EVENT_HAVE_UNISTD_H
#ifdef EVENT__HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _EVENT_HAVE_FCNTL_H
#ifdef EVENT__HAVE_FCNTL_H
#include <fcntl.h>
#endif
#undef timeout_pending
#undef timeout_initialized
#include <event.h>
#include "evrtsp.h"
#include <evutil.h>
/* #define USE_DEBUG */
#include "log.h"
#include "rtsp-internal.h"
@ -97,7 +95,7 @@
#define strdup _strdup
#endif
#ifndef _EVENT_HAVE_GETNAMEINFO
#ifndef EVENT__HAVE_GETNAMEINFO
#define NI_MAXSERV 32
#define NI_MAXHOST 1025
@ -146,7 +144,7 @@ fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
#endif
#ifndef _EVENT_HAVE_GETADDRINFO
#ifndef EVENT__HAVE_GETADDRINFO
struct addrinfo {
int ai_family;
int ai_socktype;
@ -220,7 +218,7 @@ static int evrtsp_add_header_internal(struct evkeyvalq *headers,
void evrtsp_read(int, short, void *);
void evrtsp_write(int, short, void *);
#ifndef _EVENT_HAVE_STRSEP
#ifndef EVENT__HAVE_STRSEP
/* strsep replacement for platforms that lack it. Only works if
* del is one character long. */
static char *
@ -319,8 +317,7 @@ evrtsp_write_buffer(struct evrtsp_connection *evcon,
if (event_pending(&evcon->ev, EV_WRITE|EV_TIMEOUT, NULL))
event_del(&evcon->ev);
event_set(&evcon->ev, evcon->fd, EV_WRITE, evrtsp_write, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_WRITE, evrtsp_write, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_WRITE_TIMEOUT);
}
@ -357,12 +354,12 @@ evrtsp_make_header_request(struct evrtsp_connection *evcon,
method, req->uri, req->major, req->minor);
/* Content-Length is mandatory, absent means 0 */
if ((EVBUFFER_LENGTH(req->output_buffer) > 0)
if ((evbuffer_get_length(req->output_buffer) > 0)
&& (evrtsp_find_header(req->output_headers, "Content-Length") == NULL))
{
char size[12];
evutil_snprintf(size, sizeof(size), "%ld",
(long)EVBUFFER_LENGTH(req->output_buffer));
(long)evbuffer_get_length(req->output_buffer));
evrtsp_add_header(req->output_headers, "Content-Length", size);
}
}
@ -380,7 +377,7 @@ evrtsp_make_header(struct evrtsp_connection *evcon, struct evrtsp_request *req)
}
evbuffer_add(evcon->output_buffer, "\r\n", 2);
if (EVBUFFER_LENGTH(req->output_buffer) > 0) {
if (evbuffer_get_length(req->output_buffer) > 0) {
evbuffer_add_buffer(evcon->output_buffer, req->output_buffer);
}
}
@ -498,7 +495,7 @@ evrtsp_write(int fd, short what, void *arg)
return;
}
if (EVBUFFER_LENGTH(evcon->output_buffer) != 0) {
if (evbuffer_get_length(evcon->output_buffer) != 0) {
evrtsp_add_event(&evcon->ev,
evcon->timeout, RTSP_WRITE_TIMEOUT);
return;
@ -577,9 +574,9 @@ evrtsp_read_body(struct evrtsp_connection *evcon, struct evrtsp_request *req)
if (req->ntoread < 0) {
/* Read until connection close. */
evbuffer_add_buffer(req->input_buffer, buf);
} else if (EVBUFFER_LENGTH(buf) >= req->ntoread) {
} else if (evbuffer_get_length(buf) >= req->ntoread) {
/* Completed content length */
evbuffer_add(req->input_buffer, EVBUFFER_DATA(buf),
evbuffer_add(req->input_buffer, evbuffer_pullup(buf,-1),
(size_t)req->ntoread);
evbuffer_drain(buf, (size_t)req->ntoread);
req->ntoread = 0;
@ -587,8 +584,7 @@ evrtsp_read_body(struct evrtsp_connection *evcon, struct evrtsp_request *req)
return;
}
/* Read more! */
event_set(&evcon->ev, evcon->fd, EV_READ, evrtsp_read, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_READ, evrtsp_read, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_READ_TIMEOUT);
}
@ -756,9 +752,9 @@ evrtsp_connection_reset(struct evrtsp_connection *evcon)
evcon->state = EVCON_DISCONNECTED;
evbuffer_drain(evcon->input_buffer,
EVBUFFER_LENGTH(evcon->input_buffer));
evbuffer_get_length(evcon->input_buffer));
evbuffer_drain(evcon->output_buffer,
EVBUFFER_LENGTH(evcon->output_buffer));
evbuffer_get_length(evcon->output_buffer));
}
static void
@ -776,9 +772,8 @@ evrtsp_connection_start_detectclose(struct evrtsp_connection *evcon)
if (event_initialized(&evcon->close_ev))
event_del(&evcon->close_ev);
event_set(&evcon->close_ev, evcon->fd, EV_READ,
event_assign(&evcon->close_ev, evcon->base, evcon->fd, EV_READ,
evrtsp_detect_close_cb, evcon);
EVRTSP_BASE_SET(evcon, &evcon->close_ev);
event_add(&evcon->close_ev, NULL);
}
@ -1033,7 +1028,7 @@ evrtsp_parse_firstline(struct evrtsp_request *req, struct evbuffer *buffer)
char *line;
enum message_read_status status = ALL_DATA_READ;
line = evbuffer_readline(buffer);
line = evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY);
if (line == NULL)
return (MORE_DATA_EXPECTED);
@ -1074,13 +1069,13 @@ evrtsp_append_to_last_header(struct evkeyvalq *headers, const char *line)
}
enum message_read_status
evrtsp_parse_headers(struct evrtsp_request *req, struct evbuffer* buffer)
evrtsp_parse_headers(struct evrtsp_request *req, struct evbuffer *buffer)
{
char *line;
enum message_read_status status = MORE_DATA_EXPECTED;
struct evkeyvalq* headers = req->input_headers;
while ((line = evbuffer_readline(buffer))
struct evkeyvalq *headers = req->input_headers;
while ((line = evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY))
!= NULL) {
char *skey, *svalue;
@ -1143,7 +1138,7 @@ evrtsp_get_body_length(struct evrtsp_request *req)
event_debug(("%s: bytes to read: %lld (in buffer %ld)\n",
__func__, req->ntoread,
EVBUFFER_LENGTH(req->evcon->input_buffer)));
evbuffer_get_length(req->evcon->input_buffer)));
return (0);
}
@ -1401,8 +1396,7 @@ evrtsp_connection_connect(struct evrtsp_connection *evcon)
}
/* Set up a callback for successful connection setup */
event_set(&evcon->ev, evcon->fd, EV_WRITE, evrtsp_connectioncb, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_WRITE, evrtsp_connectioncb, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_CONNECT_TIMEOUT);
evcon->state = EVCON_CONNECTING;
@ -1467,9 +1461,7 @@ evrtsp_start_read(struct evrtsp_connection *evcon)
/* Set up an event to read the headers */
if (event_initialized(&evcon->ev))
event_del(&evcon->ev);
event_set(&evcon->ev, evcon->fd, EV_READ, evrtsp_read, evcon);
EVRTSP_BASE_SET(evcon, &evcon->ev);
event_assign(&evcon->ev, evcon->base, evcon->fd, EV_READ, evrtsp_read, evcon);
evrtsp_add_event(&evcon->ev, evcon->timeout, RTSP_READ_TIMEOUT);
evcon->state = EVCON_READING_FIRSTLINE;
}
@ -1604,7 +1596,7 @@ evrtsp_request_uri(struct evrtsp_request *req) {
static struct addrinfo *
addr_from_name(char *address)
{
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
struct addrinfo ai, *aitop;
int ai_result;
@ -1635,7 +1627,7 @@ name_from_addr(struct sockaddr *sa, socklen_t salen,
char strport[NI_MAXSERV];
int ni_result;
#ifdef _EVENT_HAVE_GETNAMEINFO
#ifdef EVENT__HAVE_GETNAMEINFO
ni_result = getnameinfo(sa, salen,
ntop, sizeof(ntop), strport, sizeof(strport),
NI_NUMERICHOST|NI_NUMERICSERV);
@ -1717,7 +1709,7 @@ make_addrinfo(const char *address, u_short port)
{
struct addrinfo *aitop = NULL;
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
struct addrinfo ai;
char strport[NI_MAXSERV];
int ai_result;
@ -1767,7 +1759,7 @@ bind_socket(int family, const char *address, u_short port, int reuse)
fd = bind_socket_ai(family, aitop, reuse);
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
freeaddrinfo(aitop);
#else
fake_freeaddrinfo(aitop);
@ -1806,7 +1798,7 @@ socket_connect(int fd, const char *address, unsigned short port)
res = 0;
out:
#ifdef _EVENT_HAVE_GETADDRINFO
#ifdef EVENT__HAVE_GETADDRINFO
freeaddrinfo(ai);
#else
fake_freeaddrinfo(ai);

View File

@ -43,7 +43,11 @@
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include <libavformat/avformat.h>

View File

@ -37,7 +37,11 @@
#include <avl.h>
#include <plist/plist.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include "logger.h"
#include "db.h"

View File

@ -42,8 +42,6 @@
#endif
#include <zlib.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include "logger.h"
#include "db.h"

View File

@ -3,8 +3,11 @@
#define __HTTPD_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
void
httpd_stream_file(struct evhttp_request *req, int id);

View File

@ -38,8 +38,6 @@
#include <uninorm.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include <avl.h>
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_DAAP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
daap_init(void);

View File

@ -37,9 +37,6 @@
# include <sys/eventfd.h>
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#include "logger.h"
#include "misc.h"
#include "conffile.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_DACP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
dacp_init(void);

View File

@ -31,9 +31,6 @@
#include <regex.h>
#include <limits.h>
#include <event.h>
#include "evhttp/evhttp.h"
#include <mxml.h>
#include "logger.h"

View File

@ -3,7 +3,11 @@
#define __HTTPD_RSP_H__
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
int
rsp_init(void);

View File

@ -47,7 +47,11 @@
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
#include <gcrypt.h>

View File

@ -3,7 +3,7 @@
#define __SPOTIFY_H__
#include "db.h"
#include "evhttp/evhttp.h"
#include <event.h>
int
spotify_playback_play(struct media_file_info *mfi);

View File

@ -38,9 +38,6 @@
# include <sys/endian.h>
#endif
#include <event.h>
#include "evhttp/evhttp.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>

View File

@ -2,7 +2,12 @@
#ifndef __TRANSCODE_H__
#define __TRANSCODE_H__
#include "evhttp/evhttp.h"
#include <event.h>
#ifdef HAVE_LIBEVENT2
# include <evhttp.h>
#else
# include "evhttp/evhttp.h"
#endif
struct transcode_ctx;