Install arbitrary data files in fixed location with Automake?

时光总嘲笑我的痴心妄想 提交于 2019-12-19 07:24:37

问题


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!


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!