]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - Makefile.am
importer: Drop EDROP as it has been merged into DROP
[people/ms/libloc.git] / Makefile.am
index d0cc793948d78b93cbbe6eb9f19420866cc2eab0..b045e49e3d83aaaffed9695bb3d8229b04ee7672 100644 (file)
@@ -3,6 +3,7 @@ CLEANFILES =
 INSTALL_DIRS =
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 AM_MAKEFLAGS = --no-print-directory
+check_SCRIPTS =
 
 SUBDIRS = . po
 BINDINGS =
@@ -13,6 +14,8 @@ if ENABLE_PERL
 BINDINGS += perl
 endif
 
+bashcompletiondir = @bashcompletiondir@
+
 AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
@@ -22,7 +25,7 @@ AM_CFLAGS = ${my_CFLAGS} \
        -ffunction-sections \
        -fdata-sections
 
-AM_LDFLAGS =
+AM_LDFLAGS = ${my_LDFLAGS}
 
 # leaving a space here to work around automake's conditionals
  ifeq ($(OS),Darwin)
@@ -34,7 +37,7 @@ AM_LDFLAGS =
  endif
 
 LIBLOC_CURRENT=1
-LIBLOC_REVISION=0
+LIBLOC_REVISION=3
 LIBLOC_AGE=0
 
 DISTCHECK_CONFIGURE_FLAGS = \
@@ -51,6 +54,7 @@ SED_PROCESS = \
        -e 's,@databasedir\@,$(databasedir),g' \
        < $< > $@ || rm $@
 
+cron_dailydir = $(sysconfdir)/cron.daily
 databasedir = $(localstatedir)/lib/location
 pkgconfigdir = $(libdir)/pkgconfig
 
@@ -79,36 +83,41 @@ update-po: po/POTFILES.in
        $(MAKE) -C po update-po
 
 po/POTFILES.in: Makefile
-       find $(abs_srcdir)/src | \
-               grep -E "\.(in|py)$$" | sed -e "s@$(abs_srcdir)/@@g" | sort > $@
+       find $(abs_srcdir)/src -type f \( -name '*.in' -o -name '*.py' \) \
+               \! -exec git check-ignore -q {} \; -print | \
+               sed -e "s@$(abs_srcdir)/@@g" | LC_ALL=C sort > $@
 
 EXTRA_DIST += \
+       README.md \
        examples/private-key.pem \
        examples/public-key.pem \
        examples/python/create-database.py \
        examples/python/read-database.py
 
 pkginclude_HEADERS = \
-       src/loc/libloc.h \
-       src/loc/as.h \
-       src/loc/as-list.h \
-       src/loc/compat.h \
-       src/loc/country.h \
-       src/loc/country-list.h \
-       src/loc/database.h \
-       src/loc/format.h \
-       src/loc/network.h \
-       src/loc/network-list.h \
-       src/loc/private.h \
-       src/loc/stringpool.h \
-       src/loc/resolv.h \
-       src/loc/writer.h
+       src/libloc/libloc.h \
+       src/libloc/address.h \
+       src/libloc/as.h \
+       src/libloc/as-list.h \
+       src/libloc/compat.h \
+       src/libloc/country.h \
+       src/libloc/country-list.h \
+       src/libloc/database.h \
+       src/libloc/format.h \
+       src/libloc/network.h \
+       src/libloc/network-list.h \
+       src/libloc/network-tree.h \
+       src/libloc/private.h \
+       src/libloc/stringpool.h \
+       src/libloc/resolv.h \
+       src/libloc/writer.h
 
 lib_LTLIBRARIES = \
        src/libloc.la
 
 src_libloc_la_SOURCES = \
        src/libloc.c \
+       src/address.c \
        src/as.c \
        src/as-list.c \
        src/country.c \
@@ -116,6 +125,7 @@ src_libloc_la_SOURCES = \
        src/database.c \
        src/network.c \
        src/network-list.c \
+       src/network-tree.c \
        src/resolv.c \
        src/stringpool.c \
        src/writer.c
@@ -144,6 +154,24 @@ src_libloc_la_LIBADD = \
 src_libloc_la_DEPENDENCIES = \
        ${top_srcdir}/src/libloc.sym
 
+noinst_LTLIBRARIES = \
+       src/libloc-internal.la
+
+src_libloc_internal_la_SOURCES = \
+       $(src_libloc_la_SOURCES)
+
+src_libloc_internal_la_CFLAGS = \
+       $(src_libloc_la_CFLAGS)
+
+src_libloc_internal_la_LDFLAGS = \
+       $(filter-out -version-info %,$(src_libloc_la_LDFLAGS))
+
+src_libloc_internal_la_LIBADD = \
+       $(src_libloc_la_LIBADD)
+
+src_libloc_internal_la_DEPENDENCIES = \
+       $(src_libloc_la_DEPENDENCIES)
+
 pkgconfig_DATA = \
        src/libloc.pc
 
@@ -153,22 +181,21 @@ EXTRA_DIST += \
 CLEANFILES += \
        src/libloc.pc
 
-dist_pkgpython_PYTHON = \
-       src/python/database.py \
-       src/python/downloader.py \
-       src/python/export.py \
-       src/python/i18n.py \
-       src/python/importer.py \
-       src/python/logger.py
-
-pkgpython_PYTHON = \
-       src/python/__init__.py
+if BUILD_BASH_COMPLETION
+bashcompletion_DATA = \
+       bash-completion/location
+endif
 
 EXTRA_DIST += \
-       src/python/__init__.py.in
+       bash-completion/location
 
-CLEANFILES += \
-       src/python/__init__.py
+dist_pkgpython_PYTHON = \
+       src/python/location/__init__.py \
+       src/python/location/database.py \
+       src/python/location/downloader.py \
+       src/python/location/export.py \
+       src/python/location/i18n.py \
+       src/python/location/logger.py
 
 pyexec_LTLIBRARIES = \
        src/python/_location.la
@@ -201,6 +228,63 @@ src_python__location_la_LIBADD = \
        src/libloc.la \
        $(PYTHON_LIBS)
 
+# ------------------------------------------------------------------------------
+
+if ENABLE_LUA
+lua_LTLIBRARIES = \
+       src/lua/location.la
+
+luadir = $(LUA_INSTALL_CMOD)
+
+src_lua_location_la_SOURCES = \
+       src/lua/as.c \
+       src/lua/as.h \
+       src/lua/compat.h \
+       src/lua/country.c \
+       src/lua/country.h \
+       src/lua/database.c \
+       src/lua/database.h \
+       src/lua/location.c \
+       src/lua/location.h \
+       src/lua/network.c \
+       src/lua/network.h
+
+src_lua_location_la_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(LUA_CFLAGS)
+
+src_lua_location_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       $(LUA_LDFLAGS) \
+       -shared \
+       -module \
+       -avoid-version
+
+src_lua_location_la_LIBADD = \
+       src/libloc.la \
+       $(LUA_LIBS)
+endif
+
+EXTRA_DIST += \
+       src/lua/as.c \
+       src/lua/as.h \
+       src/lua/country.c \
+       src/lua/country.h \
+       src/lua/database.c \
+       src/lua/database.h \
+       src/lua/location.c \
+       src/lua/location.h \
+       src/lua/network.c \
+       src/lua/network.h
+
+LUA_TESTS = \
+       tests/lua/main.lua
+
+EXTRA_DIST += \
+       $(LUA_TESTS)
+
+# ------------------------------------------------------------------------------
+
 # Compile & install bindings
 all-local: $(foreach binding,$(BINDINGS),build-$(binding))
 check-local: $(foreach binding,$(BINDINGS),check-$(binding))
@@ -218,8 +302,7 @@ EXTRA_DIST += \
        src/perl/t/Location.t \
        src/perl/typemap
 
-.PHONY: build-perl
-build-perl:
+build-perl: src/libloc.la
        @mkdir -p $(builddir)/src/perl/{lib,t}
        @test -e $(builddir)/src/perl/Location.xs || ln -s --relative $(srcdir)/src/perl/Location.xs $(builddir)/src/perl/
        @test -e $(builddir)/src/perl/MANIFEST || ln -s --relative $(srcdir)/src/perl/MANIFEST $(builddir)/src/perl/
@@ -228,45 +311,49 @@ build-perl:
        @test -e $(builddir)/src/perl/t/Location.t || ln -s --relative $(srcdir)/src/perl/t/Location.t $(builddir)/src/perl/t/
        @test -e $(builddir)/src/perl/typemap || ln -s --relative $(srcdir)/src/perl/typemap $(builddir)/src/perl/
 
-       cd $(builddir)/src/perl && $(PERL) Makefile.PL PREFIX="$(prefix)" \
+       cd $(builddir)/src/perl && $(PERL) Makefile.PL NO_PACKLIST=1 NO_PERLLOCAL=1 \
+               INSTALLDIRS=vendor \
                INC="-I$(abs_srcdir)/src" LIBS="-L$(abs_builddir)/src/.libs -lloc"
-       cd $(builddir)/src/perl && $(MAKE) CC="$(CC)" LD="$(LD)" LD_RUN_PATH=
+       cd $(builddir)/src/perl && $(MAKE)
+       touch build-perl
 
 .PHONY: check-perl
-check-perl: testdata.db
+check-perl: testdata.db build-perl
        cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test \
                database="../../$<" keyfile="$(abs_srcdir)/examples/public-key.pem"
 
 .PHONY: install-perl
-install-perl:
-       cd $(builddir)/src/perl && $(MAKE) install
+install-perl: build-perl
+       cd $(builddir)/src/perl && $(MAKE) install DESTDIR=$(DESTDIR)
 
 .PHONY: clean-perl
 clean-perl:
        cd $(builddir)/src/perl && $(MAKE) distclean
+       rm -f build-perl
 
 .PHONY: uninstall-perl
 uninstall-perl:
-       rm -rvf \
-               $(DESTDIR)/$(prefix)/lib/*/perl/*/Location.pm \
-               $(DESTDIR)/$(prefix)/lib/*/perl/*/auto/Location \
-               $(DESTDIR)/$(prefix)/lib/*/perl/*/perllocal.pod \
-               $(DESTDIR)/$(prefix)/man/man3/Location.3pm
+       rm -vf \
+               $(DESTDIR)/@PERL_MODPATH@/Location.pm \
+               $(DESTDIR)/@PERL_MODPATH@/auto/Location/Location.so \
+               $(DESTDIR)/@PERL_MANPATH@/Location.3pm
+       -rmdir $(DESTDIR)/@PERL_MODPATH@/auto/Location
 
 bin_SCRIPTS = \
-       src/python/location \
-       src/python/location-importer
+       src/scripts/location \
+       src/scripts/location-importer
 
 EXTRA_DIST += \
-       src/python/location.in \
-       src/python/location-importer.in
+       src/scripts/location.in \
+       src/scripts/location-importer.in
 
 CLEANFILES += \
-       src/python/location \
-       src/python/location-importer
+       src/scripts/location \
+       src/scripts/location-importer
 
 # ------------------------------------------------------------------------------
 
+# Use systemd timers if available
 if HAVE_SYSTEMD
 systemdsystemunit_DATA = \
        src/systemd/location-update.service \
@@ -277,16 +364,33 @@ CLEANFILES += \
 
 INSTALL_DIRS += \
        $(systemdsystemunitdir)
+
+# Otherwise fall back to cron
+else
+cron_daily_SCRIPTS = \
+       src/cron/location-update
+
+CLEANFILES += \
+       $(cron_daily_DATA)
 endif
 
 EXTRA_DIST += \
+       src/cron/location-update.in \
        src/systemd/location-update.service.in \
        src/systemd/location-update.timer.in
 
 # ------------------------------------------------------------------------------
 
 dist_database_DATA = \
-       src/signing-key.pem
+       data/database.db \
+       data/signing-key.pem
+
+install-data-hook:
+       chmod 444 $(DESTDIR)$(databasedir)/database.db
+
+.PHONY: update-database
+update-database:
+       curl https://location.ipfire.org/databases/1/location.db.xz | xz -d > data/database.db
 
 # ------------------------------------------------------------------------------
 
@@ -295,31 +399,52 @@ TESTS_CFLAGS = \
        -DLIBLOC_PRIVATE \
        -DABS_SRCDIR=\"$(abs_srcdir)\"
 
+TESTS_LDADD = \
+       src/libloc.la \
+       src/libloc-internal.la
+
+TESTS_ENVIRONMENT = \
+       LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" \
+       LUA_CPATH="$(abs_builddir)/src/lua/.libs/?.so;;" \
+       PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
+       TEST_DATA_DIR="$(abs_top_srcdir)/data" \
+       TEST_DATABASE="$(abs_top_srcdir)/data/database.db" \
+       TEST_SIGNING_KEY="$(abs_top_srcdir)/data/signing-key.pem"
+
 TESTS = \
-       src/test-libloc \
-       src/test-stringpool \
-       src/test-database \
-       src/test-as \
-       src/test-network \
-       src/test-country \
-       src/test-signature
+       $(check_PROGRAMS) \
+       $(check_SCRIPTS) \
+       $(dist_check_SCRIPTS)
 
 CLEANFILES += \
        testdata.db
 
 testdata.db: examples/python/create-database.py
-       PYTHONPATH=$(abs_builddir)/src/python/.libs \
+       PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
        ABS_SRCDIR="$(abs_srcdir)" \
                $(PYTHON) $< $@
 
+dist_check_SCRIPTS = \
+       tests/python/country.py \
+       tests/python/networks-dedup.py \
+       tests/python/test-database.py \
+       tests/python/test-export.py
+
+if ENABLE_LUA
+check_SCRIPTS += \
+       $(LUA_TESTS)
+endif
+
 check_PROGRAMS = \
        src/test-libloc \
        src/test-stringpool \
        src/test-database \
        src/test-as \
        src/test-network \
+       src/test-network-list \
        src/test-country \
-       src/test-signature
+       src/test-signature \
+       src/test-address
 
 src_test_libloc_SOURCES = \
        src/test-libloc.c
@@ -328,7 +453,7 @@ src_test_libloc_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_libloc_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
 
 src_test_as_SOURCES = \
        src/test-as.c
@@ -337,7 +462,7 @@ src_test_as_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_as_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
 
 src_test_country_SOURCES = \
        src/test-country.c
@@ -346,7 +471,7 @@ src_test_country_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_country_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
 
 src_test_network_SOURCES = \
        src/test-network.c
@@ -355,7 +480,16 @@ src_test_network_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_network_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
+
+src_test_network_list_SOURCES = \
+       src/test-network-list.c
+
+src_test_network_list_CFLAGS = \
+       $(TESTS_CFLAGS)
+
+src_test_network_list_LDADD = \
+       $(TESTS_LDADD)
 
 src_test_stringpool_SOURCES = \
        src/test-stringpool.c
@@ -364,7 +498,7 @@ src_test_stringpool_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_stringpool_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
 
 src_test_database_SOURCES = \
        src/test-database.c
@@ -373,7 +507,7 @@ src_test_database_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_database_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
 
 src_test_signature_SOURCES = \
        src/test-signature.c
@@ -382,21 +516,48 @@ src_test_signature_CFLAGS = \
        $(TESTS_CFLAGS)
 
 src_test_signature_LDADD = \
-       src/libloc.la
+       $(TESTS_LDADD)
+
+src_test_address_SOURCES = \
+       src/test-address.c
+
+src_test_address_CFLAGS = \
+       $(TESTS_CFLAGS)
+
+src_test_address_LDADD = \
+       $(TESTS_LDADD)
 
 # ------------------------------------------------------------------------------
 
 MANPAGES = \
-       man/location.8
-
-MANPAGES_TXT  = $(patsubst %.8,%.txt,$(MANPAGES))
-MANPAGES_HTML = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
-MANPAGES_XML  = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
+       $(MANPAGES_3) \
+       $(MANPAGES_1)
+
+MANPAGES_3 = \
+       man/libloc.3 \
+       man/loc_database_count_as.3 \
+       man/loc_database_get_as.3 \
+       man/loc_database_get_country.3 \
+       man/loc_database_lookup.3 \
+       man/loc_database_new.3 \
+       man/loc_get_log_priority.3 \
+       man/loc_new.3 \
+       man/loc_set_log_fn.3 \
+       man/loc_set_log_priority.3
+
+MANPAGES_1 = \
+       man/location.1
+
+MANPAGES_TXT   = $(MANPAGES_TXT_3) $(MANPAGES_TXT_1)
+MANPAGES_TXT_3 = $(patsubst %.3,%.txt,$(MANPAGES_3))
+MANPAGES_TXT_1 = $(patsubst %.1,%.txt,$(MANPAGES_1))
+MANPAGES_HTML  = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
+MANPAGES_XML   = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
 
 .PHONY: man
 man: $(MANPAGES) $(MANPAGES_HTML)
 
-if ENABLE_MANPAGES
+if ENABLE_MAN_PAGES
 man_MANS = \
        $(MANPAGES)
 endif
@@ -434,7 +595,10 @@ man/%.xml: man/%.txt man/asciidoc.conf
                -f $(abs_srcdir)/man/asciidoc.conf \
                -d manpage -b docbook -o $@ $<
 
-man/%.8: man/%.xml
+man/%.3: man/%.xml
+       $(XSLTPROC_COMMAND_MAN)
+
+man/%.1: man/%.xml
        $(XSLTPROC_COMMAND_MAN)
 
 man/%.html: man/%.txt man/asciidoc.conf
@@ -447,19 +611,27 @@ man/%.html: man/%.txt man/asciidoc.conf
 upload-man: $(MANPAGES_HTML)
        rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
 
+EXTRA_DIST += \
+       tools/copy.py
+
 EXTRA_DIST += \
        debian/build.sh \
        debian/changelog \
-       debian/compat \
        debian/control \
        debian/copyright \
-       debian/location.install \
-       debian/location.manpages \
-       debian/location-python.install \
+       debian/genchangelog.sh \
+       debian/gensymbols.sh \
        debian/libloc1.install \
+       debian/libloc1.symbols \
        debian/libloc-dev.install \
+       debian/location.install \
+       debian/location.postinst \
+       debian/location.postrm \
+       debian/python3-location.examples \
+       debian/python3-location.install \
        debian/rules \
-       debian/source/format
+       debian/source/format \
+       debian/watch
 
 .PHONY: debian
 debian: dist