automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: automake and dist data


From: Matěj Týč
Subject: Re: automake and dist data
Date: Tue, 10 Feb 2009 20:53:05 +0100

What I do (not sure whether it is correct) is that I define a variable
in configure.ac:

AC_ARG_WITH([datadir],
            [AS_HELP_STRING([--with-datadir=path-to-your-foo-datafiles],
                            [Normally you don't have to use this, but it is 
handy when you
want to use foo without installing it or if you want to use already
installed data. In the first case, use for instance
--with-datadir=`pwd`/data (if it makes sense) ])], 
            [DATADIR_NAME="$with_datadir"],
            [DATADIR_NAME='$(datadir)/'foo])
AC_SUBST([DATADIR_NAME])

I provide a possibility for the user to specify the content of the
variable DATADIR_NAME variable like that, but the default is
'$(datadir)/'foo

Then I have this in my Makefile.am:

AM_CPPFLAGS = -D'DATADIR="@DATADIR_NAME@"'

Then the DATADIR macro in your C files are substituted by the variable
expanded by automake -  for instance '$(datadir)/'foo
becomes /usr/share/foo. I think that you should save it to some string
inside your program rather than getting deeply involved with the
preprocessor.

Hope it helps
Matej

On Tue, 2009-02-10 at 19:06 +0100, address@hidden wrote:
> Hello,
> 
> I hope someone here will be able to help me.
> 
> I'm developping a middle-scale library that uses autoconf and automake. This 
> library comes
> along with some demo and test programs. Those demo and test programs now 
> require some
> input files in order to run. Those input files also have to be distributed 
> with the
> package. I actually tried to put those input data files into the header 
> directory and
> I also wondered if I could put them into the share subdirectory.
> 
> The problem I'm facing is this one:
> 
> The test programs will have to read those data, but I actually can't know 
> where those
> input data are stored (it is top_srcdir/include) but it is somewhat 
> impossible from
> what I know to give that directory to C/C++ file functions.
> Of course, I can code that in the hard way. But that will work as long as the 
> project
> is not installed. But once installed (on any uknown machine), I really can't 
> know
> where to find those input files. If they are installed in the include 
> subdirectory,
> then I can have a look at /usr/include, or it might be /usr/local/include, or
> whatever directory a final user would have put to configure. It is the same 
> thing if
> I put those data in the share subdirectory.
> 
> Does anyone has an advice, a hint, or a solution for me ?
> 
> Thanks
> 
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]