/* This is the file you should edit, before compiling.
 * You should not have to alter any other file. See
 * "INSTALL" for details on compiling
 *
 * The next few things are probably the only things you might
 * need to change.
 *
 * UNCOMPRESS: put your favourite  uncompress command in here.
 *   If you don't have gzip... get it!
 *   If you still won't.. well then you'll have to change the line
 *     to something that will uncompress the file to stdout
 *   You'll also have to change the UNCOMPRESSEXT to .Z, or whatever's
 *   appropriate to you.
 *
 * Note: If you don't choose to compress your dictionaries, for 
 * whatever reason.. that's okay.
 * If it doesn't have the UNCOMPRESSEXT extension, kdrill will assume
 * it is not compressed, and treat it as a plain file.
 */

/* You might need the full pathname to gzip. If you dont have it at all,
 * just leave this be. Or substitute with 'compress'. But you should
 * really get gzip, as appropriate
 */
UNCOMPRESS = gzip -d -c
UNCOMPRESSEXT = .gz

/* UNCOMPRESS = compress -d -c
 * UNCOMPRESSEXT = .Z
 */

/* You can change these here, and KDrill.ad will 
 * get created with the matching values. Yaaay!
 */
DICTLOCATION= /usr/local/lib/kanjidic.gz
EDICTLOCATION= /usr/local/lib/edict.gz
RADLOCATION= /usr/local/lib/radkfile

# If for some reason, the user prefs stuff isn't working for you, 
# and you can't compile, uncomment this
# I THINK X11R5 and newer should always support this, though.
# XrmFileFlag=-DNOXRMSAVE


# Where to install? This is an example.
# The system should pick some default for you.
# If you dont like it, uncomment this and use it as you like.
# This isn't compiled in anywhere, it's just a convenience thing.
# BINDIR = /usr/local/bin/X11



/******************************************************************
 *   Okay, halt, whoa, cease, desist, go no further...            *
 ******************************************************************/

DEPLIBS = XawClientDepLibs
LOCAL_LIBRARIES = XawClientLibs

COMPRESSDEFS = -DUNCOMPRESS='"$(UNCOMPRESS)"' \
		-DUNCOMPRESSEXT='"$(UNCOMPRESSEXT)"'


DICTDEFS = -DDICTLOCATION='"KDrill*kdictfile:	 $(DICTLOCATION)"'
EDICTDEFS = -DEDICTLOCATION='"KDrill*edictfile:	 $(EDICTLOCATION)"'
RADDEFS = -DRADLOCATION='"KDrill*radkfile:	 $(RADLOCATION)"'


/* 
 * I don't like putting <X11/...> for everything, so..
 */
INCLUDES = -I$(INCROOT)/X11

/*
 *  If you need to debug things, use this
 * CDEBUGFLAGS = -g -Wall -O -isystem $(INCROOT)/X11
 */

/* If you need to force use of gcc over cc, then use these lines
 * in addition to the one above:
 * CC = gcc
 * CCOPTIONS = 
 */

EXTRA_DEFINES = $(XrmFileFlag)


SRCS = main.c options.c readfile.c game.c init.c widgets.c grades.c \
	frequency.c mainwindow.c search.c log.c utils.c kanasearch.c \
	convert.c multikanji.c kanjisearch.c strokesearch.c \
	searchwidgets.c prefs.c badguess.c skipsearch.c learn.c timeout.c

OBJS = main.o options.o readfile.o game.o init.o widgets.o grades.o \
	frequency.o mainwindow.o search.o log.o utils.o kanasearch.o \
	convert.o multikanji.o kanjisearch.o strokesearch.o radsearch.o \
	searchwidgets.o prefs.o badguess.o skipsearch.o learn.o timeout.o

ComplexProgramTarget(kdrill)

SpecialObjectRule(utils.o,utils.c, $(COMPRESSDEFS) )
SpecialObjectRule(init.o,init.c, $(DICTDEFS) $(EDICTDEFS) $(RADDEFS) )
SpecialObjectRule(radsearch.o,radsearch.c, $(RADDEFS) )
InstallAppDefaults(KDrill)

AllTarget(KDrill.ad)
AllTarget(patchlevel.h)

KDrill.ad:	KDrill.ad-dist Imakefile Makefile
	sed -e "s:EDICTLOCATION:$(EDICTLOCATION):" \
	     -e "s:KDICTLOCATION:$(DICTLOCATION):" \
	     -e "s:RADLOCATION:$(RADLOCATION):" \
	< KDrill.ad-dist > $@

VERSION=6.4


main.o:	patchlevel.h

Makefile::	Imakefile

patchlevel.h: Imakefile
	sed "s/version-sed/$(VERSION)/" patchlevel.h-dist >$@

# SOLARIS pkg format


ARCH=`uname -p`
PKG=BOLTkdrl
PKGFILE=$(PKG)-$(ARCH).pkg

pkg:	kdrill
	sed s/VERSION-sed/$(VERSION)/ pkginfo-dist >pkginfo
	pkgmk -o -d /tmp -a $(ARCH)
	touch $(PKGFILE)
	pkgtrans -s /tmp $(PKGFILE) $(PKG)
	-rm -r /tmp/$(PKG)
	@echo package file is $(PKGFILE)

clean::
	$(RM) kdrill.log .kanjiusefile $(PKGFILE)
