Commit 123a847d authored by Marek Vavruša's avatar Marek Vavruša

resolver: use pkg-config to find libknot and libuv

parent 2ae6adee
# Knot DNS Resolver
## Preparation
The Knot DNS Resolver depends on the Knot DNS library which is introduced in current master, and on the
reasonably recent version of the `libuv`.
### libuv
If the libuv with a version at least 1.0 is not present on your system,
compile and install the sources code from the Git repository.
```
$ git clone https://github.com/joyent/libuv.git
$ cd libuv
$ ./autogen.sh
$ make && make install
```
## Compilation
./configure
make
```
$ export PKG_CONFIG_PATH="..." # Change, if you installed the libknot somewhere else
$ ./configure
$ autoreconf -if
$ make
```
## Running
There is a separate resolver library in the `lib` directory, and a minimalistic daemon in
the `daemon` directory. The daemon accepts a few CLI parameters, and there's no support for configuration
right now.
```
$ ./daemon/kresolved -h
$ ./daemon/kresolved -a 127.0.0.1#53
```
......@@ -30,13 +30,10 @@ LT_INIT
PKG_PROG_PKG_CONFIG
# Check for dependencies
AM_CHECK_CMOCKA
AM_CHECK_LIBUV
PKG_CHECK_MODULES([libuv], [libuv])
PKG_CHECK_MODULES([libknot], [libknot])
# Check headers
AC_CHECK_HEADERS([stdlib.h],,, [AC_INCLUDES_DEFAULT])
# Search libraries
# Search other libraries
AC_SEARCH_LIBS([mdb_env_open], [lmdb])
# Config files
......@@ -53,9 +50,8 @@ AC_MSG_RESULT([
Target: $host_os $host_cpu
Compiler: ${CC}
CFlags: ${CFLAGS} ${CPPFLAGS}
LDFlags: ${LDFLAGS}
Libs: ${LIBS}
CFlags: ${CFLAGS} ${CPPFLAGS} ${libuv_CFLAGS} ${libknot_CFLAGS}
LDFlags: ${LDFLAGS} ${libuv_LIBS} ${libknot_LIBS}
Continue with 'make' command
])
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-I$(top_srcdir)/lib
-I$(top_srcdir)/lib \
$(libuv_CFLAGS) \
$(libknot_CFLAGS)
sbin_PROGRAMS = kresolved
......@@ -12,6 +14,4 @@ kresolved_SOURCES = \
main.c
# sbin programs
kresolved_LDADD = $(top_builddir)/lib/libknotresolve.la \
$(KNOT_LIBS) \
$(libuv_LIBS)
kresolved_LDADD = $(top_builddir)/lib/libknotresolve.la
......@@ -4,7 +4,7 @@
#include <uv.h>
#include <common/sockaddr.h>
#include <libknot/internal/sockaddr.h>
#include "lib/resolve.h"
#include "worker.h"
......
#include <uv.h>
#include <libknot/packet/pkt.h>
#include <common/net.h>
#include <libknot/internal/net.h>
#include "daemon/worker.h"
#include "daemon/layer/query.h"
......
......@@ -17,7 +17,7 @@ limitations under the License.
#include <uv.h>
#include <common/mempattern.h>
#include <libknot/internal/mempattern.h>
#include "lib/resolve.h"
struct worker_ctx {
......
......@@ -20,3 +20,6 @@ libknotresolve_la_SOURCES = \
rplan.c \
cache.h \
cache.c
libknotresolve_la_CPPFLAGS = $(AM_CPPFLAGS) $(libknot_CFLAGS) $(libuv_CFLAGS)
libknotresolve_la_LDFLAGS = $(AM_LDFLAGS) $(libknot_LIBS) $(libuv_LIBS)
......@@ -2,7 +2,7 @@
#include <time.h>
#include <lmdb.h>
#include <common/mempattern.h>
#include <libknot/internal/mempattern.h>
#include <libknot/descriptor.h>
#include "lib/cache.h"
......
#include <string.h>
#include <sys/time.h>
#include <common/sockaddr.h>
#include <libknot/internal/sockaddr.h>
#include "lib/context.h"
#include "lib/rplan.h"
......
......@@ -16,8 +16,9 @@ limitations under the License.
#pragma once
#include <stdint.h>
#include <common/mempattern.h>
#include <common/sockaddr.h>
#include <libknot/internal/mempattern.h>
#include <libknot/internal/sockaddr.h>
#include "lib/delegpt.h"
#include "lib/rplan.h"
......
#include "lib/delegpt.h"
#include "lib/defines.h"
#include <common/mempool.h>
#include <libknot/internal/mempool.h>
static void ns_free(struct kr_ns *ns, mm_ctx_t *mm)
{
......
......@@ -16,9 +16,9 @@ limitations under the License.
#pragma once
#include <libknot/packet/pkt.h>
#include <common/lists.h>
#include <common/sockaddr.h>
#include <common/trie/hat-trie.h>
#include <libknot/internal/lists.h>
#include <libknot/internal/sockaddr.h>
#include <libknot/internal/trie/hat-trie.h>
/*! \brief Name server flag. */
enum kr_ns_flag {
......
......@@ -16,6 +16,7 @@ limitations under the License.
#pragma once
#include <libknot/processing/layer.h>
#include "lib/context.h"
/*!
......
......@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#include <common/print.h>
#include <libknot/internal/print.h>
#include "lib/layer/stats.h"
#include "lib/rplan.h"
......
......@@ -16,7 +16,7 @@ limitations under the License.
#pragma once
#include <libknot/dname.h>
#include <common/lists.h>
#include <libknot/internal/lists.h>
enum {
RESOLVE_QUERY = 0 << 0,
......
dnl A macro to check presence of cmocka on the system
AC_DEFUN([AM_CHECK_CMOCKA],
[
PKG_CHECK_EXISTS(cmocka,
[AC_CHECK_HEADERS([stdarg.h stddef.h setjmp.h],
[], dnl We are only intrested in action-if-not-found
[AC_MSG_WARN([Header files stdarg.h stddef.h setjmp.h are required by cmocka])
cmocka_required_headers="no"
]
)
AS_IF([test x"$cmocka_required_headers" != x"no"],
[PKG_CHECK_MODULES([cmocka], [cmocka], [have_cmocka="yes"])]
)],
dnl PKG_CHECK_EXISTS ACTION-IF-NOT-FOUND
[AC_MSG_WARN([No libcmocka library found, cmocka tests will not be built])]
)
AM_CONDITIONAL([HAVE_CMOCKA], [test x$have_cmocka = xyes])
])
dnl A macro to check presence of liblmdb on the system
AC_DEFUN([AM_CHECK_LMDB],
[
PKG_CHECK_EXISTS(lmdb,
[AC_CHECK_HEADERS([lmdb.h],
[], dnl We are only intrested in action-if-not-found
[AC_MSG_WARN([Header file lmdb.h is required.])
lmdb_required_headers="no"
]
)
AS_IF([test x"$lmdb_required_headers" != x"no"],
[PKG_CHECK_MODULES([lmdb], [lmdb], [have_lmdb="yes"])]
)],
dnl PKG_CHECK_EXISTS ACTION-IF-NOT-FOUND
[AC_MSG_WARN([No lmdb library found.])]
)
AM_CONDITIONAL([HAVE_LMDB], [test x$have_lmdb = xyes])
])
dnl A macro to check presence of libuv on the system
AC_DEFUN([AM_CHECK_LIBUV],
[
AC_CHECK_HEADERS([uv.h], [], [AC_MSG_ERROR([Header file uv.h is required.])])
AC_CHECK_LIB([uv], [uv_version], [], [AC_MSG_ERROR([libuv is required.])])
])
......@@ -4,8 +4,6 @@ AM_CPPFLAGS = \
LDADD = \
$(top_builddir)/lib/libknotresolve.la \
$(KNOT_LIBS) \
$(libuv_LIBS) \
$(cmocka_LIBS)
check_PROGRAMS = \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment