diff --git a/Makefile b/Makefile deleted file mode 100644 index 4cd87be..0000000 --- a/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -CFLAGS:=-O2 -Wall -Werror -Wpointer-arith -fPIC $(CFLAGS) -INSTALL_FOLDER:=/lib/x86_64-linux-gnu -VERSION:=2 -LIB_NAME:=libnss_homehosts.so -LIB_NAME_WITH_VERSION:=$(LIB_NAME).$(VERSION) - -.PHONY: all -all: $(LIB_NAME_WITH_VERSION) - -$(LIB_NAME_WITH_VERSION): libnss_homehosts.o - $(CC) $(CFLAGS) -shared -o $@ $< - -libnss_homehosts.o: libnss_homehosts.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: clean -clean: - rm -f $(LIB_NAME) libnss_homehosts.o - -.PHONY: install -install: $(LIB_NAME) - install -m 644 $< $(INSTALL_FOLDER) - rm -f $(INSTALL_FOLDER)/$(LIB_NAME_WITH_VERSION) - ln -s $(LIB_NAME) $(INSTALL_FOLDER)/$(LIB_NAME_WITH_VERSION) - ldconfig -.PHONY: uninstall -uninstall: - rm -f $(INSTALL_FOLDER)/$(LIB_NAME) - rm -f $(INSTALL_FOLDER)/$(LIB_NAME_WITH_VERSION) -.PHONY: test -test: - echo 198.18.1.1 libnss-homehost.test.example.net >> ~/.hosts - getent -s homehosts hosts libnss-homehost.test.example.net - sed -e '/^198.18.1.1 libnss-homehost.test.example.net$/d' -i ~/.hosts diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d4e2f9b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,5 @@ +ACLOCAL_AMFLAGS = -I m4 + +lib_LTLIBRARIES = libnss_homehosts.la +libnss_homehosts_la_SOURCES = libnss_homehosts.c +libnss_homehosts_la_LDFLAGS = $(LT_LDFLAGS) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..5552b53 --- /dev/null +++ b/configure.ac @@ -0,0 +1,41 @@ +AC_PREREQ([2.69]) +AC_INIT([libnss_homehosts], [2.0], [https://github.com/bAndie91/libnss_homehosts/issues], [libnss-homehosts], [https://github.com/bAndie91/libnss_homehosts]) + +AC_CONFIG_SRCDIR([libnss_homehosts.c]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIRS([m4]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LN_S + +AM_INIT_AUTOMAKE([foreign]) +LT_PREREQ([2.4.6]) +LT_INIT + +LT_LDFLAGS="-version-info 2 -no-undefined" + +# Checks for header files. +AC_CHECK_HEADER([arpa/inet.h], [], [AC_MSG_ERROR([Arpa inet header not found])]) +AC_CHECK_HEADER([netdb.h], [], [AC_MSG_ERROR([Netdb header not found])]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_CHECK_HEADER_STDBOOL +AC_TYPE_SIZE_T + +# Checks for library functions. +AC_CHECK_FUNCS([memset strcasecmp strchr]) + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], [enable debug output in homehosts])], + [debug_enabled=$enableval], + [debug_enabled=no]) +if test "x$debug_enabled" != xno; then + AC_DEFINE([DEBUG], [1], [Define to 1 to enable debug mode of homehosts]) +fi + +AC_SUBST(LT_LDFLAGS) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/libnss_homehosts.c b/libnss_homehosts.c index b30c497..2bcfe08 100644 --- a/libnss_homehosts.c +++ b/libnss_homehosts.c @@ -11,6 +11,7 @@ #include #include #include "res_hconf.h" +#include "config.h" struct ipaddr { diff --git a/libnss_homehosts.so b/libnss_homehosts.so deleted file mode 120000 index 53aa53b..0000000 --- a/libnss_homehosts.so +++ /dev/null @@ -1 +0,0 @@ -libnss_homehosts.so.2 \ No newline at end of file