Tell a configure script to use a relative path for --datarootdir
Asked Answered
S

2

7

I have used GNU autoconf to generate a configure script for a program of mine, which I am now trying to cross-compile for Windows.

Under Linux, to change the location of the data files I supply --datarootdir=/blah which works fine. Under Windows however, my application's path won't be known until run time (as the user could choose to install it anywhere.) Therefore I want to set the data directory to be the current directory, wherever that may be at the time the application is launched.

Unfortunately, passing --datarootdir=. doesn't work:

configure: error: expected an absolute directory name for --datarootdir: .

How do you tell Autoconf/configure that you want a path relative to the current directory at run time?

Shine answered 11/3, 2012 at 10:11 Comment(0)
S
3

I think I have found a partial solution for this. It seems --datarootdir is used to control where the files are installed to, so it needs to be an absolute path for the benefit of make install. However it can be overridden during compilation:

make datadir="."

This way, during compilation the code thinks the $(datadir) is "." but when running make install the files are still placed in the absolute path given to ./configure --datarootdir=...

Shine answered 11/3, 2012 at 12:24 Comment(1)
Of course I have since realised that this isn't the best solution either. When launching the .exe directly it works fine (.exe is in the current directory), but when double-clicking on a document file associated with the app, the .exe is launched from the document file's directory, which means the data files cannot be found...Shine
D
1

Just give it an absolute path that is equal to the current working directory:

./configure --datarootdir=$PWD
Depressant answered 11/3, 2012 at 23:7 Comment(1)
The problem there is that if one user chooses to install my app on the target system into C:\Program Files, and another into D:\Apps, the datarootdir will be different between the two. $PWD will only be accurate at compile time, whereas I need the value to be relative to the run time current directory.Shine

© 2022 - 2024 — McMap. All rights reserved.