简体   繁体   中英

debhelper: add `prefix=/usr' to all implicit make invocations

I have a Makefile that starts with

prefix      = /opt/$(PACKAGE)

and expects make prefix=/usr in case someone wants a non- /opt installation. There's no ./configure (and no need for one really).

The package is trivially debianizable via

%:
        dh $@ 

as debian/rules except that, due to the prefix=/usr requirement, one would have to litter the rules with

override_dh_auto_install:
        make prefix=/usr DESTDIR=debian/BUILD install

(also dh_auto_build ).

What is the elegant way to tell debhelper to add a prefix= to all make invocations (preferably without touching the makefile, otherwise there are many workarounds)?

You can do this:

%:
    prefix=/usr dh $@

This works because make converts environment variable into make variables, see https://www.gnu.org/software/make/manual/html_node/Environment.html

Just make sure that you upstream Makefile uses conditional assignment like in:

prefix ?= /usr/local

Ciao, Antonio

在您的规则文件中导出MAKEFLAGS=prefix=/usr (或者那些琐碎的代码段所在的位置)是否按照您的意愿进行操作?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM