# *created  "Mon Sep 28 15:49:32 2015" *by "Paul E. Black"
# *modified "Wed Jan  6 09:31:21 2016" *by "Paul E. Black"
#
# SATE V Ockham Criteria
#
# For each class, extract sites from selected Juliet test cases into a file
#

.PHONY: all clean default

SITE_FILES = write_buffer_sites.xml write_what_where_sites.xml read_buffer_sites.xml pointer_deref_sites.xml integer_inc_sites.xml divide_sites.xml variable_ref_sites.xml return_var_sites.xml

default:
	@echo make any of these lists of sites:
	@echo $(SITE_FILES)
	@echo 'or "make all"'

all: $(SITE_FILES)

################################################################################
# NOTE: all these should really depend on extractor.py, site.py, etc. since
#    changes to those could, in theory, cause different sites to be extracted.
#    In practice, the code is quite separate, so changes to extracting one
#    kind of site rarely, if ever, changes extraction of another.  So we
#    trigger each extraction manually as needed.
################################################################################

# extract sites of write (outside) buffer, indicating the buggy ones.
write_buffer_sites.xml: get_write_buffer_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_write_buffer_sites.py | tee write_buffer_report

# extract sites of write arbitrary values at arbitrary locations (write what
# where), indicating the buggy ones.
write_what_where_sites.xml: get_write_what_where_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_write_what_where_sites.py | tee write_what_where_report

# extract sites of read (outside) buffer, indicating the buggy ones.
read_buffer_sites.xml: get_read_buffer_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	# sites are filtered, so any counts would be inaccurate
	python get_read_buffer_sites.py

# extract sites of (null) pointer dereference, indicating the buggy ones.
pointer_deref_sites.xml: get_pointer_deref_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_pointer_deref_sites.py | tee pointer_deref_report

# extract sites of integer increases, indicating the buggy ones.
integer_inc_sites.xml: get_integer_inc_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_integer_inc_sites.py | tee integer_inc_report

# extract sites of integer division, indicating the buggy ones (divide by zero).
divide_sites.xml: get_divide_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_divide_sites.py | tee divide_report

# extract sites of variable access, indicating the buggy ones (uninitialized variables)
variable_ref_sites.xml: get_variable_ref_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_variable_ref_sites.py | tee variable_ref_report

# extract sites of return address, indicating the buggy ones (stack variables)
return_var_sites.xml: get_return_var_sites.py
	-mv $@ $@.bak
	@echo This takes over half an hour to run
	python get_return_var_sites.py | tee return_var_report

clean:
	@echo It takes over half an hour to regenerate each one of these
	rm -if $(SITE_FILES) *_report

# end of Makefile
