File: build-clheplib.in

package info (click to toggle)
clhep 2.1.4.1+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 10,004 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,691; perl: 28
file content (142 lines) | stat: -rwxr-xr-x 3,231 bytes parent folder | download | duplicates (3)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /bin/sh
# @configure_input@
#
#  This script creates clheplib, which provides a list of libararies to link
#

prefix=@prefix@
exec_prefix=@exec_prefix@
uselibdir=$exec_prefix/lib

usage()
{
    echo "Usage: ./build-clheplib <list of subdirs>"
    exit $1
}

getdeplist()
{
    # recursive check for library dependencies
    # packages are listed multiple times, but tsort takes care of this
    dpkg=$1
    dfile=$2
    oldlist=`cat $dfile`
    if test -f $dpkg/$dpkg-deps; then 
	# strip out the package name and add it to $dfile
	newlist=`tsort $dpkg/$dpkg-deps | sed 's/CLHEP-//' | sed 's/-@VERSION@//'`
	echo $newlist >> $dfile
	# this is the recursive part
	for x in $newlist; do
            if test "$x" != "$dpkg"; then
                getdeplist $x $dfile
	    fi
	done
    fi
}

makeliblist()
{
    pkg=$1
    pkgfile="$pkg-library-list"
    rm -f $pkgfile
    touch $pkgfile
    depfile="$pkg-dep-list"
    rm -f $depfile
    touch $depfile
    # get relevant lists
    if test -f $pkg/$pkg-deps; then
	getdeplist $pkg $depfile
	list=`cat $depfile`
	for entry in $list; do
	    if test -f $entry/$entry-deps; then
	       cat $entry/$entry-deps >> $pkgfile
	    fi
	done
    fi
}

if test $# -eq 0; then
    usage 1
fi

while test $# -gt 0; do
    sublist="$sublist $1"
    shift
done

# create the concatenated library list
libfile="library-list"
rm -f $libfile
touch $libfile
for subdir in $sublist; do
    if test -f $subdir/$subdir-deps; then 
        cat $subdir/$subdir-deps >> $libfile
    fi
done

rm -f clheplib
echo "#! /bin/sh" > clheplib
echo "# " >> clheplib
echo "# " >> clheplib
echo " " >> clheplib
echo "usage() " >> clheplib
echo "{ " >> clheplib
echo "    echo \"Usage: clhepib [package]\" " >> clheplib
echo "    exit 1 " >> clheplib
echo "} " >> clheplib
echo " " >> clheplib
echo "if test \$# -eq 0; then " >> clheplib
echo "    pkg="all" " >> clheplib
echo "else " >> clheplib
echo "    pkg=\$1 " >> clheplib
echo "fi " >> clheplib
echo " " >> clheplib
echo "libdir=\"$uselibdir\" " >> clheplib
echo "if test -n \"\$CLHEP_DIR\"; then " >> clheplib
echo "    libdir=\"\$CLHEP_DIR/lib\" " >> clheplib
echo "fi " >> clheplib
echo " " >> clheplib
echo "case "\$pkg" in " >> clheplib

clibs=" "
tlist=`tsort $libfile`
for lib in $tlist; do
    clibs="$clibs -l$lib"
done
echo "all) " >> clheplib
echo "  if test -f \$libdir/libCLHEP-@VERSION@.a || test -f \$libdir/libCLHEP-@VERSION@.so " >> clheplib
echo "  then   " >> clheplib
echo "    echo -L\$libdir -lCLHEP-@VERSION@ " >> clheplib
echo "  else " >> clheplib
echo "    echo -L\$libdir $clibs" >> clheplib
echo "  fi " >> clheplib
echo "  ;; " >> clheplib

for sub in $sublist; do
    if test -f $sub/$sub-deps; then 
	makeliblist $sub
	tlist=`tsort $pkg-library-list`
	clibs=" "
	for lib in $tlist; do
	    clibs="$clibs -l$lib"
	done
	echo "$sub) " >> clheplib
	echo "  echo -L\$libdir $clibs" >> clheplib
	echo "  ;; " >> clheplib
    else
	echo "$sub) " >> clheplib
	echo "  echo -L\$libdir " >> clheplib
	echo "  ;; " >> clheplib
    fi
done

echo "*) " >> clheplib
echo "  echo unknown package \$pkg " >> clheplib
echo "  ;; " >> clheplib
echo "esac " >> clheplib
echo " " >> clheplib
echo "exit 0 " >> clheplib

chmod +x clheplib

exit 0