# =============================================================================
# Makefile for CMU 15-213 Lecture 8 (design and debugging)
# =============================================================================
#
#   make run      run the three demos
#   make clean    remove build/
#
# Demos 01 and 02 are Python drivers that compile small C programs (src/fib.c,
# src/bugs.c) many ways and read the results; 03 is a native C program.
# Requirements: a C compiler with AddressSanitizer and UndefinedBehaviorSanitizer
# (clang or gcc), and Python 3.9+.
# -----------------------------------------------------------------------------

CC     ?= cc
NATIVE := -std=c11 -Wall -Wextra -O0 -g

.PHONY: run clean
run: build/03_contracts
	@python3 01_scientific_debugging.py
	@echo; python3 02_tools.py
	@echo; ./build/03_contracts

build:
	mkdir -p build

build/03_contracts: 03_contracts.c | build
	$(CC) $(NATIVE) -o $@ 03_contracts.c

clean:
	rm -rf build __pycache__
