From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH] Using CFLAGS on the make command line
Date: Sun, 03 Jul 2005 22:06:24 -0400 [thread overview]
Message-ID: <1120442784.1265.20.camel@dv> (raw)
Hello!
This patch changes the top-level Makefile to be more compatible with
expectations of users accustomed to automake-generated makefiles.
I'm used to specifying CFLAGS after make, i.e. as an argument rather
than as an environment variable. It doesn't work with git because
CFLAGS is modified in Makefile.
Automake and Autoconf allow CFLAGS to be fully user-serviceable. It
defaults to something reasonable (usually "-O2 -g") that can be replaced
without breaking compilation. Other variables such as CPPFLAGS are
recognized, but they are rarely used.
COPTS is not recognized, and I don't think it's needed in git once
CFLAGS works in the expected way. Besides, why is -O2 in COPTS whereas
-Wall is not?
Automake-generated makefiles use the COMPILE variable to hold all
compile flags. COMPILE is not user-serviceable.
Also, projects generated by Automake can be compiled with "make -r",
i.e. without implicit rules. It's useful to have all rules we need
(there are just 2 of them) written explicitly so that users can
understand and modify them. It's also needed to use COMPILE instead of
the implicit CFLAGS in the .o.c rule.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,8 @@
# BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly
# break unless your underlying filesystem supports those sub-second times
# (my ext3 doesn't).
-COPTS=-O2
-CFLAGS=-g $(COPTS) -Wall
+CFLAGS=-g -O2 -Wall
+COMPILE=$(CFLAGS)
prefix=$(HOME)
bin=$(prefix)/bin
@@ -82,22 +82,28 @@ else
endif
endif
-CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'
+COMPILE += '-DSHA1_HEADER=$(SHA1_HEADER)'
$(LIB_FILE): $(LIB_OBJS)
$(AR) rcs $@ $(LIB_OBJS)
check:
- for i in *.c; do sparse $(CFLAGS) $(SPARSE_FLAGS) $$i; done
+ for i in *.c; do sparse $(COMPILE) $(SPARSE_FLAGS) $$i; done
test-date: test-date.c date.o
- $(CC) $(CFLAGS) -o $@ test-date.c date.o
+ $(CC) $(COMPILE) -o $@ test-date.c date.o
test-delta: test-delta.c diff-delta.o patch-delta.o
- $(CC) $(CFLAGS) -o $@ $^
+ $(CC) $(COMPILE) -o $@ $^
git-%: %.c $(LIB_FILE)
- $(CC) $(CFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
+ $(CC) $(COMPILE) -o $@ $(filter %.c,$^) $(LIBS)
+
+.c.o:
+ $(CC) -c $(COMPILE) $<
+
+.S.o:
+ $(CC) -c $(ASFLAGS) $<
git-update-cache: update-cache.c
git-diff-files: diff-files.c
@@ -172,3 +178,5 @@ clean:
backup: clean
cd .. ; tar czvf dircache.tar.gz dir-cache
+
+.SUFFIXES: .c .o .S
--
Regards,
Pavel Roskin
reply other threads:[~2005-07-04 2:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1120442784.1265.20.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).