xref: /linux/usr/include/Makefile (revision 41f1a08645abb5ef7d2a3ed8835c747334878774)
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
68e2772ba5SThomas Weißschuhifeq ($(SRCARCH),xtensa)
69e2772ba5SThomas Weißschuhno-header-test += linux/bpf_perf_event.h
70e2772ba5SThomas Weißschuhendif
71e2772ba5SThomas Weißschuh
72d6fc9fcbSMasahiro Yamada# asm-generic/*.h is used by asm/*.h, and should not be included directly
730186b126SMasahiro Yamadano-header-test += asm-generic/%
74d6fc9fcbSMasahiro Yamada
756059b880SThomas Weißschuh# The following are using libc header and types.
766059b880SThomas Weißschuh#
776059b880SThomas Weißschuh# Do not add a new header to the list without legitimate reason.
786059b880SThomas Weißschuh# Please consider to fix the header first.
796059b880SThomas Weißschuh#
806059b880SThomas Weißschuh# Sorted alphabetically.
816059b880SThomas Weißschuhuses-libc += linux/a.out.h
826059b880SThomas Weißschuhuses-libc += linux/atmbr2684.h
836059b880SThomas Weißschuhuses-libc += linux/auto_dev-ioctl.h
846059b880SThomas Weißschuhuses-libc += linux/auto_fs.h
856059b880SThomas Weißschuhuses-libc += linux/auto_fs4.h
866059b880SThomas Weißschuhuses-libc += linux/btrfs_tree.h
876059b880SThomas Weißschuhuses-libc += linux/cec-funcs.h
886059b880SThomas Weißschuhuses-libc += linux/cec.h
896059b880SThomas Weißschuhuses-libc += linux/dvb/dmx.h
906059b880SThomas Weißschuhuses-libc += linux/dvb/video.h
916059b880SThomas Weißschuhuses-libc += linux/ethtool.h
926059b880SThomas Weißschuhuses-libc += linux/ethtool_netlink.h
936059b880SThomas Weißschuhuses-libc += linux/fuse.h
946059b880SThomas Weißschuhuses-libc += linux/gsmmux.h
956059b880SThomas Weißschuhuses-libc += linux/icmp.h
966059b880SThomas Weißschuhuses-libc += linux/idxd.h
976059b880SThomas Weißschuhuses-libc += linux/if.h
986059b880SThomas Weißschuhuses-libc += linux/if_arp.h
996059b880SThomas Weißschuhuses-libc += linux/if_bonding.h
1006059b880SThomas Weißschuhuses-libc += linux/if_pppox.h
1016059b880SThomas Weißschuhuses-libc += linux/if_tunnel.h
1026059b880SThomas Weißschuhuses-libc += linux/input.h
1036059b880SThomas Weißschuhuses-libc += linux/ip6_tunnel.h
1046059b880SThomas Weißschuhuses-libc += linux/joystick.h
1056059b880SThomas Weißschuhuses-libc += linux/llc.h
1066059b880SThomas Weißschuhuses-libc += linux/mctp.h
1076059b880SThomas Weißschuhuses-libc += linux/mdio.h
1086059b880SThomas Weißschuhuses-libc += linux/mii.h
1096059b880SThomas Weißschuhuses-libc += linux/mptcp.h
1106059b880SThomas Weißschuhuses-libc += linux/netdevice.h
1116059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_RATEEST.h
1126059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_hashlimit.h
1136059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_physdev.h
1146059b880SThomas Weißschuhuses-libc += linux/netfilter/xt_rateest.h
1156059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arp_tables.h
1166059b880SThomas Weißschuhuses-libc += linux/netfilter_arp/arpt_mangle.h
1176059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge.h
1186059b880SThomas Weißschuhuses-libc += linux/netfilter_bridge/ebtables.h
1196059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4.h
1206059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv4/ip_tables.h
1216059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6.h
1226059b880SThomas Weißschuhuses-libc += linux/netfilter_ipv6/ip6_tables.h
1236059b880SThomas Weißschuhuses-libc += linux/route.h
1246059b880SThomas Weißschuhuses-libc += linux/shm.h
1256059b880SThomas Weißschuhuses-libc += linux/soundcard.h
1266059b880SThomas Weißschuhuses-libc += linux/string.h
1276059b880SThomas Weißschuhuses-libc += linux/tipc_config.h
1286059b880SThomas Weißschuhuses-libc += linux/uhid.h
1296059b880SThomas Weißschuhuses-libc += linux/uinput.h
1306059b880SThomas Weißschuhuses-libc += linux/vhost.h
1316059b880SThomas Weißschuhuses-libc += linux/vhost_types.h
1326059b880SThomas Weißschuhuses-libc += linux/virtio_ring.h
1336059b880SThomas Weißschuhuses-libc += linux/wireless.h
1346059b880SThomas Weißschuhuses-libc += regulator/regulator.h
1356059b880SThomas Weißschuhuses-libc += scsi/fc/fc_els.h
1366059b880SThomas Weißschuh
1376059b880SThomas Weißschuhifeq ($(SRCARCH),hexagon)
1386059b880SThomas Weißschuhuses-libc += asm/sigcontext.h
1396059b880SThomas Weißschuhendif
1406059b880SThomas Weißschuh
1416059b880SThomas Weißschuhifeq ($(SRCARCH),nios2)
1426059b880SThomas Weißschuhuses-libc += asm/ptrace.h
1436059b880SThomas Weißschuhuses-libc += linux/bpf_perf_event.h
1446059b880SThomas Weißschuhendif
1456059b880SThomas Weißschuh
1466059b880SThomas Weißschuhifeq ($(SRCARCH),s390)
1476059b880SThomas Weißschuhuses-libc += asm/chpid.h
1486059b880SThomas Weißschuhuses-libc += asm/chsc.h
1496059b880SThomas Weißschuhendif
1506059b880SThomas Weißschuh
151c1ea04d8SMasahiro Yamadaalways-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
152fcbb8461SMasahiro Yamada
1534ac85d9bSThomas Weißschuhtarget-no-libc = $(filter-out $(uses-libc), $*.h)
154*2a0a3080SThomas Weißschuhtarget-can-compile = $(and $(filter-out $(no-header-test), $*.h), \
155*2a0a3080SThomas Weißschuh                           $(or $(CONFIG_CC_CAN_LINK), $(target-no-libc)))
1564ac85d9bSThomas Weißschuh
15700d76a0cSMasahiro Yamada# Include the header twice to detect missing include guard.
158fcbb8461SMasahiro Yamadaquiet_cmd_hdrtest = HDRTEST $<
1597ecaf069SMasahiro Yamada      cmd_hdrtest = \
1603788d69dSThomas Weißschuh		$(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \
1614ac85d9bSThomas Weißschuh			$(if $(target-no-libc), -nostdinc) \
1624ac85d9bSThomas Weißschuh			$(if $(target-can-compile), -include $< -include $<); \
163d67393f4SGeert Uytterhoeven		$(PERL) $(src)/headers_check.pl $(obj) $<; \
1647ecaf069SMasahiro Yamada		touch $@
165fcbb8461SMasahiro Yamada
166d4b7080bSThomas Weißschuh$(obj)/%.hdrtest: $(obj)/%.h $(src)/headers_check.pl FORCE
167fcbb8461SMasahiro Yamada	$(call if_changed_dep,hdrtest)
168d6fc9fcbSMasahiro Yamada
16950a48340SMasahiro Yamada# Since GNU Make 4.3, $(patsubst $(obj)/%/,%,$(wildcard $(obj)/*/)) works.
17050a48340SMasahiro Yamada# To support older Make versions, use a somewhat tedious way.
17150a48340SMasahiro Yamadaclean-files += $(filter-out Makefile headers_check.pl, $(notdir $(wildcard $(obj)/*)))
172