reversed(top()) code tags rss about

How to install data directory with automake

September 28, 2014
[howto] [issue] [autoconf] [build] [make]

I thought that adding directory to pkgdata_DATA variable in file would be enough, but make install command gave this error:

/usr/bin/ginstall: omitting directory ‘../data/vim/’

I already knew that just listing all the files I want to copy in pkgdata_DATA won’t help as it doesn’t care about paths and flattens directory structure.

I have found several posts on this topic and stopped on approach described in this post (see first quoted e-mail). It basically covers it, but I’d like to provide a more verbose description.

Here we go. The task is to install one of directories available in the source tree to share/{appname}/. The sub-tree structure is as follows:


These are all directories and as we know now install refuses to copy them. This means that one needs to list files to copy and specify correct prefixes for them.

Good news is that directory creation automatically takes care of non-existing parent directories, so no need to worry about destination path and about autoload/ directory in it. Other six directories contain these files:


Note doc/tags file, which we don’t want to install. Luckily, we can just omit it from list of files and that’s it. If we were copying whole directories, this would’ve been much harder to take care of, which is the reason why I decided to do not use install-data-hook instead (described in one of posts linked above).

Now look at directory structure of the project:

|-- data/
|  |
|  `-- vim/
`-- src/

And here are new lines for src/

vim_dir = $(pkgdatadir)/vim
vim_autoload_vifm_dir = $(vim_dir)/autoload/vifm
vim_doc_dir = $(vim_dir)/doc
vim_ftdetect_dir = $(vim_dir)/ftdetect
vim_ftplugin_dir = $(vim_dir)/ftplugin
vim_plugin_dir = $(vim_dir)/plugin
vim_syntax_dir = $(vim_dir)/syntax

vim_autoload_vifm__DATA = ../data/vim/autoload/vifm/edit.vim
vim_doc__DATA = ../data/vim/doc/vifm.txt
vim_ftdetect__DATA = ../data/vim/ftdetect/vifm.vim
vim_ftplugin__DATA = ../data/vim/ftplugin/vifm.vim \
                     ../data/vim/ftplugin/vifm-cmdedit.vim \
vim_plugin__DATA = ../data/vim/plugin/vifm.vim
vim_syntax__DATA = ../data/vim/syntax/vifm.vim

Here are some details:

  • $(pkgdatadir) - expanded to path like ../share/{appname}/;
  • vim_dir - destination directory;
  • other *_dir variables - destination subdirectories;
  • *__DATA variables - list of files to install into corresponding subdirectory;
  • underscore is doubled (__) because each {x}_DATA directory is matched with {x}dir and in this case there is already an underscore before the dir suffix.

Hope this will help somebody to deal with automake. It’s a great tool, that just lacks instructions that are easy to grasp (here are docs, by the way).