Makefile
changeset 1 820b22e13ff1
parent 0 37428ad74fc2
--- a/Makefile	Mon Nov 16 10:04:44 2009 +0000
+++ b/Makefile	Fri Jan 08 16:16:51 2010 +0000
@@ -26,10 +26,15 @@
 include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk
 endif
 
+ifeq '$(file)' ''
+file = diffs.patch
+endif
+
 garage = $(EPOCROOT)/build/makefiles-garage
 garage_makefiles = $(shell find $(garage) -name Makefile)
 targets = $(notdir $(patsubst %/Makefile,%,$(garage_makefiles)))
 clean_targets = $(addsuffix -clean,$(targets))
+what_targets = $(addsuffix -what,$(targets))
 garage_make_dirs = $(patsubst %/Makefile,%,$(garage_makefiles))
 make_dirs = $(patsubst $(garage)%,$(EPOCROOT)/build%,$(garage_make_dirs)) 
 makefiles = $(patsubst $(garage)/%,$(EPOCROOT)/build/%,$(garage_makefiles))
@@ -38,7 +43,8 @@
 subdirs = imgtools e32tools sbsv2 srctools buildframework buildtoolguides bintools
 	
 .PHONY: all tools export gen_preinclude clean distclean deploy_makefiles gather_makefiles help \
-sbs_comp_list sbs_targ_list list_hacks list_prereqs
+sbs_comp_list sbs_targ_list list_fixups list_prereqs
+
 
 all: tools
 
@@ -64,21 +70,25 @@
 	@echo "  clean            - Remove all build object files, libraries and executables"
 	@echo "  TARGET-clean     - clean the real target TARGET"
 	@echo "  distclean        - Remove everything but the original files"
-	@echo "  deploy_makefiles - Copy makefiles from the garage to the locations where they run"
-	@echo "  gather_makefiles - Gather any new or updated makefiles from the places where they run into the garage"
+	@echo "  deploy_makefiles - Copy makefiles from the 'makefiles_garage' to the locations where they run"
+	@echo "  gather_makefiles - Gather any new or updated makefiles from the places where they run into the 'makefiles_garage'"
 	@echo "  export           - TODO: No exports are implemented yet"
-	@echo "  what             - TODO: \"What is built?\" not implemented yet"
-	@echo "  TARGET-what      - TODO: \"What is built for TARGET?\" not implemented yet" 
+	@echo "  what             - List the files built by the real targets."
+	@echo "  missing          - List the real targets that do not exist."
+	@echo "  TARGET-what      - List the files built by the real target TARGET." 
 	@echo "  sbs_comp_list    - List the components that sbs would find (BLD.INF files)"
 	@echo "  sbs_targ_list    - List the targets that sbs would find (MMP files)"
 	@echo "  list_prereqs     - List the dependency graph of final targets"
-	@echo "  list_hacks       - List the targets and files for which hacks are currently applied."
-	@echo "                     The hacks are applied by the make and removed by clean." 
+	@echo "  list_fixes       - List the targets and files for which fixes are currently applied."
+	@echo "                     The fixes are applied by the make and removed by clean."
+	@echo "  fix              - Just apply the fixes. Don't build."
+	@echo "  diff [file=FILE] - List the diffs that are generated by applying the fixups."
+	@echo "                     The diffs are written to FILE, if specified, else to ./diffs.patch."
 	@echo ""  
 	@echo "Real targets in hierarchy:"
 	@echo ""
 	@for file in $(sort $(garage_makefiles)); do \
-		dummy=`grep 'include $$(EPOCROOT)/build/makefiles-garage/todo.mk' $$file 2> /dev/null`;\
+		dummy=`grep '^include $$(EPOCROOT)/build/makefiles-garage/todo.mk' $$file 2> /dev/null`;\
 		todo=;\
 		file=$${file#$(garage)/};\
 		file=$${file%/Makefile};\
@@ -119,16 +129,44 @@
 sbs_targ_list:
 	@for file in `find . -iname '*.mmp'`; do echo $${file}; done
 
-list_hacks: $(makefiles)
+list_fixes: $(makefiles)
 	@for make_dir in $(sort $(make_dirs)); do \
-		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} hacks; \
+		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _list_fixes; \
 	done	
 
 list_prereqs: $(makefiles)
 	@for make_dir in $(sort $(make_dirs)); do \
-		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} prereqs; \
+		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _list_prereqs; \
+	done
+
+fix: $(makefiles)
+	@for make_dir in $(sort $(make_dirs)); do \
+		$(MAKE) -C $$make_dir call_in=1 fixes; \
+	done
+
+what: $(makefiles)
+	@for make_dir in $(sort $(make_dirs)); do \
+		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _what; \
 	done
 
+missing: $(makefiles) 
+	@for make_dir in $(sort $(make_dirs)); do \
+		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _missing; \
+	done
+
+diff:
+	$(MAKE) distclean && \
+	rm -fr ../pristine && \
+	mkdir ../pristine && \
+	cp -r -t ../pristine * && \
+	$(MAKE) fix && \
+	diff -r -b ../pristine ../build > $(file)
+	for file in `find bintools/rcomp -name '*.CPP.original' -or -name '*.H.original' -or -name '*.LEX.original' -or -name '*.YACC.original'`; do \
+		lcfile=$$(file%\.original) && \
+		lcfile=`echo $$lcile | tr '[:upper:]' '[:lower:]'` && \
+		diff -r -b $$file $$lcfile >> $(file); \
+	done   
+
 $(targets): $(preinclude) $(makefiles)
 	garage_makedir=`find $(garage) -name $@`;\
 	makedir=$${garage_makedir##$(garage)/};\
@@ -139,8 +177,20 @@
 	targ=$@; \
 	targ=$${targ%-clean}; \
 	garage_makedir=`find $(garage) -name $${targ}`;\
-	echo $$targ; \
-	makedir=$${garage_makedir##$(garage)/};\
-	makedir=$(EPOCROOT)/build/$${makedir};\
-	$(MAKE) -C $${makedir} clean
+	if [ "$$garage_makedir" != "" ]; then \
+		makedir=$${garage_makedir##$(garage)/};\
+		makedir=$(EPOCROOT)/build/$${makedir};\
+		$(MAKE) -C $${makedir} clean; \
+	fi
+
 
+$(what_targets): $(makefiles)
+	@targ=$@; \
+	targ=$${targ%-what}; \
+	garage_makedir=`find $(garage) -name $${targ}`;\
+	if [ "$$garage_makedir" != "" ]; then \
+		makedir=$${garage_makedir##$(garage)/};\
+		makedir=$(EPOCROOT)/build/$${makedir};\
+		$(MAKE) -C $${makedir} call_in=1 targ=$${make_dir##*/} what; \
+	fi
+