Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Next: , Previous: Why Not Imake, Up: FAQ

19.5 How Do I #define Installation Directories?

     My program needs library files, installed in datadir and
     similar.  If I use
     
          AC_DEFINE_UNQUOTED([DATADIR], [$datadir],
            [Define to the read-only architecture-independent
             data directory.])
     

I get

          #define DATADIR "${prefix}/share"
     

As already explained, this behavior is on purpose, mandated by the GNU Coding Standards, see Installation Directory Variables. There are several means to achieve a similar goal:

  • Do not use AC_DEFINE but use your makefile to pass the actual value of datadir via compilation flags. See Installation Directory Variables, for the details.
  • This solution can be simplified when compiling a program: you may either extend the CPPFLAGS:
              CPPFLAGS = -DDATADIR='"$(datadir)"' @CPPFLAGS@
         

    or create a dedicated header file:

              DISTCLEANFILES = datadir.h
              datadir.h: Makefile
                      echo '#define DATADIR "$(datadir)"' >$@
         
  • Use AC_DEFINE but have configure compute the literal value of datadir and others. Many people have wrapped macros to automate this task. For instance, the macro AC_DEFINE_DIR from the Autoconf Macro Archive.

    This solution does not conform to the GNU Coding Standards.

  • Note that all the previous solutions hard wire the absolute name of these directories in the executables, which is not a good property. You may try to compute the names relative to prefix, and try to find prefix at runtime, this way your package is relocatable. Some macros are already available to address this issue: see adl_COMPUTE_RELATIVE_PATHS and adl_COMPUTE_STANDARD_RELATIVE_PATHS on the Autoconf Macro Archive.

 
 
  Published under the terms of the GNU General Public License Design by Interspire