# =============================================================================
# Makefile for CMU 15-213 Lecture 15 (code optimization)
# =============================================================================
#
#   make run      run all three demos
#   make clean
#
# 01 inspects compiler output (Python driver, cross-compiles src/opts.c to
# x86-64 as the slides do); 02 and 03 are native timing measurements at -O2.
# -----------------------------------------------------------------------------

CC     ?= cc
CFLAGS := -std=c11 -O2 -Wall -Wextra

.PHONY: all run clean
all: build/02_blockers build/03_cpe

build:
	mkdir -p build

build/02_blockers: 02_blockers.c timer.h | build
	$(CC) $(CFLAGS) -o $@ 02_blockers.c

build/03_cpe: 03_cpe.c timer.h | build
	$(CC) $(CFLAGS) -o $@ 03_cpe.c

run: all
	@python3 01_compiler_opts.py
	@echo; ./build/02_blockers
	@echo; ./build/03_cpe

clean:
	rm -rf build __pycache__
