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