Makefile
changeset 1 820b22e13ff1
parent 0 37428ad74fc2
equal deleted inserted replaced
0:37428ad74fc2 1:820b22e13ff1
    24 
    24 
    25 ifdef EPOCROOT
    25 ifdef EPOCROOT
    26 include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk
    26 include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk
    27 endif
    27 endif
    28 
    28 
       
    29 ifeq '$(file)' ''
       
    30 file = diffs.patch
       
    31 endif
       
    32 
    29 garage = $(EPOCROOT)/build/makefiles-garage
    33 garage = $(EPOCROOT)/build/makefiles-garage
    30 garage_makefiles = $(shell find $(garage) -name Makefile)
    34 garage_makefiles = $(shell find $(garage) -name Makefile)
    31 targets = $(notdir $(patsubst %/Makefile,%,$(garage_makefiles)))
    35 targets = $(notdir $(patsubst %/Makefile,%,$(garage_makefiles)))
    32 clean_targets = $(addsuffix -clean,$(targets))
    36 clean_targets = $(addsuffix -clean,$(targets))
       
    37 what_targets = $(addsuffix -what,$(targets))
    33 garage_make_dirs = $(patsubst %/Makefile,%,$(garage_makefiles))
    38 garage_make_dirs = $(patsubst %/Makefile,%,$(garage_makefiles))
    34 make_dirs = $(patsubst $(garage)%,$(EPOCROOT)/build%,$(garage_make_dirs)) 
    39 make_dirs = $(patsubst $(garage)%,$(EPOCROOT)/build%,$(garage_make_dirs)) 
    35 makefiles = $(patsubst $(garage)/%,$(EPOCROOT)/build/%,$(garage_makefiles))
    40 makefiles = $(patsubst $(garage)/%,$(EPOCROOT)/build/%,$(garage_makefiles))
    36 raptor_linux_binaries = $(EPOCROOT)/build/sbsv2/raptor/linux-*
    41 raptor_linux_binaries = $(EPOCROOT)/build/sbsv2/raptor/linux-*
    37 new_subdirs = $(EPOCROOT)/build/imgtools/romtools/r_t_areaset
    42 new_subdirs = $(EPOCROOT)/build/imgtools/romtools/r_t_areaset
    38 subdirs = imgtools e32tools sbsv2 srctools buildframework buildtoolguides bintools
    43 subdirs = imgtools e32tools sbsv2 srctools buildframework buildtoolguides bintools
    39 	
    44 	
    40 .PHONY: all tools export gen_preinclude clean distclean deploy_makefiles gather_makefiles help \
    45 .PHONY: all tools export gen_preinclude clean distclean deploy_makefiles gather_makefiles help \
    41 sbs_comp_list sbs_targ_list list_hacks list_prereqs
    46 sbs_comp_list sbs_targ_list list_fixups list_prereqs
       
    47 
    42 
    48 
    43 all: tools
    49 all: tools
    44 
    50 
    45 tools: $(preinclude) $(makefiles)
    51 tools: $(preinclude) $(makefiles)
    46 	for dir in $(subdirs); do $(MAKE) -C $$dir; done
    52 	for dir in $(subdirs); do $(MAKE) -C $$dir; done
    62 	@echo "  help"
    68 	@echo "  help"
    63 	@echo "  all              - Build all real targets (default)"
    69 	@echo "  all              - Build all real targets (default)"
    64 	@echo "  clean            - Remove all build object files, libraries and executables"
    70 	@echo "  clean            - Remove all build object files, libraries and executables"
    65 	@echo "  TARGET-clean     - clean the real target TARGET"
    71 	@echo "  TARGET-clean     - clean the real target TARGET"
    66 	@echo "  distclean        - Remove everything but the original files"
    72 	@echo "  distclean        - Remove everything but the original files"
    67 	@echo "  deploy_makefiles - Copy makefiles from the garage to the locations where they run"
    73 	@echo "  deploy_makefiles - Copy makefiles from the 'makefiles_garage' to the locations where they run"
    68 	@echo "  gather_makefiles - Gather any new or updated makefiles from the places where they run into the garage"
    74 	@echo "  gather_makefiles - Gather any new or updated makefiles from the places where they run into the 'makefiles_garage'"
    69 	@echo "  export           - TODO: No exports are implemented yet"
    75 	@echo "  export           - TODO: No exports are implemented yet"
    70 	@echo "  what             - TODO: \"What is built?\" not implemented yet"
    76 	@echo "  what             - List the files built by the real targets."
    71 	@echo "  TARGET-what      - TODO: \"What is built for TARGET?\" not implemented yet" 
    77 	@echo "  missing          - List the real targets that do not exist."
       
    78 	@echo "  TARGET-what      - List the files built by the real target TARGET." 
    72 	@echo "  sbs_comp_list    - List the components that sbs would find (BLD.INF files)"
    79 	@echo "  sbs_comp_list    - List the components that sbs would find (BLD.INF files)"
    73 	@echo "  sbs_targ_list    - List the targets that sbs would find (MMP files)"
    80 	@echo "  sbs_targ_list    - List the targets that sbs would find (MMP files)"
    74 	@echo "  list_prereqs     - List the dependency graph of final targets"
    81 	@echo "  list_prereqs     - List the dependency graph of final targets"
    75 	@echo "  list_hacks       - List the targets and files for which hacks are currently applied."
    82 	@echo "  list_fixes       - List the targets and files for which fixes are currently applied."
    76 	@echo "                     The hacks are applied by the make and removed by clean." 
    83 	@echo "                     The fixes are applied by the make and removed by clean."
       
    84 	@echo "  fix              - Just apply the fixes. Don't build."
       
    85 	@echo "  diff [file=FILE] - List the diffs that are generated by applying the fixups."
       
    86 	@echo "                     The diffs are written to FILE, if specified, else to ./diffs.patch."
    77 	@echo ""  
    87 	@echo ""  
    78 	@echo "Real targets in hierarchy:"
    88 	@echo "Real targets in hierarchy:"
    79 	@echo ""
    89 	@echo ""
    80 	@for file in $(sort $(garage_makefiles)); do \
    90 	@for file in $(sort $(garage_makefiles)); do \
    81 		dummy=`grep 'include $$(EPOCROOT)/build/makefiles-garage/todo.mk' $$file 2> /dev/null`;\
    91 		dummy=`grep '^include $$(EPOCROOT)/build/makefiles-garage/todo.mk' $$file 2> /dev/null`;\
    82 		todo=;\
    92 		todo=;\
    83 		file=$${file#$(garage)/};\
    93 		file=$${file#$(garage)/};\
    84 		file=$${file%/Makefile};\
    94 		file=$${file%/Makefile};\
    85 		targ=$${file##*/};\
    95 		targ=$${file##*/};\
    86 		file=$${file%/*};\
    96 		file=$${file%/*};\
   117 	@for file in `find . -iname 'bld.inf'`; do echo $${file}; done
   127 	@for file in `find . -iname 'bld.inf'`; do echo $${file}; done
   118 
   128 
   119 sbs_targ_list:
   129 sbs_targ_list:
   120 	@for file in `find . -iname '*.mmp'`; do echo $${file}; done
   130 	@for file in `find . -iname '*.mmp'`; do echo $${file}; done
   121 
   131 
   122 list_hacks: $(makefiles)
   132 list_fixes: $(makefiles)
   123 	@for make_dir in $(sort $(make_dirs)); do \
   133 	@for make_dir in $(sort $(make_dirs)); do \
   124 		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} hacks; \
   134 		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _list_fixes; \
   125 	done	
   135 	done	
   126 
   136 
   127 list_prereqs: $(makefiles)
   137 list_prereqs: $(makefiles)
   128 	@for make_dir in $(sort $(make_dirs)); do \
   138 	@for make_dir in $(sort $(make_dirs)); do \
   129 		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} prereqs; \
   139 		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _list_prereqs; \
   130 	done
   140 	done
       
   141 
       
   142 fix: $(makefiles)
       
   143 	@for make_dir in $(sort $(make_dirs)); do \
       
   144 		$(MAKE) -C $$make_dir call_in=1 fixes; \
       
   145 	done
       
   146 
       
   147 what: $(makefiles)
       
   148 	@for make_dir in $(sort $(make_dirs)); do \
       
   149 		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _what; \
       
   150 	done
       
   151 
       
   152 missing: $(makefiles) 
       
   153 	@for make_dir in $(sort $(make_dirs)); do \
       
   154 		$(MAKE) -s -C $$make_dir call_in=1 targ=$${make_dir##*/} _missing; \
       
   155 	done
       
   156 
       
   157 diff:
       
   158 	$(MAKE) distclean && \
       
   159 	rm -fr ../pristine && \
       
   160 	mkdir ../pristine && \
       
   161 	cp -r -t ../pristine * && \
       
   162 	$(MAKE) fix && \
       
   163 	diff -r -b ../pristine ../build > $(file)
       
   164 	for file in `find bintools/rcomp -name '*.CPP.original' -or -name '*.H.original' -or -name '*.LEX.original' -or -name '*.YACC.original'`; do \
       
   165 		lcfile=$$(file%\.original) && \
       
   166 		lcfile=`echo $$lcile | tr '[:upper:]' '[:lower:]'` && \
       
   167 		diff -r -b $$file $$lcfile >> $(file); \
       
   168 	done   
   131 
   169 
   132 $(targets): $(preinclude) $(makefiles)
   170 $(targets): $(preinclude) $(makefiles)
   133 	garage_makedir=`find $(garage) -name $@`;\
   171 	garage_makedir=`find $(garage) -name $@`;\
   134 	makedir=$${garage_makedir##$(garage)/};\
   172 	makedir=$${garage_makedir##$(garage)/};\
   135 	makedir=$(EPOCROOT)/build/$${makedir};\
   173 	makedir=$(EPOCROOT)/build/$${makedir};\
   137 
   175 
   138 $(clean_targets): $(makefiles)
   176 $(clean_targets): $(makefiles)
   139 	targ=$@; \
   177 	targ=$@; \
   140 	targ=$${targ%-clean}; \
   178 	targ=$${targ%-clean}; \
   141 	garage_makedir=`find $(garage) -name $${targ}`;\
   179 	garage_makedir=`find $(garage) -name $${targ}`;\
   142 	echo $$targ; \
   180 	if [ "$$garage_makedir" != "" ]; then \
   143 	makedir=$${garage_makedir##$(garage)/};\
   181 		makedir=$${garage_makedir##$(garage)/};\
   144 	makedir=$(EPOCROOT)/build/$${makedir};\
   182 		makedir=$(EPOCROOT)/build/$${makedir};\
   145 	$(MAKE) -C $${makedir} clean
   183 		$(MAKE) -C $${makedir} clean; \
       
   184 	fi
   146 
   185 
       
   186 
       
   187 $(what_targets): $(makefiles)
       
   188 	@targ=$@; \
       
   189 	targ=$${targ%-what}; \
       
   190 	garage_makedir=`find $(garage) -name $${targ}`;\
       
   191 	if [ "$$garage_makedir" != "" ]; then \
       
   192 		makedir=$${garage_makedir##$(garage)/};\
       
   193 		makedir=$(EPOCROOT)/build/$${makedir};\
       
   194 		$(MAKE) -C $${makedir} call_in=1 targ=$${make_dir##*/} what; \
       
   195 	fi
       
   196