summaryrefslogtreecommitdiffstats
path: root/extra/scripts/install_headers.sh
diff options
context:
space:
mode:
authorKhem Raj <kraj@mvista.com>2008-06-27 04:01:29 +0000
committerKhem Raj <kraj@mvista.com>2008-06-27 04:01:29 +0000
commitd3f9546960f56c05624e2932a899db7f1d38a480 (patch)
tree6c63cec6c57ad8060a4b6ef983b3b24ece5fc87c /extra/scripts/install_headers.sh
parentda3e789d079c47fea519270269e0c63dd5d497e2 (diff)
downloaduClibc-alpine-d3f9546960f56c05624e2932a899db7f1d38a480.tar.bz2
uClibc-alpine-d3f9546960f56c05624e2932a899db7f1d38a480.tar.xz
Sync build machinery stuff from trunk. Some more fixed for mips nptl port
Diffstat (limited to 'extra/scripts/install_headers.sh')
-rwxr-xr-xextra/scripts/install_headers.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/extra/scripts/install_headers.sh b/extra/scripts/install_headers.sh
new file mode 100755
index 000000000..6d73ad2c6
--- /dev/null
+++ b/extra/scripts/install_headers.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Parameters:
+# $1 = source dir
+# $2 = dst dir
+# $top_builddir = well you guessed it
+
+die_if_not_dir()
+{
+ for dir in "$@"; do
+ test -d "$dir" && continue
+ echo "Error: '$dir' is not a directory"
+ exit 1
+ done
+}
+
+
+# Ensure that created dirs/files have 755/644 perms
+umask 022
+
+
+# Sanity tests
+die_if_not_dir "$1"
+mkdir -p "$2" 2>/dev/null
+die_if_not_dir "$2"
+die_if_not_dir "$top_builddir"
+if ! test -x "$top_builddir/extra/scripts/unifdef"; then
+ echo "Error: need '$top_builddir/extra/scripts/unifdef' executable"
+ exit 1
+fi
+
+
+# Sanitize and copy uclibc headers
+(
+# We must cd, or else we'll prepend "$1" to filenames!
+cd "$1" || exit 1
+find ! -name '.' -a ! -path '*/.*'
+) | \
+(
+IFS=''
+while read -r filename; do
+ filename="${filename#./}"
+ if test -d "$1/$filename"; then
+ mkdir -p "$2/$filename" 2>/dev/null
+ else
+ # NB: unifdef exits with 1 if output is not
+ # exactly the same as input. That's ok.
+ # Do not abort the script if unifdef "fails"!
+ "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL "$1/$filename" \
+ | grep -v '^libc_hidden_proto[ ]*([a-zA-Z0-9_]*)$' >"$2/$filename"
+ fi
+done
+)
+
+
+# Fix mode/owner bits
+cd "$2" || exit 1
+chmod -R u=rwX,go=rX . >/dev/null 2>&1
+chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1