summaryrefslogtreecommitdiff
path: root/scripts/headers_install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/headers_install.sh')
-rwxr-xr-x[-rw-r--r--]scripts/headers_install.sh31
1 files changed, 15 insertions, 16 deletions
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index d2308ddbb3b5..6c0761e4990d 100644..100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -3,7 +3,7 @@
# headers_install prepare the listed header files for use in
# user space and copy the files to their destination.
#
-# Usage: headers_install.pl readdir installdir arch [files...]
+# Usage: headers_install.sh readdir installdir arch [files...]
# readdir: dir to open files
# installdir: dir to install the files
# arch: current architecture
@@ -16,6 +16,9 @@
# 2) Drop include of compiler.h
# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
+# This is a port to shell of the original Perl version, to avoid
+# requiring Perl when building only the Linux API headers.
+
set -eu
readdir="$1"
@@ -27,11 +30,7 @@ unifdef="scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"
for file in "$@"
do
- tmpfile=$(mktemp -d "$installdir")
-
- while (my $line = <$in>) {
- printf {$out} "%s", $line;
- }
+ tmpfile=$(mktemp --tmpdir="$installdir")
sed -r \
-e 's/([[:space:](])__user[[:space:]]/\1/g' \
@@ -39,25 +38,25 @@ do
-e 's/([[:space:](])__iomem[[:space:]]/\1/g' \
-e 's/([[:space:]])__attribute_const__[[:space:]]/ /g' \
-e 's/([[:space:]])__attribute_const__$//g' \
- -e 's/\<__packed\>/__attribute__((packed))/g' \
- -e 's/^#include <linux\/compiler.h>//' \
- -e 's/(^|[[:space:]])(inline)\>/\1__\2__/g' \
- -e 's/(^|[[:space:]])(asm)\>([[:space:](]|$)/\1__\2__\3/g' \
- -e 's/(^|[[:space:](])(volatile)\>([[:space:](]|$)/\1__\2__\3/g' \
+ -e 's/\<__packed\>/__attribute__((packed))/g' \
+ -e 's/^#include <linux\/compiler.h>//' \
+ -e 's/(^|[[:space:]])(inline)\>/\1__\2__/g' \
+ -e 's/(^|[[:space:]])(asm)\>([[:space:](]|$)/\1__\2__\3/g' \
+ -e 's/(^|[[:space:](])(volatile)\>([[:space:](]|$)/\1__\2__\3/g' \
"$readdir/$file" > "$tmpfile"
set +e
- $unifdef "$tmpfile" > "$installdir/$file"
+ $unifdef "$tmpfile" > "$installdir/$file"
exit=$?
set -e
- # unifdef will exit 0 on success, and will exit 1 when the
- # file was processed successfully but no changes were made,
- # so abort only when it's higher than that.
+ # unifdef will exit 0 on success, and will exit 1 when the
+ # file was processed successfully but no changes were made,
+ # so abort only when it's higher than that.
if [ "$exit" != 0 ] && [ "$exit" != 1 ]
then
exit 1
fi
- rm "$tmpfile"
+ rm "$tmpfile"
done