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