[Gllug] automake/autoconf

Stig Brautaset stigbrau at start.no
Tue Jun 25 14:15:20 UTC 2002


* Nix <nix at esperi.demon.co.uk> spake thus:
> On Mon, 24 Jun 2002, Stig Brautaset mused:
> > I have been trying to use automake/autoconf for my program. I don't want
> > to put data files/ config files in hardcoded paths. I thought it would
> > be natural to have a macro that defined the standard data directory for
> > the install so I could use this.
> 
> Yes, and it's called, um, `datadir' ;}. It's ${prefix}/share by default,
> but site-config files may change it: your configure.in should not, and
> while it may consult it, it should (as with all these path variables)
> put off expansion as long as possible, so that `make install
> datadir=...' works.

ACK, I evidently failed to communicate my problem.

I know how to make automake store my files in the datadir defined by the
distribution, but what I lack is the ability for my program to *access*
the files there. What I *think* I want is a macro to define in my
configure.in that will produce a "#define DATADIR $pkgdata" where
$pkgdata is the expanded, quoted string naming the location of the
stored files. I've looked all through the autobook files, + through the
info pages on autoconf/automake.

This is what I've been able to dig up on the problem: 

AC_EXPAND_DIR(LOCALEDIR, "$datadir/locale")
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")

(It's taken from
http://www.geocrawler.com/archives/3/403/1998/8/0/2134325/ -- note the
familiar name? :)

however, the sollutions described here does not work for me (autoheader
fails with a 'missing template: LOCALEDIR' message.

I want to use this macro thus in my program (error checking omitted for
brevity);

	FILE fin;
	char fn[FILENAME_MAX];
	strcpy(fn, LOCALEDIR);
	strcat(fn, "mydatafile.dat");

	fin = fopen(fn, "r");

	...

	fclose(fn);

Hopefully I managed to explain better what I want now :)

-- 
brautaset.org


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list