Install arbitrary data files in fixed location with Automake?

后端 未结 1 523
故里飘歌
故里飘歌 2021-01-12 16:35

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

相关标签:
1条回答
  • 2021-01-12 16:52

    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.

    0 讨论(0)
提交回复
热议问题