kaykun
kaykun

Reputation: 2267

Autotools with Data Files

I want to distribute my source code and relevant data files using Autotools:

~/foo$ ls -R
.:
conf  configure.ac  dat  Makefile.am  src

./conf:
foo-pref.conf

./dat:
data.dat

./src:
main.c  Makefile.am

This is what I have so far. Without the ./conf and ./dat subdirectories I can get Autotools to work to set it up for a single executable file. But I want data.dat to be installed in $(prefix)/share and foo-pref.conf to be installed in the appropriate /etc directory. What can I do to achieve this?

Upvotes: 4

Views: 1681

Answers (1)

dennycrane
dennycrane

Reputation: 2331

You can use dist_data_DATA = dat/data.dat and dist_sysconf_DATA = conf/foo-pref.conf to achieve what you want. The dist_ prefix says that those files should be distributed by distributions generated with make dist. The (in this case) middle part says what the target directory is: data for ${datadir}, sysconf for ${sysconfdir}, ... others can be looked up in the generated Makefile, if need be. Well, and the DATA primary says to do nothing spectacular with those files, as opposed to, say SCRIPTS.

Note that by default, configure will set ${sysconfdir} to ${prefix}/etc as opposed to the more customary /etc. If you want to change that, you need to call configure with e.g. ./configure --sysconfdir=/etc.

Upvotes: 7

Related Questions