michael@0: # -*- Mode: makefile -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # This Makefile is used to kick off a static rooting analysis. This Makefile is michael@0: # NOT intended for use as part of the standard Mozilla build. Instead, this michael@0: # Makefile will use $PATH to subvert compiler invocations to add in the sixgill michael@0: # plugin, and then do a regular build of whatever portion of the tree you are michael@0: # analyzing. The plugins will dump out several xdb database files. Various michael@0: # analysis scripts, written in JS, will run over those database files to michael@0: # produce the final analysis output. michael@0: michael@0: include $(topsrcdir)/config/config.mk michael@0: michael@0: # Tree to build and analyze, defaulting to the current tree michael@0: TARGET_JSOBJDIR ?= $(MOZ_BUILD_ROOT) michael@0: michael@0: # Path to a JS binary to use to run the analysis. You really want this to be an michael@0: # optimized build. michael@0: JS ?= $(MOZ_BUILD_ROOT)/shell/js michael@0: michael@0: # Path to an xgill checkout containing the GCC plugin, xdb-processing binaries, michael@0: # and compiler wrapper scripts used to automatically integrate into an existing michael@0: # build system. michael@0: SIXGILL ?= @SIXGILL_PATH@ michael@0: michael@0: # Path to the JS scripts that will perform the analysis, defaulting to the same michael@0: # place as this Makefile.in, which is probably what you want. michael@0: ANALYSIS_SCRIPT_DIR ?= $(srcdir) michael@0: michael@0: # Number of simultanous analyzeRoots.js scripts to run. michael@0: JOBS ?= 6 michael@0: michael@0: all : rootingHazards.txt allFunctions.txt michael@0: michael@0: CALL_JS := time env PATH=$$PATH:$(SIXGILL)/bin XDB=$(SIXGILL)/bin/xdb.so $(JS) michael@0: michael@0: src_body.xdb src_comp.xdb: run_complete michael@0: @echo Started compilation at $$(date) michael@0: $(ANALYSIS_SCRIPT_DIR)/run_complete --foreground --build-root=$(TARGET_JSOBJDIR) --work-dir=work -b $(SIXGILL)/bin $(CURDIR) michael@0: @echo Finished compilation at $$(date) michael@0: michael@0: callgraph.txt: src_body.xdb src_comp.xdb computeCallgraph.js michael@0: @echo Started computation of $@ at $$(date) michael@0: $(CALL_JS) $(ANALYSIS_SCRIPT_DIR)/computeCallgraph.js > $@.tmp michael@0: mv $@.tmp $@ michael@0: @echo Finished computation of $@ at $$(date) michael@0: michael@0: gcFunctions.txt: callgraph.txt computeGCFunctions.js annotations.js michael@0: @echo Started computation of $@ at $$(date) michael@0: $(CALL_JS) $(ANALYSIS_SCRIPT_DIR)/computeGCFunctions.js ./callgraph.txt > $@.tmp michael@0: mv $@.tmp $@ michael@0: @echo Finished computation of $@ at $$(date) michael@0: michael@0: gcFunctions.lst: gcFunctions.txt michael@0: perl -lne 'print $$1 if /^GC Function: (.*)/' gcFunctions.txt > $@ michael@0: michael@0: suppressedFunctions.lst: gcFunctions.txt michael@0: perl -lne 'print $$1 if /^Suppressed Function: (.*)/' gcFunctions.txt > $@ michael@0: michael@0: gcTypes.txt: src_comp.xdb computeGCTypes.js annotations.js michael@0: @echo Started computation of $@ at $$(date) michael@0: $(CALL_JS) $(ANALYSIS_SCRIPT_DIR)/computeGCTypes.js > $@.tmp michael@0: mv $@.tmp $@ michael@0: @echo Finished computation of $@ at $$(date) michael@0: michael@0: allFunctions.txt: src_body.xdb michael@0: @echo Started computation of $@ at $$(date) michael@0: time $(SIXGILL)/bin/xdbkeys $^ > $@.tmp michael@0: mv $@.tmp $@ michael@0: @echo Finished computation of $@ at $$(date) michael@0: michael@0: rootingHazards.txt: gcFunctions.lst suppressedFunctions.lst gcTypes.txt analyzeRoots.js annotations.js gen-hazards.sh michael@0: @echo Started computation of $@ at $$(date) michael@0: time env JS=$(JS) ANALYZE='$(ANALYSIS_SCRIPT_DIR)/analyzeRoots.js' SIXGILL='$(SIXGILL)' '$(ANALYSIS_SCRIPT_DIR)/gen-hazards.sh' $(JOBS) > $@.tmp michael@0: mv $@.tmp $@ michael@0: @echo Finished computation of $@ at $$(date)