Back to index

cell-binutils  2.17cvs20070401
relocatable.h
Go to the documentation of this file.
00001 /* Provide relocatable packages.
00002    Copyright (C) 2003 Free Software Foundation, Inc.
00003    Written by Bruno Haible <bruno@clisp.org>, 2003.
00004 
00005    This program is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
00018    USA.  */
00019 
00020 #ifndef _RELOCATABLE_H
00021 #define _RELOCATABLE_H
00022 
00023 /* This can be enabled through the configure --enable-relocatable option.  */
00024 #if ENABLE_RELOCATABLE
00025 
00026 /* When building a DLL, we must export some functions.  Note that because
00027    this is a private .h file, we don't need to use __declspec(dllimport)
00028    in any case.  */
00029 #if defined _MSC_VER && BUILDING_DLL
00030 # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
00031 #else
00032 # define RELOCATABLE_DLL_EXPORTED
00033 #endif
00034 
00035 /* Sets the original and the current installation prefix of the package.
00036    Relocation simply replaces a pathname starting with the original prefix
00037    by the corresponding pathname with the current prefix instead.  Both
00038    prefixes should be directory names without trailing slash (i.e. use ""
00039    instead of "/").  */
00040 extern RELOCATABLE_DLL_EXPORTED void
00041        set_relocation_prefix (const char *orig_prefix,
00042                            const char *curr_prefix);
00043 
00044 /* Returns the pathname, relocated according to the current installation
00045    directory.  */
00046 extern const char * relocate (const char *pathname);
00047 
00048 /* Memory management: relocate() leaks memory, because it has to construct
00049    a fresh pathname.  If this is a problem because your program calls
00050    relocate() frequently, think about caching the result.  */
00051 
00052 /* Convenience function:
00053    Computes the current installation prefix, based on the original
00054    installation prefix, the original installation directory of a particular
00055    file, and the current pathname of this file.  Returns NULL upon failure.  */
00056 extern const char * compute_curr_prefix (const char *orig_installprefix,
00057                                     const char *orig_installdir,
00058                                     const char *curr_pathname);
00059 
00060 #else
00061 
00062 /* By default, we use the hardwired pathnames.  */
00063 #define relocate(pathname) (pathname)
00064 
00065 #endif
00066 
00067 #endif /* _RELOCATABLE_H */