Teach Makefile to respect external variables: CFLAGS and others.
PATCH 1/1 Teach Makefile to respect external variables: CFLAGS and others.
If one is not using the configure script, then there is no way to redefine variables CFLAGS, LFLAGS, CC, AR, TAR, INSTALL, RPMBUILD, TCL_PATCH and TCLTK_PATH. This shouldn't be so, since these variables can be manually set by user and we should respect them.
The patch originates from the FreeBSD port and was originally made by Ed Schouten, ed at fxq dot nl.
--- Makefile | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
Makefile +9 -9
@@ -135,8 +135,8 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not') # CFLAGS and LDFLAGS are for the users to override from the command line. -CFLAGS = -g -O2 -Wall -LDFLAGS = +CFLAGS ?= -g -O2 -Wall +LDFLAGS ?= ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip
@@ -172,13 +172,13 @@ GITWEB_SITE_FOOTER = export prefix bindir gitexecdir sharedir template_dir sysconfdir -CC = gcc -AR = ar -TAR = tar -INSTALL = install -RPMBUILD = rpmbuild -TCL_PATH = tclsh -TCLTK_PATH = wish +CC ?= gcc +AR ?= ar +TAR ?= tar +INSTALL ?= install +RPMBUILD ?= rpmbuild +TCL_PATH ?= tclsh +TCLTK_PATH ?= wish export TCL_PATH TCLTK_PATH
Signature · 1 line
1.5.2.1
Quoted 4 lines · Eygene Ryabinkin
If one is not using the configure script, then there is no way to redefine variables CFLAGS, LFLAGS, CC, AR, TAR, INSTALL, RPMBUILD,
TCL_PATCHandTCLTK_PATH. This shouldn't be so, since these variables can be manually set by user and we should respect them.
make distingush between environment variables and make variables. So for make there is a big difference between:
export FOO=foobar
make
and
make FOO=foobar
The latter will work as expected without your changes.
And the good part about this is that some random environment variables does not influence the build.
Sam
I run "make CFLAGS=-O0 -g" all the time. Also "make CC=echo" seems to "work" as expected ;-).
Care to elaborate what problem you are trying to solve?
Junio, Sam, good day.
Quoted 4 lines · Junio C Hamano
I run "make CFLAGS=-O0 -g" all the time. Also "make CC=echo" seems to "work" as expected ;-).
Care to elaborate what problem you are trying to solve?
As Sam Ravnborg kindly pointed out, you're using make variables and I am trying to give the respect to the environment variables.
And the real problem is that one (for example, me) can try to build Git with the different compiler than CC (gccX or icc, for example). And it is much better for lazy people to do 'export CC=whatever' once and then fire make any number of times ;))
Answering Sam: yes, with my patch it is easier to inherit the variables from the environment. But it is not clear if it is good or bad ;))
But anyway, this patch is only my suggestion, and it can be thrown away :)
Signature · 1 line
Eygene
Quoted 16 lines · Eygene Ryabinkin
Junio, Sam, good day.
Quoted 4 lines · Junio C Hamano
I run "make CFLAGS=-O0 -g" all the time. Also "make CC=echo" seems to "work" as expected ;-).
Care to elaborate what problem you are trying to solve?
As Sam Ravnborg kindly pointed out, you're using make variables and I am trying to give the respect to the environment variables.
And the real problem is that one (for example, me) can try to build Git with the different compiler than CC (gccX or icc, for example). And it is much better for lazy people to do 'export CC=whatever' once and then fire make any number of times ;))
Quoted 6 lines
Answering Sam: yes, with my patch it is easier to inherit the variables from the environment. But it is not clear if it is good or bad ;))
But anyway, this patch is only my suggestion, and it can be thrown away :)
If you want to fix it for your own checkout of git just put whatever you like in config.mak. For example I add -ggdb3 to CFLAGS, set the prefix variable and add some custom make targets in this file.
Quoted 16 lines · Eygene Ryabinkin
Junio, Sam, good day.
Quoted 4 lines · Junio C Hamano
I run "make CFLAGS=-O0 -g" all the time. Also "make CC=echo" seems to "work" as expected ;-).
Care to elaborate what problem you are trying to solve?
As Sam Ravnborg kindly pointed out, you're using make variables and I am trying to give the respect to the environment variables.
And the real problem is that one (for example, me) can try to build Git with the different compiler than CC (gccX or icc, for example). And it is much better for lazy people to do 'export CC=whatever' once and then fire make any number of times ;))
Quoted 6 lines
Answering Sam: yes, with my patch it is easier to inherit the variables from the environment. But it is not clear if it is good or bad ;))
But anyway, this patch is only my suggestion, and it can be thrown away :)
Oh, I will, very gladly ;-), as it is obviously inferior than how we currently do our build.
I would personally hate environment affecting build (or anything for that matter), as it makes it unnecessarily difficult to diagnose when something goes wrong. I consider that it is a beautiful thing that make can take explicit override from the command line.
Lazy people like me can always have a make wrapper. E.g. I have a checkout of my 'todo' branch at Meta in git.git repository, so I would say
$ Meta/Make -pedantic
to ask for specific set of CFLAGS. If something goes wrong and I need to ask for help from other people, it is crystal clear to them that I am using something "customized" from the above command line.
If you modify Makefile to allow the build procedure to be easily contaminated with stray environment, and when your build breaks, you would answer that your command line is:
$ make
when asked how you tried to build things -- and leave people who try to help you scratching their head, wasting their time.
Junio,
Quoted 5 lines · Junio C Hamano
Quoted 2 lines
But anyway, this patch is only my suggestion, and it can be thrown away :)
Oh, I will, very gladly ;-), as it is obviously inferior than how we currently do our build.
OK, then this topic can be closed ;))
Thank you!
Signature · 1 line
Eygene