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

auto-detect changed prefix and/or changed build flags

Detect changed prefix and/or changed build flags in the middle of the build (or between 'make' and 'make install'), and if change is detected, make sure all objects are compiled with same build flags and same prefix, thus avoiding inconsistent/broken build. [jc: removed otherwise unnecessary Makefile target to test the change this patch introduces. ] Signed-off-by: Yakov Lerner <iler.ml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Yakov Lerner committed Jun 15, 2006 at 01:36 UTC ca3bcabf1187f4f09e62fdb1bc8aafa16d3ceea0
1 file changed +20 -8
Makefile
+20 -8
@@ -464,6 +464,7 @@ DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
464 bindir_SQ = $(subst ','\'',$(bindir))
465 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
466 template_dir_SQ = $(subst ','\'',$(template_dir))
467 +prefix_SQ = $(subst ','\'',$(prefix))
468
469 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
470 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -484,7 +485,7 @@ all:
485 strip: $(PROGRAMS) git$X
486 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
487
487 -git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS)
488 +git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
489 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
490 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
491 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
@@ -516,7 +517,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
517 chmod +x $@+
518 mv $@+ $@
519
519 -$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
520 +$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py GIT-CFLAGS
521 rm -f $@ $@+
522 sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
523 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
@@ -540,19 +541,19 @@ git$X git.spec \
541 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
542 : GIT-VERSION-FILE
543
543 -%.o: %.c
544 +%.o: %.c GIT-CFLAGS
545 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
546 %.o: %.S
547 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
548
548 -exec_cmd.o: exec_cmd.c
549 +exec_cmd.o: exec_cmd.c GIT-CFLAGS
550 $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
551
551 -http.o: http.c
552 +http.o: http.c GIT-CFLAGS
553 $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
554
555 ifdef NO_EXPAT
555 -http-fetch.o: http-fetch.c http.h
556 +http-fetch.o: http-fetch.c http.h GIT-CFLAGS
557 $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
558 endif
559
@@ -609,6 +610,17 @@ tags:
610 rm -f tags
611 find . -name '*.[hcS]' -print | xargs ctags -a
612
613 +### Detect prefix changes
614 +TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_VERSION):\
615 + $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
616 +
617 +GIT-CFLAGS: .FORCE-GIT-CFLAGS
618 + @FLAGS='$(TRACK_CFLAGS)'; \
619 + if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
620 + echo 1>&2 " * new build flags or prefix"; \
621 + echo "$$FLAGS" >GIT-CFLAGS; \
622 + fi
623 +
624 ### Testing rules
625
626 # GNU make supports exporting all variables by "export" without parameters.
@@ -711,10 +723,10 @@ clean:
723 $(MAKE) -C Documentation/ clean
724 $(MAKE) -C templates clean
725 $(MAKE) -C t/ clean
714 - rm -f GIT-VERSION-FILE
726 + rm -f GIT-VERSION-FILE GIT-CFLAGS
727
728 .PHONY: all install clean strip
717 -.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags
729 +.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
730
731 ### Check documentation
732 #