]> git.ipfire.org Git - location/libloc.git/blame - Makefile.am
python: Expend VERSION at build time
[location/libloc.git] / Makefile.am
CommitLineData
46aded9a
MT
1EXTRA_DIST =
2CLEANFILES =
be748fa8 3INSTALL_DIRS =
46aded9a
MT
4ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
5AM_MAKEFLAGS = --no-print-directory
6
2bb7d64e 7SUBDIRS = . po
747cbcb1
MT
8BINDINGS =
9
afe51420
MT
10OS = $(shell uname -s)
11
a8778efa
MT
12DEBIAN_TARBALL_NAME = $(PACKAGE_NAME)_$(PACKAGE_VERSION).orig.tar.xz
13
fe51657e
MT
14CLEANFILES += \
15 $(DEBIAN_TARBALL_NAME)
16
747cbcb1
MT
17if ENABLE_PERL
18BINDINGS += perl
19endif
2bb7d64e 20
46aded9a
MT
21AM_CPPFLAGS = \
22 -include $(top_builddir)/config.h \
23 -DSYSCONFDIR=\""$(sysconfdir)"\" \
24 -I${top_srcdir}/src
25
26AM_CFLAGS = ${my_CFLAGS} \
46aded9a
MT
27 -ffunction-sections \
28 -fdata-sections
29
afe51420
MT
30AM_LDFLAGS =
31
32# leaving a space here to work around automake's conditionals
33 ifeq ($(OS),Darwin)
34 AM_LDFLAGS += -Wl,-dead_strip
35 else
36 AM_LDFLAGS += \
37 -Wl,--as-needed \
38 -Wl,--gc-sections
39 endif
46aded9a
MT
40
41LIBLOC_CURRENT=0
42LIBLOC_REVISION=0
43LIBLOC_AGE=0
44
be748fa8
MT
45DISTCHECK_CONFIGURE_FLAGS = \
46 --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
47
46aded9a
MT
48SED_PROCESS = \
49 $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
50 -e 's,@VERSION\@,$(VERSION),g' \
51 -e 's,@prefix\@,$(prefix),g' \
52 -e 's,@exec_prefix\@,$(exec_prefix),g' \
be748fa8 53 -e 's,@bindir\@,$(bindir),g' \
46aded9a
MT
54 -e 's,@libdir\@,$(libdir),g' \
55 -e 's,@includedir\@,$(includedir),g' \
73d1b258 56 -e 's,@databasedir\@,$(databasedir),g' \
46aded9a
MT
57 < $< > $@ || rm $@
58
8703cdb4 59databasedir = $(localstatedir)/lib/location
46aded9a
MT
60pkgconfigdir = $(libdir)/pkgconfig
61
7c13a4e6
MT
62# XXX hardcode path for Debian
63pythondir = $(prefix)/lib/python3/dist-packages
64pyexecdir = $(prefix)/lib/python$(PYTHON_VERSION)/lib-dynload
65
66# Overwrite Python path
67pkgpythondir = $(pythondir)/location
68
73d1b258 69%: %.in Makefile
46aded9a
MT
70 $(SED_PROCESS)
71
2bb7d64e
MT
72@INTLTOOL_POLICY_RULE@
73
161ac92d
MT
74# ------------------------------------------------------------------------------
75
76AM_V_ASCIIDOC = $(AM_V_ASCIIDOC_$(V))
77AM_V_ASCIIDOC_ = $(AM_V_ASCIIDOC_$(AM_DEFAULT_VERBOSITY))
78AM_V_ASCIIDOC_0 = @echo " ASCIIDOC" $@;
79
80AM_V_XSLT = $(AM_V_XSLT_$(V))
81AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
82AM_V_XSLT_0 = @echo " XSLT " $@;
83
84# ------------------------------------------------------------------------------
85
2bb7d64e
MT
86.PHONY: update-po
87update-po:
88 $(MAKE) -C po update-po
89
e51e1dec 90EXTRA_DIST += \
726f9984
MT
91 examples/private-key.pem \
92 examples/public-key.pem \
e51e1dec
MT
93 examples/python/create-database.py \
94 examples/python/read-database.py
95
46aded9a 96pkginclude_HEADERS = \
c182393f 97 src/loc/libloc.h \
9fc7f001 98 src/loc/as.h \
42f3ccd7 99 src/loc/compat.h \
ec684c1a 100 src/loc/country.h \
9fc7f001
MT
101 src/loc/database.h \
102 src/loc/format.h \
103 src/loc/network.h \
104 src/loc/private.h \
105 src/loc/stringpool.h \
f4fef543 106 src/loc/resolv.h \
c182393f 107 src/loc/writer.h
46aded9a
MT
108
109lib_LTLIBRARIES = \
110 src/libloc.la
111
9fc7f001 112src_libloc_la_SOURCES = \
62b83e6d 113 src/libloc.c \
a5db3e49 114 src/as.c \
ec684c1a 115 src/country.c \
2601e83e 116 src/database.c \
3b5f4af2 117 src/network.c \
f4fef543 118 src/resolv.c \
62b83e6d 119 src/stringpool.c \
c182393f 120 src/writer.c
46aded9a
MT
121
122EXTRA_DIST += src/libloc.sym
123
18e2b14c
MT
124src_libloc_la_CFLAGS = \
125 $(AM_CFLAGS) \
1a3cb1b4 126 -DLIBLOC_PRIVATE \
18e2b14c
MT
127 -fvisibility=hidden
128
46aded9a
MT
129src_libloc_la_LDFLAGS = \
130 $(AM_LDFLAGS) \
a76b0b96
MT
131 -version-info $(LIBLOC_CURRENT):$(LIBLOC_REVISION):$(LIBLOC_AGE)
132
133if HAVE_LD_VERSION_SCRIPT
e81a6b04 134src_libloc_la_LDFLAGS += -Wl,--version-script=$(top_srcdir)/src/libloc.sym
a76b0b96 135else
e81a6b04 136src_libloc_la_LDFLAGS += -export-symbols $(top_srcdir)/src/libloc.sym
a76b0b96 137endif
46aded9a 138
f4fef543 139src_libloc_la_LIBADD = \
e568f8d4 140 $(OPENSSL_LIBS) \
f4fef543
MT
141 $(RESOLV_LIBS)
142
46aded9a
MT
143src_libloc_la_DEPENDENCIES = \
144 ${top_srcdir}/src/libloc.sym
145
146pkgconfig_DATA = \
147 src/libloc.pc
148
149EXTRA_DIST += \
150 src/libloc.pc.in
151
152CLEANFILES += \
153 src/libloc.pc
154
7c13a4e6
MT
155dist_pkgpython_PYTHON = \
156 src/python/__init__.py
157
a2ab8ddf 158pyexec_LTLIBRARIES = \
7c13a4e6 159 src/python/_location.la
18e2b14c 160
7c13a4e6 161src_python__location_la_SOURCES = \
9cdf6c53 162 src/python/locationmodule.c \
62ffafdd 163 src/python/locationmodule.h \
fadebc89
MT
164 src/python/as.c \
165 src/python/as.h \
af208e26
MT
166 src/python/country.c \
167 src/python/country.h \
9cdf6c53 168 src/python/database.c \
d688e569 169 src/python/database.h \
39967361
MT
170 src/python/network.c \
171 src/python/network.h \
d688e569
MT
172 src/python/writer.c \
173 src/python/writer.h
18e2b14c 174
7c13a4e6 175src_python__location_la_CFLAGS = \
18e2b14c
MT
176 $(AM_CFLAGS) \
177 $(PYTHON_CFLAGS)
178
7c13a4e6 179src_python__location_la_LDFLAGS = \
18e2b14c
MT
180 $(AM_LDFLAGS) \
181 -shared \
182 -module \
183 -avoid-version
184
7c13a4e6 185src_python__location_la_LIBADD = \
18e2b14c
MT
186 src/libloc.la \
187 $(PYTHON_LIBS)
188
747cbcb1
MT
189# Compile & install bindings
190all-local: $(foreach binding,$(BINDINGS),build-$(binding))
191check-local: $(foreach binding,$(BINDINGS),check-$(binding))
192install-exec-local: $(foreach binding,$(BINDINGS),install-$(binding))
193clean-local: $(foreach binding,$(BINDINGS),clean-$(binding))
194uninstall-local: $(foreach binding,$(BINDINGS),uninstall-$(binding))
195
196# Perl Bindings
197EXTRA_DIST += \
198 src/perl/.gitignore \
199 src/perl/Location.xs \
200 src/perl/MANIFEST \
201 src/perl/Makefile.PL \
202 src/perl/lib/Location.pm \
203 src/perl/t/Location.t \
204 src/perl/typemap
205
206.PHONY: build-perl
207build-perl:
208 @mkdir -p $(builddir)/src/perl/{lib,t}
209 @test -e $(builddir)/src/perl/Location.xs || ln -s --relative $(srcdir)/src/perl/Location.xs $(builddir)/src/perl/
210 @test -e $(builddir)/src/perl/MANIFEST || ln -s --relative $(srcdir)/src/perl/MANIFEST $(builddir)/src/perl/
211 @test -e $(builddir)/src/perl/Makefile.PL || ln -s --relative $(srcdir)/src/perl/Makefile.PL $(builddir)/src/perl/
212 @test -e $(builddir)/src/perl/lib/Location.pm || ln -s --relative $(srcdir)/src/perl/lib/Location.pm $(builddir)/src/perl/lib/
213 @test -e $(builddir)/src/perl/t/Location.t || ln -s --relative $(srcdir)/src/perl/t/Location.t $(builddir)/src/perl/t/
214 @test -e $(builddir)/src/perl/typemap || ln -s --relative $(srcdir)/src/perl/typemap $(builddir)/src/perl/
215
216 cd $(builddir)/src/perl && $(PERL) Makefile.PL PREFIX="$(prefix)" \
217 INC="-I$(abs_srcdir)/src" LIBS="-L$(abs_builddir)/src/.libs -lloc"
fb574759 218 cd $(builddir)/src/perl && $(MAKE) LD_RUN_PATH=
747cbcb1
MT
219
220.PHONY: check-perl
f852b157 221check-perl: testdata.db
2061ff77
SS
222 cd $(builddir)/src/perl && $(MAKE) LD_LIBRARY_PATH="$(abs_builddir)/src/.libs" test \
223 database="../../$<" keyfile="$(abs_srcdir)/examples/public-key.pem"
747cbcb1
MT
224
225.PHONY: install-perl
226install-perl:
227 cd $(builddir)/src/perl && $(MAKE) install
228
229.PHONY: clean-perl
230clean-perl:
231 cd $(builddir)/src/perl && $(MAKE) distclean
232
233.PHONY: uninstall-perl
234uninstall-perl:
235 rm -rvf \
236 $(DESTDIR)/$(prefix)/lib/*/perl/*/Location.pm \
237 $(DESTDIR)/$(prefix)/lib/*/perl/*/auto/Location \
238 $(DESTDIR)/$(prefix)/lib/*/perl/*/perllocal.pod \
239 $(DESTDIR)/$(prefix)/man/man3/Location.3pm
240
5118a4b8 241bin_SCRIPTS = \
244a3b61 242 src/python/location-downloader \
6838b55a 243 src/python/location-exporter \
5118a4b8
MT
244 src/python/location-query
245
73d1b258 246EXTRA_DIST += \
244a3b61 247 src/python/location-downloader.in \
6838b55a 248 src/python/location-exporter.in \
73d1b258
MT
249 src/python/location-query.in
250
251CLEANFILES += \
244a3b61 252 src/python/location-downloader \
6838b55a 253 src/python/location-exporter \
73d1b258 254 src/python/location-query
6838b55a 255
be748fa8
MT
256# ------------------------------------------------------------------------------
257
258if HAVE_SYSTEMD
259systemdsystemunit_DATA = \
260 src/systemd/location-downloader.service \
261 src/systemd/location-downloader.timer
262
263CLEANFILES += \
264 $(systemdsystemunit_DATA)
265
266INSTALL_DIRS += \
267 $(systemdsystemunitdir)
268endif
269
270EXTRA_DIST += \
271 src/systemd/location-downloader.service.in \
272 src/systemd/location-downloader.timer.in
73d1b258 273
161ac92d
MT
274# ------------------------------------------------------------------------------
275
a7d90ad4
MT
276dist_database_DATA = \
277 src/signing-key.pem
278
279# ------------------------------------------------------------------------------
280
30ac38a1
MT
281TESTS_CFLAGS = \
282 $(AM_CFLAGS) \
726f9984
MT
283 -DLIBLOC_PRIVATE \
284 -DABS_SRCDIR=\"$(abs_srcdir)\"
30ac38a1 285
46aded9a 286TESTS = \
62b83e6d 287 src/test-libloc \
2601e83e 288 src/test-stringpool \
a5db3e49 289 src/test-database \
3b5f4af2 290 src/test-as \
ec684c1a 291 src/test-network \
25deb4d8 292 src/test-country
46aded9a 293
f3bf970a 294CLEANFILES += \
f852b157
MT
295 test.db \
296 testdata.db
f3bf970a 297
f852b157 298testdata.db: examples/python/create-database.py
726f9984
MT
299 PYTHONPATH=$(abs_builddir)/src/python/.libs \
300 ABS_SRCDIR="$(abs_srcdir)" \
301 $(PYTHON) $< $@
1235c0b0 302
46aded9a 303check_PROGRAMS = \
62b83e6d 304 src/test-libloc \
2601e83e 305 src/test-stringpool \
a5db3e49 306 src/test-database \
3b5f4af2 307 src/test-as \
ec684c1a 308 src/test-network \
e8fd8389
MT
309 src/test-country \
310 src/test-signature
46aded9a
MT
311
312src_test_libloc_SOURCES = \
313 src/test-libloc.c
314
30ac38a1
MT
315src_test_libloc_CFLAGS = \
316 $(TESTS_CFLAGS)
317
46aded9a
MT
318src_test_libloc_LDADD = \
319 src/libloc.la
62b83e6d 320
a5db3e49
MT
321src_test_as_SOURCES = \
322 src/test-as.c
323
30ac38a1
MT
324src_test_as_CFLAGS = \
325 $(TESTS_CFLAGS)
326
a5db3e49
MT
327src_test_as_LDADD = \
328 src/libloc.la
329
ec684c1a
MT
330src_test_country_SOURCES = \
331 src/test-country.c
332
333src_test_country_CFLAGS = \
334 $(TESTS_CFLAGS)
335
336src_test_country_LDADD = \
337 src/libloc.la
338
3b5f4af2
MT
339src_test_network_SOURCES = \
340 src/test-network.c
341
30ac38a1
MT
342src_test_network_CFLAGS = \
343 $(TESTS_CFLAGS)
344
3b5f4af2
MT
345src_test_network_LDADD = \
346 src/libloc.la
347
62b83e6d
MT
348src_test_stringpool_SOURCES = \
349 src/test-stringpool.c
350
30ac38a1
MT
351src_test_stringpool_CFLAGS = \
352 $(TESTS_CFLAGS)
353
62b83e6d
MT
354src_test_stringpool_LDADD = \
355 src/libloc.la
2601e83e
MT
356
357src_test_database_SOURCES = \
358 src/test-database.c
359
30ac38a1
MT
360src_test_database_CFLAGS = \
361 $(TESTS_CFLAGS)
362
2601e83e
MT
363src_test_database_LDADD = \
364 src/libloc.la
161ac92d 365
e8fd8389
MT
366src_test_signature_SOURCES = \
367 src/test-signature.c
368
369src_test_signature_CFLAGS = \
370 $(TESTS_CFLAGS)
371
372src_test_signature_LDADD = \
373 src/libloc.la
374
161ac92d
MT
375# ------------------------------------------------------------------------------
376
377MANPAGES = \
bf50d56b 378 man/location-downloader.8 \
161ac92d
MT
379 man/location-query.8
380
381MANPAGES_TXT = $(patsubst %.8,%.txt,$(MANPAGES))
382MANPAGES_HTML = $(patsubst %.txt,%.html,$(MANPAGES_TXT))
383MANPAGES_XML = $(patsubst %.txt,%.xml,$(MANPAGES_TXT))
384
385.PHONY: man
386man: $(MANPAGES) $(MANPAGES_HTML)
387
388if ENABLE_MANPAGES
389man_MANS = \
390 $(MANPAGES)
391endif
392
393CLEANFILES += \
394 $(MANPAGES) \
395 $(MANPAGES_HTML) \
396 $(MANPAGES_XML)
397
398EXTRA_DIST += \
399 man/asciidoc.conf \
400 $(MANPAGES_TXT)
401
402XSLTPROC_FLAGS = \
403 --nonet \
404 --stringparam man.output.quietly 1 \
405 --stringparam funcsynopsis.style ansi \
406 --stringparam man.th.extra1.suppress 1 \
407 --stringparam man.authors.section.enabled 1 \
408 --stringparam man.copyright.section.enabled 1
409
410XSLTPROC_COMMAND_MAN = \
411 $(AM_V_XSLT)$(MKDIR_P) $(dir $@) && \
412 $(XSLTPROC) -o $@ $(XSLTPROC_FLAGS) \
413 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
414
43c16e73
MT
415# Let XSLT find its source on Mac OS X
416 ifeq ($(OS),Darwin)
417export XML_CATALOG_FILES = /usr/local/etc/xml/catalog
418 endif
419
161ac92d
MT
420man/%.xml: man/%.txt man/asciidoc.conf
421 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
422 $(ASCIIDOC) \
423 -f $(abs_srcdir)/man/asciidoc.conf \
424 -d manpage -b docbook -o $@ $<
425
426man/%.8: man/%.xml
427 $(XSLTPROC_COMMAND_MAN)
428
429man/%.html: man/%.txt man/asciidoc.conf
430 $(AM_V_ASCIIDOC)$(MKDIR_P) $(dir $@) && \
431 $(ASCIIDOC) \
432 -f $(abs_srcdir)/man/asciidoc.conf \
433 -b html5 -a icons -a theme=flask -o $@ $<
434
435.PHONY: upload-man
436upload-man: $(MANPAGES_HTML)
437 rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
a8778efa
MT
438
439$(DEBIAN_TARBALL_NAME): dist
440 cp -v $(distdir).tar.xz $@
441
442.PHONY: debian
443debian: $(DEBIAN_TARBALL_NAME)
444 debuild -i -us -uc -b