-# Standard installation pathnames
+# Copyright 2007 NLnet Labs
# See the file LICENSE for the license
+#
+# Standard installation pathnames
+
+QUIET=yes
+ifeq "$(QUIET)" "yes"
+ Q=@
+ INFO=@echo
+else
+ Q=
+ INFO=@:
+endif
+
SHELL=@SHELL@
VERSION=@PACKAGE_VERSION@
srcdir=@srcdir@
RUNTIME_PATH=@RUNTIME_PATH@
DATE=$(shell date +%Y%m%d)
LIBTOOL=$(libtool)
+ifeq "$(QUIET)" "yes"
+ LIBTOOL+=--quiet
+endif
BUILD=build/
LINT=splint
INSTALL=$(srcdir)/install-sh
-COMMON_SRC=$(wildcard *.c)
+COMMON_SRC=$(wildcard services/*.c util/*.c)
COMMON_OBJ=$(addprefix $(BUILD),$(COMMON_SRC:.c=.o) $(LIBOBJS))
-ALL_SOURCES=$(COMMON_SRC)
+UNITTEST_SRC=$(wildcard testcode/*.c)
+UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o))
+DAEMON_SRC=$(wildcard daemon/*.c)
+DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o))
+ALL_SRC=$(COMMON_SRC) $(UNITTEST_SRC) $(DAEMON_SRC)
+ALL_OBJ=$(addprefix $(BUILD),$(ALL_SRC:.c=.o) $(LIBOBJS))
COMPILE=$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
LINK=$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS)
LINK_LIB=$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -release $(VERSION)
$(BUILD)%.o: $(srcdir)/%.c
- @if test ! -d $(BUILD); then mkdir $(BUILD); fi
- $(COMPILE) -c $< -o $@
+ $(INFO) Build $<
+ @if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
+ $Q$(COMPILE) -c $< -o $@
.PHONY: clean realclean doc lint all
-all: $(COMMON_OBJ) main
+all: $(COMMON_OBJ) unbound unittest
+
+unbound: $(COMMON_OBJ) $(DAEMON_OBJ)
+ $(INFO) Link $@
+ $Q$(LINK) -o $@ $^
-main: $(COMMON_OBJ)
- $(LINK) -o $@ $<
+unittest: $(COMMON_OBJ) $(UNITTEST_OBJ)
+ $(INFO) Link $@
+ $Q$(LINK) -o $@ $^
clean:
rm -f *.o *.d *.lo *~ tags
rm -f Makefile
lint:
- for i in $(SOURCES); do \
+ for i in $(ALL_SRC); do \
$(LINT) $(LINTFLAGS) -I. -I$(srcdir) $(srcdir)/$$i ; \
if [ $$? -ne 0 ] ; then exit 1 ; fi ; \
done
# Automatic dependencies.
$(BUILD)%.d: $(srcdir)/%.c
- @if test ! -d $(BUILD); then mkdir $(BUILD); fi
- $(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
+ $(INFO) Depend $<
+ @if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
+ $Q$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
| sed '\''s!\(.*\)\.o[ :]*!$(dir $@)\1.o $@ : !g'\'' > $@; \
[ -s $@ ] || rm -f $@'
--include $(addprefix $(BUILD),$(ALL_SOURCES:.c=.d))
+-include $(addprefix $(BUILD),$(ALL_SRC:.c=.d))
AC_CHECK_LIB(ldns, ldns_rr_new,, [AC_MSG_ERROR([Can't find ldns library])])
+AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.])
+
AH_BOTTOM([
#include <stdio.h>
#include <string.h>
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
+
+#ifdef HAVE_ATTR_FORMAT
+# define ATTR_FORMAT(archetype, string_index, first_to_check) \
+ __attribute__ ((format (archetype, string_index, first_to_check)))
+#else /* !HAVE_ATTR_FORMAT */
+# define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
+#endif /* !HAVE_ATTR_FORMAT */
+#if defined(__cplusplus)
+# define ATTR_UNUSED(x)
+#elif defined(HAVE_ATTR_UNUSED)
+# define ATTR_UNUSED(x) x __attribute__((unused))
+#else /* !HAVE_ATTR_UNUSED */
+# define ATTR_UNUSED(x) x
+#endif /* !HAVE_ATTR_UNUSED */
+
])
AC_CONFIG_FILES([Makefile])
--- /dev/null
+/*
+ * daemon/unbound.c - main program for unbound DNS resolver daemon.
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+#include "config.h"
+#include "util/log.h"
+
+int
+main(int argc, char* argv[])
+{
+ if(argc != 1) {
+ printf("usage: %s\n", argv[0]);
+ printf("\tstart unbound daemon DNS resolver.\n");
+ return 1;
+ }
+ log_init();
+ log_info("Start of %s.", PACKAGE_STRING);
+ return 0;
+}
You need a ssh login. There is no https access yet.
- Added LICENSE, the BSD license.
- Added doc/README with compile help.
+ - main program stub and quiet makefile.
+ - minimal logging service (to stderr).
15 December 2006: Wouter
- Created Makefile.in and configure.ac.
--- /dev/null
+/*
+ * testcode/unitmain.c - unit test main program for unbound.
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+#include "config.h"
+
+int main(int argc, char* argv[])
+{
+ if(argc != 1) {
+ printf("usage: %s\n", argv[0]);
+ printf("\tperforms unit tests.\n");
+ return 1;
+ }
+ printf("Start of %s unit test.\n", PACKAGE_STRING);
+ return 0;
+}
--- /dev/null
+/*
+ * util/log.c - implementation of the log code
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+#include "config.h"
+#include "util/log.h"
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+
+void
+log_init()
+{
+}
+
+void
+log_vmsg(const char *format, va_list args)
+{
+ char message[MAXSYSLOGMSGLEN];
+ const char* ident="unbound";
+ vsnprintf(message, sizeof(message), format, args);
+ fprintf(stderr, "[%d] %s[%d]: %s\n",
+ (int)time(NULL), ident, (int)getpid(), message);
+}
+
+void
+log_info(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ log_vmsg(format, args);
+ va_end(args);
+}
--- /dev/null
+/*
+ * util/log.h - logging service
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+#ifndef UTIL_LOG_H
+#define UTIL_LOG_H
+
+#include "config.h"
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
+/**
+ * call this to initialize logging services
+ */
+void log_init();
+
+/**
+ * Pass printf formatted arguments. No trailing newline is needed.
+ */
+void log_info(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
+
+/**
+ * va_list argument version of log_info.
+ */
+void log_vmsg(const char *format, va_list args);
+
+#endif /* UTIL_LOG_H */