]> git.ipfire.org Git - thirdparty/kmod.git/blob - Makefile.am
make: install/uninstall tools symlinks to kmod
[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 if BUILD_TOOLS
115 for tool in insmod lsmod rmmod depmod modprobe modinfo; do \
116 $(LN_S) kmod $(DESTDIR)$(bindir)/$$tool; \
117 done
118 endif
119
120 uninstall-hook:
121 rm -f $(DESTDIR)$(rootlibdir)/libkmod.so*
122 if BUILD_TOOLS
123 for tool in insmod lsmod rmmod depmod modprobe modinfo; do \
124 rm -f $(DESTDIR)$(bindir)/$$tool; \
125 done
126 endif
127
128 if BUILD_TOOLS
129 bin_PROGRAMS = tools/kmod
130
131 noinst_SCRIPTS = \
132 tools/insmod tools/rmmod tools/lsmod \
133 tools/modprobe tools/modinfo tools/depmod
134
135 tools_kmod_SOURCES = \
136 tools/kmod.c tools/kmod.h tools/lsmod.c \
137 tools/rmmod.c tools/insmod.c \
138 tools/modinfo.c tools/modprobe.c \
139 tools/depmod.c tools/log.h tools/log.c \
140 tools/static-nodes.c
141
142 if BUILD_EXPERIMENTAL
143 tools_kmod_SOURCES += \
144 tools/insert.c \
145 tools/remove.c
146 endif
147
148 tools_kmod_LDADD = \
149 shared/libshared.la \
150 libkmod/libkmod-internal.la
151
152 ${noinst_SCRIPTS}: tools/kmod
153 $(AM_V_GEN) ($(RM) $@; \
154 $(LN_S) $(notdir $<) $@)
155 endif
156
157 # ------------------------------------------------------------------------------
158 # TESTSUITE
159 # ------------------------------------------------------------------------------
160
161 EXTRA_DIST += testsuite/setup-rootfs.sh
162
163 MODULE_PLAYGROUND = testsuite/module-playground
164 ROOTFS = testsuite/rootfs
165 ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine
166 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)
167
168 build-module-playground:
169 $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \
170 $(RM) -rf testsuite/module-playground && \
171 mkdir -p testsuite/ && \
172 cp -r $(top_srcdir)/$(MODULE_PLAYGROUND) $(top_builddir)/$(MODULE_PLAYGROUND) && \
173 find $(top_builddir)/$(MODULE_PLAYGROUND) -type d -exec chmod +w {} \; ; \
174 fi
175 if BUILD_MODULES
176 $(MAKE) -C $(MODULE_PLAYGROUND)
177 else
178 $(MAKE) -C $(MODULE_PLAYGROUND) FAKE_BUILD=1
179 endif
180
181
182 rootfs: build-module-playground
183 $(CREATE_ROOTFS)
184
185 .PHONY: rootfs build-playground
186
187 $(ROOTFS): $(ROOTFS_PRISTINE)
188 $(CREATE_ROOTFS)
189
190 TESTSUITE_OVERRIDE_LIBS = \
191 testsuite/uname.la testsuite/path.la \
192 testsuite/init_module.la \
193 testsuite/delete_module.la
194 TESTSUITE_OVERRIDE_LIBS_LDFLAGS = \
195 avoid-version -module -shared -export-dynamic -rpath /nowhere -ldl
196
197 check-am: rootfs
198
199
200 EXTRA_DIST += \
201 testsuite/module-playground/cache \
202 testsuite/module-playground/dummy.pkcs7 \
203 testsuite/module-playground/dummy.sha1 \
204 testsuite/module-playground/dummy.sha256 \
205 testsuite/module-playground/Makefile \
206 testsuite/module-playground/Makefile.arch \
207 testsuite/module-playground/mod-fake-cciss.c \
208 testsuite/module-playground/mod-fake-hpsa.c \
209 testsuite/module-playground/mod-fake-scsi-mod.c \
210 testsuite/module-playground/mod-foo-a.c \
211 testsuite/module-playground/mod-foo-b.c \
212 testsuite/module-playground/mod-foo.c \
213 testsuite/module-playground/mod-foo-c.c \
214 testsuite/module-playground/mod-loop-a.c \
215 testsuite/module-playground/mod-loop-b.c \
216 testsuite/module-playground/mod-loop-c.c \
217 testsuite/module-playground/mod-loop-d.c \
218 testsuite/module-playground/mod-loop-e.c \
219 testsuite/module-playground/mod-loop-f.c \
220 testsuite/module-playground/mod-loop-g.c \
221 testsuite/module-playground/mod-loop-h.c \
222 testsuite/module-playground/mod-loop-i.c \
223 testsuite/module-playground/mod-loop-j.c \
224 testsuite/module-playground/mod-loop-k.c \
225 testsuite/module-playground/mod-loop.h \
226 testsuite/module-playground/mod-simple.c \
227 testsuite/module-playground/mod-simple-i386.ko \
228 testsuite/module-playground/mod-simple-sparc64.ko \
229 testsuite/module-playground/mod-simple-x86_64.ko \
230 testsuite/module-playground/README
231
232 check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
233
234 testsuite_uname_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
235 testsuite_path_la_CPPFLAGS = $(AM_CPPFLAGS) \
236 -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
237 testsuite_path_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
238
239 testsuite_delete_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
240 testsuite_init_module_la_LDFLAGS = $(TESTSUITE_OVERRIDE_LIBS_LDFLAGS)
241 testsuite_init_module_la_SOURCES = testsuite/init_module.c \
242 testsuite/stripped-module.h
243 testsuite_init_module_la_LIBADD = libkmod/libkmod-internal.la
244
245 TESTSUITE_CPPFLAGS = $(AM_CPPFLAGS) \
246 -DTESTSUITE_ROOTFS=\"$(abs_top_builddir)/$(ROOTFS)/\" \
247 -DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"
248 TESTSUITE_LDADD = \
249 testsuite/libtestsuite.la libkmod/libkmod-internal.la \
250 shared/libshared.la
251
252 check_LTLIBRARIES += testsuite/libtestsuite.la
253 testsuite_libtestsuite_la_SOURCES = \
254 testsuite/testsuite.c testsuite/testsuite.h
255 testsuite_libtestsuite_la_DEPENDENCIES = \
256 $(ROOTFS) $(TESTSUITE_OVERRIDE_LIBS)
257 testsuite_libtestsuite_la_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
258 testsuite_libtestsuite_la_LIBADD = -lrt
259
260 TESTSUITE = \
261 testsuite/test-hash \
262 testsuite/test-array \
263 testsuite/test-scratchbuf \
264 testsuite/test-strbuf \
265 testsuite/test-init \
266 testsuite/test-initstate \
267 testsuite/test-testsuite testsuite/test-loaded \
268 testsuite/test-modinfo testsuite/test-util testsuite/test-new-module \
269 testsuite/test-modprobe testsuite/test-blacklist \
270 testsuite/test-dependencies testsuite/test-depmod \
271 testsuite/test-list
272
273 if BUILD_EXPERIMENTAL
274 TESTSUITE += \
275 testsuite/test-tools
276 endif
277
278 check_PROGRAMS = $(TESTSUITE)
279 TESTS = $(TESTSUITE)
280
281 testsuite_test_testsuite_LDADD = \
282 testsuite/libtestsuite.la shared/libshared.la
283 testsuite_test_testsuite_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
284
285 testsuite_test_hash_LDADD = $(TESTSUITE_LDADD)
286 testsuite_test_hash_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
287
288 testsuite_test_array_LDADD = $(TESTSUITE_LDADD)
289 testsuite_test_array_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
290
291 testsuite_test_scratchbuf_LDADD = $(TESTSUITE_LDADD)
292 testsuite_test_scratchbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
293
294 testsuite_test_strbuf_LDADD = $(TESTSUITE_LDADD)
295 testsuite_test_strbuf_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
296
297 testsuite_test_init_LDADD = $(TESTSUITE_LDADD)
298 testsuite_test_init_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
299 testsuite_test_initstate_LDADD = $(TESTSUITE_LDADD)
300 testsuite_test_initstate_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
301 testsuite_test_loaded_LDADD = $(TESTSUITE_LDADD)
302 testsuite_test_loaded_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
303 testsuite_test_modinfo_LDADD = $(TESTSUITE_LDADD)
304 testsuite_test_modinfo_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
305 testsuite_test_util_LDADD = $(TESTSUITE_LDADD)
306 testsuite_test_util_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
307 testsuite_test_new_module_LDADD = $(TESTSUITE_LDADD)
308 testsuite_test_new_module_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
309 testsuite_test_modprobe_LDADD = $(TESTSUITE_LDADD)
310 testsuite_test_modprobe_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
311 testsuite_test_blacklist_LDADD = $(TESTSUITE_LDADD)
312 testsuite_test_blacklist_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
313 testsuite_test_dependencies_LDADD = $(TESTSUITE_LDADD)
314 testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
315 testsuite_test_depmod_LDADD = $(TESTSUITE_LDADD)
316 testsuite_test_depmod_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
317 testsuite_test_list_LDADD = $(TESTSUITE_LDADD)
318 testsuite_test_list_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
319
320 if BUILD_EXPERIMENTAL
321 testsuite_test_tools_LDADD = $(TESTSUITE_LDADD)
322 testsuite_test_tools_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
323 endif
324
325 testsuite-distclean:
326 $(RM) -r $(ROOTFS)
327 $(RM) testsuite/stamp-rootfs
328 $(MAKE) -C testsuite/module-playground/ clean
329 if test "$(top_srcdir)" != "$(top_builddir)"; then \
330 $(RM) -rf testsuite/module-playground; \
331 fi
332
333 DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
334 EXTRA_DIST += testsuite/rootfs-pristine
335
336 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc \
337 --with-zlib --with-zstd --with-openssl \
338 --with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir)
339
340 distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
341
342 buildtest-TESTS:
343 $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
344
345 # ------------------------------------------------------------------------------
346 # coverage
347 # ------------------------------------------------------------------------------
348
349 # .PHONY so it always rebuilds it
350 .PHONY: coverage lcov-run lcov-report coverage-sync
351
352 # run lcov from scratch, always
353 coverage: all
354 $(MAKE) lcov-run
355 $(MAKE) lcov-report
356
357 coverage_dir = coverage
358 coverage_opts = --base-directory $(srcdir) --directory $(builddir) \
359 --rc 'geninfo_adjust_src_path=$(abspath $(srcdir))=>$(abspath $(builddir))'
360
361 if ENABLE_COVERAGE
362 # reset run coverage tests
363 lcov-run:
364 @rm -rf $(coverage_dir)
365 lcov $(coverage_opts) --zerocounters
366 -$(MAKE) check
367
368 # generate report based on current coverage data
369 lcov-report:
370 $(MKDIR_P) $(coverage_dir)
371 lcov $(coverage_opts) --capture --no-external --ignore-errors graph \
372 | sed 's|$(abspath $(builddir))|$(abspath $(srcdir))|' > $(coverage_dir)/.lcov.info
373 lcov --remove $(coverage_dir)/.lcov.info --output-file $(coverage_dir)/.lcov-clean.info 'test-*'
374 genhtml -t "kmod test coverage" -o $(coverage_dir) $(coverage_dir)/.lcov-clean.info
375 @echo "Coverage report generated in $(abs_builddir)/$(coverage_dir)/index.html"
376
377 else
378
379 lcov-run lcov-report:
380 echo "Need to reconfigure with --enable-coverage"
381
382 endif
383
384 # ------------------------------------------------------------------------------
385 # coverity
386 # ------------------------------------------------------------------------------
387
388 kmod-coverity-%.tar.xz:
389 rm -rf $< cov-int
390 ./autogen.sh c --disable-manpages
391 make clean
392 cov-build --dir cov-int make -j 4
393 tar caf $@ cov-int
394
395 coverity-tar: kmod-coverity-$(shell git describe 2>/dev/null).tar.xz
396
397 coverity-sync: kmod-coverity-$(shell git describe 2>/dev/null).tar.xz
398 @echo "uploading coverity tarball"
399 @curl --form token=$(COVERITY_KMOD_TOKEN) \
400 --form email=lucas.de.marchi@gmail.com \
401 --form file=@$< \
402 --form version="$(shell git describe)" \
403 --form description="" \
404 https://scan.coverity.com/builds?project=kmod
405
406 coverity-clean:
407 rm -rf kmod-coverity-*.tar.xz cov-int
408
409 # ------------------------------------------------------------------------------
410 # custom release helpers
411 # ------------------------------------------------------------------------------
412
413 git-release:
414 head -1 NEWS | grep -q "kmod $(VERSION)"
415 git commit -a -m "kmod $(VERSION)"
416 git tag -m "kmod $(VERSION)" -s v$(VERSION)
417 git gc --prune=0
418
419 kmod-$(VERSION).tar.xz:
420 make distcheck
421
422 kmod-$(VERSION).tar.sign:
423 xz -d -c kmod-$(VERSION).tar.xz | gpg --armor --detach-sign --output kmod-$(VERSION).tar.sign
424
425 tar: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
426
427 tar-sync: kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign
428 kup put kmod-$(VERSION).tar.xz kmod-$(VERSION).tar.sign /pub/linux/utils/kernel/kmod/