Statistics
| Branch: | Revision:

iof-bird-daemon / tools / mergedirs @ eeb05158

History | View | Annotate | Download (1.06 KB)

1
#!/bin/sh
2

    
3
if [ -z "$4" ] ; then
4
	echo "Usage: mergedirs <src-dir> <src-dir-rel> <obj-dir> <list-of-dirs>"
5
	exit 1
6
	fi
7
SRCDIR=$1
8
shift
9
SRCREL=$1
10
case $SRCDIR in
11
	/*) ;;
12
	*) SRCREL="../$SRCREL" ;;
13
	esac
14
shift
15
OBJDIR=$1
16
LIBDIR=$OBJDIR/lib
17
CONFDIR=$OBJDIR/conf
18
shift
19

    
20
echo "Merging system-dependent modules ($@)"
21
MODULES=`for a in $@ ; do
22
		sed <$SRCDIR/$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
23
		done |
24
	sort +0 -1 -u |
25
	cut -d ' ' -f 2`
26
rm -rf $LIBDIR $CONFDIR
27
mkdir -p $LIBDIR $CONFDIR
28
for a in $MODULES ; do
29
	b=`basename $a`
30
	case $b in
31
		*.h)	ln -s $SRCREL/$a $LIBDIR/$b
32
			;;
33
		*.c)	OBJ=`echo $b | sed 's/\.c$/\.o/'`
34
			OBJS="$OBJS $OBJ"
35
			SRCS="$SRCS \\
36
	$b"
37
			ln -s $SRCREL/$a $LIBDIR/$b
38
			;;
39
		*.Y)	CONFS="$CONFS\$(srcdir)/$a "
40
			ln -s $SRCREL/$a $CONFDIR/$b
41
			;;
42
		*)	echo "$b: Unknown file type"
43
			exit 1
44
			;;
45
		esac
46
	done
47

    
48
cat >$LIBDIR/Makefile <<EOF
49
source=$SRCS
50
lib-dest=birdlib.a
51
root-rel=../
52

    
53
include ../Rules
54
EOF
55

    
56
sed <$SRCDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
57
CONFS=`cd $SRCDIR ; ls conf/*.[chl]`
58
for a in $CONFS ; do
59
	ln -s $SRCREL/$a $CONFDIR/
60
done