diff options
Diffstat (limited to 'share/mk/lint/c')
-rw-r--r-- | share/mk/lint/c/_.mk | 18 | ||||
-rw-r--r-- | share/mk/lint/c/checkpatch.mk | 35 | ||||
-rw-r--r-- | share/mk/lint/c/clang-tidy.mk | 188 | ||||
-rw-r--r-- | share/mk/lint/c/cppcheck.mk | 74 | ||||
-rw-r--r-- | share/mk/lint/c/cpplint.mk | 27 | ||||
-rw-r--r-- | share/mk/lint/c/iwyu.mk | 109 |
6 files changed, 451 insertions, 0 deletions
diff --git a/share/mk/lint/c/_.mk b/share/mk/lint/c/_.mk new file mode 100644 index 0000000..dc2f3e2 --- /dev/null +++ b/share/mk/lint/c/_.mk @@ -0,0 +1,18 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_INCLUDED +MAKEFILE_LINT_C_INCLUDED := 1 + + +.PHONY: lint-c +lint-c: \ + lint-c-checkpatch \ + lint-c-clang-tidy \ + lint-c-cppcheck \ + lint-c-cpplint \ + lint-c-iwyu + + +endif # include guard diff --git a/share/mk/lint/c/checkpatch.mk b/share/mk/lint/c/checkpatch.mk new file mode 100644 index 0000000..7777a10 --- /dev/null +++ b/share/mk/lint/c/checkpatch.mk @@ -0,0 +1,35 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CHECKPATCH_INCLUDED +MAKEFILE_LINT_C_CHECKPATCH_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/checkpatch.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_checkpatch := $(_MANDIR)/man2/bpf.2.d/bpf.lint-c.checkpatch.touch + + +_LINT_c_checkpatch := $(patsubst %.c, %.lint-c.checkpatch.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_checkpatch := $(filter-out $(_XFAIL_LINT_c_checkpatch), $(_LINT_c_checkpatch)) +endif + + +$(_LINT_c_checkpatch): %.lint-c.checkpatch.touch: %.c $(CHECKPATCH_CONF) $(MK) + $(info $(INFO_)CHECKPATCH $@) + $(CHECKPATCH) $(CHECKPATCHFLAGS) -f $< >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-checkpatch +lint-c-checkpatch: $(_LINT_c_checkpatch); + + +endif # include guard diff --git a/share/mk/lint/c/clang-tidy.mk b/share/mk/lint/c/clang-tidy.mk new file mode 100644 index 0000000..fd2e536 --- /dev/null +++ b/share/mk/lint/c/clang-tidy.mk @@ -0,0 +1,188 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CLANG_TIDY_INCLUDED +MAKEFILE_LINT_C_CLANG_TIDY_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/clang.mk +include $(MAKEFILEDIR)/configure/build-depends/clang-tidy.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpp.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_clang_tidy := \ + $(_MANDIR)/man2/add_key.2.d/add_key.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/bpf.2.d/bpf.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/chown.2.d/chown.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/clone.2.d/clone.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/close_range.2.d/close_range.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/copy_file_range.2.d/copy_file_range.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/eventfd.2.d/eventfd.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/execve.2.d/execve.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/execve.2.d/myecho.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/futex.2.d/futex.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/getdents.2.d/getdents.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/getrlimit.2.d/getrlimit.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/display_fat_volume_id.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/ioctl_fat.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/toggle_fat_archive_flag.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_ns.2.d/ns_show.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_tty.2.d/tcgets.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/kcmp.2.d/kcmp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/keyctl.2.d/key_instantiate.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/listxattr.2.d/listxattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/membarrier.2.d/membarrier.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_get_seals.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_memfd_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mmap.2.d/mmap.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mount_setattr.2.d/mount_setattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mprotect.2.d/mprotect.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/msgop.2.d/msgop.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_name_to_handle_at.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_open_by_handle_at.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/perf_event_open.2.d/perf_event_open.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pidfd_open.2.d/pidfd_open.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pidfd_send_signal.2.d/pidfd_send_signal.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pipe.2.d/pipe.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pivot_root.2.d/pivot_root.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/poll.2.d/poll_input.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/process_vm_readv.2.d/process_vm_readv.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/readlink.2.d/readlink.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/recvmmsg.2.d/recvmmsg.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/request_key.2.d/t_request_key.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sched_setaffinity.2.d/sched_setaffinity.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/seccomp.2.d/seccomp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/seccomp_unotify.2.d/seccomp_unotify.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/select_tut.2.d/select.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/semget.2.d/t_semget.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sendmmsg.2.d/sendmmsg.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/setns.2.d/setns.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_read.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_write.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sigaction.2.d/sigaction.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/spu_run.2.d/spu_run.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/stat.2.d/stat.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/_syscall.2.d/_syscall.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/syscall.2.d/syscall.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sysctl.2.d/sysctl.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/tee.2.d/tee.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/timer_create.2.d/timer_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/timerfd_create.2.d/timerfd_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/unshare.2.d/unshare.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/userfaultfd.2.d/userfaultfd.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/wait.2.d/wait.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/atexit.3.d/atexit.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/backtrace.3.d/backtrace.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/bswap.3.d/bswap.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/cacos.3.d/cacos.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/cacosh.3.d/cacosh.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/catan.3.d/catan.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/catanh.3.d/catanh.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/circleq.3.d/circleq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/clock_getcpuclockid.3.d/clock_getcpuclockid.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/CPU_SET.3.d/CPU_SET.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/dlinfo.3.d/dlinfo.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/duplocale.3.d/duplocale.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/encrypt.3.d/encrypt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/end.3.d/end.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/endian.3.d/endian.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fmemopen.3.d/fmemopen.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fopencookie.3.d/fopencookie.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fread.3.d/fread.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/frexp.3.d/frexp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/ftw.3.d/ftw.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/_Generic.3.d/_Generic.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/client.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/server.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/async.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/sync.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getdate.3.d/getdate.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getgrent_r.3.d/getgrent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getline.3.d/getline.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt_long.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getprotoent_r.3.d/getprotoent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getpwnam.3.d/getpwnam.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getservent_r.3.d/getservent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getsubopt.3.d/getsubopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getutent.3.d/getutent.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/hsearch.3.d/hsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/if_nameindex.3.d/if_nameindex.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet.3.d/inet.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet_pton.3.d/inet_pton.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/insque.3.d/insque.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/list.3.d/list.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mallinfo.3.d/mallinfo.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mallopt.3.d/mallopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/matherr.3.d/matherr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/MAX.3.d/MAX.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mbstowcs.3.d/mbstowcs.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mq_getattr.3.d/mq_getattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mq_notify.3.d/mq_notify.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/offsetof.3.d/offsetof.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/posix_spawn.3.d/posix_spawn.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/__ppc_get_timebase.3.d/__ppc_get_timebase.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_cleanup_push.3.d/pthread_cleanup_push.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_create.3.d/pthread_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_setname_np.3.d/pthread_setname_np.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/qsort.3.d/qsort.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rand.3.d/rand.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rpmatch.3.d/rpmatch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rtime.3.d/rtime.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/scandir.3.d/scandir.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/sem_wait.3.d/sem_wait.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/setbuf.3.d/setbuf.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_bounce.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/slist.3.d/slist.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/stailq.3.d/stailq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/static_assert.3.d/must_be.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/stpncpy.3.d/stpncpy.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strcmp.3.d/string_comp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strcpy.3.d/strcpy.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strftime.3.d/strftime.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strsep.3.d/strsep.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strtok.3.d/strtok.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strtol.3.d/strtol.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strverscmp.3.d/strverscmp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/tailq.3.d/tailq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/tsearch.3.d/tsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/wordexp.3.d/wordexp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3const/EXIT_SUCCESS.3const.d/EXIT_SUCCESS.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3head/printf.h.3head.d/register_printf_specifier.lint-c.clang-tidy.touch + + +_LINT_c_clang_tidy := $(patsubst %.c, %.lint-c.clang-tidy.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_clang_tidy := $(filter-out $(_XFAIL_LINT_c_clang_tidy), $(_LINT_c_clang_tidy)) +endif + + +$(_LINT_c_clang_tidy): %.lint-c.clang-tidy.touch: %.c $(CLANG_TIDY_CONF) $(MK) + $(info $(INFO_)CLANG_TIDY $@) + $(CLANG_TIDY) $(CLANG_TIDYFLAGS) $< -- $(CPPFLAGS) $(CLANGFLAGS) 2>&1 \ + | $(SED) '/generated\.$$/d' >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-clang-tidy +lint-c-clang-tidy: $(_LINT_c_clang_tidy); + + +endif # include guard diff --git a/share/mk/lint/c/cppcheck.mk b/share/mk/lint/c/cppcheck.mk new file mode 100644 index 0000000..5fa74ac --- /dev/null +++ b/share/mk/lint/c/cppcheck.mk @@ -0,0 +1,74 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CPPCHECK_INCLUDED +MAKEFILE_LINT_C_CPPCHECK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cppcheck.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_cppcheck := \ + $(_MANDIR)/man2/chown.2.d/chown.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/close_range.2.d/close_range.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/kcmp.2.d/kcmp.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/keyctl.2.d/key_instantiate.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_memfd_create.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/msgop.2.d/msgop.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_open_by_handle_at.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_read.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/unshare.2.d/unshare.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/dlopen.3.d/dlopen.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/encrypt.3.d/encrypt.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/async.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getdate.3.d/getdate.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/hsearch.3.d/hsearch.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mallopt.3.d/mallopt.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/matherr.3.d/matherr.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mcheck.3.d/mcheck.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mtrace.3.d/t_mtrace.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_create.3.d/pthread_create.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/setaliasent.3.d/setaliasent.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/setbuf.3.d/setbuf.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/stpncpy.3.d/stpncpy.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strftime.3.d/strftime.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strncat.3.d/strncat.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strsep.3.d/strsep.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strtok.3.d/strtok.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strtol.3.d/strtol.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/tsearch.3.d/tsearch.lint-c.cppcheck.touch + + +_LINT_c_cppcheck := $(patsubst %.c, %.lint-c.cppcheck.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_cppcheck := $(filter-out $(_XFAIL_LINT_c_cppcheck), $(_LINT_c_cppcheck)) +endif + + +$(_LINT_c_cppcheck): %.lint-c.cppcheck.touch: %.c $(CPPCHECK_SUPPRESS) $(MK) + $(info $(INFO_)CPPCHECK $@) + $(CPPCHECK) $(CPPCHECKFLAGS) $< + $(TOUCH) $@ + + +.PHONY: lint-c-cppcheck +lint-c-cppcheck: $(_LINT_c_cppcheck); + + +endif # include guard diff --git a/share/mk/lint/c/cpplint.mk b/share/mk/lint/c/cpplint.mk new file mode 100644 index 0000000..8eb3984 --- /dev/null +++ b/share/mk/lint/c/cpplint.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CPPLINT_INCLUDED +MAKEFILE_LINT_C_CPPLINT_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpplint.mk + + +_LINT_c_cpplint := $(patsubst %.c, %.lint-c.cpplint.touch, $(_UNITS_ex_c)) + + +$(_LINT_c_cpplint): %.lint-c.cpplint.touch: %.c $(CPPLINT_CONF) $(MK) + $(info $(INFO_)CPPLINT $@) + $(CPPLINT) $(CPPLINTFLAGS) $< >/dev/null + $(TOUCH) $@ + + +.PHONY: lint-c-cpplint +lint-c-cpplint: $(_LINT_c_cpplint); + + +endif # include guard diff --git a/share/mk/lint/c/iwyu.mk b/share/mk/lint/c/iwyu.mk new file mode 100644 index 0000000..32c2c07 --- /dev/null +++ b/share/mk/lint/c/iwyu.mk @@ -0,0 +1,109 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_IWYU_INCLUDED +MAKEFILE_LINT_C_IWYU_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/clang.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpp.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/iwyu.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_iwyu := \ + $(_MANDIR)/man2/clock_getres.2.d/clock_getres.lint-c.iwyu.touch \ + $(_MANDIR)/man2/getrlimit.2.d/getrlimit.lint-c.iwyu.touch \ + $(_MANDIR)/man2/listxattr.2.d/listxattr.lint-c.iwyu.touch \ + $(_MANDIR)/man2/mount_setattr.2.d/mount_setattr.lint-c.iwyu.touch \ + $(_MANDIR)/man2/recvmmsg.2.d/recvmmsg.lint-c.iwyu.touch \ + $(_MANDIR)/man2/seccomp.2.d/seccomp.lint-c.iwyu.touch \ + $(_MANDIR)/man2/seccomp_unotify.2.d/seccomp_unotify.lint-c.iwyu.touch \ + $(_MANDIR)/man2/select.2.d/select.lint-c.iwyu.touch \ + $(_MANDIR)/man2/semget.2.d/t_semget.lint-c.iwyu.touch \ + $(_MANDIR)/man2/sendmmsg.2.d/sendmmsg.lint-c.iwyu.touch \ + $(_MANDIR)/man2/_syscall.2.d/_syscall.lint-c.iwyu.touch \ + $(_MANDIR)/man2/timer_create.2.d/timer_create.lint-c.iwyu.touch \ + $(_MANDIR)/man2/userfaultfd.2.d/userfaultfd.lint-c.iwyu.touch \ + $(_MANDIR)/man3/backtrace.3.d/backtrace.lint-c.iwyu.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.iwyu.touch \ + $(_MANDIR)/man3/bswap.3.d/bswap.lint-c.iwyu.touch \ + $(_MANDIR)/man3/cacos.3.d/cacos.lint-c.iwyu.touch \ + $(_MANDIR)/man3/cacosh.3.d/cacosh.lint-c.iwyu.touch \ + $(_MANDIR)/man3/catan.3.d/catan.lint-c.iwyu.touch \ + $(_MANDIR)/man3/catanh.3.d/catanh.lint-c.iwyu.touch \ + $(_MANDIR)/man3/clock_getcpuclockid.3.d/clock_getcpuclockid.lint-c.iwyu.touch \ + $(_MANDIR)/man3/CPU_SET.3.d/CPU_SET.lint-c.iwyu.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.iwyu.touch \ + $(_MANDIR)/man3/dlinfo.3.d/dlinfo.lint-c.iwyu.touch \ + $(_MANDIR)/man3/duplocale.3.d/duplocale.lint-c.iwyu.touch \ + $(_MANDIR)/man3/endian.3.d/endian.lint-c.iwyu.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.iwyu.touch \ + $(_MANDIR)/man3/fopencookie.3.d/fopencookie.lint-c.iwyu.touch \ + $(_MANDIR)/man3/frexp.3.d/frexp.lint-c.iwyu.touch \ + $(_MANDIR)/man3/ftw.3.d/ftw.lint-c.iwyu.touch \ + $(_MANDIR)/man3/_Generic.3.d/_Generic.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/client.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/server.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getline.3.d/getline.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt_long.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getprotoent_r.3.d/getprotoent_r.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getservent_r.3.d/getservent_r.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getsubopt.3.d/getsubopt.lint-c.iwyu.touch \ + $(_MANDIR)/man3/if_nameindex.3.d/if_nameindex.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet.3.d/inet.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet_pton.3.d/inet_pton.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mallinfo.3.d/mallinfo.lint-c.iwyu.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mbstowcs.3.d/mbstowcs.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mq_getattr.3.d/mq_getattr.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mq_notify.3.d/mq_notify.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mtrace.3.d/t_mtrace.lint-c.iwyu.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.iwyu.touch \ + $(_MANDIR)/man3/posix_spawn.3.d/posix_spawn.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_cleanup_push.3.d/pthread_cleanup_push.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getattr_default_np.3.d/pthread_getattr_default_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setaffinity_np.3.d/pthread_setaffinity_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setname_np.3.d/pthread_setname_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.iwyu.touch \ + $(_MANDIR)/man3/sem_wait.3.d/sem_wait.lint-c.iwyu.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_bounce.lint-c.iwyu.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.iwyu.touch \ + $(_MANDIR)/man3/slist.3.d/slist.lint-c.iwyu.touch + + +_LINT_c_iwyu := $(patsubst %.c, %.lint-c.iwyu.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_iwyu := $(filter-out $(_XFAIL_LINT_c_iwyu), $(_LINT_c_iwyu)) +endif + + +$(_LINT_c_iwyu): %.lint-c.iwyu.touch: %.c $(MK) + $(info $(INFO_)IWYU $@) + ! ($(IWYU) $(IWYUFLAGS) $(CPPFLAGS) $(CLANGFLAGS) $< 2>&1 \ + | $(SED) -n '/should add these lines:/,$$p' \ + | $(TAC) \ + | $(SED) '/correct/{N;d}' \ + | $(TAC) \ + || $(TRUE); \ + ) \ + | $(GREP) ^ >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-iwyu +lint-c-iwyu: $(_LINT_c_iwyu); + + +endif # include guard |