As a package maintainer I'd like to override some more Makefile variables. Namely:
* DESTDIR * strip command invokation (ability to suppress it by passing /bin/true instead of /bin/strip) * pass custom gcc flags
This patch allows this. It does not break any existing workflows where it's not required to change these variables.
Signed-off-by: Peter Lemenkov lemenkov@gmail.com --- detok/Makefile | 6 +++--- romheaders/Makefile | 6 +++--- toke/Makefile | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/detok/Makefile b/detok/Makefile index 3ba6c30..0e422fb 100644 --- a/detok/Makefile +++ b/detok/Makefile @@ -24,13 +24,13 @@
PROGRAM = detok
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip +STRIP ?= strip INCLUDES = -I../shared
# Normal Flags: -CFLAGS = -O2 -Wall #-Wextra +CFLAGS ?= -O2 -Wall #-Wextra LDFLAGS =
# Coverage: diff --git a/romheaders/Makefile b/romheaders/Makefile index a216e7b..1831036 100644 --- a/romheaders/Makefile +++ b/romheaders/Makefile @@ -24,10 +24,10 @@
PROGRAM = romheaders
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip -CFLAGS = -O2 -Wall -Wextra +STRIP ?= strip +CFLAGS ?= -O2 -Wall -Wextra INCLUDES = -I../shared
SOURCES = romheaders.c ../shared/classcodes.c diff --git a/toke/Makefile b/toke/Makefile index aa75acd..8e31abd 100644 --- a/toke/Makefile +++ b/toke/Makefile @@ -24,13 +24,13 @@
PROGRAM = toke
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip +STRIP ?= strip INCLUDES = -I../shared
# Normal flags -CFLAGS = -O2 -Wall #-Wextra +CFLAGS ?= -O2 -Wall #-Wextra LDFLAGS =
# Coverage:
On 16/01/16 17:48, Peter Lemenkov wrote:
As a package maintainer I'd like to override some more Makefile variables. Namely:
- DESTDIR
- strip command invokation (ability to suppress it by passing /bin/true instead of /bin/strip)
- pass custom gcc flags
This patch allows this. It does not break any existing workflows where it's not required to change these variables.
Signed-off-by: Peter Lemenkov lemenkov@gmail.com
detok/Makefile | 6 +++--- romheaders/Makefile | 6 +++--- toke/Makefile | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/detok/Makefile b/detok/Makefile index 3ba6c30..0e422fb 100644 --- a/detok/Makefile +++ b/detok/Makefile @@ -24,13 +24,13 @@
PROGRAM = detok
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip +STRIP ?= strip INCLUDES = -I../shared
# Normal Flags: -CFLAGS = -O2 -Wall #-Wextra +CFLAGS ?= -O2 -Wall #-Wextra LDFLAGS =
# Coverage: diff --git a/romheaders/Makefile b/romheaders/Makefile index a216e7b..1831036 100644 --- a/romheaders/Makefile +++ b/romheaders/Makefile @@ -24,10 +24,10 @@
PROGRAM = romheaders
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip -CFLAGS = -O2 -Wall -Wextra +STRIP ?= strip +CFLAGS ?= -O2 -Wall -Wextra INCLUDES = -I../shared
SOURCES = romheaders.c ../shared/classcodes.c diff --git a/toke/Makefile b/toke/Makefile index aa75acd..8e31abd 100644 --- a/toke/Makefile +++ b/toke/Makefile @@ -24,13 +24,13 @@
PROGRAM = toke
-DESTDIR = /usr/local +DESTDIR ?= /usr/local CC ?= gcc -STRIP = strip +STRIP ?= strip INCLUDES = -I../shared
# Normal flags -CFLAGS = -O2 -Wall #-Wextra +CFLAGS ?= -O2 -Wall #-Wextra LDFLAGS =
# Coverage:
Hi Peter,
Thanks for the patch! It looks reasonable to me - Segher, any thoughts? Otherwise I don't see any reason why this couldn't be applied to SVN trunk.
ATB,
Mark.
On Sun, Jan 17, 2016 at 11:13:20PM +0000, Mark Cave-Ayland wrote:
-DESTDIR = /usr/local +DESTDIR ?= /usr/local
Hi Peter,
Thanks for the patch! It looks reasonable to me - Segher, any thoughts? Otherwise I don't see any reason why this couldn't be applied to SVN trunk.
Hi all,
It probably works fine. "?=" can be problematic with e.g. recursive makefiles, but you don't have those here.
But why do you need it? Why doesn't e.g.
make DESTDIR=/opt/bla
work for you as-is? Or do you need those vars to be passed in via the environment?
Segher
Hello All!
2016-01-18 7:50 GMT+01:00 Segher Boessenkool segher@kernel.crashing.org:
It probably works fine. "?=" can be problematic with e.g. recursive makefiles, but you don't have those here.
Also it's already used within the Makefiles to override C-compiler, so my patch won't change the current situation.
But why do you need it? Why doesn't e.g.
make DESTDIR=/opt/bla
work for you as-is? Or do you need those vars to be passed in via the environment?
Unfortunately this DESTDIR trick won't work. Explicitly stated variables from the Makefile itself have preference over the environment variables unless they stated with "?=". At least this is how GNU make works.