Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install arbitrary data files in fixed location with Automake?

How can I tell automake to install arbitrary data files in places I want?

I have some files I need to put in specific places, e.g. "datafile1", in my project, needs to be copied to "/usr/MyProduct/flash_memory".

  • "/usr/MyProduct/flash_memory" is an absolute path that I can't change.
  • "datafile1" is a binary data file that is not "built" by make, but just needs to be copied by make install.
  • I can't bear on make dist. It needs to be copied by make install (its a long explanation, so, pelase just take this into account).
  • I rather not use install-hook, but prefer to have a more elegant approach (if possible).

Really thanks!

like image 397
j4x Avatar asked May 23 '12 14:05

j4x


1 Answers

Do not use full paths in your Makefile.am. Ever. You can tell automake to put the datafile1 in $(datadir) which will expand to $(prefix)/share/MyProduct, or you can define flash_DIR to expand to $(prefix)/MyProduct/flash_memory and put the files there, but the end user must be allowed to set $(prefix) either to /usr or to something else. What you want to do in Makefile.am is:

flashdir = $(prefix)/$(PACKAGE)/flash_memory
flash_DATA = datafile1

(It would probably be more appropriate to use $(prefix)/@PACKAGE@/flash_memory, since PACKAGE probably should not be modifiable at make time, but I don't think this is terribly important.)

Then, when you are a user, run make install with prefix set to /usr. If you try to use an absolute path in the Makefile.am, it will disallow staged installations (ie setting DESTDIR), will restrict user flexibility, and is the wrong thing to do. The main point is that the package maintainer does not get to choose the final location; that is a decision for the user.

like image 70
William Pursell Avatar answered Oct 14 '22 14:10

William Pursell