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

all: turn comp

turn: turn.o oware.o
	gcc -O -Wall turn.o oware.o -o turn

comp: comp.o oware.o
	gcc -O -Wall comp.o oware.o -o comp

turn.o: turn.c oware.h

comp.o: comp.c oware.h

oware.o: oware.h oware.c

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

bench: comp
	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

#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
