问题
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" bymake
, but just needs to be copied bymake install
. - I can't bear on
make dist
. It needs to be copied bymake 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!
回答1:
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.
来源:https://stackoverflow.com/questions/10721826/install-arbitrary-data-files-in-fixed-location-with-automake