{"thread":{"id":"1098","subject":"[PATCH] Using CFLAGS on the make command line","startedAt":"2005-07-04T02:06:24Z","lastAt":"2005-07-04T02:06:24Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5618","messageId":"1120442784.1265.20.camel@dv","threadId":"1098","inReplyTo":null,"subject":"[PATCH] Using CFLAGS on the make command line","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-07-04T02:06:24Z","receivedAt":"2005-07-04T02:06:24Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\nThis patch changes the top-level Makefile to be more compatible with\nexpectations of users accustomed to automake-generated makefiles.\n\nI'm used to specifying CFLAGS after make, i.e. as an argument rather\nthan as an environment variable.  It doesn't work with git because\nCFLAGS is modified in Makefile.\n\nAutomake and Autoconf allow CFLAGS to be fully user-serviceable.  It\ndefaults to something reasonable (usually \"-O2 -g\") that can be replaced\nwithout breaking compilation.  Other variables such as CPPFLAGS are\nrecognized, but they are rarely used.\n\nCOPTS is not recognized, and I don't think it's needed in git once\nCFLAGS works in the expected way.  Besides, why is -O2 in COPTS whereas\n-Wall is not?\n\nAutomake-generated makefiles use the COMPILE variable to hold all\ncompile flags.  COMPILE is not user-serviceable.\n\nAlso, projects generated by Automake can be compiled with \"make -r\",\ni.e. without implicit rules.  It's useful to have all rules we need\n(there are just 2 of them) written explicitly so that users can\nunderstand and modify them.  It's also needed to use COMPILE instead of\nthe implicit CFLAGS in the .o.c rule.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -9,8 +9,8 @@\n # BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly\n # break unless your underlying filesystem supports those sub-second times\n # (my ext3 doesn't).\n-COPTS=-O2\n-CFLAGS=-g $(COPTS) -Wall\n+CFLAGS=-g -O2 -Wall\n+COMPILE=$(CFLAGS)\n \n prefix=$(HOME)\n bin=$(prefix)/bin\n@@ -82,22 +82,28 @@ else\n endif\n endif\n \n-CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'\n+COMPILE += '-DSHA1_HEADER=$(SHA1_HEADER)'\n \n $(LIB_FILE): $(LIB_OBJS)\n \t$(AR) rcs $@ $(LIB_OBJS)\n \n check:\n-\tfor i in *.c; do sparse $(CFLAGS) $(SPARSE_FLAGS) $$i; done\n+\tfor i in *.c; do sparse $(COMPILE) $(SPARSE_FLAGS) $$i; done\n \n test-date: test-date.c date.o\n-\t$(CC) $(CFLAGS) -o $@ test-date.c date.o\n+\t$(CC) $(COMPILE) -o $@ test-date.c date.o\n \n test-delta: test-delta.c diff-delta.o patch-delta.o\n-\t$(CC) $(CFLAGS) -o $@ $^\n+\t$(CC) $(COMPILE) -o $@ $^\n \n git-%: %.c $(LIB_FILE)\n-\t$(CC) $(CFLAGS) -o $@ $(filter %.c,$^) $(LIBS)\n+\t$(CC) $(COMPILE) -o $@ $(filter %.c,$^) $(LIBS)\n+\n+.c.o:\n+\t$(CC) -c $(COMPILE) $<\n+\n+.S.o:\n+\t$(CC) -c $(ASFLAGS) $<\n \n git-update-cache: update-cache.c\n git-diff-files: diff-files.c\n@@ -172,3 +178,5 @@ clean:\n \n backup: clean\n \tcd .. ; tar czvf dircache.tar.gz dir-cache\n+\n+.SUFFIXES: .c .o .S\n\n\n-- \nRegards,\nPavel Roskin\n"}]}