summaryrefslogtreecommitdiff
path: root/debian/scripts/link-headers
blob: fb42dbd12e4df240b861f060d5c72c2b2edc9cee (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash -e

. debian/debian.env

hdrdir="$1"
symdir="$2"
flavour="$3"

echo "Symlinking and copying headers for $flavour..."

excludes="( -path ./debian -prune -o -path ./${DEBIAN} -prune -o -path ./.git ) -prune -o"

(
find . $excludes  -type f \
	\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
	-name '*.sh' -o -name '*.pl' -o -name '*.lds' \) -print
find ./include ./scripts -name .gitignore -prune -o -type f -print
find ./include -mindepth 1 -maxdepth 1 $excludes -type d -print
) | (
while read file; do
	dir=$file
	lastdir=$file

	if [ -e "$hdrdir/$file" -o -L "$hdrdir/$file" ]; then
		continue
	fi

	while [ ! -e "$hdrdir/$dir" -a ! -L "$hdrdir/$dir" ]; do
		lastdir=$dir
		dir=`dirname $dir`
	done
	# If the last item to exist is a symlink we assume all is good
	if [ ! -L "$hdrdir/$dir" ]; then
		# Turns things like "./foo" into "../"
		deref="`echo -n $lastdir | sed -e 's/^\.//' -e's,/[^/]*,../,g'`"
		item="`echo -n $lastdir | sed -e 's/^\.\///'`"
		ln -s $deref$symdir/$item $hdrdir/$item
	fi
done
)

exit