@matheusbsbs / matheus-bagliano / commits / 0bcd9ae85d
Fork 0

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 <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Apr 21, 2011 at 20:14 UTC 0bcd9ae85d7e05e78a10a69a2ebe98dcde130937
1 file changed +28 -17
Makefile
+28 -17
@@ -1581,6 +1581,7 @@ ifndef V
1581 QUIET_LNCP = @echo ' ' LN/CP $@;
1582 QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
1583 QUIET_GCOV = @echo ' ' GCOV $@;
1584 + QUIET_SP = @echo ' ' SP $<;
1585 QUIET_SUBDIR0 = +@subdir=
1586 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
1587 $(MAKE) $(PRINT_DIR) -C $$subdir
@@ -1676,17 +1677,17 @@ strip: $(PROGRAMS) git$X
1677 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
1678
1679 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)"' \
1681 '-DGIT_HTML_PATH="$(htmldir_SQ)"'
1682
1683 git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
1684 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
1685 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
1686
1686 -help.o: common-cmds.h
1687 +help.sp help.o: common-cmds.h
1688
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 = \
1691 '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1692 '-DGIT_MAN_PATH="$(mandir_SQ)"' \
1693 '-DGIT_INFO_PATH="$(infodir_SQ)"'
@@ -1972,30 +1973,34 @@ $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \
1973 test-svn-fe.o: vcs-svn/svndump.h
1974 endif
1975
1975 -exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
1976 +exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
1977 '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
1978 '-DBINDIR="$(bindir_relative_SQ)"' \
1979 '-DPREFIX="$(prefix_SQ)"'
1980
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 = \
1982 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
1983
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)"'
1986
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)"'
1989
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)"'
1992
1993 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
1995 endif
1996
1997 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
2000 endif
2001
2002 ifdef USE_NED_ALLOCATOR
1998 -compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
2003 +compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
2004 -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
2005 endif
2006
@@ -2161,14 +2166,20 @@ test-%$X: test-%.o $(GITLIBS)
2166 check-sha1:: test-sha1$X
2167 ./test-sha1.sh
2168
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 +
2178 check: common-cmds.h
2179 @if sparse; \
2180 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; \
2183 else \
2184 echo 2>&1 "Did you mean 'make test'?"; \
2185 exit 1; \