# Hanzi Master makefile. (Version 1.3, 3/2002)

#########################################
## Where you want stuff installed:
#########################################

# set INSTALLROOT to the installation base; it is used to set the
# other directory variables below
INSTALLROOT = /usr/local
#INSTALLROOT = /usr

# set LIBDIR to where you will keep the datafiles, fontspecs, and "hanwin.tcl"
LIBDIR = $(INSTALLROOT)/lib/Hanzim
#LIBDIR = /usr/local/lib/Hanzim
# for debugging
#LIBDIR = ./Data

#set BINDIR to where you want the hanzim binary to reside
BINDIR = $(INSTALLROOT)/bin
#BINDIR = /usr/local/bin

# set MANDIR to where you want the manpage to reside
MANDIR = $(INSTALLROOT)/man
#MANDIR = /usr/local/man

# set DOCDIR to where you want the documentation files to reside
DOCDIR = $(INSTALLROOT)/doc
#DOCDIR = $(INSTALLROOT)/share/doc
#DOCDIR = /usr/local/share/doc
#DOCDIR = /usr/share/doc
#DOCDIR = /usr/local/doc
#DOCDIR = /usr/doc


#########################################
## How you want things compiled:
#########################################

# System type
OS=UNIX
#OS=WINDOWS

# location of Tcl and Tk libraries
LIBTCLDIR = -L /usr/lib

# location of x library
LIBXDIR = -L /usr/X11/lib

# you might need to change "libtcl" and "libtk" to "libtcl8.x" and "libtk8.x"
LIBS = $(LIBXDIR) $(LIBTCLDIR) -ltk -ltcl -lX11 -lm -ldl

INSTALL = install
RM = rm -f

# End of configuration.
###############################################################################

CC = cc
DEFINES = -D$(OS) -DLIBDIR=\"$(LIBDIR)\"
CFLAGS = -O2 $(DEFINES)
#CFLAGS = -O2 -Wall -pedantic -ansi $(DEFINES)
LFLAGS = $(LIBS)  -s

DIST_FILES = Hanzim/hanzim.h Hanzim/hgb_utf.h \
		Hanzim/hanzim.c Hanzim/hanwin.c Hanzim/hinit.c Hanzim/hutil.c \
		Hanzim/hanzim.doc Hanzim/hanzim.man \
		Hanzim/TODO Hanzim/CHANGES Hanzim/README Hanzim/COPYING \
		Hanzim/Data/hanwin.tcl \
		Hanzim/Data/fonts.unix Hanzim/Data/fonts.windows \
		Hanzim/Data/zidianf.gb Hanzim/Data/zidianfl.b5 \
		Hanzim/Data/cidianf.gb Hanzim/Data/bushou.gb \
		Hanzim/Data/sanzicidianf.gb Hanzim/Data/parts.gb \
		Hanzim/Makefile Hanzim/hanzim \
		Hanzim/makefile.vc Hanzim/hanzim.exe Hanzim/README.windows \
		Hanzim/README.macintosh

     hanzim : hanzim.o hanwin.o hinit.o hutil.o
		$(CC) -o hanzim hanwin.o hanzim.o hinit.o hutil.o $(LFLAGS)

     hanzim.o : hanzim.c hanzim.h
		$(CC) $(CFLAGS) -c hanzim.c
     hanwin.o : hanwin.c hanzim.h
		$(CC) $(CFLAGS) -c hanwin.c
     hinit.o : hinit.c hanzim.h
		$(CC) $(CFLAGS) -c hinit.c
     hutil.o : hutil.c hanzim.h hgb_utf.h
		$(CC) $(CFLAGS) -c hutil.c

     install : hanzim
	$(INSTALL) -s hanzim $(BINDIR)
	$(INSTALL) -m 0644 hanzim.man $(MANDIR)/man1/hanzim.1
	$(INSTALL) -m 0755 -d $(DOCDIR)
	$(INSTALL) -m 0644 hanzim.doc $(DOCDIR)
	$(INSTALL) -m 0755 -d $(LIBDIR)
	cd Data ; \
	$(INSTALL) -m 0644 hanwin.tcl fonts.unix fonts.windows \
			   zidianf.gb zidianfl.b5 bushou.gb \
		           cidianf.gb sanzicidianf.gb parts.gb $(LIBDIR)
	$(BINDIR)/hanzim -buildDB

     uninstall : 
	$(RM) $(BINDIR)/hanzim
	$(RM) $(MANDIR)/man1/hanzim.1
	$(RM)  $(DOCDIR)/hanzim.doc
	cd $(LIBDIR) ; $(RM) hanwin.tcl fonts.unix fonts.windows \
			   zidianf.gb zidianfl.b5 bushou.gb \
		           cidianf.gb sanzicidianf.gb parts.gb hcompound.dat
	rmdir $(LIBDIR)

     clean : 
	rm -f hanzim *.o

     archive :
	tar cf hbak.tar hanzim.h hgb_utf.h hanzim.c hanwin.c hinit.c hutil.c \
	Data/hanwin.tcl hanzim.doc hanzim.man TODO CHANGES Makefile COPYING \
	makefile.vc README.windows README.macintosh hanzim.exe \
	Data/fonts.unix Data/fonts.windows
	gzip hbak.tar

     dbarchive :
	tar cf Data/hdb.tar Data/zidianf.gb Data/zidianfl.b5 Data/cidianf.gb \
		Data/sanzicidianf.gb Data/bushou.gb Data/parts.gb
	gzip Data/hdb.tar

     distribution :
	cd .. ; tar zcf Hanzim/hanzim-1.3.tgz $(DIST_FILES)
     zip : 
	cd .. ; zip Hanzim/hanzim-1.3.zip $(DIST_FILES)

