summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-12-05 19:20:08 +0000
committerLennart Poettering <lennart@poettering.net>2004-12-05 19:20:08 +0000
commit9cc3df6a1958c18bee866a6af19661623d6cd71e (patch)
treef63ec3054bd13a27093c8d89dd6d232e84f4fa2b
parent5a12f4f892685adcbbeecbdc406a297152d0dad1 (diff)
port to autotools
git-svn-id: file:///home/lennart/svn/public/nss-mdns/trunk@54 0ee8848e-81ea-0310-a63a-f631d1a40d77
-rw-r--r--Makefile.am42
-rwxr-xr-xbootstrap.sh47
-rw-r--r--configure.ac85
-rw-r--r--src/Makefile28
-rw-r--r--src/Makefile.am45
-rw-r--r--src/nss.c28
-rw-r--r--src/query.c27
-rw-r--r--src/query.h5
8 files changed, 271 insertions, 36 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..c30bfa6
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,42 @@
+# $Id$
+#
+# This file is part of nss-mdns.
+#
+# nss-mdns is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# nss-mdns is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with nss-mdns; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+EXTRA_DIST=bootstrap.sh README LICENSE
+SUBDIRS=src # doc
+
+#MAINTAINERCLEANFILES=README
+#noinst_DATA = README
+
+README:
+ rm -f README
+ $(MAKE) -C doc README
+ cd $(srcdir) && ln -s doc/README README
+
+homepage: all dist doxygen
+ test -d $$HOME/homepage/private
+ mkdir -p $$HOME/homepage/private/projects/nss-mdns $$HOME/homepage/private/projects/nss-mdns/doxygen
+ cp nss-mdns-@PACKAGE_VERSION@.tar.gz $$HOME/homepage/private/projects/nss-mdns
+ cp doc/README.html doc/FAQ.html doc/cli.html doc/daemon.html doc/modules.html doc/style.css $$HOME/homepage/private/projects/nss-mdns
+ cp -a doxygen/html/* $$HOME/homepage/private/projects/nss-mdns/doxygen
+ cp $$HOME/homepage/private/projects/nss-mdns/README.html $$HOME/homepage/private/projects/nss-mdns/index.html
+
+distcleancheck:
+ @:
+
+.PHONY: homepage distcleancheck
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..903c21d
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# $Id$
+
+# This file is part of nss-mdns.
+#
+# nss-mdns is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# nss-mdns is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with nss-mdns; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+run_versioned() {
+ local P
+ type -p "$1-$2" &> /dev/null && P="$1-$2" || local P="$1"
+
+ shift 2
+ "$P" "$@"
+}
+
+if [ "x$1" = "xam" ] ; then
+ set -ex
+ run_versioned automake 1.7 -a -c --foreign
+ ./config.status
+else
+ set -ex
+
+ rm -rf autom4te.cache
+ rm -f config.cache
+
+ run_versioned aclocal 1.7
+ libtoolize -c --force
+ autoheader
+ run_versioned automake 1.7 -a -c --foreign
+ autoconf -Wall
+
+ CFLAGS="-g -O0" ./configure --sysconfdir=/etc "$@"
+
+ make clean
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c54d538
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,85 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# $Id$
+
+# This file is part of nss-mdns.
+#
+# nss-mdns is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# nss-mdns is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with nss-mdns; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+AC_PREREQ(2.57)
+AC_INIT([nss-mdns],[0.1],[mzaffzqaf (at) 0pointer (dot) de])
+AC_CONFIG_SRCDIR([src/query.c])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/nss-mdns/])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+# libtool stuff
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h nss.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_SELECT_ARGTYPES
+AC_CHECK_FUNCS([gethostbyaddr gethostbyname gettimeofday inet_ntoa memset select socket strcspn strdup strerror strncasecmp])
+
+# If using GCC specify some additional parameters
+if test "x$GCC" = "xyes" ; then
+ CFLAGS="$CFLAGS -pipe -W -Wall -pedantic"
+
+ AC_LANG_CONFTEST([int main() {}])
+ $CC -c conftest.c -std=c99 -Wno-unused-parameter $CFLAGS > /dev/null 2> /dev/null && CFLAGS="$CFLAGS -std=c99 -Wno-unused-parameter"
+ rm -f conftest.o
+fi
+
+# LYNX documentation generation
+AC_ARG_ENABLE(lynx,
+ AS_HELP_STRING(--disable-lynx,Turn off lynx usage for documentation generation),
+[case "${enableval}" in
+ yes) lynx=yes ;;
+ no) lynx=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-lynx) ;;
+esac],[lynx=yes])
+
+if test x$lynx = xyes ; then
+ AC_CHECK_PROG(have_lynx, lynx, yes, no)
+
+ if test x$have_lynx = xno ; then
+ AC_MSG_WARN([*** lynx not found, plain text README will not be built ***])
+ fi
+fi
+
+AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
+
+AC_CONFIG_FILES([Makefile src/Makefile]) # doc/Makefile doc/README.html ])
+AC_OUTPUT
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 1b70117..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-CFLAGS=-Wall -fPIC -g -O0 -W -pipe '-DDEBUG_TRAP=__asm__("int $$3")'
-
-all: mdns-test nss-test libnss_mdns.so.2 libnss_mdns6.so.2 libnss_mdns4.so.2
-
-mdns-test: query.o dns.o util.o mdns-test.o
- $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-
-nss-test: nss-test.o
-
-libnss_mdns.so.2: query.o dns.o util.o nss.o
- $(CC) -shared -o $@ -Wl,-soname,$@ $^
-
-libnss_mdns4.so.2: query.o dns.o util.o nss4.o
- $(CC) -shared -o $@ -Wl,-soname,$@ $^
-
-libnss_mdns6.so.2: query.o dns.o util.o nss6.o
- $(CC) -shared -o $@ -Wl,-soname,$@ $^
-
-nss6.o: nss.c
- $(CC) $(CFLAGS) -DNSS_IPV6_ONLY=1 -c -o $@ $<
-
-nss4.o: nss.c
- $(CC) $(CFLAGS) -DNSS_IPV4_ONLY=1 -c -o $@ $<
-
-*.o: *.h
-
-clean:
- rm -f *.o mdns-test *.so.2 nss-test
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..dc2513c
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,45 @@
+# $Id$
+#
+# This file is part of nss-mdns.
+#
+# nss-mdns is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# nss-mdns is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with nss-mdns; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA.
+
+rootlibdir=/
+
+AM_CFLAGS=-D_GNU_SOURCE
+
+# This cool debug trap works on i386/gcc only
+AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")'
+
+noinst_PROGRAMS = nss-test mdns-test
+
+rootlib_LTLIBRARIES = libnss_mdns.la libnss_mdns4.la libnss_mdns6.la
+
+mdns_test_SOURCES = query.c dns.c util.c mdns-test.c
+
+nss_test_SOURCES = nss-test.c
+
+libnss_mdns_la_SOURCES = query.c dns.c util.c nss.c
+libnss_mdns_la_CFLAGS=$(AM_CFLAGS)
+libnss_mdns_la_LDFLAGS=-avoid-version -module -export-dynamic -shrext .so.2
+
+libnss_mdns4_la_SOURCES=$(libnss_mdns_la_SOURCES)
+libnss_mdns4_la_CFLAGS=$(libnss_mdns_la_CFLAGS) -DNSS_IPV4_ONLY=1
+libnss_mdns4_la_LDFLAGS=$(libnss_mdns_la_LDFLAGS)
+
+libnss_mdns6_la_SOURCES=$(libnss_mdns_la_SOURCES)
+libnss_mdns6_la_CFLAGS=$(libnss_mdns_la_CFLAGS) -DNSS_IPV6_ONLY=1
+libnss_mdns6_la_LDFLAGS=$(libnss_mdns_la_LDFLAGS)
diff --git a/src/nss.c b/src/nss.c
index 0515b2d..b9e69e9 100644
--- a/src/nss.c
+++ b/src/nss.c
@@ -30,6 +30,7 @@ struct userdata {
} data;
};
+#ifndef NSS_IPV6_ONLY
static void ipv4_callback(const ipv4_address_t *ipv4, void *userdata) {
struct userdata *u = userdata;
assert(ipv4 && userdata);
@@ -40,7 +41,9 @@ static void ipv4_callback(const ipv4_address_t *ipv4, void *userdata) {
u->data.ipv4[u->count++] = *ipv4;
u->data_len += sizeof(ipv4_address_t);
}
+#endif
+#ifndef NSS_IPV4_ONLY
static void ipv6_callback(const ipv6_address_t *ipv6, void *userdata) {
struct userdata *u = userdata;
assert(ipv6 && userdata);
@@ -51,6 +54,7 @@ static void ipv6_callback(const ipv6_address_t *ipv6, void *userdata) {
u->data.ipv6[u->count++] = *ipv6;
u->data_len += sizeof(ipv6_address_t);
}
+#endif
static void name_callback(const char*name, void *userdata) {
struct userdata *u = userdata;
@@ -76,6 +80,8 @@ enum nss_status _nss_mdns_gethostbyname2_r(
enum nss_status status = NSS_STATUS_UNAVAIL;
int fd = -1, r, i;
size_t address_length, l, index, astart;
+ void (*ipv4_func)(const ipv4_address_t *ipv4, void *userdata);
+ void (*ipv6_func)(const ipv6_address_t *ipv6, void *userdata);
/* DEBUG_TRAP; */
@@ -113,8 +119,20 @@ enum nss_status _nss_mdns_gethostbyname2_r(
u.count = 0;
u.data_len = 0;
+
+#ifndef NSS_IPV6_ONLY
+ ipv4_func = af == AF_INET ? ipv4_callback : NULL;
+#else
+ ipv4_func = NULL;
+#endif
+
+#ifndef NSS_IPV4_ONLY
+ ipv6_func = af == AF_INET6 ? ipv6_callback : NULL;
+#else
+ ipv6_func = NULL;
+#endif
- if ((r = mdns_query_name(fd, name, af == AF_INET ? ipv4_callback : NULL, af == AF_INET6 ? ipv6_callback : NULL, &u)) < 0) {
+ if ((r = mdns_query_name(fd, name, ipv4_func, ipv6_func, &u)) < 0) {
*errnop = ETIMEDOUT;
*h_errnop = HOST_NOT_FOUND;
goto finish;
@@ -240,10 +258,18 @@ enum nss_status _nss_mdns_gethostbyaddr_r(
goto finish;
}
+#if ! defined(NSS_IPV6_ONLY) && ! defined(NSS_IPV4_ONLY)
if (af == AF_INET)
+#endif
+#ifndef NSS_IPV6_ONLY
r = mdns_query_ipv4(fd, (ipv4_address_t*) addr, name_callback, &u);
+#endif
+#if ! defined(NSS_IPV6_ONLY) && ! defined(NSS_IPV4_ONLY)
else
+#endif
+#ifndef NSS_IPV4_ONLY
r = mdns_query_ipv6(fd, (ipv6_address_t*) addr, name_callback, &u);
+#endif
if (r < 0) {
*errnop = ETIMEDOUT;
diff --git a/src/query.c b/src/query.c
index 5673c3e..441f1d8 100644
--- a/src/query.c
+++ b/src/query.c
@@ -192,6 +192,7 @@ static int send_name_query(int fd, const char *name, int query_ipv4, int query_i
dns_packet_set_field(p, DNS_FIELD_FLAGS, DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+#ifndef NSS_IP6_ONLY
if (query_ipv4) {
if (!(prev_name = dns_packet_append_name(p, name))) {
fprintf(stderr, "Bad host name\n");
@@ -202,7 +203,9 @@ static int send_name_query(int fd, const char *name, int query_ipv4, int query_i
dns_packet_append_uint16(p, DNS_CLASS_IN);
qdcount++;
}
-
+#endif
+
+#ifndef NSS_IP4_ONLY
if (query_ipv6) {
if (!dns_packet_append_name_compressed(p, name, prev_name)) {
fprintf(stderr, "Bad host name\n");
@@ -213,7 +216,8 @@ static int send_name_query(int fd, const char *name, int query_ipv4, int query_i
dns_packet_append_uint16(p, DNS_CLASS_IN);
qdcount++;
}
-
+#endif
+
dns_packet_set_field(p, DNS_FIELD_QDCOUNT, qdcount);
if (send_dns_packet(fd, p) < 0)
@@ -287,6 +291,7 @@ static int process_name_response(int fd, const char *name, usec_t timeout, void
/* Remove mDNS cache flush bit */
class &= ~0x8000;
+#ifndef NSS_IPV6_ONLY
if (ipv4_func &&
type == DNS_TYPE_A &&
class == DNS_CLASS_IN &&
@@ -301,7 +306,13 @@ static int process_name_response(int fd, const char *name, usec_t timeout, void
ipv4_func(&ipv4, userdata);
done = 1;
- } else if (ipv6_func &&
+ }
+#endif
+#if ! defined(NSS_IPV6_ONLY) && ! defined(NSS_IPV4_ONLY)
+ else
+#endif
+#ifndef NSS_IPV4_ONLY
+ if (ipv6_func &&
type == DNS_TYPE_AAAA &&
class == DNS_CLASS_IN &&
!domain_cmp(name, pname) &&
@@ -314,7 +325,9 @@ static int process_name_response(int fd, const char *name, usec_t timeout, void
ipv6_func(&ipv6, userdata);
done = 1;
- } else {
+ }
+#endif
+ else {
/* Step over */
@@ -486,7 +499,7 @@ static int query_reverse(int fd, const char *name, void (*name_func)(const char
return -1;
}
-
+#ifndef NSS_IPV6_ONLY
int mdns_query_ipv4(int fd, const ipv4_address_t *ipv4, void (*name_func)(const char *name, void *userdata), void *userdata) {
char name[256];
uint32_t a;
@@ -497,7 +510,9 @@ int mdns_query_ipv4(int fd, const ipv4_address_t *ipv4, void (*name_func)(const
return query_reverse(fd, name, name_func, userdata);
}
+#endif
+#ifndef NSS_IPV4_ONLY
int mdns_query_ipv6(int fd, const ipv6_address_t *ipv6, void (*name_func)(const char *name, void *userdata), void *userdata) {
char name[256];
assert(fd >= 0 && ipv6 && name_func);
@@ -538,4 +553,4 @@ int mdns_query_ipv6(int fd, const ipv6_address_t *ipv6, void (*name_func)(const
return query_reverse(fd, name, name_func, userdata);
}
-
+#endif
diff --git a/src/query.h b/src/query.h
index 0c22c49..2d77912 100644
--- a/src/query.h
+++ b/src/query.h
@@ -19,14 +19,17 @@ int mdns_query_name(int fd,
void (*ipv6_func)(const ipv6_address_t *ipv6, void *userdata),
void *userdata);
+#ifndef NSS_IPV6_ONLY
int mdns_query_ipv4(int fd,
const ipv4_address_t *ipv4,
void (*name_func)(const char *name, void *userdata),
void *userdata);
-
+#endif
+#ifndef NSS_IPV4_ONLY
int mdns_query_ipv6(int fd,
const ipv6_address_t *ipv6,
void (*name_func)(const char *name, void *userdata),
void *userdata);
+#endif
#endif