使用Automake在固定位置安装任意数据文件? [英] Install arbitrary data files in fixed location with Automake?

查看:120
本文介绍了使用Automake在固定位置安装任意数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何告诉automake在想要的位置安装任意数据文件?

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

我需要将某些文件放在特定的位置,例如在我的项目中,"datafile1"需要复制到"/usr/MyProduct/flash_memory".

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"是我无法更改的绝对路径.
  • "datafile1"是二进制数据文件,不是由make构建"的,而仅需要由make install复制.
  • 我不能忍受make dist.它需要用make install复制(它有很长的解释,因此,请考虑一下).
  • 我宁愿不使用install-hook,而是喜欢采用更优雅的方法(如果可能的话).
  • "/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).

真的谢谢!

推荐答案

请勿在Makefile.am中使用完整路径.曾经.您可以告诉automake将datafile1放在$(datadir)中,该内容将扩展为$(prefix)/share/MyProduct,或者您可以定义flash_DIR扩展为$(prefix)/MyProduct/flash_memory并将文件放置在此处,但是必须允许最终用户设置$(prefix)/usr或其他内容.您想要在Makefile.am中做的是:

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

(使用$(prefix)/@PACKAGE@/flash_memory可能更合适,因为PACKAGE可能不应在制造时进行修改,但我认为这并不重要.)

(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.)

然后,当您是用户时,运行make install,并将前缀设置为/usr.如果您尝试在Makefile.am中使用绝对路径,则它将不允许分阶段安装(即,设置DESTDIR),将限制用户的灵活性,这是错误要做的事情.要点是,软件包维护者无法选择最终位置;这是用户的决定.

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.

这篇关于使用Automake在固定位置安装任意数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆