Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 
0003 # Unlike the kernel space, exported headers are written in standard C.
0004 #  - Forbid C++ style comments
0005 #  - Use '__inline__', '__asm__' instead of 'inline', 'asm'
0006 #
0007 # -std=c90 (equivalent to -ansi) catches the violation of those.
0008 # We cannot go as far as adding -Wpedantic since it emits too many warnings.
0009 UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration
0010 
0011 # In theory, we do not care -m32 or -m64 for header compile tests.
0012 # It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
0013 UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
0014 
0015 # USERCFLAGS might contain sysroot location for CC.
0016 UAPI_CFLAGS += $(USERCFLAGS)
0017 
0018 override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include
0019 
0020 # The following are excluded for now because they fail to build.
0021 #
0022 # Do not add a new header to the blacklist without legitimate reason.
0023 # Please consider to fix the header first.
0024 #
0025 # Sorted alphabetically.
0026 no-header-test += asm/ucontext.h
0027 no-header-test += drm/vmwgfx_drm.h
0028 no-header-test += linux/am437x-vpfe.h
0029 no-header-test += linux/coda.h
0030 no-header-test += linux/cyclades.h
0031 no-header-test += linux/errqueue.h
0032 no-header-test += linux/hdlc/ioctl.h
0033 no-header-test += linux/ivtv.h
0034 no-header-test += linux/matroxfb.h
0035 no-header-test += linux/omap3isp.h
0036 no-header-test += linux/omapfb.h
0037 no-header-test += linux/patchkey.h
0038 no-header-test += linux/phonet.h
0039 no-header-test += linux/sctp.h
0040 no-header-test += linux/sysctl.h
0041 no-header-test += linux/usb/audio.h
0042 no-header-test += linux/v4l2-mediabus.h
0043 no-header-test += linux/v4l2-subdev.h
0044 no-header-test += linux/videodev2.h
0045 no-header-test += linux/vm_sockets.h
0046 no-header-test += sound/asequencer.h
0047 no-header-test += sound/asoc.h
0048 no-header-test += sound/asound.h
0049 no-header-test += sound/compress_offload.h
0050 no-header-test += sound/emu10k1.h
0051 no-header-test += sound/sfnt_info.h
0052 no-header-test += xen/evtchn.h
0053 no-header-test += xen/gntdev.h
0054 no-header-test += xen/privcmd.h
0055 
0056 # More headers are broken in some architectures
0057 
0058 ifeq ($(SRCARCH),arc)
0059 no-header-test += linux/bpf_perf_event.h
0060 endif
0061 
0062 ifeq ($(SRCARCH),ia64)
0063 no-header-test += asm/setup.h
0064 no-header-test += asm/sigcontext.h
0065 no-header-test += linux/if_bonding.h
0066 endif
0067 
0068 ifeq ($(SRCARCH),powerpc)
0069 no-header-test += linux/bpf_perf_event.h
0070 endif
0071 
0072 ifeq ($(SRCARCH),sparc)
0073 no-header-test += asm/uctx.h
0074 no-header-test += asm/fbio.h
0075 endif
0076 
0077 # asm-generic/*.h is used by asm/*.h, and should not be included directly
0078 no-header-test += asm-generic/%
0079 
0080 always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
0081 
0082 # Include the header twice to detect missing include guard.
0083 quiet_cmd_hdrtest = HDRTEST $<
0084       cmd_hdrtest = \
0085                 $(CC) $(c_flags) -fsyntax-only -x c /dev/null \
0086                         $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ 
0087                 $(PERL) $(srctree)/$(src)/headers_check.pl $(obj) $(SRCARCH) $<; \
0088                 touch $@
0089 
0090 $(obj)/%.hdrtest: $(obj)/%.h FORCE
0091         $(call if_changed_dep,hdrtest)
0092 
0093 # Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
0094 # To support older Make versions, use a somewhat tedious way.
0095 clean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*)))