[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: config variables in config.h
From: |
Akim Demaille |
Subject: |
Re: config variables in config.h |
Date: |
11 Sep 2002 12:07:09 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
I tried to summarize the answers to this *very* FAQ. If people see
other things to put in the FAQ, please...
Index: ChangeLog
from Akim Demaille <address@hidden>
* doc/autoconf.texi (Questions): Rename as...
(FAQ): this.
(Defining Directories): New.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.670
diff -u -u -r1.670 autoconf.texi
--- doc/autoconf.texi 9 Sep 2002 16:27:02 -0000 1.670
+++ doc/autoconf.texi 11 Sep 2002 10:10:28 -0000
@@ -163,7 +163,7 @@
* config.status Invocation:: Recreating a configuration
* Obsolete Constructs:: Kept for backward compatibility
* Using Autotest:: Creating portable test suites
-* Questions:: Questions about Autoconf, with answers
+* FAQ:: Frequent Questions about Autoconf, with answers
* History:: History of Autoconf
* Copying This Manual:: How to make copies of this manual
* Indices:: Indices of symbols, concepts, etc.
@@ -426,12 +426,13 @@
* testsuite Scripts:: The concepts of Autotest
* Autotest Logs:: Their contents
-Questions About Autoconf
+Frequently Asked Questions About Autoconf
* Distributing:: Distributing @command{configure} scripts
* Why GNU m4:: Why not use the standard M4?
* Bootstrapping:: Autoconf and GNU M4 require each other?
* Why Not Imake:: Why GNU uses @command{configure} instead of
Imake
+* Defining Directories:: Passing @code{datadir} to program
History of Autoconf
@@ -527,8 +528,8 @@
do not have. You must use version 1.4 or later of @sc{gnu} M4.
@xref{Autoconf 1}, for information about upgrading from version 1.
address@hidden, for the story of Autoconf's development.
address@hidden, for answers to some common questions about Autoconf.
address@hidden, for the story of Autoconf's development. @xref{FAQ},
+for answers to some common questions about Autoconf.
See the @href{http://www.gnu.org/software/autoconf/autoconf.html,
@@ -13750,10 +13751,10 @@
address@hidden ================================================ Questions About
Autoconf.
address@hidden =============================== Frequently Asked Questions About
Autoconf
address@hidden Questions
address@hidden Questions About Autoconf
address@hidden FAQ
address@hidden Frequently Asked Questions About Autoconf
Several questions about Autoconf come up occasionally. Here some of them
are addressed.
@@ -13763,6 +13764,7 @@
* Why GNU m4:: Why not use the standard M4?
* Bootstrapping:: Autoconf and GNU M4 require each other?
* Why Not Imake:: Why GNU uses @command{configure} instead of
Imake
+* Defining Directories:: Passing @code{datadir} to program
@end menu
@node Distributing
@@ -13937,6 +13939,74 @@
duplicated, even though they normally are in @command{configure} setups.
@end quotation
+
address@hidden Defining Directories
address@hidden How Do I @code{#define} Installation Directories?
+
address@hidden
+My program needs library files, installed in @code{datadir} and
+similar. If I use
+
address@hidden
+AC_DEFINE_UNQUOTED([DATADIR], [$datadir],
+ [Define to the read-only architecture-independent
+ data directory.])
address@hidden example
+
address@hidden
+I get
+
address@hidden
+#define DATADIR "address@hidden@}/share"
address@hidden example
address@hidden display
+
+As already explained, this behavior is on purpose, mandated by the GNU
+Coding Standards, see @ref{Installation Directory Variables}. There are
+several means to acheive a similar goal:
+
address@hidden @minus
address@hidden
+Do not use @code{AC_DEFINE} but use your @file{Makefile} to pass the
+actual value of @code{datadir} via compilation flags, see
address@hidden Directory Variables}, for the details.
+
address@hidden
+This solution can be simplified when compiling a program: you may either
+extend the @code{CPPFLAGS}:
+
address@hidden
+CPPFLAGS = -DDATADIR=\"$(datadir)\" @@CPPFLAGS@@
address@hidden example
+
address@hidden
+or create a dedicated header file:
+
address@hidden
+DISTCLEANFILES = datadir.h
+datadir.h: Makefile
+ echo '#define DATADIR "$(datadir)"' >$@@
address@hidden example
+
address@hidden
+Use @code{AC_DEFINE} but have @command{configure} compute the literal
+value of @code{datadir} and others. Many people have wrapped macros to
+automate this task. For instance, the macro @code{AC_DEFINE_DIR} from
+the @href{http://www.gnu.org/software/ac-archive/, Autoconf Macro
+Archive}.
+
+This solution is not conformant with the GNU Coding Standards.
+
address@hidden
+Note that all the previous solutions hard wire the absolute path to
+these directories in the executables, which is not a good property. You
+may try to compute the paths relatively to @code{prefix}, and try to
+find @code{prefix} at runtime, this way your package is relocatable.
+Some macros are already available to address this issue: see
address@hidden and
address@hidden on the
address@hidden://www.gnu.org/software/ac-archive/, Autoconf Macro Archive}.
address@hidden itemize
- Re: config variables in config.h,
Akim Demaille <=