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