CFLAGS=-O3 -Wall
DISTFILES=common.c common.h turn.c comp.c Makefile HEADER.html start1

all: turn comp

clean:
	rm *.o turn comp

turn: turn.o common.o
	gcc $(CFLAGS) turn.o common.o -o turn

comp: comp.o common.o
	gcc $(CFLAGS) -Wall comp.o common.o -o comp

turn.o: turn.c common.h

comp.o: comp.c common.h

common.o: common.h common.c

dist: $(DISTFILES)
	rm -rf fuenf fuenf.zip
	mkdir fuenf
	cp -rp $(DISTFILES) fuenf
	zip -9r fuenf.zip fuenf

bench: comp
	LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u comp 4 start1

#LC_NUMERIC=en_US.utf8 perf stat -B -e cycles:u -e instructions:u -e branches:u -e branch-misses:u comp 12 0 14 9 8 7 5 0 0 1 0 0 0 4 0
#Position:
#    4  0  0  0  1  0
#  0                  0
#    0 14  9  8  7  5
#Best move (1-6): 5  Value: -1
#
# Performance counter stats for 'comp 12 0 14 9 8 7 5 0 0 1 0 0 0 4 0':
#
#   344,306,194,571      cycles:u
#   711,065,944,240      instructions:u            #    2.07  insn per cycle
#   123,045,591,793      branches:u
#     4,643,565,058      branch-misses:u           #    3.77% of all branches
#
#     102.935136358 seconds time elapsed
