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. 9d6fc9fcbSMasahiro YamadaUAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration 10d6fc9fcbSMasahiro Yamada 11*9371f86eSMasahiro Yamada# In theory, we do not care -m32 or -m64 for header compile tests. 12*9371f86eSMasahiro Yamada# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64. 13*9371f86eSMasahiro YamadaUAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS)) 14*9371f86eSMasahiro Yamada 1530a77297SMasahiro Yamadaoverride c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include 16d6fc9fcbSMasahiro Yamada 17d6fc9fcbSMasahiro Yamada# The following are excluded for now because they fail to build. 18d6fc9fcbSMasahiro Yamada# 19d6fc9fcbSMasahiro Yamada# Do not add a new header to the blacklist without legitimate reason. 20d6fc9fcbSMasahiro Yamada# Please consider to fix the header first. 21d6fc9fcbSMasahiro Yamada# 22d6fc9fcbSMasahiro Yamada# Sorted alphabetically. 230186b126SMasahiro Yamadano-header-test += asm/shmbuf.h 240186b126SMasahiro Yamadano-header-test += asm/signal.h 250186b126SMasahiro Yamadano-header-test += asm/ucontext.h 260186b126SMasahiro Yamadano-header-test += drm/vmwgfx_drm.h 270186b126SMasahiro Yamadano-header-test += linux/am437x-vpfe.h 280186b126SMasahiro Yamadano-header-test += linux/android/binder.h 290186b126SMasahiro Yamadano-header-test += linux/android/binderfs.h 300186b126SMasahiro Yamadano-header-test += linux/coda.h 310186b126SMasahiro Yamadano-header-test += linux/elfcore.h 320186b126SMasahiro Yamadano-header-test += linux/errqueue.h 330186b126SMasahiro Yamadano-header-test += linux/fsmap.h 340186b126SMasahiro Yamadano-header-test += linux/hdlc/ioctl.h 350186b126SMasahiro Yamadano-header-test += linux/ivtv.h 360186b126SMasahiro Yamadano-header-test += linux/kexec.h 370186b126SMasahiro Yamadano-header-test += linux/matroxfb.h 380186b126SMasahiro Yamadano-header-test += linux/nfc.h 390186b126SMasahiro Yamadano-header-test += linux/omap3isp.h 400186b126SMasahiro Yamadano-header-test += linux/omapfb.h 410186b126SMasahiro Yamadano-header-test += linux/patchkey.h 420186b126SMasahiro Yamadano-header-test += linux/phonet.h 430186b126SMasahiro Yamadano-header-test += linux/reiserfs_xattr.h 440186b126SMasahiro Yamadano-header-test += linux/sctp.h 450186b126SMasahiro Yamadano-header-test += linux/signal.h 460186b126SMasahiro Yamadano-header-test += linux/sysctl.h 470186b126SMasahiro Yamadano-header-test += linux/usb/audio.h 480186b126SMasahiro Yamadano-header-test += linux/v4l2-mediabus.h 490186b126SMasahiro Yamadano-header-test += linux/v4l2-subdev.h 500186b126SMasahiro Yamadano-header-test += linux/videodev2.h 510186b126SMasahiro Yamadano-header-test += linux/vm_sockets.h 520186b126SMasahiro Yamadano-header-test += sound/asequencer.h 530186b126SMasahiro Yamadano-header-test += sound/asoc.h 540186b126SMasahiro Yamadano-header-test += sound/asound.h 550186b126SMasahiro Yamadano-header-test += sound/compress_offload.h 560186b126SMasahiro Yamadano-header-test += sound/emu10k1.h 570186b126SMasahiro Yamadano-header-test += sound/sfnt_info.h 580186b126SMasahiro Yamadano-header-test += xen/evtchn.h 590186b126SMasahiro Yamadano-header-test += xen/gntdev.h 600186b126SMasahiro Yamadano-header-test += xen/privcmd.h 61d6fc9fcbSMasahiro Yamada 62d6fc9fcbSMasahiro Yamada# More headers are broken in some architectures 63d6fc9fcbSMasahiro Yamada 64d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),arc) 650186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h 66d6fc9fcbSMasahiro Yamadaendif 67d6fc9fcbSMasahiro Yamada 68d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),ia64) 690186b126SMasahiro Yamadano-header-test += asm/setup.h 700186b126SMasahiro Yamadano-header-test += asm/sigcontext.h 710186b126SMasahiro Yamadano-header-test += asm/perfmon.h 720186b126SMasahiro Yamadano-header-test += asm/perfmon_default_smpl.h 730186b126SMasahiro Yamadano-header-test += linux/if_bonding.h 74d6fc9fcbSMasahiro Yamadaendif 75d6fc9fcbSMasahiro Yamada 76d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),mips) 770186b126SMasahiro Yamadano-header-test += asm/stat.h 78d6fc9fcbSMasahiro Yamadaendif 79d6fc9fcbSMasahiro Yamada 80d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),powerpc) 810186b126SMasahiro Yamadano-header-test += asm/stat.h 820186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h 83d6fc9fcbSMasahiro Yamadaendif 84d6fc9fcbSMasahiro Yamada 85d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),riscv) 860186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h 87d6fc9fcbSMasahiro Yamadaendif 88d6fc9fcbSMasahiro Yamada 89d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),sparc) 900186b126SMasahiro Yamadano-header-test += asm/stat.h 910186b126SMasahiro Yamadano-header-test += asm/uctx.h 920186b126SMasahiro Yamadano-header-test += asm/fbio.h 93d6fc9fcbSMasahiro Yamadaendif 94d6fc9fcbSMasahiro Yamada 95d6fc9fcbSMasahiro Yamada# asm-generic/*.h is used by asm/*.h, and should not be included directly 960186b126SMasahiro Yamadano-header-test += asm-generic/% 97d6fc9fcbSMasahiro Yamada 98cf6b58abSMasahiro Yamadaextra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) 99fcbb8461SMasahiro Yamada 10000d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard. 101fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $< 1027ecaf069SMasahiro Yamada cmd_hdrtest = \ 1037ecaf069SMasahiro Yamada $(CC) $(c_flags) -S -o /dev/null -x c /dev/null \ 1040186b126SMasahiro Yamada $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ 1057ecaf069SMasahiro Yamada $(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \ 1067ecaf069SMasahiro Yamada touch $@ 107fcbb8461SMasahiro Yamada 108fcbb8461SMasahiro Yamada$(obj)/%.hdrtest: $(obj)/%.h FORCE 109fcbb8461SMasahiro Yamada $(call if_changed_dep,hdrtest) 110d6fc9fcbSMasahiro Yamada 1111634f2bfSMasahiro Yamadaclean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*))) 112