OPTIMIZE=-g -Wall
#OPTIMIZE=-O2 

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

PREFIX=/usr/local
DATADIR=$(PREFIX)/share

# location in which binaries are installed
BINDIR=$(PREFIX)/bin
# location in which data files will be installed
LIBDIR=$(DATADIR)/kanjipad

INSTALL=install

####### 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 gtkglyphlabel.o padarea.o
	$(CC) -o kanjipad kanjipad.o gtkglyphlabel.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
	install -d $(BINDIR)
	install -m 0755 kanjipad $(BINDIR)/kanjipad
	install -m 0755 kpengine $(BINDIR)/kpengine
	install -d $(LIBDIR)
	install -m 0644 jdata.dat $(LIBDIR)/jdata.dat

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