]> git.ipfire.org Git - location/libloc.git/blob - Makefile.am
Makefile: Pack all debian files into the tarball
[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 databasedir = $(localstatedir)/lib/location
55 pkgconfigdir = $(libdir)/pkgconfig
56
57 # Overwrite Python path
58 #pkgpythondir = $(pythondir)/location
59 pkgpythondir = /usr/lib/python3/dist-packages/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 .PHONY: build-perl
236 build-perl:
237 @mkdir -p $(builddir)/src/perl/{lib,t}
238 @test -e $(builddir)/src/perl/Location.xs || ln -s --relative $(srcdir)/src/perl/Location.xs $(builddir)/src/perl/
239 @test -e $(builddir)/src/perl/MANIFEST || ln -s --relative $(srcdir)/src/perl/MANIFEST $(builddir)/src/perl/
240 @test -e $(builddir)/src/perl/Makefile.PL || ln -s --relative $(srcdir)/src/perl/Makefile.PL $(builddir)/src/perl/
241 @test -e $(builddir)/src/perl/lib/Location.pm || ln -s --relative $(srcdir)/src/perl/lib/Location.pm $(builddir)/src/perl/lib/
242 @test -e $(builddir)/src/perl/t/Location.t || ln -s --relative $(srcdir)/src/perl/t/Location.t $(builddir)/src/perl/t/
243 @test -e $(builddir)/src/perl/typemap || ln -s --relative $(srcdir)/src/perl/typemap $(builddir)/src/perl/
244
245 cd $(builddir)/src/perl && $(PERL) Makefile.PL PREFIX="$(prefix)" \
246 INC="-I$(abs_srcdir)/src" LIBS="-L$(abs_builddir)/src/.libs -lloc"
247 cd $(builddir)/src/perl && $(MAKE) LD_RUN_PATH=
248
249 .PHONY: check-perl
250 check-perl: testdata.db
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:
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
262 .PHONY: uninstall-perl
263 uninstall-perl:
264 rm -rvf \
265 $(DESTDIR)/$(prefix)/lib/*/perl/*/Location.pm \
266 $(DESTDIR)/$(prefix)/lib/*/perl/*/auto/Location \
267 $(DESTDIR)/$(prefix)/lib/*/perl/*/perllocal.pod \
268 $(DESTDIR)/$(prefix)/man/man3/Location.3pm
269
270 bin_SCRIPTS = \
271 src/scripts/location \
272 src/scripts/location-importer
273
274 EXTRA_DIST += \
275 src/scripts/location.in \
276 src/scripts/location-importer.in
277
278 CLEANFILES += \
279 src/scripts/location \
280 src/scripts/location-importer
281
282 # ------------------------------------------------------------------------------
283
284 if HAVE_SYSTEMD
285 systemdsystemunit_DATA = \
286 src/systemd/location-update.service \
287 src/systemd/location-update.timer
288
289 CLEANFILES += \
290 $(systemdsystemunit_DATA)
291
292 INSTALL_DIRS += \
293 $(systemdsystemunitdir)
294 endif
295
296 EXTRA_DIST += \
297 src/systemd/location-update.service.in \
298 src/systemd/location-update.timer.in
299
300 # ------------------------------------------------------------------------------
301
302 dist_database_DATA = \
303 src/signing-key.pem
304
305 # ------------------------------------------------------------------------------
306
307 TESTS_CFLAGS = \
308 $(AM_CFLAGS) \
309 -DLIBLOC_PRIVATE \
310 -DABS_SRCDIR=\"$(abs_srcdir)\"
311
312 TESTS_LDADD = \
313 src/libloc.la \
314 src/libloc-internal.la
315
316 TESTS_ENVIRONMENT = \
317 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
318 TEST_DATA_DIR="$(abs_top_srcdir)/tests/data"
319
320 TESTS = \
321 $(check_PROGRAMS) \
322 $(dist_check_SCRIPTS)
323
324 EXTRA_DIST += \
325 tests/data/location-2022-03-30.db
326
327 CLEANFILES += \
328 testdata.db
329
330 testdata.db: examples/python/create-database.py
331 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
332 ABS_SRCDIR="$(abs_srcdir)" \
333 $(PYTHON) $< $@
334
335 dist_check_SCRIPTS = \
336 tests/python/test-export.py
337
338 check_PROGRAMS = \
339 src/test-libloc \
340 src/test-stringpool \
341 src/test-database \
342 src/test-as \
343 src/test-network \
344 src/test-network-list \
345 src/test-country \
346 src/test-signature \
347 src/test-address
348
349 src_test_libloc_SOURCES = \
350 src/test-libloc.c
351
352 src_test_libloc_CFLAGS = \
353 $(TESTS_CFLAGS)
354
355 src_test_libloc_LDADD = \
356 $(TESTS_LDADD)
357
358 src_test_as_SOURCES = \
359 src/test-as.c
360
361 src_test_as_CFLAGS = \
362 $(TESTS_CFLAGS)
363
364 src_test_as_LDADD = \
365 $(TESTS_LDADD)
366
367 src_test_country_SOURCES = \
368 src/test-country.c
369
370 src_test_country_CFLAGS = \
371 $(TESTS_CFLAGS)
372
373 src_test_country_LDADD = \
374 $(TESTS_LDADD)
375
376 src_test_network_SOURCES = \
377 src/test-network.c
378
379 src_test_network_CFLAGS = \
380 $(TESTS_CFLAGS)
381
382 src_test_network_LDADD = \
383 $(TESTS_LDADD)
384
385 src_test_network_list_SOURCES = \
386 src/test-network-list.c
387
388 src_test_network_list_CFLAGS = \
389 $(TESTS_CFLAGS)
390
391 src_test_network_list_LDADD = \
392 $(TESTS_LDADD)
393
394 src_test_stringpool_SOURCES = \
395 src/test-stringpool.c
396
397 src_test_stringpool_CFLAGS = \
398 $(TESTS_CFLAGS)
399
400 src_test_stringpool_LDADD = \
401 $(TESTS_LDADD)
402
403 src_test_database_SOURCES = \
404 src/test-database.c
405
406 src_test_database_CFLAGS = \
407 $(TESTS_CFLAGS)
408
409 src_test_database_LDADD = \
410 $(TESTS_LDADD)
411
412 src_test_signature_SOURCES = \
413 src/test-signature.c
414
415 src_test_signature_CFLAGS = \
416 $(TESTS_CFLAGS)
417
418 src_test_signature_LDADD = \
419 $(TESTS_LDADD)
420
421 src_test_address_SOURCES = \
422 src/test-address.c
423
424 src_test_address_CFLAGS = \
425 $(TESTS_CFLAGS)
426
427 src_test_address_LDADD = \
428 $(TESTS_LDADD)
429
430 # ------------------------------------------------------------------------------
431
432 MANPAGES = \
433 $(MANPAGES_3) \
434 $(MANPAGES_8)
435
436 MANPAGES_3 = \
437 man/libloc.3 \
438 man/loc_database_count_as.3 \
439 man/loc_database_get_as.3 \
440 man/loc_database_get_country.3 \
441 man/loc_database_lookup.3 \
442 man/loc_database_new.3 \
443 man/loc_get_log_priority.3 \
444 man/loc_new.3 \
445 man/loc_set_log_fn.3 \
446 man/loc_set_log_priority.3
447
448 MANPAGES_8 = \
449 man/location.8
450
451 MANPAGES_TXT = $(MANPAGES_TXT_3) $(MANPAGES_TXT_8)
452 MANPAGES_TXT_3 = $(patsubst %.3,%.txt,$(MANPAGES_3))
453 MANPAGES_TXT_8 = $(patsubst %.8,%.txt,$(MANPAGES_8))
454 MANPAGES_HTML = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
455 MANPAGES_XML = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
456
457 .PHONY: man
458 man: $(MANPAGES) $(MANPAGES_HTML)
459
460 if ENABLE_MAN_PAGES
461 man_MANS = \
462 $(MANPAGES)
463 endif
464
465 CLEANFILES += \
466 $(MANPAGES) \
467 $(MANPAGES_HTML) \
468 $(MANPAGES_XML)
469
470 EXTRA_DIST += \
471 man/asciidoc.conf \
472 $(MANPAGES_TXT)
473
474 XSLTPROC_FLAGS = \
475 --nonet \
476 --stringparam man.output.quietly 1 \
477 --stringparam funcsynopsis.style ansi \
478 --stringparam man.th.extra1.suppress 1 \
479 --stringparam man.authors.section.enabled 1 \
480 --stringparam man.copyright.section.enabled 1
481
482 XSLTPROC_COMMAND_MAN = \
483 $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
484 $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) \
485 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
486
487 # Let XSLT find its source on Mac OS X
488 ifeq ($(OS),Darwin)
489 export XML_CATALOG_FILES = /usr/local/etc/xml/catalog
490 endif
491
492 man/%.xml: man/%.txt man/asciidoc.conf
493 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
494 $(ASCIIDOC) \
495 -f $(abs_srcdir)/man/asciidoc.conf \
496 -d manpage -b docbook -o $@ $<
497
498 man/%.3: man/%.xml
499 $(XSLTPROC_COMMAND_MAN)
500
501 man/%.8: man/%.xml
502 $(XSLTPROC_COMMAND_MAN)
503
504 man/%.html: man/%.txt man/asciidoc.conf
505 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
506 $(ASCIIDOC) \
507 -f $(abs_srcdir)/man/asciidoc.conf \
508 -b html5 -a icons -a theme=flask -o $@ $<
509
510 .PHONY: upload-man
511 upload-man: $(MANPAGES_HTML)
512 rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
513
514 EXTRA_DIST += \
515 debian/build.sh \
516 debian/changelog \
517 debian/control \
518 debian/copyright \
519 debian/genchangelog.sh \
520 debian/gensymbols.sh \
521 debian/libloc1.install \
522 debian/libloc1.symbols \
523 debian/libloc-dev.install \
524 debian/location.install \
525 debian/location.postinst \
526 debian/location.postrm \
527 debian/python3-location.examples \
528 debian/python3-location.install \
529 debian/rules \
530 debian/source/format \
531 debian/watch
532
533 .PHONY: debian
534 debian: dist
535 $(SHELL) debian/build.sh $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(distdir).tar.xz