]> git.ipfire.org Git - location/libloc.git/blob - Makefile.am
lua: Add a Database object with a dummy lookup function
[location/libloc.git] / Makefile.am
1 EXTRA_DIST =
2 CLEANFILES =
3 INSTALL_DIRS =
4 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
5 AM_MAKEFLAGS = --no-print-directory
6 check_SCRIPTS =
7
8 SUBDIRS = . po
9 BINDINGS =
10
11 OS = $(shell uname -s)
12
13 if ENABLE_PERL
14 BINDINGS += perl
15 endif
16
17 bashcompletiondir = @bashcompletiondir@
18
19 AM_CPPFLAGS = \
20 -include $(top_builddir)/config.h \
21 -DSYSCONFDIR=\""$(sysconfdir)"\" \
22 -I${top_srcdir}/src
23
24 AM_CFLAGS = ${my_CFLAGS} \
25 -ffunction-sections \
26 -fdata-sections
27
28 AM_LDFLAGS = ${my_LDFLAGS}
29
30 # leaving a space here to work around automake's conditionals
31 ifeq ($(OS),Darwin)
32 AM_LDFLAGS += -Wl,-dead_strip
33 else
34 AM_LDFLAGS += \
35 -Wl,--as-needed \
36 -Wl,--gc-sections
37 endif
38
39 LIBLOC_CURRENT=1
40 LIBLOC_REVISION=3
41 LIBLOC_AGE=0
42
43 DISTCHECK_CONFIGURE_FLAGS = \
44 --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
45
46 SED_PROCESS = \
47 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
48 -e 's,@VERSION\@,$(VERSION),g' \
49 -e 's,@prefix\@,$(prefix),g' \
50 -e 's,@exec_prefix\@,$(exec_prefix),g' \
51 -e 's,@bindir\@,$(bindir),g' \
52 -e 's,@libdir\@,$(libdir),g' \
53 -e 's,@includedir\@,$(includedir),g' \
54 -e 's,@databasedir\@,$(databasedir),g' \
55 < $< > $@ || rm $@
56
57 cron_dailydir = $(sysconfdir)/cron.daily
58 databasedir = $(localstatedir)/lib/location
59 pkgconfigdir = $(libdir)/pkgconfig
60
61 # Overwrite Python path
62 pkgpythondir = $(pythondir)/location
63
64 %: %.in Makefile
65 $(SED_PROCESS)
66
67 @INTLTOOL_POLICY_RULE@
68
69 # ------------------------------------------------------------------------------
70
71 AM_V_ASCIIDOC = $(AM_V_ASCIIDOC_$(V))
72 AM_V_ASCIIDOC_ = $(AM_V_ASCIIDOC_$(AM_DEFAULT_VERBOSITY))
73 AM_V_ASCIIDOC_0 = @echo " ASCIIDOC" $@;
74
75 AM_V_XSLT = $(AM_V_XSLT_$(V))
76 AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
77 AM_V_XSLT_0 = @echo " XSLT " $@;
78
79 # ------------------------------------------------------------------------------
80
81 .PHONY: update-po
82 update-po: po/POTFILES.in
83 $(MAKE) -C po update-po
84
85 po/POTFILES.in: Makefile
86 find $(abs_srcdir)/src -type f \( -name '*.in' -o -name '*.py' \) \
87 \! -exec git check-ignore -q {} \; -print | \
88 sed -e "s@$(abs_srcdir)/@@g" | LC_ALL=C sort > $@
89
90 EXTRA_DIST += \
91 examples/private-key.pem \
92 examples/public-key.pem \
93 examples/python/create-database.py \
94 examples/python/read-database.py
95
96 pkginclude_HEADERS = \
97 src/libloc/libloc.h \
98 src/libloc/address.h \
99 src/libloc/as.h \
100 src/libloc/as-list.h \
101 src/libloc/compat.h \
102 src/libloc/country.h \
103 src/libloc/country-list.h \
104 src/libloc/database.h \
105 src/libloc/format.h \
106 src/libloc/network.h \
107 src/libloc/network-list.h \
108 src/libloc/network-tree.h \
109 src/libloc/private.h \
110 src/libloc/stringpool.h \
111 src/libloc/resolv.h \
112 src/libloc/writer.h
113
114 lib_LTLIBRARIES = \
115 src/libloc.la
116
117 src_libloc_la_SOURCES = \
118 src/libloc.c \
119 src/address.c \
120 src/as.c \
121 src/as-list.c \
122 src/country.c \
123 src/country-list.c \
124 src/database.c \
125 src/network.c \
126 src/network-list.c \
127 src/network-tree.c \
128 src/resolv.c \
129 src/stringpool.c \
130 src/writer.c
131
132 EXTRA_DIST += src/libloc.sym
133
134 src_libloc_la_CFLAGS = \
135 $(AM_CFLAGS) \
136 -DLIBLOC_PRIVATE \
137 -fvisibility=hidden
138
139 src_libloc_la_LDFLAGS = \
140 $(AM_LDFLAGS) \
141 -version-info $(LIBLOC_CURRENT):$(LIBLOC_REVISION):$(LIBLOC_AGE)
142
143 if HAVE_LD_VERSION_SCRIPT
144 src_libloc_la_LDFLAGS += -Wl,--version-script=$(top_srcdir)/src/libloc.sym
145 else
146 src_libloc_la_LDFLAGS += -export-symbols $(top_srcdir)/src/libloc.sym
147 endif
148
149 src_libloc_la_LIBADD = \
150 $(OPENSSL_LIBS) \
151 $(RESOLV_LIBS)
152
153 src_libloc_la_DEPENDENCIES = \
154 ${top_srcdir}/src/libloc.sym
155
156 noinst_LTLIBRARIES = \
157 src/libloc-internal.la
158
159 src_libloc_internal_la_SOURCES = \
160 $(src_libloc_la_SOURCES)
161
162 src_libloc_internal_la_CFLAGS = \
163 $(src_libloc_la_CFLAGS)
164
165 src_libloc_internal_la_LDFLAGS = \
166 $(filter-out -version-info %,$(src_libloc_la_LDFLAGS))
167
168 src_libloc_internal_la_LIBADD = \
169 $(src_libloc_la_LIBADD)
170
171 src_libloc_internal_la_DEPENDENCIES = \
172 $(src_libloc_la_DEPENDENCIES)
173
174 pkgconfig_DATA = \
175 src/libloc.pc
176
177 EXTRA_DIST += \
178 src/libloc.pc.in
179
180 CLEANFILES += \
181 src/libloc.pc
182
183 if BUILD_BASH_COMPLETION
184 bashcompletion_DATA = \
185 bash-completion/location
186 endif
187
188 EXTRA_DIST += \
189 bash-completion/location
190
191 dist_pkgpython_PYTHON = \
192 src/python/location/__init__.py \
193 src/python/location/database.py \
194 src/python/location/downloader.py \
195 src/python/location/export.py \
196 src/python/location/i18n.py \
197 src/python/location/importer.py \
198 src/python/location/logger.py
199
200 pyexec_LTLIBRARIES = \
201 src/python/_location.la
202
203 src_python__location_la_SOURCES = \
204 src/python/locationmodule.c \
205 src/python/locationmodule.h \
206 src/python/as.c \
207 src/python/as.h \
208 src/python/country.c \
209 src/python/country.h \
210 src/python/database.c \
211 src/python/database.h \
212 src/python/network.c \
213 src/python/network.h \
214 src/python/writer.c \
215 src/python/writer.h
216
217 src_python__location_la_CFLAGS = \
218 $(AM_CFLAGS) \
219 $(PYTHON_CFLAGS)
220
221 src_python__location_la_LDFLAGS = \
222 $(AM_LDFLAGS) \
223 -shared \
224 -module \
225 -avoid-version
226
227 src_python__location_la_LIBADD = \
228 src/libloc.la \
229 $(PYTHON_LIBS)
230
231 # ------------------------------------------------------------------------------
232
233 if ENABLE_LUA
234 lua_LTLIBRARIES = \
235 src/lua/location.la
236
237 luadir = $(LUA_INSTALL_CMOD)
238
239 src_lua_location_la_SOURCES = \
240 src/lua/database.c \
241 src/lua/database.h \
242 src/lua/location.c \
243 src/lua/location.h
244
245 src_lua_location_la_CFLAGS = \
246 $(AM_CFLAGS) \
247 $(LUA_CFLAGS)
248
249 src_lua_location_la_LDFLAGS = \
250 $(AM_LDFLAGS) \
251 $(LUA_LDFLAGS) \
252 -shared \
253 -module \
254 -avoid-version
255
256 src_lua_location_la_LIBADD = \
257 src/libloc.la \
258 $(LUA_LIBS)
259 endif
260
261 EXTRA_DIST += \
262 src/lua/database.c \
263 src/lua/database.h \
264 src/lua/location.c \
265 src/lua/location.h
266
267 LUA_TESTS = \
268 tests/lua/main.lua
269
270 EXTRA_DIST += \
271 $(LUA_TESTS)
272
273 # ------------------------------------------------------------------------------
274
275 # Compile & install bindings
276 all-local: $(foreach binding,$(BINDINGS),build-$(binding))
277 check-local: $(foreach binding,$(BINDINGS),check-$(binding))
278 install-exec-local: $(foreach binding,$(BINDINGS),install-$(binding))
279 clean-local: $(foreach binding,$(BINDINGS),clean-$(binding))
280 uninstall-local: $(foreach binding,$(BINDINGS),uninstall-$(binding))
281
282 # Perl Bindings
283 EXTRA_DIST += \
284 src/perl/.gitignore \
285 src/perl/Location.xs \
286 src/perl/MANIFEST \
287 src/perl/Makefile.PL \
288 src/perl/lib/Location.pm \
289 src/perl/t/Location.t \
290 src/perl/typemap
291
292 build-perl: src/libloc.la
293 @mkdir -p $(builddir)/src/perl/{lib,t}
294 @test -e $(builddir)/src/perl/Location.xs || ln -s --relative $(srcdir)/src/perl/Location.xs $(builddir)/src/perl/
295 @test -e $(builddir)/src/perl/MANIFEST || ln -s --relative $(srcdir)/src/perl/MANIFEST $(builddir)/src/perl/
296 @test -e $(builddir)/src/perl/Makefile.PL || ln -s --relative $(srcdir)/src/perl/Makefile.PL $(builddir)/src/perl/
297 @test -e $(builddir)/src/perl/lib/Location.pm || ln -s --relative $(srcdir)/src/perl/lib/Location.pm $(builddir)/src/perl/lib/
298 @test -e $(builddir)/src/perl/t/Location.t || ln -s --relative $(srcdir)/src/perl/t/Location.t $(builddir)/src/perl/t/
299 @test -e $(builddir)/src/perl/typemap || ln -s --relative $(srcdir)/src/perl/typemap $(builddir)/src/perl/
300
301 cd $(builddir)/src/perl && $(PERL) Makefile.PL NO_PACKLIST=1 NO_PERLLOCAL=1 \
302 INSTALLDIRS=vendor \
303 INC="-I$(abs_srcdir)/src" LIBS="-L$(abs_builddir)/src/.libs -lloc"
304 cd $(builddir)/src/perl && $(MAKE)
305 touch build-perl
306
307 .PHONY: check-perl
308 check-perl: testdata.db build-perl
309 cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test \
310 database="../../$<" keyfile="$(abs_srcdir)/examples/public-key.pem"
311
312 .PHONY: install-perl
313 install-perl: build-perl
314 cd $(builddir)/src/perl && $(MAKE) install DESTDIR=$(DESTDIR)
315
316 .PHONY: clean-perl
317 clean-perl:
318 cd $(builddir)/src/perl && $(MAKE) distclean
319 rm -f build-perl
320
321 .PHONY: uninstall-perl
322 uninstall-perl:
323 rm -vf \
324 $(DESTDIR)/@PERL_MODPATH@/Location.pm \
325 $(DESTDIR)/@PERL_MODPATH@/auto/Location/Location.so \
326 $(DESTDIR)/@PERL_MANPATH@/Location.3pm
327 -rmdir $(DESTDIR)/@PERL_MODPATH@/auto/Location
328
329 bin_SCRIPTS = \
330 src/scripts/location \
331 src/scripts/location-importer
332
333 EXTRA_DIST += \
334 src/scripts/location.in \
335 src/scripts/location-importer.in
336
337 CLEANFILES += \
338 src/scripts/location \
339 src/scripts/location-importer
340
341 # ------------------------------------------------------------------------------
342
343 # Use systemd timers if available
344 if HAVE_SYSTEMD
345 systemdsystemunit_DATA = \
346 src/systemd/location-update.service \
347 src/systemd/location-update.timer
348
349 CLEANFILES += \
350 $(systemdsystemunit_DATA)
351
352 INSTALL_DIRS += \
353 $(systemdsystemunitdir)
354
355 # Otherwise fall back to cron
356 else
357 cron_daily_SCRIPTS = \
358 src/cron/location-update
359
360 CLEANFILES += \
361 $(cron_daily_DATA)
362 endif
363
364 EXTRA_DIST += \
365 src/cron/location-update.in \
366 src/systemd/location-update.service.in \
367 src/systemd/location-update.timer.in
368
369 # ------------------------------------------------------------------------------
370
371 dist_database_DATA = \
372 data/database.db \
373 data/signing-key.pem
374
375 install-data-hook:
376 chmod 444 $(DESTDIR)$(databasedir)/database.db
377
378 .PHONY: update-database
379 update-database:
380 curl https://location.ipfire.org/databases/1/location.db.xz | xz -d > data/database.db
381
382 # ------------------------------------------------------------------------------
383
384 TESTS_CFLAGS = \
385 $(AM_CFLAGS) \
386 -DLIBLOC_PRIVATE \
387 -DABS_SRCDIR=\"$(abs_srcdir)\"
388
389 TESTS_LDADD = \
390 src/libloc.la \
391 src/libloc-internal.la
392
393 TESTS_ENVIRONMENT = \
394 LUA_CPATH="$(abs_builddir)/src/lua/.libs/?.so;;" \
395 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
396 TEST_DATA_DIR="$(abs_top_srcdir)/data" \
397 TEST_DATABASE="$(abs_top_srcdir)/data/database.db"
398
399 TESTS = \
400 $(check_PROGRAMS) \
401 $(check_SCRIPTS) \
402 $(dist_check_SCRIPTS)
403
404 CLEANFILES += \
405 testdata.db
406
407 testdata.db: examples/python/create-database.py
408 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
409 ABS_SRCDIR="$(abs_srcdir)" \
410 $(PYTHON) $< $@
411
412 dist_check_SCRIPTS = \
413 tests/python/country.py \
414 tests/python/networks-dedup.py \
415 tests/python/test-database.py \
416 tests/python/test-export.py
417
418 if ENABLE_LUA
419 check_SCRIPTS += \
420 $(LUA_TESTS)
421 endif
422
423 check_PROGRAMS = \
424 src/test-libloc \
425 src/test-stringpool \
426 src/test-database \
427 src/test-as \
428 src/test-network \
429 src/test-network-list \
430 src/test-country \
431 src/test-signature \
432 src/test-address
433
434 src_test_libloc_SOURCES = \
435 src/test-libloc.c
436
437 src_test_libloc_CFLAGS = \
438 $(TESTS_CFLAGS)
439
440 src_test_libloc_LDADD = \
441 $(TESTS_LDADD)
442
443 src_test_as_SOURCES = \
444 src/test-as.c
445
446 src_test_as_CFLAGS = \
447 $(TESTS_CFLAGS)
448
449 src_test_as_LDADD = \
450 $(TESTS_LDADD)
451
452 src_test_country_SOURCES = \
453 src/test-country.c
454
455 src_test_country_CFLAGS = \
456 $(TESTS_CFLAGS)
457
458 src_test_country_LDADD = \
459 $(TESTS_LDADD)
460
461 src_test_network_SOURCES = \
462 src/test-network.c
463
464 src_test_network_CFLAGS = \
465 $(TESTS_CFLAGS)
466
467 src_test_network_LDADD = \
468 $(TESTS_LDADD)
469
470 src_test_network_list_SOURCES = \
471 src/test-network-list.c
472
473 src_test_network_list_CFLAGS = \
474 $(TESTS_CFLAGS)
475
476 src_test_network_list_LDADD = \
477 $(TESTS_LDADD)
478
479 src_test_stringpool_SOURCES = \
480 src/test-stringpool.c
481
482 src_test_stringpool_CFLAGS = \
483 $(TESTS_CFLAGS)
484
485 src_test_stringpool_LDADD = \
486 $(TESTS_LDADD)
487
488 src_test_database_SOURCES = \
489 src/test-database.c
490
491 src_test_database_CFLAGS = \
492 $(TESTS_CFLAGS)
493
494 src_test_database_LDADD = \
495 $(TESTS_LDADD)
496
497 src_test_signature_SOURCES = \
498 src/test-signature.c
499
500 src_test_signature_CFLAGS = \
501 $(TESTS_CFLAGS)
502
503 src_test_signature_LDADD = \
504 $(TESTS_LDADD)
505
506 src_test_address_SOURCES = \
507 src/test-address.c
508
509 src_test_address_CFLAGS = \
510 $(TESTS_CFLAGS)
511
512 src_test_address_LDADD = \
513 $(TESTS_LDADD)
514
515 # ------------------------------------------------------------------------------
516
517 MANPAGES = \
518 $(MANPAGES_3) \
519 $(MANPAGES_1)
520
521 MANPAGES_3 = \
522 man/libloc.3 \
523 man/loc_database_count_as.3 \
524 man/loc_database_get_as.3 \
525 man/loc_database_get_country.3 \
526 man/loc_database_lookup.3 \
527 man/loc_database_new.3 \
528 man/loc_get_log_priority.3 \
529 man/loc_new.3 \
530 man/loc_set_log_fn.3 \
531 man/loc_set_log_priority.3
532
533 MANPAGES_1 = \
534 man/location.1
535
536 MANPAGES_TXT = $(MANPAGES_TXT_3) $(MANPAGES_TXT_1)
537 MANPAGES_TXT_3 = $(patsubst %.3,%.txt,$(MANPAGES_3))
538 MANPAGES_TXT_1 = $(patsubst %.1,%.txt,$(MANPAGES_1))
539 MANPAGES_HTML = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
540 MANPAGES_XML = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
541
542 .PHONY: man
543 man: $(MANPAGES) $(MANPAGES_HTML)
544
545 if ENABLE_MAN_PAGES
546 man_MANS = \
547 $(MANPAGES)
548 endif
549
550 CLEANFILES += \
551 $(MANPAGES) \
552 $(MANPAGES_HTML) \
553 $(MANPAGES_XML)
554
555 EXTRA_DIST += \
556 man/asciidoc.conf \
557 $(MANPAGES_TXT)
558
559 XSLTPROC_FLAGS = \
560 --nonet \
561 --stringparam man.output.quietly 1 \
562 --stringparam funcsynopsis.style ansi \
563 --stringparam man.th.extra1.suppress 1 \
564 --stringparam man.authors.section.enabled 1 \
565 --stringparam man.copyright.section.enabled 1
566
567 XSLTPROC_COMMAND_MAN = \
568 $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
569 $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) \
570 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
571
572 # Let XSLT find its source on Mac OS X
573 ifeq ($(OS),Darwin)
574 export XML_CATALOG_FILES = /usr/local/etc/xml/catalog
575 endif
576
577 man/%.xml: man/%.txt man/asciidoc.conf
578 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
579 $(ASCIIDOC) \
580 -f $(abs_srcdir)/man/asciidoc.conf \
581 -d manpage -b docbook -o $@ $<
582
583 man/%.3: man/%.xml
584 $(XSLTPROC_COMMAND_MAN)
585
586 man/%.1: man/%.xml
587 $(XSLTPROC_COMMAND_MAN)
588
589 man/%.html: man/%.txt man/asciidoc.conf
590 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
591 $(ASCIIDOC) \
592 -f $(abs_srcdir)/man/asciidoc.conf \
593 -b html5 -a icons -a theme=flask -o $@ $<
594
595 .PHONY: upload-man
596 upload-man: $(MANPAGES_HTML)
597 rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
598
599 EXTRA_DIST += \
600 tools/copy.py
601
602 EXTRA_DIST += \
603 debian/build.sh \
604 debian/changelog \
605 debian/control \
606 debian/copyright \
607 debian/genchangelog.sh \
608 debian/gensymbols.sh \
609 debian/libloc1.install \
610 debian/libloc1.symbols \
611 debian/libloc-dev.install \
612 debian/location.install \
613 debian/location.postinst \
614 debian/location.postrm \
615 debian/python3-location.examples \
616 debian/python3-location.install \
617 debian/rules \
618 debian/source/format \
619 debian/watch
620
621 .PHONY: debian
622 debian: dist
623 $(SHELL) debian/build.sh $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(distdir).tar.xz