]> git.ipfire.org Git - people/ms/libloc.git/blob - Makefile.am
lua: Create scaffolding for a module
[people/ms/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/location.c \
241 src/lua/location.h
242
243 src_lua_location_la_CFLAGS = \
244 $(AM_CFLAGS) \
245 $(LUA_CFLAGS)
246
247 src_lua_location_la_LDFLAGS = \
248 $(AM_LDFLAGS) \
249 $(LUA_LDFLAGS) \
250 -shared \
251 -module \
252 -avoid-version
253
254 src_lua_location_la_LIBADD = \
255 src/libloc.la \
256 $(LUA_LIBS)
257 endif
258
259 EXTRA_DIST += \
260 src/lua/location.c \
261 src/lua/location.h
262
263 LUA_TESTS = \
264 tests/lua/main.lua
265
266 EXTRA_DIST += \
267 $(LUA_TESTS)
268
269 # ------------------------------------------------------------------------------
270
271 # Compile & install bindings
272 all-local: $(foreach binding,$(BINDINGS),build-$(binding))
273 check-local: $(foreach binding,$(BINDINGS),check-$(binding))
274 install-exec-local: $(foreach binding,$(BINDINGS),install-$(binding))
275 clean-local: $(foreach binding,$(BINDINGS),clean-$(binding))
276 uninstall-local: $(foreach binding,$(BINDINGS),uninstall-$(binding))
277
278 # Perl Bindings
279 EXTRA_DIST += \
280 src/perl/.gitignore \
281 src/perl/Location.xs \
282 src/perl/MANIFEST \
283 src/perl/Makefile.PL \
284 src/perl/lib/Location.pm \
285 src/perl/t/Location.t \
286 src/perl/typemap
287
288 build-perl: src/libloc.la
289 @mkdir -p $(builddir)/src/perl/{lib,t}
290 @test -e $(builddir)/src/perl/Location.xs || ln -s --relative $(srcdir)/src/perl/Location.xs $(builddir)/src/perl/
291 @test -e $(builddir)/src/perl/MANIFEST || ln -s --relative $(srcdir)/src/perl/MANIFEST $(builddir)/src/perl/
292 @test -e $(builddir)/src/perl/Makefile.PL || ln -s --relative $(srcdir)/src/perl/Makefile.PL $(builddir)/src/perl/
293 @test -e $(builddir)/src/perl/lib/Location.pm || ln -s --relative $(srcdir)/src/perl/lib/Location.pm $(builddir)/src/perl/lib/
294 @test -e $(builddir)/src/perl/t/Location.t || ln -s --relative $(srcdir)/src/perl/t/Location.t $(builddir)/src/perl/t/
295 @test -e $(builddir)/src/perl/typemap || ln -s --relative $(srcdir)/src/perl/typemap $(builddir)/src/perl/
296
297 cd $(builddir)/src/perl && $(PERL) Makefile.PL NO_PACKLIST=1 NO_PERLLOCAL=1 \
298 INSTALLDIRS=vendor \
299 INC="-I$(abs_srcdir)/src" LIBS="-L$(abs_builddir)/src/.libs -lloc"
300 cd $(builddir)/src/perl && $(MAKE)
301 touch build-perl
302
303 .PHONY: check-perl
304 check-perl: testdata.db build-perl
305 cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test \
306 database="../../$<" keyfile="$(abs_srcdir)/examples/public-key.pem"
307
308 .PHONY: install-perl
309 install-perl: build-perl
310 cd $(builddir)/src/perl && $(MAKE) install DESTDIR=$(DESTDIR)
311
312 .PHONY: clean-perl
313 clean-perl:
314 cd $(builddir)/src/perl && $(MAKE) distclean
315 rm -f build-perl
316
317 .PHONY: uninstall-perl
318 uninstall-perl:
319 rm -vf \
320 $(DESTDIR)/@PERL_MODPATH@/Location.pm \
321 $(DESTDIR)/@PERL_MODPATH@/auto/Location/Location.so \
322 $(DESTDIR)/@PERL_MANPATH@/Location.3pm
323 -rmdir $(DESTDIR)/@PERL_MODPATH@/auto/Location
324
325 bin_SCRIPTS = \
326 src/scripts/location \
327 src/scripts/location-importer
328
329 EXTRA_DIST += \
330 src/scripts/location.in \
331 src/scripts/location-importer.in
332
333 CLEANFILES += \
334 src/scripts/location \
335 src/scripts/location-importer
336
337 # ------------------------------------------------------------------------------
338
339 # Use systemd timers if available
340 if HAVE_SYSTEMD
341 systemdsystemunit_DATA = \
342 src/systemd/location-update.service \
343 src/systemd/location-update.timer
344
345 CLEANFILES += \
346 $(systemdsystemunit_DATA)
347
348 INSTALL_DIRS += \
349 $(systemdsystemunitdir)
350
351 # Otherwise fall back to cron
352 else
353 cron_daily_SCRIPTS = \
354 src/cron/location-update
355
356 CLEANFILES += \
357 $(cron_daily_DATA)
358 endif
359
360 EXTRA_DIST += \
361 src/cron/location-update.in \
362 src/systemd/location-update.service.in \
363 src/systemd/location-update.timer.in
364
365 # ------------------------------------------------------------------------------
366
367 dist_database_DATA = \
368 data/database.db \
369 data/signing-key.pem
370
371 install-data-hook:
372 chmod 444 $(DESTDIR)$(databasedir)/database.db
373
374 .PHONY: update-database
375 update-database:
376 curl https://location.ipfire.org/databases/1/location.db.xz | xz -d > data/database.db
377
378 # ------------------------------------------------------------------------------
379
380 TESTS_CFLAGS = \
381 $(AM_CFLAGS) \
382 -DLIBLOC_PRIVATE \
383 -DABS_SRCDIR=\"$(abs_srcdir)\"
384
385 TESTS_LDADD = \
386 src/libloc.la \
387 src/libloc-internal.la
388
389 TESTS_ENVIRONMENT = \
390 LUA_PATH="$(abs_builddir)/src/lua/.libs/?.so;;" \
391 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
392 TEST_DATA_DIR="$(abs_top_srcdir)/data"
393
394 TESTS = \
395 $(check_PROGRAMS) \
396 $(check_SCRIPTS) \
397 $(dist_check_SCRIPTS)
398
399 CLEANFILES += \
400 testdata.db
401
402 testdata.db: examples/python/create-database.py
403 PYTHONPATH=$(abs_srcdir)/src/python:$(abs_builddir)/src/python/.libs \
404 ABS_SRCDIR="$(abs_srcdir)" \
405 $(PYTHON) $< $@
406
407 dist_check_SCRIPTS = \
408 tests/python/country.py \
409 tests/python/networks-dedup.py \
410 tests/python/test-database.py \
411 tests/python/test-export.py
412
413 if ENABLE_LUA
414 check_SCRIPTS += \
415 $(LUA_TESTS)
416 endif
417
418 check_PROGRAMS = \
419 src/test-libloc \
420 src/test-stringpool \
421 src/test-database \
422 src/test-as \
423 src/test-network \
424 src/test-network-list \
425 src/test-country \
426 src/test-signature \
427 src/test-address
428
429 src_test_libloc_SOURCES = \
430 src/test-libloc.c
431
432 src_test_libloc_CFLAGS = \
433 $(TESTS_CFLAGS)
434
435 src_test_libloc_LDADD = \
436 $(TESTS_LDADD)
437
438 src_test_as_SOURCES = \
439 src/test-as.c
440
441 src_test_as_CFLAGS = \
442 $(TESTS_CFLAGS)
443
444 src_test_as_LDADD = \
445 $(TESTS_LDADD)
446
447 src_test_country_SOURCES = \
448 src/test-country.c
449
450 src_test_country_CFLAGS = \
451 $(TESTS_CFLAGS)
452
453 src_test_country_LDADD = \
454 $(TESTS_LDADD)
455
456 src_test_network_SOURCES = \
457 src/test-network.c
458
459 src_test_network_CFLAGS = \
460 $(TESTS_CFLAGS)
461
462 src_test_network_LDADD = \
463 $(TESTS_LDADD)
464
465 src_test_network_list_SOURCES = \
466 src/test-network-list.c
467
468 src_test_network_list_CFLAGS = \
469 $(TESTS_CFLAGS)
470
471 src_test_network_list_LDADD = \
472 $(TESTS_LDADD)
473
474 src_test_stringpool_SOURCES = \
475 src/test-stringpool.c
476
477 src_test_stringpool_CFLAGS = \
478 $(TESTS_CFLAGS)
479
480 src_test_stringpool_LDADD = \
481 $(TESTS_LDADD)
482
483 src_test_database_SOURCES = \
484 src/test-database.c
485
486 src_test_database_CFLAGS = \
487 $(TESTS_CFLAGS)
488
489 src_test_database_LDADD = \
490 $(TESTS_LDADD)
491
492 src_test_signature_SOURCES = \
493 src/test-signature.c
494
495 src_test_signature_CFLAGS = \
496 $(TESTS_CFLAGS)
497
498 src_test_signature_LDADD = \
499 $(TESTS_LDADD)
500
501 src_test_address_SOURCES = \
502 src/test-address.c
503
504 src_test_address_CFLAGS = \
505 $(TESTS_CFLAGS)
506
507 src_test_address_LDADD = \
508 $(TESTS_LDADD)
509
510 # ------------------------------------------------------------------------------
511
512 MANPAGES = \
513 $(MANPAGES_3) \
514 $(MANPAGES_1)
515
516 MANPAGES_3 = \
517 man/libloc.3 \
518 man/loc_database_count_as.3 \
519 man/loc_database_get_as.3 \
520 man/loc_database_get_country.3 \
521 man/loc_database_lookup.3 \
522 man/loc_database_new.3 \
523 man/loc_get_log_priority.3 \
524 man/loc_new.3 \
525 man/loc_set_log_fn.3 \
526 man/loc_set_log_priority.3
527
528 MANPAGES_1 = \
529 man/location.1
530
531 MANPAGES_TXT = $(MANPAGES_TXT_3) $(MANPAGES_TXT_1)
532 MANPAGES_TXT_3 = $(patsubst %.3,%.txt,$(MANPAGES_3))
533 MANPAGES_TXT_1 = $(patsubst %.1,%.txt,$(MANPAGES_1))
534 MANPAGES_HTML = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
535 MANPAGES_XML = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
536
537 .PHONY: man
538 man: $(MANPAGES) $(MANPAGES_HTML)
539
540 if ENABLE_MAN_PAGES
541 man_MANS = \
542 $(MANPAGES)
543 endif
544
545 CLEANFILES += \
546 $(MANPAGES) \
547 $(MANPAGES_HTML) \
548 $(MANPAGES_XML)
549
550 EXTRA_DIST += \
551 man/asciidoc.conf \
552 $(MANPAGES_TXT)
553
554 XSLTPROC_FLAGS = \
555 --nonet \
556 --stringparam man.output.quietly 1 \
557 --stringparam funcsynopsis.style ansi \
558 --stringparam man.th.extra1.suppress 1 \
559 --stringparam man.authors.section.enabled 1 \
560 --stringparam man.copyright.section.enabled 1
561
562 XSLTPROC_COMMAND_MAN = \
563 $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
564 $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) \
565 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
566
567 # Let XSLT find its source on Mac OS X
568 ifeq ($(OS),Darwin)
569 export XML_CATALOG_FILES = /usr/local/etc/xml/catalog
570 endif
571
572 man/%.xml: man/%.txt man/asciidoc.conf
573 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
574 $(ASCIIDOC) \
575 -f $(abs_srcdir)/man/asciidoc.conf \
576 -d manpage -b docbook -o $@ $<
577
578 man/%.3: man/%.xml
579 $(XSLTPROC_COMMAND_MAN)
580
581 man/%.1: man/%.xml
582 $(XSLTPROC_COMMAND_MAN)
583
584 man/%.html: man/%.txt man/asciidoc.conf
585 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
586 $(ASCIIDOC) \
587 -f $(abs_srcdir)/man/asciidoc.conf \
588 -b html5 -a icons -a theme=flask -o $@ $<
589
590 .PHONY: upload-man
591 upload-man: $(MANPAGES_HTML)
592 rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
593
594 EXTRA_DIST += \
595 tools/copy.py
596
597 EXTRA_DIST += \
598 debian/build.sh \
599 debian/changelog \
600 debian/control \
601 debian/copyright \
602 debian/genchangelog.sh \
603 debian/gensymbols.sh \
604 debian/libloc1.install \
605 debian/libloc1.symbols \
606 debian/libloc-dev.install \
607 debian/location.install \
608 debian/location.postinst \
609 debian/location.postrm \
610 debian/python3-location.examples \
611 debian/python3-location.install \
612 debian/rules \
613 debian/source/format \
614 debian/watch
615
616 .PHONY: debian
617 debian: dist
618 $(SHELL) debian/build.sh $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(distdir).tar.xz