File: getlibdir

package info (click to toggle)
gnump3d 2.9.3-1sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,420 kB
  • ctags: 366
  • sloc: perl: 10,649; sh: 188; makefile: 147
file content (67 lines) | stat: -rwxr-xr-x 1,538 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w
#
#  getlibdir - Determine an appropriate library directory.
#
#  GNU MP3D - A portable(ish) MP3 server.
#
# Homepage:
#   http://www.gnump3d.org/
#
# Author:
#  Steve Kemp <steve@steve.org.uk>
#
# Version:
#  $Id: getlibdir,v 1.4 2004/11/23 09:32:52 skx Exp $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#  Steve Kemp
#  ---
#  http://www.steve.org.uk/
#
#


use strict;


#
#  Only examine directories beneath /usr or /Library
# (The latter is for Mac OS X).
#
my @dirs = grep( /^\/usr|^\/Library/, @INC );


#
# we prefer /share/ to /lib/ since this is arch-indep
#
if ( grep(m|/share/|, @dirs) ) {
    @dirs = grep(m|/share/|, @dirs);
}

#
#  Find the shortest one.
#
@dirs = sort { length( $a ) <=> length( $ b ) }  @dirs ;


#
#  Print it out - stripping the trailing '/' if present
#
if ( $dirs[0] =~ /(.*)\/$/ ) {
    $dirs[0] = $1;
}

print $dirs[0];