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