1d6fc9fcbSMasahiro Yamada# SPDX-License-Identifier: GPL-2.0-only 2d6fc9fcbSMasahiro Yamada 3d6fc9fcbSMasahiro Yamada# Unlike the kernel space, exported headers are written in standard C. 4d6fc9fcbSMasahiro Yamada# - Forbid C++ style comments 5d6fc9fcbSMasahiro Yamada# - Use '__inline__', '__asm__' instead of 'inline', 'asm' 6d6fc9fcbSMasahiro Yamada# 7d6fc9fcbSMasahiro Yamada# -std=c90 (equivalent to -ansi) catches the violation of those. 8d6fc9fcbSMasahiro Yamada# We cannot go as far as adding -Wpedantic since it emits too many warnings. 9*c4cb34aeSThomas WeißschuhUAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration 10d6fc9fcbSMasahiro Yamada 11*c4cb34aeSThomas Weißschuhoverride c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include 12d6fc9fcbSMasahiro Yamada 13d6fc9fcbSMasahiro Yamada# The following are excluded for now because they fail to build. 14d6fc9fcbSMasahiro Yamada# 15d6fc9fcbSMasahiro Yamada# Do not add a new header to the blacklist without legitimate reason. 16d6fc9fcbSMasahiro Yamada# Please consider to fix the header first. 17d6fc9fcbSMasahiro Yamada# 18d6fc9fcbSMasahiro Yamada# Sorted alphabetically. 190186b126SMasahiro Yamadano-header-test += asm/ucontext.h 200186b126SMasahiro Yamadano-header-test += drm/vmwgfx_drm.h 210186b126SMasahiro Yamadano-header-test += linux/am437x-vpfe.h 220186b126SMasahiro Yamadano-header-test += linux/coda.h 23d1ad2721SGreg Kroah-Hartmanno-header-test += linux/cyclades.h 240186b126SMasahiro Yamadano-header-test += linux/errqueue.h 250186b126SMasahiro Yamadano-header-test += linux/hdlc/ioctl.h 260186b126SMasahiro Yamadano-header-test += linux/ivtv.h 270186b126SMasahiro Yamadano-header-test += linux/matroxfb.h 280186b126SMasahiro Yamadano-header-test += linux/omap3isp.h 290186b126SMasahiro Yamadano-header-test += linux/omapfb.h 300186b126SMasahiro Yamadano-header-test += linux/patchkey.h 310186b126SMasahiro Yamadano-header-test += linux/phonet.h 320186b126SMasahiro Yamadano-header-test += linux/sctp.h 330186b126SMasahiro Yamadano-header-test += linux/sysctl.h 340186b126SMasahiro Yamadano-header-test += linux/usb/audio.h 350186b126SMasahiro Yamadano-header-test += linux/v4l2-mediabus.h 360186b126SMasahiro Yamadano-header-test += linux/v4l2-subdev.h 370186b126SMasahiro Yamadano-header-test += linux/videodev2.h 380186b126SMasahiro Yamadano-header-test += linux/vm_sockets.h 390186b126SMasahiro Yamadano-header-test += sound/asequencer.h 400186b126SMasahiro Yamadano-header-test += sound/asoc.h 410186b126SMasahiro Yamadano-header-test += sound/asound.h 420186b126SMasahiro Yamadano-header-test += sound/compress_offload.h 430186b126SMasahiro Yamadano-header-test += sound/emu10k1.h 440186b126SMasahiro Yamadano-header-test += sound/sfnt_info.h 450186b126SMasahiro Yamadano-header-test += xen/evtchn.h 460186b126SMasahiro Yamadano-header-test += xen/gntdev.h 470186b126SMasahiro Yamadano-header-test += xen/privcmd.h 48d6fc9fcbSMasahiro Yamada 49d6fc9fcbSMasahiro Yamada# More headers are broken in some architectures 50d6fc9fcbSMasahiro Yamada 51d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),arc) 520186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h 53d6fc9fcbSMasahiro Yamadaendif 54d6fc9fcbSMasahiro Yamada 5556045757SRandy Dunlapifeq ($(SRCARCH),openrisc) 5656045757SRandy Dunlapno-header-test += linux/bpf_perf_event.h 5756045757SRandy Dunlapendif 5856045757SRandy Dunlap 59d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),powerpc) 600186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h 61d6fc9fcbSMasahiro Yamadaendif 62d6fc9fcbSMasahiro Yamada 63d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),sparc) 640186b126SMasahiro Yamadano-header-test += asm/uctx.h 650186b126SMasahiro Yamadano-header-test += asm/fbio.h 66d6fc9fcbSMasahiro Yamadaendif 67d6fc9fcbSMasahiro Yamada 68d6fc9fcbSMasahiro Yamada# asm-generic/*.h is used by asm/*.h, and should not be included directly 690186b126SMasahiro Yamadano-header-test += asm-generic/% 70d6fc9fcbSMasahiro Yamada 71c1ea04d8SMasahiro Yamadaalways-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) 72fcbb8461SMasahiro Yamada 7300d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard. 74fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $< 757ecaf069SMasahiro Yamada cmd_hdrtest = \ 763788d69dSThomas Weißschuh $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ 770186b126SMasahiro Yamada $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ 78d67393f4SGeert Uytterhoeven $(PERL) $(src)/headers_check.pl $(obj) $<; \ 797ecaf069SMasahiro Yamada touch $@ 80fcbb8461SMasahiro Yamada 81d4b7080bSThomas Weißschuh$(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE 82fcbb8461SMasahiro Yamada $(call if_changed_dep,hdrtest) 83d6fc9fcbSMasahiro Yamada 8450a48340SMasahiro Yamada# Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works. 8550a48340SMasahiro Yamada# To support older Make versions, use a somewhat tedious way. 8650a48340SMasahiro Yamadaclean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*))) 87