# configuration info

NAME = gnugo
VERSION = 2.0

CFLAGS = -g $(COLOR) $(GRID) $(OPTIONS) -DVERSION=\"$(VERSION)\" 
# Use GCC if you have it. Otherwise any ANSI compiler should work.
CC = gcc

# COLOR OPTIONS are a debugging aid (see DRAGONS) for programmers.

# uncomment the next 2 lines to get a color board display with curses (rxvt)
#COLOR=-DCURSES
#COLORLIB=-lncurses 

# or this to use hardcoded ansi escape sequences (dtterm, linux console, rxvt)
#COLOR=-DANSI_COLOR

# GRID OPTIMIZATION (now the default) is a speedup.
# (See matchpat.c and PATTERNS)

# uncomment to get a fast version using grid optimization 
GRID = -DGRID_OPT

# Optionally choose one of these. On some systems no options may work best,
# but use GCCOPTIONS if you have GCC. Or write your own (and tell us about 
# it at gnugo@gnu.org)

OPTIONS=$(GCCOPTS)
# OPTIONS=$(AIXOPTS)



# preconfigured settings for various configurations

GCCOPTS=-O2 -Wall -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations

AIXOPTS=-O -qmaxmem=16384 -qro -qroconst -qinfo


#
#
# You should not need to touch anything below here
#
#	


# SRC excludes patterns.c and gmp.c

SRC = main.c \
      attdef.c \
      dragon.c \
      genmove.c \
      halfeyes.c \
      helpers.c \
      matchpat.c \
      reading.c \
      sethand.c \
      semeai.c \
      shapes.c \
      showbord.c \
      utils.c

OBJ = $(SRC:.c=.o)

ALLOBJ =  $(OBJ) patterns.o gmp.o

$(NAME) : $(ALLOBJ)
	$(CC) $(CFLAGS) $(ALLOBJ) -o $(NAME) $(COLORLIB)

matchpat.o : matchpat.c patterns.h

halfeyes.o : halfeyes.c hey.h

gmp.o : gmp.c 
	$(CC) -g -c gmp.c -o gmp.o

$(OBJ) : liberty.h Makefile

patterns.c : patterns.db mkpat Makefile
	./mkpat pat <patterns.db >patterns.c

hey.h : mkpat hey.db
	./mkpat -h hey <hey.db >hey.h

# renumber patterns.db (see intro to that file) 

renum :
	mv patterns.db patterns.db.bak
	awk '{if ($$0 !~ /^# pattern/) print $0; else {printf("# pattern %d\n",i); i+=1}}' patterns.db.bak>patterns.db

mkpat : mkpat.c Makefile
	$(CC) $(CFLAGS) mkpat.c -o mkpat

clean: 
	rm -f $(ALLOBJ) patterns.c helper.o gmp.o $(NAME) mkpat hey.h

