{"thread":{"id":"27154","subject":"[PATCH v3 7/9] sparse: Fix errors due to missing target-specific variables","startedAt":"2011-04-21T19:14:42Z","lastAt":"2011-04-21T19:14:42Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":3,"patchTotal":9},"messages":[{"id":"166200","messageId":"4DB08222.5020902@ramsay1.demon.co.uk","threadId":"27154","inReplyTo":null,"subject":"[PATCH v3 7/9] sparse: Fix errors due to missing target-specific variables","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2011-04-21T19:14:42Z","receivedAt":"2011-04-21T19:14:42Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn particular, sparse issues the following errors:\n\n    attr.c:472:43: error: undefined identifier 'ETC_GITATTRIBUTES'\n    config.c:821:43: error: undefined identifier 'ETC_GITCONFIG'\n    exec_cmd.c:14:37: error: undefined identifier 'PREFIX'\n    exec_cmd.c:83:28: error: undefined identifier 'GIT_EXEC_PATH'\n    builtin/help.c:328:46: error: undefined identifier 'GIT_MAN_PATH'\n    builtin/help.c:374:40: error: undefined identifier 'GIT_INFO_PATH'\n    builtin/help.c:382:45: error: undefined identifier 'GIT_HTML_PATH'\n    git.c:96:42: error: undefined identifier 'GIT_HTML_PATH'\n    git.c:241:35: error: invalid initializer\n    http.c:293:43: error: undefined identifier 'GIT_HTTP_USER_AGENT'\n\nwhich is caused by not passing the target-specific additions to\nthe EXTRA_CPPFLAGS variable to cgcc.\n\nIn order to fix the problem, we define a new sparse target which\ndepends on a set of non-existent \"sparse object\" files (*.sp)\nwhich correspond to the set of C source files. In addition to the\nnew target, we also provide a new pattern rule for \"creating\" the\nsparse object files from the source files by running cgcc.  This\nallows us to add '*.sp' to the rules setting the target-specific\nEXTRA_CPPFLAGS variable, which is then included in the new pattern\nrule to run cgcc.\n\nAlso, we change the 'check' target to re-direct the user to the\nnew sparse target.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nChanges from v2:\n    - remove \"common-cmds.h\" dependency from the sparse target\n      (this was only there to mirror the dependency on the \"check\"\n       target; in particular, the \"GEN common-cmds.h\" processing\n       happens at the start ... this is not a good reason to add\n       such a dependency!)\n    - Mark the sparse and $(SP_OBJ) targets as .PHONY\n\n\n Makefile |   45 ++++++++++++++++++++++++++++-----------------\n 1 files changed, 28 insertions(+), 17 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 385193a..c7c1530 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1581,6 +1581,7 @@ ifndef V\n \tQUIET_LNCP     = @echo '   ' LN/CP $@;\n \tQUIET_XGETTEXT = @echo '   ' XGETTEXT $@;\n \tQUIET_GCOV     = @echo '   ' GCOV $@;\n+\tQUIET_SP       = @echo '   ' SP $<;\n \tQUIET_SUBDIR0  = +@subdir=\n \tQUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \\\n \t\t\t $(MAKE) $(PRINT_DIR) -C $$subdir\n@@ -1676,17 +1677,17 @@ strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n git.o: common-cmds.h\n-git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n+git.sp git.s git.o: EXTRA_CPPFLAGS = -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n \t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"'\n \n git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n-help.o: common-cmds.h\n+help.sp help.o: common-cmds.h\n \n-builtin/help.o: common-cmds.h\n-builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \\\n+builtin/help.sp builtin/help.o: common-cmds.h\n+builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n \t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"'\n@@ -1972,30 +1973,34 @@ $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \\\n test-svn-fe.o: vcs-svn/svndump.h\n endif\n \n-exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n+exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n \t'-DPREFIX=\"$(prefix_SQ)\"'\n \n-builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n+builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \t-DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"'\n \n-config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n+config.sp config.s config.o: EXTRA_CPPFLAGS = \\\n+\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n \n-attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n+attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n+\t-DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n \n-http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n+http.sp http.s http.o: EXTRA_CPPFLAGS = \\\n+\t-DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n \n ifdef NO_EXPAT\n-http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\n+http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\n endif\n \n ifdef NO_REGEX\n-compat/regex/regex.o: EXTRA_CPPFLAGS = -DGAWK -DNO_MBSUPPORT\n+compat/regex/regex.sp compat/regex/regex.o: EXTRA_CPPFLAGS = \\\n+\t-DGAWK -DNO_MBSUPPORT\n endif\n \n ifdef USE_NED_ALLOCATOR\n-compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n+compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n \t-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR\n endif\n \n@@ -2161,14 +2166,20 @@ test-%$X: test-%.o $(GITLIBS)\n check-sha1:: test-sha1$X\n \t./test-sha1.sh\n \n+SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))\n+\n+$(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE\n+\t$(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) \\\n+\t\t$(SPARSE_FLAGS) $<\n+\n+.PHONY: sparse $(SP_OBJ)\n+sparse: $(SP_OBJ)\n+\n check: common-cmds.h\n \t@if sparse; \\\n \tthen \\\n-\t\tfor i in $(patsubst %.o, %.c, $(GIT_OBJS)); \\\n-\t\tdo \\\n-\t\t\techo '   ' SP $$i; \\\n-\t\t\tcgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \\\n-\t\tdone; \\\n+\t\techo 2>&1 \"Use 'make sparse' instead\"; \\\n+\t\t$(MAKE) --no-print-directory sparse; \\\n \telse \\\n \t\techo 2>&1 \"Did you mean 'make test'?\"; \\\n \t\texit 1; \\\n-- \n1.7.4\n"}]}