OPTIMIZE = -g -Wall
#OPTIMIZE = -O2 

GTKLIBS = `gtk-config --libs`
GTKINC = `gtk-config --cflags`

## If GTK was compiled with XInput support, -lXi must be added to GTKLIBS
#
# GTKLIBS = -lgtk -lgdk -lglib -L/usr/X11R6/lib -lX11 -lXext -lXi -lm

## If GTK is not installed in a place your compiler/linker search
## by default, use something like the following:
#
# GTKINC = -I/usr/local/include
# GTKLIBS = -L/usr/local/lib -lgtk -lgdk -lglib -L/usr/X11R6/lib -lX11 -lXext -lXi -lm

# location in which binaries are installed
BINDIR=/usr/local/bin
# location in which data files will be installed
LIBDIR=/usr/local/lib/kanjipad

####### No editing should be needed below here ##########

OBJS = kpengine.o scoring.o util.o
CFLAGS = $(OPTIMIZE) $(GTKINC) -DFOR_PILOT_COMPAT -DKP_LIBDIR=\"$(LIBDIR)\"

all: kpengine kanjipad jdata.dat

scoring.o: jstroke/scoring.c
	$(CC) -c -o scoring.o $(CFLAGS) -Ijstroke jstroke/scoring.c

util.o: jstroke/util.c
	$(CC) -c -o util.o $(CFLAGS) -Ijstroke jstroke/util.c

kpengine: $(OBJS)
	$(CC) -o kpengine $(OBJS)

kanjipad: kanjipad.o padarea.o
	$(CC) -o kanjipad kanjipad.o padarea.o $(GTKLIBS)

jdata.dat: jstroke/strokedata.h conv_jdata.pl
	perl conv_jdata.pl < jstroke/strokedata.h > jdata.dat

install: kanjipad kpengine jdata.dat
	cp kanjipad $(BINDIR)
	chmod 0755 $(BINDIR)/kanjipad
	cp kpengine $(BINDIR)
	chmod 0755 $(BINDIR)/kpengine
	if [ ! -d $(LIBDIR) ]; then mkdir -p $(LIBDIR); fi
	cp jdata.dat $(LIBDIR)
	chmod 0644 $(LIBDIR)/jdata.dat

clean:
	rm -rf *.o jdata.dat kpengine kanjipad