4

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)?

dan3
  • 2,528
  • 22
  • 20

2 Answers2

1

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

0

Does exporting MAKEFLAGS=prefix=/usr in your rules file (or wherever that trivial snippet lives) do what you want?

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
  • It doesn't work. I think dh "sanitizes" MAKEFLAGS. Strangely, if I add `echo "$$MAKEFLAGS"` to my all: target, it seems the flags are "w" (a single char) – dan3 Nov 26 '13 at 18:08
  • Hm... so something is stomping over your MAKEFLAGS then. I saw reference to mangling MAKEFLAGS with regard to -j but nothing more general than that. I doubt it will but you could try and see if 'dh $@ -O=prefix=/usr' (or however that syntax needs to work exactly) works? – Etan Reisner Nov 26 '13 at 18:25
  • Neither `-O prefix=/usr` nor `-O=prefix=/usr` work, and I don't know "however that syntax needs to work" :) -O doesn't seem to be documented – dan3 Nov 26 '13 at 18:39
  • It is a debhelper option. From `[debhelper options]` in the dh man page. But I'm trying to put pieces together that I don't have any real knowledge of at this point. Sorry. – Etan Reisner Nov 26 '13 at 18:43