File: symlinks.sh

package info (click to toggle)
tcng 10b-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,644 kB
  • sloc: ansic: 19,040; pascal: 4,640; yacc: 2,619; sh: 1,914; perl: 1,546; lex: 772; makefile: 751
file content (99 lines) | stat: -rwxr-xr-x 1,978 bytes parent folder | download | duplicates (4)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash -e
#
# symlinks.sh - Generate convenience symbolic links
#
# Written 2001,2002,2004 by Werner Almesberger
#
# Copyright 2001,2002 Network Robots, Bivio Networks
# Copyright 2002,2004 Werner Almesberger
#

if [ \( "$1" != list -a "$1" != link \) -o -z "$2" -o ! -z "$3" ]; then
    echo "usage: $0 mode target_dir" 1>&2
    echo '  mode is "list" or "link"' 1>&2
    exit 1
fi
mode=$1

if [ $mode = link ]; then
    . ./config
fi

link()
{
    dest="$1"
    shift
    if [ $mode != list ]; then
	mkdir -p "$dest"
    fi
    for n in "$@"; do
#--- for sanity checks only ---------------------------------------------------
#	if [ ! -e "$n" ]; then
#	    echo "$n does not exist" 1>&2
#	    exit 1
#	fi
#------------------------------------------------------------------------------
	if [ $mode = list ]; then
	    echo "$dest/`basename \"$n\"`" | sed 's|^\./||'
	else
	    ln -sf $TOPDIR/"$n" "$dest"
	fi
    done
}


#
# bin/tcng is special
#

if [ $mode = list ]; then
    echo $2/bin/tcng | sed 's|^\./||'
else
    mkdir -p $2/bin
    ln -sf $TOPDIR/tcc/tcc $2/bin/tcng
fi

#
# bin
#
link $2/bin \
  tcc/tcc tcc/tcc_var2fix.pl \
  tcsim/tcsim tcsim/tcsim_filter tcsim/tcsim_plot tcsim/tcsim_pretty

#
# lib/tcng/bin
#
link $2/lib/tcng/bin \
  tcc/tcc-module tcc/ext/tcc-ext-err tcc/ext/tcc-ext-null \
  tcc/ext/tcc-ext-file \
  tcsim/modules/kmod_cc tcsim/modules/tcmod_cc

#
# lib/tcng/include
#
link $2/lib/tcng/include \
  tcc/default.tc tcc/meta.tc tcc/fields.tc tcc/fields4.tc tcc/fields6.tc \
  tcc/values.tc tcc/meters.tc tcc/ports.tc tcc/idiomatic.tc \
  tcc/ext/tccext.h tcc/ext/echoh.h \
  tcc/tccmeta.h \
  tcsim/default.tcsim \
  tcsim/ip.def tcsim/packet.def tcsim/packet4.def tcsim/packet6.def \
  tcsim/tcngreg.def \
  tcsim/klib tcsim/ulib

#
# lib/tcng/lib
#
link $2/lib/tcng/lib \
  tcc/tcm_cls.c tcc/tcm_f.c \
  tcc/ext/libtccext.a

#
# lib/tcng/tests
#
if [ $mode == link ]; then
    ln -sfn ../.. lib/tcng/tests
    mkdir -p "$dest"
fi

exit 0