Lines 1-60
Link Here
|
1 |
# -*- Mode: Python; py-indent-offset: 4 -*- |
|
|
2 |
# ltihooks.py: python import hooks that understand libtool libraries. |
3 |
# Copyright (C) 2000 James Henstridge. |
4 |
# |
5 |
# This program is free software; you can redistribute it and/or modify |
6 |
# it under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 2 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# This program is distributed in the hope that it will be useful, |
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with this program; if not, write to the Free Software |
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 |
|
19 |
import os, ihooks |
20 |
|
21 |
class LibtoolHooks(ihooks.Hooks): |
22 |
def get_suffixes(self): |
23 |
"""Like normal get_suffixes, but adds .la suffixes to list""" |
24 |
ret = ihooks.Hooks.get_suffixes(self) |
25 |
ret.insert(0, ('module.la', 'rb', 3)) |
26 |
ret.insert(0, ('.la', 'rb', 3)) |
27 |
return ret |
28 |
|
29 |
def load_dynamic(self, name, filename, file=None): |
30 |
"""Like normal load_dynamic, but treat .la files specially""" |
31 |
if len(filename) > 3 and filename[-3:] == '.la': |
32 |
fp = open(filename, 'r') |
33 |
dlname = '' |
34 |
installed = 1 |
35 |
line = fp.readline() |
36 |
while line: |
37 |
if len(line) > 7 and line[:7] == 'dlname=': |
38 |
dlname = line[8:-2] |
39 |
elif len(line) > 10 and line[:10] == 'installed=': |
40 |
installed = line[10:-1] == 'yes' |
41 |
line = fp.readline() |
42 |
fp.close() |
43 |
if dlname: |
44 |
if installed: |
45 |
filename = os.path.join(os.path.dirname(filename), |
46 |
dlname) |
47 |
else: |
48 |
filename = os.path.join(os.path.dirname(filename), |
49 |
'.libs', dlname) |
50 |
return ihooks.Hooks.load_dynamic(self, name, filename, file) |
51 |
|
52 |
importer = ihooks.ModuleImporter() |
53 |
importer.set_hooks(LibtoolHooks()) |
54 |
|
55 |
def install(): |
56 |
importer.install() |
57 |
def uninstall(): |
58 |
importer.uninstall() |
59 |
|
60 |
install() |