xref: /linux/usr/include/Makefile (revision 6059b880a93c38a90d178b49fa80403c76d1a89f)
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.
9c4cb34aeSThomas WeißschuhUAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration
10d6fc9fcbSMasahiro Yamada
11c4cb34aeSThomas 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
71*6059b880SThomas Weißschuh# The following are using libc header and types.
72*6059b880SThomas Weißschuh#
73*6059b880SThomas Weißschuh# Do not add a new header to the list without legitimate reason.
74*6059b880SThomas Weißschuh# Please consider to fix the header first.
75*6059b880SThomas Weißschuh#
76*6059b880SThomas Weißschuh# Sorted alphabetically.
77*6059b880SThomas Weißschuhuses-libc += linux/a.out.h
78*6059b880SThomas Weißschuhuses-libc += linux/atmbr2684.h
79*6059b880SThomas Weißschuhuses-libc += linux/auto_dev-ioctl.h
80*6059b880SThomas Weißschuhuses-libc += linux/auto_fs.h
81*6059b880SThomas Weißschuhuses-libc += linux/auto_fs4.h
82*6059b880SThomas Weißschuhuses-libc += linux/btrfs_tree.h
83*6059b880SThomas Weißschuhuses-libc += linux/cec-funcs.h
84*6059b880SThomas Weißschuhuses-libc += linux/cec.h
85*6059b880SThomas Weißschuhuses-libc += linux/dvb/dmx.h
86*6059b880SThomas Weißschuhuses-libc += linux/dvb/video.h
87*6059b880SThomas Weißschuhuses-libc += linux/ethtool.h
88*6059b880SThomas Weißschuhuses-libc += linux/ethtool_netlink.h
89*6059b880SThomas Weißschuhuses-libc += linux/fuse.h
90*6059b880SThomas Weißschuhuses-libc += linux/gsmmux.h
91*6059b880SThomas Weißschuhuses-libc += linux/icmp.h
92*6059b880SThomas Weißschuhuses-libc += linux/idxd.h
93*6059b880SThomas Weißschuhuses-libc += linux/if.h
94*6059b880SThomas Weißschuhuses-libc += linux/if_arp.h
95*6059b880SThomas Weißschuhuses-libc += linux/if_bonding.h
96*6059b880SThomas Weißschuhuses-libc += linux/if_pppox.h
97*6059b880SThomas Weißschuhuses-libc += linux/if_tunnel.h
98*6059b880SThomas Weißschuhuses-libc += linux/input.h
99*6059b880SThomas Weißschuhuses-libc += linux/ip6_tunnel.h
100*6059b880SThomas Weißschuhuses-libc += linux/joystick.h
101*6059b880SThomas Weißschuhuses-libc += linux/llc.h
102*6059b880SThomas Weißschuhuses-libc += linux/mctp.h
103*6059b880SThomas Weißschuhuses-libc += linux/mdio.h
104*6059b880SThomas Weißschuhuses-libc += linux/mii.h
105*6059b880SThomas Weißschuhuses-libc += linux/mptcp.h
106*6059b880SThomas Weißschuhuses-libc += linux/netdevice.h
107*6059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_RATEEST.h
108*6059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_hashlimit.h
109*6059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_physdev.h
110*6059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_rateest.h
111*6059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arp_tables.h
112*6059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arpt_mangle.h
113*6059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge.h
114*6059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge/ebtables.h
115*6059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4.h
116*6059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4/ip_tables.h
117*6059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6.h
118*6059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6/ip6_tables.h
119*6059b880SThomas Weißschuhuses-libc += linux/route.h
120*6059b880SThomas Weißschuhuses-libc += linux/shm.h
121*6059b880SThomas Weißschuhuses-libc += linux/soundcard.h
122*6059b880SThomas Weißschuhuses-libc += linux/string.h
123*6059b880SThomas Weißschuhuses-libc += linux/tipc_config.h
124*6059b880SThomas Weißschuhuses-libc += linux/uhid.h
125*6059b880SThomas Weißschuhuses-libc += linux/uinput.h
126*6059b880SThomas Weißschuhuses-libc += linux/vhost.h
127*6059b880SThomas Weißschuhuses-libc += linux/vhost_types.h
128*6059b880SThomas Weißschuhuses-libc += linux/virtio_ring.h
129*6059b880SThomas Weißschuhuses-libc += linux/wireless.h
130*6059b880SThomas Weißschuhuses-libc += regulator/regulator.h
131*6059b880SThomas Weißschuhuses-libc += scsi/fc/fc_els.h
132*6059b880SThomas Weißschuh
133*6059b880SThomas Weißschuhifeq ($(SRCARCH),hexagon)
134*6059b880SThomas Weißschuhuses-libc += asm/sigcontext.h
135*6059b880SThomas Weißschuhendif
136*6059b880SThomas Weißschuh
137*6059b880SThomas Weißschuhifeq ($(SRCARCH),nios2)
138*6059b880SThomas Weißschuhuses-libc += asm/ptrace.h
139*6059b880SThomas Weißschuhuses-libc += linux/bpf_perf_event.h
140*6059b880SThomas Weißschuhendif
141*6059b880SThomas Weißschuh
142*6059b880SThomas Weißschuhifeq ($(SRCARCH),s390)
143*6059b880SThomas Weißschuhuses-libc += asm/chpid.h
144*6059b880SThomas Weißschuhuses-libc += asm/chsc.h
145*6059b880SThomas Weißschuhendif
146*6059b880SThomas Weißschuh
147c1ea04d8SMasahiro Yamadaalways-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
148fcbb8461SMasahiro Yamada
14900d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard.
150fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $<
1517ecaf069SMasahiro Yamada      cmd_hdrtest = \
1523788d69dSThomas Weißschuh		$(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \
153*6059b880SThomas Weißschuh			$(if $(filter-out $(uses-libc), $*.h), -nostdinc) \
1540186b126SMasahiro Yamada			$(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \
155d67393f4SGeert Uytterhoeven		$(PERL) $(src)/headers_check.pl $(obj) $<; \
1567ecaf069SMasahiro Yamada		touch $@
157fcbb8461SMasahiro Yamada
158d4b7080bSThomas Weißschuh$(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE
159fcbb8461SMasahiro Yamada	$(call if_changed_dep,hdrtest)
160d6fc9fcbSMasahiro Yamada
16150a48340SMasahiro Yamada# Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
16250a48340SMasahiro Yamada# To support older Make versions, use a somewhat tedious way.
16350a48340SMasahiro Yamadaclean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*)))
164