# A simple makefile for building a program composed of C source files.
# Refer to CS107 guide to Make for background info on makefiles

PROGRAMS = test_while abstest data_transfer print_arr stack-ex

all:: $(PROGRAMS) $(PROGRAMS_OG) $(PROGRAMS_O3)

CC = gcc
CFLAGS = -g -Og -std=gnu99 -Wall $$warnflags

export warnflags = -Wfloat-equal -Wtype-limits -Wpointer-arith -Wlogical-op -Wshadow -fno-diagnostics-show-option
LDFLAGS =
LDLIBS =

$(PROGRAMS): %:%.c
	$(CC) -c $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS)
	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@

test_while: while_loop.c 

abstest: absdiff.s cmovdiff.s clockticks.o

clean::
	#rm -f $(PROGRAMS) *.o
	rm -f $(PROGRAMS) absdiff.o abstest.o cmovdiff.o test_while.o while_loop.o data_transfer.o

.PHONY: clean all
