###########################################################################
#
# Makefile.in -- Makefile for the MGPP system
# Copyright (C) 1994  Neil Sharman;  1995 Tim Shimmin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#       @(#)Makefile.in	1.10 22 Mar 1994
#
###########################################################################

PACKAGE = @PACKAGE@
VERSION = @VERSION@

UNAC_DIR = @UNAC_DIR@

ENABLE_ACCENTFOLD = @ENABLE_ACCENTFOLD@
ifeq ($(ENABLE_ACCENTFOLD), 1)
AFLIBS = $(UNAC_DIR)/libunac.a 
AFINCLUDES = -I$(UNAC_DIR)
AFFLAGS = -DENABLE_ACCENTFOLD
else
AFLIBS = 
AFINCLUDES =
AFFLAGS = 
endif


SHELL = /bin/sh
VPATH = @srcdir@
exec_prefix = @exec_prefix@
prefix = @prefix@
bindir = @bindir@
srcdir = @srcdir@
libdir = @libdir@
subdir = text
top_srcdir = @top_srcdir@
transform = @program_transform_name@

AR = ar
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@ -ansi @ARCH_DEP_FLAGS@ -DSILENT -DSHORT_SUFFIX $(AFFLAGS)
CXXFLAGS = @CXXFLAGS@ @ARCH_DEP_FLAGS@ -DSILENT -DSHORT_SUFFIX $(AFFLAGS)
DEFS = @DEFS@
RANLIB = @RANLIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LDFLAGS = @LDFLAGS@
TOUCH = echo timestamp >
AWK = @AWK@
GSDLOS = @gsdlos@
ifeq ($(GSDLOS),darwin)
  DEP_LIBS = ../lib/libmgpplib.a $(AFLIBS) 
  LIBS = $(DEP_LIBS) -liconv -lstdc++ @LIBS@
else
  DEP_LIBS = ../lib/libmgpplib.a $(AFLIBS) ../../../packages/iconv/lib/libiconv.a
  LIBS = $(DEP_LIBS) -lstdc++ @LIBS@
endif


datadir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
localedir = $(datadir)/locale
mandir = $(prefix)/man/man1

COMPILE = $(CC) -c $(DEFS) $(TREC_MODE) $(READLINE) $(INCLUDES) $(CFLAGS)
CXXCOMPILE = $(CXX) -c $(DEFS) $(TREC_MODE) $(READLINE) $(INCLUDES) $(CXXFLAGS)
LINK = $(CXX) $(LDFLAGS) @ARCH_DEP_FLAGS@ -o $@

.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
	$(COMPILE) $<

.SUFFIXES: .cpp .o
.cpp.o:
	$(CXXCOMPILE) $<


ANSI2KNR = @ANSI2KNR@
o = .@U@o

.SUFFIXES: ._c ._o
.c._c:
	./ansi2knr $< > $*.tmp && mv $*.tmp $@
._c._o:
	@echo $(COMPILE) $<
	@rm -f _$*.c
	@ln $< _$*.c && $(COMPILE) _$*.c && mv _$*.o $@ && rm _$*.c
.c._o:
	./ansi2knr $< > $*.tmp && mv $*.tmp $*._c
	@echo $(COMPILE) $*._c
	@rm -f _$*.c
	@ln $*._c _$*.c && $(COMPILE) _$*.c && mv _$*.o $@ && rm _$*.c

INCLUDES = -I.. -I../lib -I. $(AFINCLUDES)

#############################################################################
#
# Uncomment (and possibly edit) the following lines if you wish
# to use the GNU readline library for the input in mgquery
# 
#READLINE = -DGNU_READLINE -I/opt/gnu/include/readline -L/opt/gnu/lib
#READLINE_LIBS = -lreadline -ltermcap
#
#
#############################################################################

SOURCES = \
  FIvfLevelInfo.cpp        ivf.pass1.cpp            mgpp_invf_dump.cpp       \
  FText.cpp                ivf.pass2.cpp            mgpp_passes.cpp          \
  FileBuf.cpp              locallib.cpp             mgpp_perf_hash_build.cpp \
  FragLevelConvert.cpp     mg.special.cpp           mgpp_stem_idx.cpp        \
  IndexData.cpp            mgpp_compression_dict.cpp  mgpp_weights_build.cpp   \
  TagInfo.cpp              mgpp_decompress_text.cpp   stemmer.cpp            \
  TextEl.cpp               mg_errors.cpp            text.cpp               \
  TextGet.cpp              mgpp_fast_comp_dict.cpp    text.pass1.cpp         \
  UCArray.cpp              mg_files.cpp             text.pass2.cpp         \
  comp_dict.cpp            mgpp_invf_dict.cpp         words.cpp              \
  invf.cpp                 mgpp_invf_dict_dump.cpp    Weights.cpp            \
  MGQuery.cpp              Terms.cpp                QueryTester.cpp        \
  QueryLex.cpp             QueryParser.cpp         \
  GSDLQueryLex.cpp	   GSDLQueryParser.cpp      Queryer.cpp \
	mgpp_passes_4jni.cpp


HEADERS = \
  FIvfLevelInfo.h     TextEl.h            hash.h              stemmer.h  \
  FText.h             TextGet.h           invf.h              text.h     \
  FileBuf.h           UCArray.h           locallib.h          words.h    \
  FragLevelConvert.h  WordData.h          mg.h                           \
  IndexData.h         build.h             mg_errors.h                    \
  TagInfo.h           comp_dict.h         mg_files.h          Weights.h  \
  MGQuery.h           Terms.h             QueryLex.h          QueryParser.h \
  GSDLQueryLex.h	GSDLQueryParser.h  mgpp_passes_4jni.h


MISC          = Makefile.in 

ALLFILES      =	$(SOURCES) $(HEADERS) $(MISC) $(MAN)

DISTFILES     = $(ALLFILES) 

EXEC          = mgpp_passes mgpp_decompress_text mgpp_perf_hash_build \
                mgpp_invf_dump mgpp_weights_build mgpp_invf_dict mgpp_stem_idx \
                mgpp_invf_dict_dump mgpp_compression_dict mgpp_fast_comp_dict \
                QueryTester Queryer

MAN           =  mgpp_weights_build.1  mgpp_invf_dict.1 \
                 mgpp_passes.1 mgpp_perf_hash_build.1 \
                 mgpp_compression_dict.1  mgpp_fast_comp_dict.1 \
                 mgpp_stem_idx.1

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


all:	$(EXEC) libmgpptext.a libmgpppass.a

depend:
	makedepend -Y -- $(DEFS) $(INCLUDES) $(CXXFLAGS) $(CFLAGS) -- $(SOURCES)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


PASSES_OBJS = \
	mgpp_passes$o text.pass1$o comp_dict$o \
	text.pass2$o locallib$o \
	ivf.pass1$o ivf.pass2$o mg.special$o mg_files$o \
	words$o invf$o FileBuf$o TextEl$o UCArray$o TagInfo$o \
        FText$o text$o FIvfLevelInfo$o

mgpp_passes: $(PASSES_OBJS) $(DEP_LIBS)
	$(LINK) $(PASSES_OBJS) $(LIBS)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

QUERYER_OBJS = Queryer$o mg_files$o mg_errors$o locallib$o invf$o UCArray$o \
               FIvfLevelInfo$o FragLevelConvert$o Terms$o MGQuery$o \
               IndexData$o stemmer$o Weights$o TextGet$o text$o FText$o \
               GSDLQueryParser$o GSDLQueryLex$o words$o

Queryer: $(QUERYER_OBJS) $(DEP_LIBS)
	$(LINK) $(QUERYER_OBJS) $(LIBS)

QUERY_TESTER_OBJS = QueryTester$o mg_files$o invf$o UCArray$o \
                    FIvfLevelInfo$o FragLevelConvert$o Terms$o MGQuery$o \
                    IndexData$o stemmer$o Weights$o

QueryTester: $(QUERY_TESTER_OBJS) $(DEP_LIBS)
	$(LINK) $(QUERY_TESTER_OBJS) $(LIBS)

WEIGHTS_BUILD_OBJS = mgpp_weights_build$o mg_files$o invf$o UCArray$o \
                     FIvfLevelInfo$o FragLevelConvert$o

mgpp_weights_build: $(WEIGHTS_BUILD_OBJS) $(DEP_LIBS)
	$(LINK) $(WEIGHTS_BUILD_OBJS) $(LIBS)

COMP_DICT_OBJS = mgpp_compression_dict$o mg_files$o locallib$o

mgpp_compression_dict: $(COMP_DICT_OBJS) $(DEP_LIBS)
	$(LINK) $(COMP_DICT_OBJS) $(LIBS)

FAST_COMP_OBJS = mgpp_fast_comp_dict$o mg_files$o locallib$o

mgpp_fast_comp_dict: $(FAST_COMP_OBJS) $(DEP_LIBS)
	$(LINK) $(FAST_COMP_OBJS) $(LIBS)

INVF_DUMP_OBJS = mgpp_invf_dump$o locallib$o mg_files$o invf$o UCArray$o

mgpp_invf_dump: $(INVF_DUMP_OBJS) $(DEP_LIBS)
	$(LINK) $(INVF_DUMP_OBJS) $(LIBS)

INVF_DICT_OBJS = mgpp_invf_dict$o mg_files$o invf$o UCArray$o

mgpp_invf_dict: $(INVF_DICT_OBJS) $(DEP_LIBS)
	$(LINK) $(INVF_DICT_OBJS) $(LIBS)

INVF_DICT_DUMP_OBJS = mgpp_invf_dict_dump$o mg_files$o invf$o UCArray$o

mgpp_invf_dict_dump: $(INVF_DICT_DUMP_OBJS) $(DEP_LIBS)
	$(LINK) $(INVF_DICT_DUMP_OBJS) $(LIBS)

PERF_HASH_OBJS = mgpp_perf_hash_build$o mg_files$o invf$o UCArray$o

mgpp_perf_hash_build: $(PERF_HASH_OBJS) $(DEP_LIBS)
	$(LINK) $(PERF_HASH_OBJS) $(LIBS)

STEM_IDX_OBJS = mgpp_stem_idx$o mg_files$o stemmer$o \
                invf$o UCArray$o

mgpp_stem_idx: $(STEM_IDX_OBJS) $(DEP_LIBS)
	$(LINK) $(STEM_IDX_OBJS) $(LIBS)

DECOMPRESS_TEXT_OBJS = \
                mgpp_decompress_text$o mg_files$o mg_errors$o \
                locallib$o text$o UCArray$o TextGet$o FText$o

mgpp_decompress_text: $(DECOMPRESS_TEXT_OBJS) $(DEP_LIBS)
	$(LINK) $(DECOMPRESS_TEXT_OBJS) $(LIBS)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

ansi2knr: ansi2knr.o
	$(LINK) ansi2knr.o $(LIBS)

install: execinstall
uninstall: execuninstall

execinstall: $(EXEC)
	../mkinstalldirs $(bindir); \
	for name in $(EXEC); do \
	  $(INSTALL_PROGRAM) $$name \
	  $(bindir)/`echo $$name | sed '$(transform)'`; \
	done 

execuninstall:
	for name in $(EXEC); do \
	 rm -f $(bindir)/`echo $$name | sed '$(transform)'`; \
	done

maninstall: $(MAN)
	$(top_srcdir)/mkinstalldirs $(mandir); \
	for f in $(MAN); do \
	  $(INSTALL_DATA) $$f $(mandir)/$$f ;\
	done

manuninstall: $(MAN)
	for f in $(MAN); do \
	  rm -f $(mandir)/$$f ;\
	done

LIB_OBJS = mg_files$o  mg_errors$o locallib$o invf$o UCArray$o \
           FIvfLevelInfo$o FragLevelConvert$o Terms$o MGQuery$o \
           IndexData$o stemmer$o Weights$o TextGet$o text$o FText$o \
           GSDLQueryParser$o GSDLQueryLex$o words$o

libmgpptext.a: $(LIB_OBJS)
	rm -f libmgpptext.a
	$(AR) cru libmgpptext.a $(LIB_OBJS)
	$(RANLIB) libmgpptext.a

JNI_LIB_OBJS = \
	mgpp_passes_4jni$o text.pass1$o comp_dict$o \
	text.pass2$o locallib$o \
	ivf.pass1$o ivf.pass2$o mg.special$o mg_files$o \
	words$o invf$o FileBuf$o TextEl$o UCArray$o TagInfo$o \
        FText$o text$o FIvfLevelInfo$o

libmgpppass.a: $(JNI_LIB_OBJS)
	rm -f libmgpppass.a
	$(AR) cru libmgpppass.a $(JNI_LIB_OBJS)
	$(RANLIB) libmgpppass.a

mostlyclean:
	rm -f *$o _*.c _*.o *._c *._o core core.*

clean: mostlyclean
	rm -f $(EXEC) libmgpptext.a libmgpppass.a

distclean: clean
	rm -f ansi2knr
	rm -f Makefile

maintainer-clean: distclean
	@echo "This command is intended only for maintainers to use;"
	@echo "rebuilding the deleted files may require special tools."

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $(srcdir)/$$file $(distdir) 2> /dev/null \
	  || cp -p $(srcdir)/$$file $(distdir); \
	done

movclean:
	for file in $(SOURCES); do \
          test = $$file; \
          echo $("test.c"##*.c); \
        done 


# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exc


