File: make-export

package info (click to toggle)
swi-prolog 6.6.6-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 82,312 kB
  • sloc: ansic: 322,250; perl: 245,822; sh: 6,651; java: 5,254; makefile: 4,423; cpp: 4,153; ruby: 1,594; yacc: 843; xml: 82; sed: 12; sql: 6
file content (121 lines) | stat: -rwxr-xr-x 2,368 bytes parent folder | download | duplicates (6)
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
#!/bin/bash
#
# This script copies shared  objects  needed   by  the  system  into the
# hierarchy, making the tree less  dependent   on  the  operating system
# version. It use chrpath(1) to make  the search-path for shared objects
# relative to the executable.
#
# This script is highly specific to Linux  and intended to create fairly
# cross-distribution portable binary installations of SWI-Prolog.
#
# Usage:
#
# 	make-export [target dir]

os=`uname | tr A-Z a-z`
arch=`uname -m`-$os
archlib=lib/$arch
archsys=$archlib/OS
xpcelib=xpce/lib/$arch/pl2xpce.so

swipl=bin/$arch/swipl

if [ -z "$1" ]; then
  here=`pwd`
else
  here=`readlink -f $1`
  cd $here
fi

if [ ! -f $swipl ]; then
  echo "ERROR: Cannot find $swipl"
  exit 1
fi

################################################################
# The functions
################################################################

used_shared_objects()
{ find $1 -name '*.so' | xargs ldd | awk '/=> *\// { print $3; }' | sort -u
}

# copy_shared_object file dir

copy_shared_object()
{ file="$1";
  dest="$2";

  sofile=`readlink -f "$file"`
  if [ $? = 0 ]; then
    cp -av $sofile $dest
    (cd $dest && ln -s `basename $sofile` `basename $1`)
  else
    cp -av $file $dest
  fi
}


# docopy decides on the shared objects that are copied.

docopy()
{ case "$1" in
    *java*|*odbc*)			# We definitely do not want these
	return 1
	;;
    $here*)				# These are already ours
	return 1
	;;
    */libgmp*)				# These seem to make sense
	return 0
	;;
    */libreadline*)
	return 0
	;;
    */libncurses*)
	return 0
	;;
    */libjpeg*|*/libXpm*)
        return 0
	;;
    *)					# By default, do not copy
	return 1
	;;
  esac
}


copy_system_objects()
{ for so in `used_shared_objects .`; do
    if docopy $so; then
      copy_shared_object $so $archsys
    fi
  done
}


fix_rpath_bin()
{ chrpath -r "\${ORIGIN}/../../$archlib:\$ORIGIN/../../$archsys" $1
}

fix_rpath_lib()
{ chrpath -r "\${ORIGIN}/OS" $1
}

fix_rpath_xpce()
{ chrpath -r "\${ORIGIN}/../../../$archlib:\$ORIGIN/../../../$archsys" $1
}

################################################################
# Toplevel
################################################################

fix_rpath_bin $swipl
for lib in $archlib/*.so; do
  fix_rpath_lib $lib
done
fix_rpath_xpce $xpcelib

[ ! -d $archsys ] || rm -r $archsys
mkdir -p $archsys
copy_system_objects