{"thread":{"id":"8581","subject":"[PATCH] Teach Makefile to respect external variables: CFLAGS and others.","startedAt":"2007-06-13T05:42:30Z","lastAt":"2007-06-13T07:53:35Z","messageCount":7,"participants":["Eygene Ryabinkin","Junio C Hamano","Sam Ravnborg","Matthias Lederhofer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"44891","messageId":"20070613054229.GM86872@void.codelabs.ru","threadId":"8581","inReplyTo":null,"subject":"[PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Eygene Ryabinkin","fromEmail":"rea-git@codelabs.ru","sentAt":"2007-06-13T05:42:30Z","receivedAt":"2007-06-13T05:42:30Z","isPatch":true,"sender":{"key":"rea-git@codelabs.ru","avatar":null},"body":"If one is not using the configure script, then there is no way to\nredefine variables CFLAGS, LFLAGS, CC, AR, TAR, INSTALL, RPMBUILD,\nTCL_PATCH and TCLTK_PATH.  This shouldn't be so, since these variables\ncan be manually set by user and we should respect them.\n\nThe patch originates from the FreeBSD port and was originally made\nby Ed Schouten, ed at fxq dot nl.\n\nSigned-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>\n---\n Makefile |   18 +++++++++---------\n 1 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 30a4052..6cd9ea2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -135,8 +135,8 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')\n \n # CFLAGS and LDFLAGS are for the users to override from the command line.\n \n-CFLAGS = -g -O2 -Wall\n-LDFLAGS =\n+CFLAGS ?= -g -O2 -Wall\n+LDFLAGS ?=\n ALL_CFLAGS = $(CFLAGS)\n ALL_LDFLAGS = $(LDFLAGS)\n STRIP ?= strip\n@@ -172,13 +172,13 @@ GITWEB_SITE_FOOTER =\n \n export prefix bindir gitexecdir sharedir template_dir sysconfdir\n \n-CC = gcc\n-AR = ar\n-TAR = tar\n-INSTALL = install\n-RPMBUILD = rpmbuild\n-TCL_PATH = tclsh\n-TCLTK_PATH = wish\n+CC ?= gcc\n+AR ?= ar\n+TAR ?= tar\n+INSTALL ?= install\n+RPMBUILD ?= rpmbuild\n+TCL_PATH ?= tclsh\n+TCLTK_PATH ?= wish\n \n export TCL_PATH TCLTK_PATH\n \n-- \n1.5.2.1\n"},{"id":"44892","messageId":"7v4plcgzer.fsf@assigned-by-dhcp.pobox.com","threadId":"8581","inReplyTo":"20070613054229.GM86872@void.codelabs.ru","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-13T06:07:56Z","receivedAt":"2007-06-13T06:07:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I run \"make CFLAGS=-O0 -g\" all the time.  Also \"make CC=echo\"\nseems to \"work\" as expected ;-).\n\nCare to elaborate what problem you are trying to solve?\n"},{"id":"44893","messageId":"20070613061234.GA20648@uranus.ravnborg.org","threadId":"8581","inReplyTo":"20070613054229.GM86872@void.codelabs.ru","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Sam Ravnborg","fromEmail":"sam@ravnborg.org","sentAt":"2007-06-13T06:12:34Z","receivedAt":"2007-06-13T06:12:34Z","isPatch":true,"sender":{"key":"sam@ravnborg.org","avatar":"https://gravatar.com/avatar/168a912606ed0742d840bb365e3cc21db390c36531a58341dc7a069cc1f15f62?d=mp&s=160"},"body":"On Wed, Jun 13, 2007 at 09:42:30AM +0400, Eygene Ryabinkin wrote:\n> If one is not using the configure script, then there is no way to\n> redefine variables CFLAGS, LFLAGS, CC, AR, TAR, INSTALL, RPMBUILD,\n> TCL_PATCH and TCLTK_PATH.  This shouldn't be so, since these variables\n> can be manually set by user and we should respect them.\n\nmake distingush between environment variables and make variables.\nSo for make there is a big difference between:\n\nexport FOO=foobar\nmake\n\nand\nmake FOO=foobar\n\nThe latter will work as expected without your changes.\nAnd the good part about this is that some random environment variables\ndoes not influence the build.\n\n\tSam\n"},{"id":"44896","messageId":"20070613071514.GP86872@void.codelabs.ru","threadId":"8581","inReplyTo":"7v4plcgzer.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Eygene Ryabinkin","fromEmail":"rea-git@codelabs.ru","sentAt":"2007-06-13T07:15:14Z","receivedAt":"2007-06-13T07:15:14Z","isPatch":true,"sender":{"key":"rea-git@codelabs.ru","avatar":null},"body":"Junio, Sam, good day.\n\nTue, Jun 12, 2007 at 11:07:56PM -0700, Junio C Hamano wrote:\n> I run \"make CFLAGS=-O0 -g\" all the time.  Also \"make CC=echo\"\n> seems to \"work\" as expected ;-).\n> \n> Care to elaborate what problem you are trying to solve?\n\nAs Sam Ravnborg kindly pointed out, you're using make variables\nand I am trying to give the respect to the environment variables.\n\nAnd the real problem is that one (for example, me) can try to\nbuild Git with the different compiler than CC (gccX or icc, for\nexample).  And it is much better for lazy people to do 'export\nCC=whatever' once and then fire make any number of times ;))\n\nAnswering Sam: yes, with my patch it is easier to inherit the\nvariables from the environment.  But it is not clear if it is\ngood or bad ;))\n\nBut anyway, this patch is only my suggestion, and it can be\nthrown away :)\n-- \nEygene\n"},{"id":"44899","messageId":"7vhcpcfglr.fsf@assigned-by-dhcp.pobox.com","threadId":"8581","inReplyTo":"20070613071514.GP86872@void.codelabs.ru","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-13T07:39:28Z","receivedAt":"2007-06-13T07:39:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eygene Ryabinkin <rea-git@codelabs.ru> writes:\n\n> Junio, Sam, good day.\n>\n> Tue, Jun 12, 2007 at 11:07:56PM -0700, Junio C Hamano wrote:\n>> I run \"make CFLAGS=-O0 -g\" all the time.  Also \"make CC=echo\"\n>> seems to \"work\" as expected ;-).\n>> \n>> Care to elaborate what problem you are trying to solve?\n>\n> As Sam Ravnborg kindly pointed out, you're using make variables\n> and I am trying to give the respect to the environment variables.\n>\n> And the real problem is that one (for example, me) can try to\n> build Git with the different compiler than CC (gccX or icc, for\n> example).  And it is much better for lazy people to do 'export\n> CC=whatever' once and then fire make any number of times ;))\n>\n> Answering Sam: yes, with my patch it is easier to inherit the\n> variables from the environment.  But it is not clear if it is\n> good or bad ;))\n>\n> But anyway, this patch is only my suggestion, and it can be\n> thrown away :)\n\nOh, I will, very gladly ;-), as it is obviously inferior than\nhow we currently do our build.\n\nI would personally hate environment affecting build (or anything\nfor that matter), as it makes it unnecessarily difficult to\ndiagnose when something goes wrong.  I consider that it is a\nbeautiful thing that make can take explicit override from the\ncommand line.\n\nLazy people like me can always have a make wrapper.  E.g. I have\na checkout of my 'todo' branch at Meta in git.git repository, so\nI would say\n\n\t$ Meta/Make -pedantic\n\nto ask for specific set of CFLAGS.  If something goes wrong and\nI need to ask for help from other people, it is crystal clear to\nthem that I am using something \"customized\" from the above\ncommand line.\n\nIf you modify Makefile to allow the build procedure to be easily\ncontaminated with stray environment, and when your build breaks,\nyou would answer that your command line is:\n\n\t$ make\n\nwhen asked how you tried to build things -- and leave people who\ntry to help you scratching their head, wasting their time.\n"},{"id":"44901","messageId":"20070613074240.GA12894@moooo.ath.cx","threadId":"8581","inReplyTo":"20070613071514.GP86872@void.codelabs.ru","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-06-13T07:42:40Z","receivedAt":"2007-06-13T07:42:40Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Eygene Ryabinkin <rea-git@codelabs.ru> wrote:\n> Junio, Sam, good day.\n> \n> Tue, Jun 12, 2007 at 11:07:56PM -0700, Junio C Hamano wrote:\n> > I run \"make CFLAGS=-O0 -g\" all the time.  Also \"make CC=echo\"\n> > seems to \"work\" as expected ;-).\n> > \n> > Care to elaborate what problem you are trying to solve?\n> \n> As Sam Ravnborg kindly pointed out, you're using make variables\n> and I am trying to give the respect to the environment variables.\n> \n> And the real problem is that one (for example, me) can try to\n> build Git with the different compiler than CC (gccX or icc, for\n> example).  And it is much better for lazy people to do 'export\n> CC=whatever' once and then fire make any number of times ;))\n> \n> Answering Sam: yes, with my patch it is easier to inherit the\n> variables from the environment.  But it is not clear if it is\n> good or bad ;))\n> \n> But anyway, this patch is only my suggestion, and it can be\n> thrown away :)\n\nIf you want to fix it for your own checkout of git just put whatever\nyou like in config.mak.  For example I add -ggdb3 to CFLAGS, set the\nprefix variable and add some custom make targets in this file.\n"},{"id":"44902","messageId":"20070613075335.GR86872@void.codelabs.ru","threadId":"8581","inReplyTo":"7vhcpcfglr.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [PATCH] Teach Makefile to respect external variables: CFLAGS and others.","fromName":"Eygene Ryabinkin","fromEmail":"rea-git@codelabs.ru","sentAt":"2007-06-13T07:53:35Z","receivedAt":"2007-06-13T07:53:35Z","isPatch":true,"sender":{"key":"rea-git@codelabs.ru","avatar":null},"body":"Junio,\n\nWed, Jun 13, 2007 at 12:39:28AM -0700, Junio C Hamano wrote:\n> > But anyway, this patch is only my suggestion, and it can be\n> > thrown away :)\n> \n> Oh, I will, very gladly ;-), as it is obviously inferior than\n> how we currently do our build.\n\nOK, then this topic can be closed ;))\n\nThank you!\n-- \nEygene\n"}]}