xref: /linux/usr/include/Makefile (revision b4ec38cb739e9419ddb7310f6c49fb6d7bc39c1d)
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
10*b4ec38cbSThomas WeißschuhUAPI_ARCH := $(or $(HEADER_ARCH),$(SRCARCH))
11d6fc9fcbSMasahiro Yamada
12cf822413SThomas Weißschuhoverride c_flags = $(KBUILD_USERCFLAGS) $(UAPI_CFLAGS) -Wp,-MMD,$(depfile)
13d6fc9fcbSMasahiro Yamada
14d6fc9fcbSMasahiro Yamada# The following are excluded for now because they fail to build.
15d6fc9fcbSMasahiro Yamada#
16d6fc9fcbSMasahiro Yamada# Do not add a new header to the blacklist without legitimate reason.
17d6fc9fcbSMasahiro Yamada# Please consider to fix the header first.
18d6fc9fcbSMasahiro Yamada#
19d6fc9fcbSMasahiro Yamada# Sorted alphabetically.
200186b126SMasahiro Yamadano-header-test += asm/ucontext.h
210186b126SMasahiro Yamadano-header-test += drm/vmwgfx_drm.h
220186b126SMasahiro Yamadano-header-test += linux/am437x-vpfe.h
230186b126SMasahiro Yamadano-header-test += linux/coda.h
24d1ad2721SGreg Kroah-Hartmanno-header-test += linux/cyclades.h
250186b126SMasahiro Yamadano-header-test += linux/errqueue.h
260186b126SMasahiro Yamadano-header-test += linux/hdlc/ioctl.h
270186b126SMasahiro Yamadano-header-test += linux/ivtv.h
280186b126SMasahiro Yamadano-header-test += linux/matroxfb.h
290186b126SMasahiro Yamadano-header-test += linux/omap3isp.h
300186b126SMasahiro Yamadano-header-test += linux/omapfb.h
310186b126SMasahiro Yamadano-header-test += linux/patchkey.h
320186b126SMasahiro Yamadano-header-test += linux/phonet.h
330186b126SMasahiro Yamadano-header-test += linux/sctp.h
340186b126SMasahiro Yamadano-header-test += linux/sysctl.h
350186b126SMasahiro Yamadano-header-test += linux/usb/audio.h
360186b126SMasahiro Yamadano-header-test += linux/v4l2-mediabus.h
370186b126SMasahiro Yamadano-header-test += linux/v4l2-subdev.h
380186b126SMasahiro Yamadano-header-test += linux/videodev2.h
390186b126SMasahiro Yamadano-header-test += linux/vm_sockets.h
400186b126SMasahiro Yamadano-header-test += sound/asequencer.h
410186b126SMasahiro Yamadano-header-test += sound/asoc.h
420186b126SMasahiro Yamadano-header-test += sound/asound.h
430186b126SMasahiro Yamadano-header-test += sound/compress_offload.h
440186b126SMasahiro Yamadano-header-test += sound/emu10k1.h
450186b126SMasahiro Yamadano-header-test += sound/sfnt_info.h
460186b126SMasahiro Yamadano-header-test += xen/evtchn.h
470186b126SMasahiro Yamadano-header-test += xen/gntdev.h
480186b126SMasahiro Yamadano-header-test += xen/privcmd.h
49d6fc9fcbSMasahiro Yamada
50d6fc9fcbSMasahiro Yamada# More headers are broken in some architectures
51d6fc9fcbSMasahiro Yamada
52*b4ec38cbSThomas Weißschuhifneq ($(filter arc openrisc xtensa nios2, $(UAPI_ARCH)),)
5356045757SRandy Dunlapno-header-test += linux/bpf_perf_event.h
5456045757SRandy Dunlapendif
5556045757SRandy Dunlap
56*b4ec38cbSThomas Weißschuhifeq ($(UAPI_ARCH),sparc)
570186b126SMasahiro Yamadano-header-test += asm/uctx.h
580186b126SMasahiro Yamadano-header-test += asm/fbio.h
59d6fc9fcbSMasahiro Yamadaendif
60d6fc9fcbSMasahiro Yamada
61d6fc9fcbSMasahiro Yamada# asm-generic/*.h is used by asm/*.h, and should not be included directly
620186b126SMasahiro Yamadano-header-test += asm-generic/%
63d6fc9fcbSMasahiro Yamada
646059b880SThomas Weißschuh# The following are using libc header and types.
656059b880SThomas Weißschuh#
666059b880SThomas Weißschuh# Do not add a new header to the list without legitimate reason.
676059b880SThomas Weißschuh# Please consider to fix the header first.
686059b880SThomas Weißschuh#
696059b880SThomas Weißschuh# Sorted alphabetically.
706059b880SThomas Weißschuhuses-libc += linux/a.out.h
716059b880SThomas Weißschuhuses-libc += linux/atmbr2684.h
726059b880SThomas Weißschuhuses-libc += linux/auto_dev-ioctl.h
736059b880SThomas Weißschuhuses-libc += linux/auto_fs.h
746059b880SThomas Weißschuhuses-libc += linux/auto_fs4.h
756059b880SThomas Weißschuhuses-libc += linux/btrfs_tree.h
766059b880SThomas Weißschuhuses-libc += linux/cec-funcs.h
776059b880SThomas Weißschuhuses-libc += linux/cec.h
786059b880SThomas Weißschuhuses-libc += linux/dvb/dmx.h
796059b880SThomas Weißschuhuses-libc += linux/dvb/video.h
806059b880SThomas Weißschuhuses-libc += linux/ethtool.h
816059b880SThomas Weißschuhuses-libc += linux/ethtool_netlink.h
826059b880SThomas Weißschuhuses-libc += linux/fuse.h
836059b880SThomas Weißschuhuses-libc += linux/gsmmux.h
846059b880SThomas Weißschuhuses-libc += linux/icmp.h
856059b880SThomas Weißschuhuses-libc += linux/idxd.h
866059b880SThomas Weißschuhuses-libc += linux/if.h
876059b880SThomas Weißschuhuses-libc += linux/if_arp.h
886059b880SThomas Weißschuhuses-libc += linux/if_bonding.h
896059b880SThomas Weißschuhuses-libc += linux/if_pppox.h
906059b880SThomas Weißschuhuses-libc += linux/if_tunnel.h
916059b880SThomas Weißschuhuses-libc += linux/input.h
926059b880SThomas Weißschuhuses-libc += linux/ip6_tunnel.h
936059b880SThomas Weißschuhuses-libc += linux/joystick.h
946059b880SThomas Weißschuhuses-libc += linux/llc.h
956059b880SThomas Weißschuhuses-libc += linux/mctp.h
966059b880SThomas Weißschuhuses-libc += linux/mdio.h
976059b880SThomas Weißschuhuses-libc += linux/mii.h
986059b880SThomas Weißschuhuses-libc += linux/mptcp.h
996059b880SThomas Weißschuhuses-libc += linux/netdevice.h
1006059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_RATEEST.h
1016059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_hashlimit.h
1026059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_physdev.h
1036059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_rateest.h
1046059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arp_tables.h
1056059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arpt_mangle.h
1066059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge.h
1076059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge/ebtables.h
1086059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4.h
1096059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4/ip_tables.h
1106059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6.h
1116059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6/ip6_tables.h
1126059b880SThomas Weißschuhuses-libc += linux/route.h
1136059b880SThomas Weißschuhuses-libc += linux/shm.h
1146059b880SThomas Weißschuhuses-libc += linux/soundcard.h
1156059b880SThomas Weißschuhuses-libc += linux/string.h
1166059b880SThomas Weißschuhuses-libc += linux/tipc_config.h
1176059b880SThomas Weißschuhuses-libc += linux/uhid.h
1186059b880SThomas Weißschuhuses-libc += linux/uinput.h
1196059b880SThomas Weißschuhuses-libc += linux/vhost.h
1206059b880SThomas Weißschuhuses-libc += linux/vhost_types.h
1216059b880SThomas Weißschuhuses-libc += linux/virtio_ring.h
1226059b880SThomas Weißschuhuses-libc += linux/wireless.h
1236059b880SThomas Weißschuhuses-libc += regulator/regulator.h
1246059b880SThomas Weißschuhuses-libc += scsi/fc/fc_els.h
1256059b880SThomas Weißschuh
126*b4ec38cbSThomas Weißschuhifeq ($(UAPI_ARCH),hexagon)
1276059b880SThomas Weißschuhuses-libc += asm/sigcontext.h
1286059b880SThomas Weißschuhendif
1296059b880SThomas Weißschuh
130*b4ec38cbSThomas Weißschuhifeq ($(UAPI_ARCH),nios2)
1316059b880SThomas Weißschuhuses-libc += asm/ptrace.h
1326059b880SThomas Weißschuhendif
1336059b880SThomas Weißschuh
134*b4ec38cbSThomas Weißschuhifeq ($(UAPI_ARCH),s390)
1356059b880SThomas Weißschuhuses-libc += asm/chpid.h
1366059b880SThomas Weißschuhuses-libc += asm/chsc.h
1376059b880SThomas Weißschuhendif
1386059b880SThomas Weißschuh
139c1ea04d8SMasahiro Yamadaalways-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
140fcbb8461SMasahiro Yamada
141510c7a57SThomas Weißschuhtarget-libc = $(filter $(uses-libc), $*.h)
142579f103fSThomas Weißschuhtarget-can-compile = $(filter-out $(no-header-test), $*.h)
1434ac85d9bSThomas Weißschuh
14455d68ec5SThomas Weißschuhhdrtest-flags = -fsyntax-only -Werror \
145cf822413SThomas Weißschuh		-nostdinc -I $(obj) $(if $(target-libc), -I $(srctree)/usr/dummy-include)
14655d68ec5SThomas Weißschuh
14700d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard.
148fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $<
1497ecaf069SMasahiro Yamada      cmd_hdrtest = \
15055d68ec5SThomas Weißschuh		$(CC) $(c_flags) $(hdrtest-flags) -x c /dev/null \
1514ac85d9bSThomas Weißschuh			$(if $(target-can-compile), -include $< -include $<); \
152d67393f4SGeert Uytterhoeven		$(PERL) $(src)/headers_check.pl $(obj) $<; \
1537ecaf069SMasahiro Yamada		touch $@
154fcbb8461SMasahiro Yamada
155d4b7080bSThomas Weißschuh$(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE
156fcbb8461SMasahiro Yamada	$(call if_changed_dep,hdrtest)
157d6fc9fcbSMasahiro Yamada
15850a48340SMasahiro Yamada# Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
15950a48340SMasahiro Yamada# To support older Make versions, use a somewhat tedious way.
16050a48340SMasahiro Yamadaclean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*)))
161