Skip to content

Commit 0bcd9ae

Browse files
Ramsay Jonesgitster
authored andcommitted
sparse: Fix errors due to missing target-specific variables
In particular, sparse issues the following errors: attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES' config.c:821:43: error: undefined identifier 'ETC_GITCONFIG' exec_cmd.c:14:37: error: undefined identifier 'PREFIX' exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH' builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH' builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH' builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH' git.c:96:42: error: undefined identifier 'GIT_HTML_PATH' git.c:241:35: error: invalid initializer http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT' which is caused by not passing the target-specific additions to the EXTRA_CPPFLAGS variable to cgcc. In order to fix the problem, we define a new sparse target which depends on a set of non-existent "sparse object" files (*.sp) which correspond to the set of C source files. In addition to the new target, we also provide a new pattern rule for "creating" the sparse object files from the source files by running cgcc. This allows us to add '*.sp' to the rules setting the target-specific EXTRA_CPPFLAGS variable, which is then included in the new pattern rule to run cgcc. Also, we change the 'check' target to re-direct the user to the new sparse target. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e0f8c4 commit 0bcd9ae

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

Makefile

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,7 @@ ifndef V
15811581
QUIET_LNCP = @echo ' ' LN/CP $@;
15821582
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
15831583
QUIET_GCOV = @echo ' ' GCOV $@;
1584+
QUIET_SP = @echo ' ' SP $<;
15841585
QUIET_SUBDIR0 = +@subdir=
15851586
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
15861587
$(MAKE) $(PRINT_DIR) -C $$subdir
@@ -1676,17 +1677,17 @@ strip: $(PROGRAMS) git$X
16761677
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
16771678

16781679
git.o: common-cmds.h
1679-
git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
1680+
git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='"$(GIT_VERSION)"' \
16801681
'-DGIT_HTML_PATH="$(htmldir_SQ)"'
16811682

16821683
git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
16831684
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
16841685
$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
16851686

1686-
help.o: common-cmds.h
1687+
help.sp help.o: common-cmds.h
16871688

1688-
builtin/help.o: common-cmds.h
1689-
builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
1689+
builtin/help.sp builtin/help.o: common-cmds.h
1690+
builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
16901691
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
16911692
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
16921693
'-DGIT_INFO_PATH="$(infodir_SQ)"'
@@ -1972,30 +1973,34 @@ $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \
19721973
test-svn-fe.o: vcs-svn/svndump.h
19731974
endif
19741975

1975-
exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
1976+
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
19761977
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
19771978
'-DBINDIR="$(bindir_relative_SQ)"' \
19781979
'-DPREFIX="$(prefix_SQ)"'
19791980

1980-
builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
1981+
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
19811982
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
19821983

1983-
config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
1984+
config.sp config.s config.o: EXTRA_CPPFLAGS = \
1985+
-DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
19841986

1985-
attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
1987+
attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
1988+
-DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
19861989

1987-
http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"'
1990+
http.sp http.s http.o: EXTRA_CPPFLAGS = \
1991+
-DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"'
19881992

19891993
ifdef NO_EXPAT
1990-
http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
1994+
http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
19911995
endif
19921996

19931997
ifdef NO_REGEX
1994-
compat/regex/regex.o: EXTRA_CPPFLAGS = -DGAWK -DNO_MBSUPPORT
1998+
compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \
1999+
-DGAWK -DNO_MBSUPPORT
19952000
endif
19962001

19972002
ifdef USE_NED_ALLOCATOR
1998-
compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
2003+
compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
19992004
-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
20002005
endif
20012006

@@ -2161,14 +2166,20 @@ test-%$X: test-%.o $(GITLIBS)
21612166
check-sha1:: test-sha1$X
21622167
./test-sha1.sh
21632168

2169+
SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
2170+
2171+
$(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE
2172+
$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \
2173+
$(SPARSE_FLAGS) $<
2174+
2175+
.PHONY: sparse $(SP_OBJ)
2176+
sparse: $(SP_OBJ)
2177+
21642178
check: common-cmds.h
21652179
@if sparse; \
21662180
then \
2167-
for i in $(patsubst %.o, %.c, $(GIT_OBJS)); \
2168-
do \
2169-
echo ' ' SP $$i; \
2170-
cgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
2171-
done; \
2181+
echo 2>&1 "Use 'make sparse' instead"; \
2182+
$(MAKE) --no-print-directory sparse; \
21722183
else \
21732184
echo 2>&1 "Did you mean 'make test'?"; \
21742185
exit 1; \

0 commit comments

Comments
 (0)