Revision 49e7e5ee tools/mergedirs

View differences:

tools/mergedirs
1 1
#!/bin/sh
2 2

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

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

  
42 48
cat >$LIBDIR/Makefile <<EOF
43
OBJS=$OBJS
44
SRCS=$SRCS
45
LIB=birdlib.a
49
source=$SRCS
50
lib-dest=birdlib.a
51
root-rel=../
46 52

  
47
include \$(TOPDIR)/Rules
53
include ../Rules
48 54
EOF
49 55

  
50
sed <$TOPDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
51
ln -s $TOPDIR/conf/*.[chl] $CONFDIR/
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

Also available in: Unified diff