summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.asm-generic
blob: d17e0ea911edd568a039c905330420810223d07f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# include/asm-generic contains a lot of files that are used
# verbatim by several architectures.
#
# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
# and for each file listed in this file with generic-y creates
# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)

kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
-include $(kbuild-file)

include scripts/Kbuild.include

# Create output directory if not already present
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))

quiet_cmd_wrap = WRAP    $@
cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@

all: $(patsubst %, $(obj)/%, $(generic-y))
	@:

$(obj)/%.h:
	$(call cmd,wrap)
an class="c1"># could also just review the results. use strict; sub usage { print "Usage: checkincludes.pl [-r]\n"; print "By default we just warn of duplicates\n"; print "To remove duplicated includes in place use -r\n"; exit 1; } my $remove = 0; if ($#ARGV < 0) { usage(); } if ($#ARGV >= 1) { if ($ARGV[0] =~ /^-/) { if ($ARGV[0] eq "-r") { $remove = 1; shift; } else { usage(); } } } foreach my $file (@ARGV) { open(my $f, '<', $file) or die "Cannot open $file: $!.\n"; my %includedfiles = (); my @file_lines = (); while (<$f>) { if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { ++$includedfiles{$1}; } push(@file_lines, $_); } close($f); if (!$remove) { foreach my $filename (keys %includedfiles) { if ($includedfiles{$filename} > 1) { print "$file: $filename is included more than once.\n"; } } next; } open($f, '>', $file) or die("Cannot write to $file: $!"); my $dups = 0; foreach (@file_lines) { if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { foreach my $filename (keys %includedfiles) { if ($1 eq $filename) { if ($includedfiles{$filename} > 1) { $includedfiles{$filename}--; $dups++; } else { print {$f} $_; } } } } else { print {$f} $_; } } if ($dups > 0) { print "$file: removed $dups duplicate includes\n"; } close($f); }