Install arbitrary data files in a fixed location with Automake?

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

I have some files that I need to place in certain places, for example. " datafile1 " in my project needs to be copied to " /usr/MyProduct/flash_memory ".

  • " /usr/MyProduct/flash_memory " is an absolute path that I cannot change.
  • " datafile1 " is a binary data file that is not "built" on make , but just need to copy make install .
  • I can not bear make dist . It needs to be copied to make install (its a long explanation, therefore, pelase just keep that in mind).
  • I prefer not to use install-hook , but prefer to have a more elegant approach (if possible).

Thank you really!

+6
source share
1 answer

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

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

(It might be more appropriate to use $(prefix)/@ PACKAGE@ /flash_memory , since PACKAGE probably cannot be changed at runtime, but I don't think this is very important.)

Then, when you are a user, run make install with the prefix set to /usr . If you try to use the absolute path in Makefile.am, it will prohibit a phased installation (i.e. Installing DESTDIR), it will limit the flexibility of the user and this is wrong. The main thing is that the package supporter cannot choose the final location; This is a solution for the user.

+11
source

Source: https://habr.com/ru/post/916460/


All Articles