aarch64: add hwcap header file
[uclibc-ng.git] / extra / scripts / install_headers.sh
blob8c8d715ef8de2bb15a49a954d236dd2ae9f2894b
1 #!/bin/sh
2 # Parameters:
3 # $1 = source dir
4 # $2 = dst dir
5 # $top_builddir = well you guessed it
7 srcdir=${1:-include}
8 dstdir=${2:-`. ./.config 2>/dev/null && echo ${DEVEL_PREFIX}/include`}
9 : ${top_builddir:=.}
11 die_if_not_dir()
13 for dir in "$@"; do
14 test -d "$dir" && continue
15 echo "Error: '$dir' is not a directory"
16 exit 1
17 done
21 # Ensure that created dirs/files have 755/644 perms
22 umask 022
25 # Sanity tests
26 die_if_not_dir "${srcdir}"
27 mkdir -p "${dstdir}" 2>/dev/null
28 die_if_not_dir "${dstdir}"
29 die_if_not_dir "$top_builddir"
30 if ! test -x "$top_builddir/extra/scripts/unifdef"; then
31 echo "Error: need '$top_builddir/extra/scripts/unifdef' executable"
32 exit 1
35 # Sanitize and copy uclibc headers
37 # We must cd, or else we will prepend "${srcdir}" to filenames!
38 cd "${srcdir}" || exit 1
39 find . ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \
40 -e '/^config$/d'
41 ) | \
43 IFS=''
44 while read -r filename; do
45 if test -d "${srcdir}/$filename"; then
46 mkdir -p "${dstdir}/$filename" 2>/dev/null
47 continue
49 if test x"${filename##libc-*.h}" = x""; then
50 # Do not install libc-XXXX.h files
51 continue
53 # Do not abort the script if unifdef "fails"!
54 # NB2: careful with sed command arguments, they contain tab character
55 "$top_builddir/extra/scripts/unifdef" \
56 -B \
57 -t \
58 -x 2 \
59 -f "$top_builddir/include/generated/unifdef_config.h" \
60 -U_LIBC \
61 -U__UCLIBC_GEN_LOCALE \
62 -U__NO_CTYPE \
63 "${srcdir}/$filename" \
64 | sed -e '/^rtld_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
65 | sed -e '/^lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
66 > "${dstdir}/$filename"
67 done
71 # Fix mode/owner bits
72 cd "${dstdir}" || exit 1
73 chmod -R u=rwX,go=rX . >/dev/null 2>&1
74 chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1
76 # ignore errors on unrelated files
77 exit 0