OSDN Git Service

remove incorrect text from abspath option
[uclinux-h8/uClibc.git] / extra / scripts / install_headers.sh
1 #!/bin/sh
2 # Parameters:
3 # $1 = source dir
4 # $2 = dst dir
5 # $top_builddir = well you guessed it
6
7 die_if_not_dir()
8 {
9         for dir in "$@"; do
10                 test -d "$dir" && continue
11                 echo "Error: '$dir' is not a directory"
12                 exit 1
13         done
14 }
15
16
17 # Ensure that created dirs/files have 755/644 perms
18 umask 022
19
20
21 # Sanity tests
22 die_if_not_dir "$1"
23 mkdir -p "$2" 2>/dev/null
24 die_if_not_dir "$2"
25 die_if_not_dir "$top_builddir"
26 if ! test -x "$top_builddir/extra/scripts/unifdef"; then
27         echo "Error: need '$top_builddir/extra/scripts/unifdef' executable"
28         exit 1
29 fi
30
31
32 # Sanitize and copy uclibc headers
33 (
34 # We must cd, or else we'll prepend "$1" to filenames!
35 cd "$1" || exit 1
36 find . ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \
37         -e '/^config$/d'
38 ) | \
39 (
40 IFS=''
41 while read -r filename; do
42         if test -d "$1/$filename"; then
43                 mkdir -p "$2/$filename" 2>/dev/null
44                 continue
45         fi
46         if test x"${filename##libc-*.h}" = x""; then
47                 # Do not install libc-XXXX.h files
48                 continue
49         fi
50         # NB: unifdef exits with 1 if output is not
51         # exactly the same as input. That's ok.
52         # Do not abort the script if unifdef "fails"!
53         # NB2: careful with sed command arguments, they contain tab character
54         "$top_builddir/extra/scripts/unifdef" \
55                 -U_LIBC \
56                 -U__UCLIBC_GEN_LOCALE \
57                 -U__NO_CTYPE \
58                 "$1/$filename" \
59         | sed -e '/^rtld_hidden_proto[  ]*([a-zA-Z0-9_]*)$/d' \
60         | sed -e '/^lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)_hidden_proto[  ]*([a-zA-Z0-9_]*)$/d' \
61         >"$2/$filename"
62 done
63 )
64
65
66 # Fix mode/owner bits
67 cd "$2" || exit 1
68 chmod -R u=rwX,go=rX . >/dev/null 2>&1
69 chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1