CC = gcc
CFLAGS_BASE = -O2 -Wall

all: nodebug withdebug

nodebug: program.c
	$(CC) $(CFLAGS_BASE) -o $@ $< -lm

withdebug: program.c
	$(CC) $(CFLAGS_BASE) -g -o $@ $< -lm

# Show the size difference
sizes: nodebug withdebug
	@echo "File sizes:"
	@ls -lh nodebug withdebug
	@echo ""
	@echo "Section sizes (nodebug):"
	@size nodebug
	@echo ""
	@echo "Section sizes (withdebug):"
	@size withdebug

# Show symbols
symbols: nodebug withdebug
	@echo "Symbols in nodebug:"
	@nm nodebug | grep -E "compute|process|main" || true
	@echo ""
	@echo "Symbols in withdebug:"
	@nm withdebug | grep -E "compute|process|main" || true

# Strip the debug version to show what happens
stripped: withdebug
	cp withdebug stripped
	strip stripped
	@echo "Stripped file created"

clean:
	rm -f nodebug withdebug stripped perf.data perf.data.old

.PHONY: all sizes symbols clean stripped
