]> git.ipfire.org Git - thirdparty/kmod.git/blob - Makefile.am
Drop python bindings
[thirdparty/kmod.git] / Makefile.am
1 SUBDIRS = . libkmod/docs
2
3 if BUILD_MANPAGES
4 SUBDIRS += man
5 endif
6
7 DISTCLEAN_LOCAL_HOOKS =
8 EXTRA_DIST =
9 CLEANFILES = $(BUILT_FILES)
10 DISTCLEANFILES =
11 BUILT_FILES =
12 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
13 AM_MAKEFLAGS = --no-print-directory
14
15 GCC_COLORS ?= 'yes'
16 export GCC_COLORS
17
18 AM_CPPFLAGS = \
19 -include $(top_builddir)/config.h \
20 -I$(top_srcdir) \
21 -DSYSCONFDIR=\""$(sysconfdir)"\" \
22 -DDISTCONFDIR=\""$(distconfdir)"\" \
23 -DMODULE_DIRECTORY=\""$(module_directory)"\" \
24 ${zlib_CFLAGS}
25
26 AM_CFLAGS = $(OUR_CFLAGS)
27 AM_LDFLAGS = $(OUR_LDFLAGS)
28
29 # Rules for libtool versioning (from https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html)
30 # 1. Start with version information of ‘0:0:0’ for each libtool library.
31 # 2. Update the version information only immediately before a public release of
32 # your software. More frequent updates are unnecessary, and only guarantee that
33 # the current interface number gets larger faster.
34 # 3. If the library source code has changed at all since the last update, then
35 # increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
36 # 4. If any interfaces have been added, removed, or changed since the last
37 # update, increment current, and set revision to 0.
38 # 5. If any interfaces have been added since the last public release, then
39 # increment age.
40 # 6. If any interfaces have been removed or changed since the last public
41 # release, then set age to 0.
42 LIBKMOD_CURRENT=6
43 LIBKMOD_REVISION=1
44 LIBKMOD_AGE=4
45
46 noinst_LTLIBRARIES = shared/libshared.la
47 shared_libshared_la_SOURCES = \
48 shared/macro.h \
49 shared/missing.h \
50 shared/array.c \
51 shared/array.h \
52 shared/hash.c \
53 shared/hash.h \
54 shared/scratchbuf.c \
55 shared/scratchbuf.h \
56 shared/strbuf.c \
57 shared/strbuf.h \
58 shared/util.c \
59 shared/util.h
60
61 include_HEADERS = libkmod/libkmod.h
62 lib_LTLIBRARIES = libkmod/libkmod.la
63
64 libkmod_libkmod_la_SOURCES = \
65 libkmod/libkmod.h \
66 libkmod/libkmod-internal.h \
67 libkmod/libkmod.c \
68 libkmod/libkmod-builtin.c \
69 libkmod/libkmod-list.c \
70 libkmod/libkmod-config.c \
71 libkmod/libkmod-index.c \
72 libkmod/libkmod-index.h \
73 libkmod/libkmod-module.c \
74 libkmod/libkmod-file.c \
75 libkmod/libkmod-elf.c \
76 libkmod/libkmod-signature.c
77
78 EXTRA_DIST += libkmod/libkmod.sym
79 EXTRA_DIST += libkmod/README \
80 libkmod/COPYING testsuite/COPYING tools/COPYING COPYING
81
82 libkmod_libkmod_la_LDFLAGS = $(AM_LDFLAGS) \
83 -version-info $(LIBKMOD_CURRENT):$(LIBKMOD_REVISION):$(LIBKMOD_AGE) \
84 -Wl,--version-script=$(top_srcdir)/libkmod/libkmod.sym
85 libkmod_libkmod_la_DEPENDENCIES = \
86 shared/libshared.la \
87 ${top_srcdir}/libkmod/libkmod.sym
88 libkmod_libkmod_la_LIBADD = \
89 shared/libshared.la \
90 ${libzstd_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libcrypto_LIBS}
91
92 noinst_LTLIBRARIES += libkmod/libkmod-internal.la
93 libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES)
94 libkmod_libkmod_internal_la_LDFLAGS = $(AM_LDFLAGS) \
95 -Wl,--version-script=$(top_srcdir)/libkmod/libkmod.sym
96 libkmod_libkmod_internal_la_DEPENDENCIES = $(libkmod_libkmod_la_DEPENDENCIES)
97 libkmod_libkmod_internal_la_LIBADD = $(libkmod_libkmod_la_LIBADD)
98
99 pkgconfigdir = $(libdir)/pkgconfig
100 pkgconfig_DATA = libkmod/libkmod.pc tools/kmod.pc
101
102 bashcompletiondir=@bashcompletiondir@
103 dist_bashcompletion_DATA = \
104 shell-completion/bash/kmod
105
106 install-exec-hook:
107 if test "$(libdir)" != "$(rootlibdir)"; then \
108 $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
109 so_img_name=$$(readlink $(DESTDIR)$(libdir)/libkmod.so) && \
110 so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
111 ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libkmod.so && \
112 mv $(DESTDIR)$(libdir)/libkmod.so.* $(DESTDIR)$(rootlibdir); \
113 fi
114
115 uninstall-hook:
116 rm -f $(DESTDIR)$(rootlibdir)/libkmod.so*
117
118 if BUILD_TOOLS
119 bin_PROGRAMS = tools/kmod
120
121 noinst_SCRIPTS = \
122 tools/insmod tools/rmmod tools/lsmod \
123 tools/modprobe tools/modinfo tools/depmod
124
125 tools_kmod_SOURCES = \
126 tools/kmod.c tools/kmod.h tools/lsmod.c \
127 tools/rmmod.c tools/insmod.c \
128 tools/modinfo.c tools/modprobe.c \
129 tools/depmod.c tools/log.h tools/log.c \
130 tools/static-nodes.c
131
132 if BUILD_EXPERIMENTAL
133 tools_kmod_SOURCES += \
134 tools/insert.c \
135 tools/remove.c
136 endif
137
138 tools_kmod_LDADD = \
139 shared/libshared.la \
140 libkmod/libkmod-internal.la
141
142 ${noinst_SCRIPTS}: tools/kmod
143 $(AM_V_GEN) ($(RM) $@; \
144 $(LN_S) $(notdir $<) $@)
145 endif
146
147 # ------------------------------------------------------------------------------
148 # TESTSUITE
149 # ------------------------------------------------------------------------------
150
151 EXTRA_DIST += testsuite/setup-rootfs.sh
152
153 MODULE_PLAYGROUND = testsuite/module-playground
154 ROOTFS = testsuite/rootfs
155 ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
156 CREATE_ROOTFS = $(AM_V_GEN) MODULE_DIRECTORY=$(module_directory) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir)
157
158 build-module-playground:
159 $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
160 $(RM) -rf testsuite/module-playground && \
161 mkdir -p testsuite/ && \
162 cp -r $(top_srcdir)/$(MODULE_PLAYGROUND) $(top_builddir)/$(MODULE_PLAYGROUND) && \
163 find $(top_builddir)/$(MODULE_PLAYGROUND) -type d -exec chmod +w {} \; ; \
164 fi
165 if BUILD_MODULES
166 $(MAKE) -C $(MODULE_PLAYGROUND)
167 else
168 $(MAKE) -C $(MODULE_PLAYGROUND) FAKE_BUILD=1
169 endif
170
171
172 rootfs: build-module-playground
173 $(CREATE_ROOTFS)
174
175 .PHONY: rootfs build-playground
176
177 $(ROOTFS): $(ROOTFS_PRISTINE)
178 $(CREATE_ROOTFS)
179
180 TESTSUITE_OVERRIDE_LIBS = \
181 testsuite/uname.la testsuite/path.la \
182 testsuite/init_module.la \
183 testsuite/delete_module.la
184 TESTSUITE_OVERRIDE_LIBS_LDFLAGS = \
185 avoid-version -module -shared -export-dynamic -rpath /nowhere -ldl
186
187 check-am: rootfs
188
189
190 EXTRA_DIST += \
191 testsuite/module-playground/cache \
192 testsuite/module-playground/dummy.pkcs7 \
193 testsuite/module-playground/dummy.sha1 \
194 testsuite/module-playground/dummy.sha256 \
195 testsuite/module-playground/Makefile \
196 testsuite/module-playground/Makefile.arch \
197 testsuite/module-playground/mod-fake-cciss.c \
198 testsuite/module-playground/mod-fake-hpsa.c \
199 testsuite/module-playground/mod-fake-scsi-mod.c \
200 testsuite/module-playground/mod-foo-a.c \
201 testsuite/module-playground/mod-foo-b.c \
202 testsuite/module-playground/mod-foo.c \
203 testsuite/module-playground/mod-foo-c.c \
204 testsuite/module-playground/mod-loop-a.c \
205 testsuite/module-playground/mod-loop-b.c \
206 testsuite/module-playground/mod-loop-c.c \
207 testsuite/module-playground/mod-loop-d.c \
208 testsuite/module-playground/mod-loop-e.c \
209 testsuite/module-playground/mod-loop-f.c \
210 testsuite/module-playground/mod-loop-g.c \
211 testsuite/module-playground/mod-loop-h.c \
212 testsuite/module-playground/mod-loop-i.c \
213 testsuite/module-playground/mod-loop-j.c \
214 testsuite/module-playground/mod-loop-k.c \
215 testsuite/module-playground/mod-loop.h \
216 testsuite/module-playground/mod-simple.c \
217 testsuite/module-playground/mod-simple-i386.ko \
218 testsuite/module-playground/mod-simple-sparc64.ko \
219 testsuite/module-playground/mod-simple-x86_64.ko \
220 testsuite/module-playground/README
221
222 check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
223
224 testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
225 testsuite_path_la_CPPFLAGS = $(AM_CPPFLAGS) \
226 -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
227 testsuite_path_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
228
229 testsuite_delete_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
230 testsuite_init_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
231 testsuite_init_module_la_SOURCES = testsuite/init_module.c \
232 testsuite/stripped-module.h
233 testsuite_init_module_la_LIBADD = libkmod/libkmod-internal.la
234
235 TESTSUITE_CPPFLAGS = $(AM_CPPFLAGS) \
236 -DTESTSUITE_ROOTFS=\"$(abs_top_builddir)/$(ROOTFS)/\" \
237 -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
238 TESTSUITE_LDADD = \
239 testsuite/libtestsuite.la libkmod/libkmod-internal.la \
240 shared/libshared.la
241
242 check_LTLIBRARIES += testsuite/libtestsuite.la
243 testsuite_libtestsuite_la_SOURCES = \
244 testsuite/testsuite.c testsuite/testsuite.h
245 testsuite_libtestsuite_la_DEPENDENCIES = \
246 $(ROOTFS) $(TESTSUITE_OVERRIDE_LIBS)
247 testsuite_libtestsuite_la_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
248 testsuite_libtestsuite_la_LIBADD = -lrt
249
250 TESTSUITE = \
251 testsuite/test-hash \
252 testsuite/test-array \
253 testsuite/test-scratchbuf \
254 testsuite/test-strbuf \
255 testsuite/test-init \
256 testsuite/test-initstate \
257 testsuite/test-testsuite testsuite/test-loaded \
258 testsuite/test-modinfo testsuite/test-util testsuite/test-new-module \
259 testsuite/test-modprobe testsuite/test-blacklist \
260 testsuite/test-dependencies testsuite/test-depmod \
261 testsuite/test-list
262
263 if BUILD_EXPERIMENTAL
264 TESTSUITE += \
265 testsuite/test-tools
266 endif
267
268 check_PROGRAMS = $(TESTSUITE)
269 TESTS = $(TESTSUITE)
270
271 testsuite_test_testsuite_LDADD = \
272 testsuite/libtestsuite.la shared/libshared.la
273 testsuite_test_testsuite_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
274
275 testsuite_test_hash_LDADD = $(TESTSUITE_LDADD)
276 testsuite_test_hash_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
277
278 testsuite_test_array_LDADD = $(TESTSUITE_LDADD)
279 testsuite_test_array_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
280
281 testsuite_test_scratchbuf_LDADD = $(TESTSUITE_LDADD)
282 testsuite_test_scratchbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
283
284 testsuite_test_strbuf_LDADD = $(TESTSUITE_LDADD)
285 testsuite_test_strbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
286
287 testsuite_test_init_LDADD = $(TESTSUITE_LDADD)
288 testsuite_test_init_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
289 testsuite_test_initstate_LDADD = $(TESTSUITE_LDADD)
290 testsuite_test_initstate_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
291 testsuite_test_loaded_LDADD = $(TESTSUITE_LDADD)
292 testsuite_test_loaded_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
293 testsuite_test_modinfo_LDADD = $(TESTSUITE_LDADD)
294 testsuite_test_modinfo_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
295 testsuite_test_util_LDADD = $(TESTSUITE_LDADD)
296 testsuite_test_util_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
297 testsuite_test_new_module_LDADD = $(TESTSUITE_LDADD)
298 testsuite_test_new_module_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
299 testsuite_test_modprobe_LDADD = $(TESTSUITE_LDADD)
300 testsuite_test_modprobe_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
301 testsuite_test_blacklist_LDADD = $(TESTSUITE_LDADD)
302 testsuite_test_blacklist_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
303 testsuite_test_dependencies_LDADD = $(TESTSUITE_LDADD)
304 testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
305 testsuite_test_depmod_LDADD = $(TESTSUITE_LDADD)
306 testsuite_test_depmod_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
307 testsuite_test_list_LDADD = $(TESTSUITE_LDADD)
308 testsuite_test_list_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
309
310 if BUILD_EXPERIMENTAL
311 testsuite_test_tools_LDADD = $(TESTSUITE_LDADD)
312 testsuite_test_tools_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
313 endif
314
315 testsuite-distclean:
316 $(RM) -r $(ROOTFS)
317 $(RM) testsuite/stamp-rootfs
318 $(MAKE) -C testsuite/module-playground/ clean
319 if test "$(top_srcdir)" != "$(top_builddir)"; then \
320 $(RM) -rf testsuite/module-playground; \
321 fi
322
323 DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
324 EXTRA_DIST += testsuite/rootfs-pristine
325
326 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc \
327 --with-zlib --with-zstd --with-openssl \
328 --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir)
329
330 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
331
332 buildtest-TESTS:
333 $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
334
335 # ------------------------------------------------------------------------------
336 # coverage
337 # ------------------------------------------------------------------------------
338
339 # .PHONY so it always rebuilds it
340 .PHONY: coverage lcov-run lcov-report coverage-sync
341
342 # run lcov from scratch, always
343 coverage: all
344 $(MAKE) lcov-run
345 $(MAKE) lcov-report
346
347 coverage_dir = coverage
348 coverage_opts = --base-directory $(srcdir) --directory $(builddir) \
349 --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
350
351 if ENABLE_COVERAGE
352 # reset run coverage tests
353 lcov-run:
354 @rm -rf $(coverage_dir)
355 lcov $(coverage_opts) --zerocounters
356 -$(MAKE) check
357
358 # generate report based on current coverage data
359 lcov-report:
360 $(MKDIR_P) $(coverage_dir)
361 lcov $(coverage_opts) --capture --no-external --ignore-errors graph \
362 | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
363 lcov --remove $(coverage_dir)/.lcov.info --output-file $(coverage_dir)/.lcov-clean.info 'test-*'
364 genhtml -t "kmod test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov-clean.info
365 @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
366
367 else
368
369 lcov-run lcov-report:
370 echo "Need to reconfigure with --enable-coverage"
371
372 endif
373
374 # ------------------------------------------------------------------------------
375 # coverity
376 # ------------------------------------------------------------------------------
377
378 kmod-coverity-%.tar.xz:
379 rm -rf $< cov-int
380 ./autogen.sh c --disable-manpages
381 make clean
382 cov-build --dir cov-int make -j 4
383 tar caf $@ cov-int
384
385 coverity-tar: kmod-coverity-$(shell git describe 2>/dev/null).tar.xz
386
387 coverity-sync: kmod-coverity-$(shell git describe 2>/dev/null).tar.xz
388 @echo "uploading coverity tarball"
389 @curl --form token=$(COVERITY_KMOD_TOKEN) \
390 --form email=lucas.de.marchi@gmail.com \
391 --form file=@$< \
392 --form version="$(shell git describe)" \
393 --form description="" \
394 https://scan.coverity.com/builds?project=kmod
395
396 coverity-clean:
397 rm -rf kmod-coverity-*.tar.xz cov-int
398
399 # ------------------------------------------------------------------------------
400 # custom release helpers
401 # ------------------------------------------------------------------------------
402
403 git-release:
404 head -1 NEWS | grep -q "kmod $(VERSION)"
405 git commit -a -m "kmod $(VERSION)"
406 git tag -m "kmod $(VERSION)" -s v$(VERSION)
407 git gc --prune=0
408
409 kmod-$(VERSION).tar.xz:
410 make distcheck
411
412 kmod-$(VERSION).tar.sign:
413 xz -d -c kmod-$(VERSION).tar.xz | gpg --armor --detach-sign --output kmod-$(VERSION).tar.sign
414
415 tar: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
416
417 tar-sync: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
418 kup put kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign /pub/linux/utils/kernel/kmod/
419
420 # ------------------------------------------------------------------------------
421 # mkosi
422 # ------------------------------------------------------------------------------
423
424 DISTRO ?= "arch"
425
426 mkosi:
427 -$(MKDIR_P) $(top_srcdir)/testsuite/mkosi/mkosi.cache
428 $(MKOSI) -C $(top_srcdir)/testsuite/mkosi --build-sources ../../ --default mkosi.${DISTRO} -fi