* [PATCH] Using CFLAGS on the make command line
@ 2005-07-04 2:06 Pavel Roskin
0 siblings, 0 replies; only message in thread
From: Pavel Roskin @ 2005-07-04 2:06 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-07-04 2:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-04 2:06 [PATCH] Using CFLAGS on the make command line Pavel Roskin
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).