CC := gcc
CFLAGS := -pthread -O2 -ggdb3 -Wall -Wextra
TESTS := test-mutex-attributes test-mutex-printer test-condvar-attributes \
         test-condvar-printer test-rwlock-attributes test-rwlock-printer

all: $(TESTS)

# Static pattern rule which matches test-* targets to their .c and .py
# prerequisites. For each target, it compiles the test program and runs the
# test script. test_common.py must be present for all.
# Notice $* is the stem of the implicit rules (i.e. the part matched by '%').
$(TESTS): %: %.c %.py test_common.py
	$(CC) $(CFLAGS) -o $@ $*.c
	python $*.py

# Remove the compiled test programs.
clean:
	rm -f $(TESTS) *.pyc
