18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci# Unlike the kernel space, exported headers are written in standard C.
48c2ecf20Sopenharmony_ci#  - Forbid C++ style comments
58c2ecf20Sopenharmony_ci#  - Use '__inline__', '__asm__' instead of 'inline', 'asm'
68c2ecf20Sopenharmony_ci#
78c2ecf20Sopenharmony_ci# -std=c90 (equivalent to -ansi) catches the violation of those.
88c2ecf20Sopenharmony_ci# We cannot go as far as adding -Wpedantic since it emits too many warnings.
98c2ecf20Sopenharmony_ciUAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci# In theory, we do not care -m32 or -m64 for header compile tests.
128c2ecf20Sopenharmony_ci# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
138c2ecf20Sopenharmony_ciUAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cioverride c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci# The following are excluded for now because they fail to build.
188c2ecf20Sopenharmony_ci#
198c2ecf20Sopenharmony_ci# Do not add a new header to the blacklist without legitimate reason.
208c2ecf20Sopenharmony_ci# Please consider to fix the header first.
218c2ecf20Sopenharmony_ci#
228c2ecf20Sopenharmony_ci# Sorted alphabetically.
238c2ecf20Sopenharmony_cino-header-test += asm/shmbuf.h
248c2ecf20Sopenharmony_cino-header-test += asm/signal.h
258c2ecf20Sopenharmony_cino-header-test += asm/ucontext.h
268c2ecf20Sopenharmony_cino-header-test += drm/vmwgfx_drm.h
278c2ecf20Sopenharmony_cino-header-test += linux/am437x-vpfe.h
288c2ecf20Sopenharmony_cino-header-test += linux/android/binder.h
298c2ecf20Sopenharmony_cino-header-test += linux/android/binderfs.h
308c2ecf20Sopenharmony_cino-header-test += linux/coda.h
318c2ecf20Sopenharmony_cino-header-test += linux/errqueue.h
328c2ecf20Sopenharmony_cino-header-test += linux/fsmap.h
338c2ecf20Sopenharmony_cino-header-test += linux/hdlc/ioctl.h
348c2ecf20Sopenharmony_cino-header-test += linux/ivtv.h
358c2ecf20Sopenharmony_cino-header-test += linux/kexec.h
368c2ecf20Sopenharmony_cino-header-test += linux/matroxfb.h
378c2ecf20Sopenharmony_cino-header-test += linux/omap3isp.h
388c2ecf20Sopenharmony_cino-header-test += linux/omapfb.h
398c2ecf20Sopenharmony_cino-header-test += linux/patchkey.h
408c2ecf20Sopenharmony_cino-header-test += linux/phonet.h
418c2ecf20Sopenharmony_cino-header-test += linux/reiserfs_xattr.h
428c2ecf20Sopenharmony_cino-header-test += linux/sctp.h
438c2ecf20Sopenharmony_cino-header-test += linux/signal.h
448c2ecf20Sopenharmony_cino-header-test += linux/sysctl.h
458c2ecf20Sopenharmony_cino-header-test += linux/usb/audio.h
468c2ecf20Sopenharmony_cino-header-test += linux/v4l2-mediabus.h
478c2ecf20Sopenharmony_cino-header-test += linux/v4l2-subdev.h
488c2ecf20Sopenharmony_cino-header-test += linux/videodev2.h
498c2ecf20Sopenharmony_cino-header-test += linux/vm_sockets.h
508c2ecf20Sopenharmony_cino-header-test += sound/asequencer.h
518c2ecf20Sopenharmony_cino-header-test += sound/asoc.h
528c2ecf20Sopenharmony_cino-header-test += sound/asound.h
538c2ecf20Sopenharmony_cino-header-test += sound/compress_offload.h
548c2ecf20Sopenharmony_cino-header-test += sound/emu10k1.h
558c2ecf20Sopenharmony_cino-header-test += sound/sfnt_info.h
568c2ecf20Sopenharmony_cino-header-test += xen/evtchn.h
578c2ecf20Sopenharmony_cino-header-test += xen/gntdev.h
588c2ecf20Sopenharmony_cino-header-test += xen/privcmd.h
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci# More headers are broken in some architectures
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciifeq ($(SRCARCH),arc)
638c2ecf20Sopenharmony_cino-header-test += linux/bpf_perf_event.h
648c2ecf20Sopenharmony_ciendif
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciifeq ($(SRCARCH),ia64)
678c2ecf20Sopenharmony_cino-header-test += asm/setup.h
688c2ecf20Sopenharmony_cino-header-test += asm/sigcontext.h
698c2ecf20Sopenharmony_cino-header-test += asm/perfmon.h
708c2ecf20Sopenharmony_cino-header-test += asm/perfmon_default_smpl.h
718c2ecf20Sopenharmony_cino-header-test += linux/if_bonding.h
728c2ecf20Sopenharmony_ciendif
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciifeq ($(SRCARCH),mips)
758c2ecf20Sopenharmony_cino-header-test += asm/stat.h
768c2ecf20Sopenharmony_ciendif
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciifeq ($(SRCARCH),powerpc)
798c2ecf20Sopenharmony_cino-header-test += asm/stat.h
808c2ecf20Sopenharmony_cino-header-test += linux/bpf_perf_event.h
818c2ecf20Sopenharmony_ciendif
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ciifeq ($(SRCARCH),riscv)
848c2ecf20Sopenharmony_cino-header-test += linux/bpf_perf_event.h
858c2ecf20Sopenharmony_ciendif
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciifeq ($(SRCARCH),sparc)
888c2ecf20Sopenharmony_cino-header-test += asm/stat.h
898c2ecf20Sopenharmony_cino-header-test += asm/uctx.h
908c2ecf20Sopenharmony_cino-header-test += asm/fbio.h
918c2ecf20Sopenharmony_ciendif
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci# asm-generic/*.h is used by asm/*.h, and should not be included directly
948c2ecf20Sopenharmony_cino-header-test += asm-generic/%
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciextra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci# Include the header twice to detect missing include guard.
998c2ecf20Sopenharmony_ciquiet_cmd_hdrtest = HDRTEST $<
1008c2ecf20Sopenharmony_ci      cmd_hdrtest = \
1018c2ecf20Sopenharmony_ci		$(CC) $(c_flags) -S -o /dev/null -x c /dev/null \
1028c2ecf20Sopenharmony_ci			$(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \
1038c2ecf20Sopenharmony_ci		$(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \
1048c2ecf20Sopenharmony_ci		touch $@
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci$(obj)/%.hdrtest: $(obj)/%.h FORCE
1078c2ecf20Sopenharmony_ci	$(call if_changed_dep,hdrtest)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciclean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*)))
110