Preserve data file prefix when using dist_pkgdata_DATA?

258 Views Asked by At

Our test data is organized with two folders. We have TestData/ and TestVectors/, depending on the form of the data:

- TestData
  |
  + a.dat
  + b.dat
  + ...

- TestVector
  |
  + x.vec
  + y.vec
  + ...

Our Makefile.am has:

dist_pkgdata_DATA = \
   $(testdata_FILES) \
   $(testvector_FILES)

testdata_FILES = \
   TestData/a.dat TestData/b.dat \
   ...

testvector_FILES = \
   TestVectors/x.vec TestVectors/y.vec \
   ...

Automake installs them in @datadir@/@PACKAGE@/, but we lose the TestData and TestVectors prefix upon installation. That is, once installed, all the files are lumped together:

- @datadir@/@PACKAGE@/
  |
  + a.dat
  + b.dat
  + ...
  + x.vec
  + y.vec
  + ...

There's a very similar question at Install arbitrary data files in arbitrary locations with Automake?, but I am not quite following what needs to be done to ensure make install works as expected.

My question is, how do we preserve the prefix of TestData or TestVectors during install?

2

There are 2 best solutions below

1
Tom Tromey On BEST ANSWER

This is what the nobase prefix was invented for. The name stands for "don't call basename" and would be used like:

nobase_dist_pkgdata_DATA = \
    $(testdata_FILES) \
    $(testvector_FILES)

This should result in the listed files keeping their directory names in the install tree.

2
John Bollinger On

My question is, how do we preserve the prefix of TestData or TestVectors during install?

Ordinarily, Automake computes the basename of each target and uses that at install time to record the file directly in the designated directory. If the target names contain directory prefixes that you want to propagate into the installed image then you can tell Automake about it by using the nobase_ prefix on the relevant target variable. This can be combined with other prefixes such as dist_. For example,

nobase_dist_pkgdata_DATA = \
   $(testdata_FILES) \
   $(testvector_FILES)

Prefixes in general are described in section 3.3 of the Automake manual, and nobase_ in particular is detailed in section 12.1 of the Automake manual.