Make CFLAGS overridable from make command line.
This patch renames COPTS to CFLAGS, because it's COPTS that was user overridable. Also, -Wall is moved there because it's optional. What was CFLAGS is now ALL_CFLAGS, which users should not override. Defines are added to DEFINES. Since ALL_CFLAGS is recursively expanded, it uses the final value of DEFINES. Implicit rules are made explicit since the implicit rules use CFLAGS rather than ALL_CFLAGS. I believe that serious projects should not rely on implicit rules anyway. Percent rules are used because they are used already and because they don't need the .SUFFIXES target. [jc: in addition to updating the patch for 0.99.4, I fixed up a glitch in Pavel's original patch which compiled sha1.o out of mozilla-sha1/sha1.c, where it should have left the resulting object file in mozilla-sha1 directory for later "ar".] Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
5a571cdd8a
commit
b05701c5b4
46
Makefile
46
Makefile
@ -32,24 +32,24 @@
|
|||||||
|
|
||||||
# DEFINES += -DUSE_STDEV
|
# DEFINES += -DUSE_STDEV
|
||||||
|
|
||||||
GIT_VERSION=0.99.4
|
GIT_VERSION = 0.99.4
|
||||||
|
|
||||||
COPTS?=-g -O2
|
CFLAGS = -g -O2 -Wall
|
||||||
CFLAGS+=$(COPTS) -Wall $(DEFINES)
|
ALL_CFLAGS = $(CFLAGS) $(DEFINES)
|
||||||
|
|
||||||
prefix=$(HOME)
|
prefix = $(HOME)
|
||||||
bindir=$(prefix)/bin
|
bindir = $(prefix)/bin
|
||||||
template_dir=$(prefix)/share/git-core/templates/
|
template_dir = $(prefix)/share/git-core/templates/
|
||||||
# dest=
|
# dest=
|
||||||
|
|
||||||
CC?=gcc
|
CC = gcc
|
||||||
AR?=ar
|
AR = ar
|
||||||
INSTALL?=install
|
INSTALL = install
|
||||||
RPMBUILD?=rpmbuild
|
RPMBUILD = rpmbuild
|
||||||
|
|
||||||
# sparse is architecture-neutral, which means that we need to tell it
|
# sparse is architecture-neutral, which means that we need to tell it
|
||||||
# explicitly what architecture to check for. Fix this up for yours..
|
# explicitly what architecture to check for. Fix this up for yours..
|
||||||
SPARSE_FLAGS?=-D__BIG_ENDIAN__ -D__powerpc__
|
SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ ifndef NO_OPENSSL
|
|||||||
LIB_OBJS += epoch.o
|
LIB_OBJS += epoch.o
|
||||||
OPENSSL_LIBSSL=-lssl
|
OPENSSL_LIBSSL=-lssl
|
||||||
else
|
else
|
||||||
CFLAGS += '-DNO_OPENSSL'
|
DEFINES += '-DNO_OPENSSL'
|
||||||
MOZILLA_SHA1=1
|
MOZILLA_SHA1=1
|
||||||
OPENSSL_LIBSSL=
|
OPENSSL_LIBSSL=
|
||||||
endif
|
endif
|
||||||
@ -146,7 +146,7 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'
|
DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -156,12 +156,15 @@ all: $(PROG)
|
|||||||
|
|
||||||
all:
|
all:
|
||||||
$(MAKE) -C templates
|
$(MAKE) -C templates
|
||||||
|
$(MAKE) -C tools
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
||||||
|
%.o: %.S
|
||||||
|
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
||||||
|
|
||||||
.SECONDARY: %.o
|
|
||||||
.c.o:
|
|
||||||
$(CC) $(CFLAGS) -o $*.o -c $*.c
|
|
||||||
git-%: %.o $(LIB_FILE)
|
git-%: %.o $(LIB_FILE)
|
||||||
$(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
|
$(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
|
||||||
|
|
||||||
git-http-pull: pull.o
|
git-http-pull: pull.o
|
||||||
git-local-pull: pull.o
|
git-local-pull: pull.o
|
||||||
@ -172,7 +175,8 @@ git-http-pull: LIBS += -lcurl
|
|||||||
git-rev-list: LIBS += $(OPENSSL_LIBSSL)
|
git-rev-list: LIBS += $(OPENSSL_LIBSSL)
|
||||||
|
|
||||||
init-db.o: init-db.c
|
init-db.o: init-db.c
|
||||||
$(CC) -c $(CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
|
$(CC) -c $(ALL_CFLAGS) \
|
||||||
|
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
|
||||||
|
|
||||||
$(LIB_OBJS): $(LIB_H)
|
$(LIB_OBJS): $(LIB_H)
|
||||||
$(patsubst git-%,%.o,$(PROG)): $(LIB_H)
|
$(patsubst git-%,%.o,$(PROG)): $(LIB_H)
|
||||||
@ -192,13 +196,13 @@ test: all
|
|||||||
$(MAKE) -C t/ all
|
$(MAKE) -C t/ all
|
||||||
|
|
||||||
test-date: test-date.c date.o
|
test-date: test-date.c date.o
|
||||||
$(CC) $(CFLAGS) -o $@ test-date.c date.o
|
$(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
|
||||||
|
|
||||||
test-delta: test-delta.c diff-delta.o patch-delta.o
|
test-delta: test-delta.c diff-delta.o patch-delta.o
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(ALL_CFLAGS) -o $@ $^
|
||||||
|
|
||||||
check:
|
check:
|
||||||
for i in *.c; do sparse $(CFLAGS) $(SPARSE_FLAGS) $$i; done
|
for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
# Make Linus git-tools
|
# Make Linus git-tools
|
||||||
#
|
#
|
||||||
CC=gcc
|
CC=gcc
|
||||||
COPTS=-O2
|
CFLAGS = -O2 -g -Wall
|
||||||
CFLAGS=-g $(COPTS) -Wall
|
ALL_CFLAGS = $(CFLAGS)
|
||||||
INSTALL=install
|
INSTALL=install
|
||||||
HOME=$(shell echo $$HOME)
|
|
||||||
prefix=$(HOME)
|
prefix=$(HOME)
|
||||||
bindir=$(prefix)/bin
|
bindir=$(prefix)/bin
|
||||||
# dest=
|
# dest=
|
||||||
@ -14,7 +13,7 @@ PROGRAMS=git-mailsplit git-mailinfo
|
|||||||
SCRIPTS=git-applymbox git-applypatch
|
SCRIPTS=git-applymbox git-applypatch
|
||||||
|
|
||||||
git-%: %.c
|
git-%: %.c
|
||||||
$(CC) $(CFLAGS) -o $@ $(filter %.c,$^)
|
$(CC) $(ALL_CFLAGS) -o $@ $(filter %.c,$^)
|
||||||
|
|
||||||
all: $(PROGRAMS)
|
all: $(PROGRAMS)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user