Statistics
| Branch: | Revision:

iof-bird-daemon / tools / mergedirs @ eab0d1e5

History | View | Annotate | Download (1.16 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
cpp=${CPP:-gcc -E}
8
SRCDIR=$1
9
shift
10
SRCREL=$1
11
case $SRCDIR in
12
	/*) ;;
13
	*) SRCREL="../$SRCREL" ;;
14
	esac
15
shift
16
OBJDIR=$1
17
LIBDIR=$OBJDIR/lib
18
CONFDIR=$OBJDIR/conf
19
shift
20

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

    
51
cat >$LIBDIR/Makefile <<EOF
52
source=$SRCS
53
lib-dest=birdlib.a
54
root-rel=../
55

    
56
include ../Rules
57
EOF
58

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