xref: /openbmc/linux/usr/include/Makefile (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
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
119371f86eSMasahiro Yamada# In theory, we do not care -m32 or -m64 for header compile tests.
129371f86eSMasahiro Yamada# It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64.
139fbed27aSMasahiro YamadaUAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
149371f86eSMasahiro Yamada
15f67695c9SElliot Berman# USERCFLAGS might contain sysroot location for CC.
16f67695c9SElliot BermanUAPI_CFLAGS += $(USERCFLAGS)
17d6fc9fcbSMasahiro Yamada
18*02a6e4beSMasahiro Yamadaoverride c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include
19d6fc9fcbSMasahiro Yamada
20d6fc9fcbSMasahiro Yamada# The following are excluded for now because they fail to build.
21d6fc9fcbSMasahiro Yamada#
22d6fc9fcbSMasahiro Yamada# Do not add a new header to the blacklist without legitimate reason.
23d6fc9fcbSMasahiro Yamada# Please consider to fix the header first.
24d6fc9fcbSMasahiro Yamada#
25d6fc9fcbSMasahiro Yamada# Sorted alphabetically.
260186b126SMasahiro Yamadano-header-test += asm/ucontext.h
270186b126SMasahiro Yamadano-header-test += drm/vmwgfx_drm.h
280186b126SMasahiro Yamadano-header-test += linux/am437x-vpfe.h
290186b126SMasahiro Yamadano-header-test += linux/coda.h
30d1ad2721SGreg Kroah-Hartmanno-header-test += linux/cyclades.h
310186b126SMasahiro Yamadano-header-test += linux/errqueue.h
320186b126SMasahiro Yamadano-header-test += linux/hdlc/ioctl.h
330186b126SMasahiro Yamadano-header-test += linux/ivtv.h
340186b126SMasahiro Yamadano-header-test += linux/matroxfb.h
350186b126SMasahiro Yamadano-header-test += linux/omap3isp.h
360186b126SMasahiro Yamadano-header-test += linux/omapfb.h
370186b126SMasahiro Yamadano-header-test += linux/patchkey.h
380186b126SMasahiro Yamadano-header-test += linux/phonet.h
390186b126SMasahiro Yamadano-header-test += linux/sctp.h
400186b126SMasahiro Yamadano-header-test += linux/sysctl.h
410186b126SMasahiro Yamadano-header-test += linux/usb/audio.h
420186b126SMasahiro Yamadano-header-test += linux/v4l2-mediabus.h
430186b126SMasahiro Yamadano-header-test += linux/v4l2-subdev.h
440186b126SMasahiro Yamadano-header-test += linux/videodev2.h
450186b126SMasahiro Yamadano-header-test += linux/vm_sockets.h
460186b126SMasahiro Yamadano-header-test += sound/asequencer.h
470186b126SMasahiro Yamadano-header-test += sound/asoc.h
480186b126SMasahiro Yamadano-header-test += sound/asound.h
490186b126SMasahiro Yamadano-header-test += sound/compress_offload.h
500186b126SMasahiro Yamadano-header-test += sound/emu10k1.h
510186b126SMasahiro Yamadano-header-test += sound/sfnt_info.h
520186b126SMasahiro Yamadano-header-test += xen/evtchn.h
530186b126SMasahiro Yamadano-header-test += xen/gntdev.h
540186b126SMasahiro Yamadano-header-test += xen/privcmd.h
55d6fc9fcbSMasahiro Yamada
56d6fc9fcbSMasahiro Yamada# More headers are broken in some architectures
57d6fc9fcbSMasahiro Yamada
58d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),arc)
590186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h
60d6fc9fcbSMasahiro Yamadaendif
61d6fc9fcbSMasahiro Yamada
62d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),ia64)
630186b126SMasahiro Yamadano-header-test += asm/setup.h
640186b126SMasahiro Yamadano-header-test += asm/sigcontext.h
650186b126SMasahiro Yamadano-header-test += linux/if_bonding.h
66d6fc9fcbSMasahiro Yamadaendif
67d6fc9fcbSMasahiro Yamada
68d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),powerpc)
690186b126SMasahiro Yamadano-header-test += linux/bpf_perf_event.h
70d6fc9fcbSMasahiro Yamadaendif
71d6fc9fcbSMasahiro Yamada
72d6fc9fcbSMasahiro Yamadaifeq ($(SRCARCH),sparc)
730186b126SMasahiro Yamadano-header-test += asm/uctx.h
740186b126SMasahiro Yamadano-header-test += asm/fbio.h
75d6fc9fcbSMasahiro Yamadaendif
76d6fc9fcbSMasahiro Yamada
77d6fc9fcbSMasahiro Yamada# asm-generic/*.h is used by asm/*.h, and should not be included directly
780186b126SMasahiro Yamadano-header-test += asm-generic/%
79d6fc9fcbSMasahiro Yamada
80c1ea04d8SMasahiro Yamadaalways-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
81fcbb8461SMasahiro Yamada
8200d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard.
83fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $<
847ecaf069SMasahiro Yamada      cmd_hdrtest = \
859a22717bSNick Desaulniers		$(CC) $(c_flags) -fsyntax-only -x c /dev/null \
860186b126SMasahiro Yamada			$(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \
8750a48340SMasahiro Yamada		$(PERL) $(srctree)/$(src)/headers_check.pl $(obj) $(SRCARCH) $<; \
887ecaf069SMasahiro Yamada		touch $@
89fcbb8461SMasahiro Yamada
90fcbb8461SMasahiro Yamada$(obj)/%.hdrtest: $(obj)/%.h FORCE
91fcbb8461SMasahiro Yamada	$(call if_changed_dep,hdrtest)
92d6fc9fcbSMasahiro Yamada
9350a48340SMasahiro Yamada# Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
9450a48340SMasahiro Yamada# To support older Make versions, use a somewhat tedious way.
9550a48340SMasahiro Yamadaclean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*)))
96