#
# Makefile - makefile for libhtdig
#

PRODUCT = htdig

TARGET = $(LIBDIR)/libhtdig$(DLLSFX)

include ../Makedefs.win32

ARCH = win32
#MV = move
MV = mv


#define your own defaults here!
DEFAULT_CONFIG_FILE=\"/etc/htdig/htdig.conf\"
DEFAULT_DB_PATH=\"/etc/htdig/\"
BIN_DIR=\"/usr/local/bin\"
COMMON_DIR=\"/usr/local/share/htdig\"
CONFIG_DIR=\"/etc/htdig\"
DATABASE_DIR=\"/var/lib/htdig\"
IMAGE_URL_PREFIX=\"/htdig\"

DEFS= -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE=$(DEFAULT_CONFIG_FILE) -DBIN_DIR=$(BIN_DIR) -DCOMMON_DIR=$(COMMON_DIR) 
DEFS+= -DCONFIG_DIR=$(CONFIG_DIR) -DDATABASE_DIR=$(DATABASE_DIR) -DIMAGE_URL_PREFIX=$(IMAGE_URL_PREFIX)

#LEX define based on your system
LEX = flex
AM_LFLAGS = -L
LEX_OUTPUT_ROOT = lex.yy

#YACC define based on your system
YACC = bison -y
AM_YFLAGS = -l -d
YACC_OUTPUT_ROOT = y.tab


# -----------------------------------------------------------------------------
# add new library members to this list

#berkeley db c files
BDB_C_OBJS += bt_compare.obj bt_conv.obj bt_curadj.obj bt_cursor.obj bt_delete.obj bt_method.obj bt_open.obj bt_put.obj bt_rec.obj bt_reclaim.obj bt_recno.obj bt_rsearch.obj bt_search.obj bt_split.obj bt_stat.obj bt_upgrade.obj btree_auto.obj crdel_auto.obj crdel_rec.obj db.obj db_am.obj db_auto.obj db_byteorder.obj db_conv.obj db_dispatch.obj db_dup.obj db_err.obj db_getlong.obj db_iface.obj db_join.obj db_log2.obj db_meta.obj db_method.obj db_overflow.obj db_pr.obj db_rec.obj db_reclaim.obj db_ret.obj db_salloc.obj db_shash.obj db_upgrade.obj env_method.obj env_open.obj env_recover.obj env_region.obj hash.obj hash_auto.obj hash_conv.obj hash_dup.obj hash_func.obj hash_meta.obj hash_method.obj hash_page.obj hash_rec.obj hash_reclaim.obj hash_stat.obj hash_upgrade.obj lock.obj lock_conflict.obj lock_deadlock.obj lock_region.obj lock_util.obj log.obj log_archive.obj log_auto.obj log_compare.obj log_findckp.obj log_get.obj log_method.obj log_put.obj log_rec.obj log_register.obj mp_alloc.obj mp_bh.obj mp_cmpr.obj mp_fget.obj mp_fopen.obj mp_fput.obj mp_fset.obj mp_method.obj mp_region.obj mp_register.obj mp_stat.obj mp_sync.obj mp_trickle.obj mut_fcntl.obj mut_pthread.obj mut_tas.obj mutex.obj os_abs.obj os_alloc.obj os_dir.obj os_errno.obj os_fid.obj os_finit.obj os_fsync.obj os_handle.obj os_map.obj os_method.obj os_oflags.obj os_open.obj os_region.obj os_rename.obj os_root.obj os_rpath.obj os_rw.obj os_seek.obj os_sleep.obj os_spin.obj os_stat.obj os_tmpdir.obj os_unlink.obj qam.obj qam_auto.obj qam_conv.obj qam_method.obj qam_open.obj qam_rec.obj qam_stat.obj txn.obj txn_auto.obj txn_rec.obj txn_region.obj xa.obj xa_db.obj xa_map.obj 

ifdef WINDIR
BDB_C_OBJS += dirent_local.obj
endif

#htlib c files  $(REGEX)
HTLIB_C_OBJS += getcwd.obj mhash_md5.obj regex.obj vsnprintf.obj memcmp.obj mktime.obj snprintf.obj memcpy.obj myqsort.obj strerror.obj memmove.obj raise.obj timegm.obj

#htlib c++ files
HTLIB_CXX_OBJS += Configuration.obj Database.obj Dictionary.obj DB2_db.obj IntObject.obj List.obj Object.obj ParsedString.obj Queue.obj QuotedStringList.obj Stack.obj String.obj StringList.obj StringMatch.obj String_fmt.obj good_strtok.obj strcasecmp.obj strptime.obj HtCodec.obj HtWordCodec.obj HtVector.obj HtHeap.obj HtPack.obj HtDateTime.obj HtRegex.obj HtRegexList.obj HtRegexReplace.obj HtRegexReplaceList.obj HtVectorGeneric.obj HtMaxMin.obj HtWordType.obj md5.obj filecopy.obj

#htword c++ files
HTWORD_CXX_OBJS += WordBitCompress.obj WordContext.obj WordCursor.obj WordDB.obj WordDBCompress.obj WordDBInfo.obj WordDBPage.obj WordKey.obj WordKeyInfo.obj WordList.obj WordMonitor.obj WordRecord.obj WordRecordInfo.obj WordReference.obj WordStat.obj WordType.obj 

#htcommon c++ files
HTCOMMON_CXX_OBJS += DocumentDB.obj DocumentRef.obj HtWordReference.obj HtWordList.obj defaults.obj HtURLCodec.obj URL.obj URLTrans.obj HtZlibCodec.obj cgi.obj HtSGMLCodec.obj HtConfiguration.obj HtURLRewriter.obj

#htnet c++ files
HTNET_CXX_OBJS += Connection.obj Transport.obj HtHTTP.obj HtFile.obj HtNNTP.obj HtCookie.obj HtCookieJar.obj HtCookieMemJar.obj HtHTTPBasic.obj HtHTTPSecure.obj SSLConnection.obj HtFTP.obj HtCookieInFileJar.obj

#htdig c++ files
HTDIG_CXX_OBJS += Document.obj ExternalTransport.obj Parsable.obj Retriever.obj URLRef.obj ExternalParser.obj HTML.obj Plaintext.obj Server.obj

#htfuzzy c++ files
HTFUZZY_CXX_OBJS += Accents.obj EndingsDB.obj Fuzzy.obj Prefix.obj Soundex.obj Substring.obj Synonym.obj Endings.obj Exact.obj Metaphone.obj Regexp.obj Speling.obj SuffixEntry.obj 

#HTFUZZY_C_OBJS += filecopy.o

#htsearch c++ files
HTSEARCH_CXX_OBJS += Collection.obj DocMatch.obj  ResultList.obj SplitMatches.obj TemplateList.obj Display.obj  HtURLSeedScore.obj ResultMatch.obj Template.obj WeightWord.obj parser.obj

#libhtdig c++ files
LIBHTDIG_CXX_OBJS += ResultFetch.obj BasicDocument.obj TextCollector.obj libhtdig_htdig.obj libhtdig_htmerge.obj libhtdig_htfuzzy.obj libhtdig_log.obj libhtdig_htsearch.obj

#htcommon lex & yacc targets
LIBHTDIG_CXX_OBJS += conf_lexer.obj conf_parser.obj

#libhtdig c files
#LIBHTDIG_C_OBJS += filecopy.o

LXX_TARGETS += conf_lexer.cc

YXX_TARGETS += conf_parser.cc

OBJS += $(BDB_C_OBJS) $(HTLIB_C_OBJS) $(HTLIB_CXX_OBJS) $(HTWORD_CXX_OBJS)
OBJS += $(HTCOMMON_CXX_OBJS) $(HTNET_CXX_OBJS) $(HTDIG_CXX_OBJS)
OBJS += $(HTFUZZY_CXX_OBJS) $(HTFUZZY_C_OBJS) $(HTSEARCH_CXX_OBJS) $(LIBHTDIG_CXX_OBJS) $(LIBHTDIG_C_OBJS)

OTHERLIBS =  L:/win32/lib/zlib114/zlib.lib ws2_32.lib

# -----------------------------------------------------------------------------

CMNDLLS = 

CPPFLAGS += -DHAVE_CONFIG_H -I. -I../include -I../htlib -I../htcommon -I../htword \
        -I../db -I../htnet -I../htsearch -I../htdig -I../htfuzzy

CFLAGS += $(CPPFLAGS)

#ifeq ($(ARCH),win32)
CFLAGS += -DDYNAMIC_LIBUTIL
CPPFLAGS += -DDYNAMIC_LIBUTIL -DYY_NEVER_INTERACTIVE 
#endif

ifeq ($(ARCH),linux)
LDFLAGS += -Xlinker -Bsymbolic
endif

# -----------------------------------------------------------------------------


#win32/%.obj: %.cc %.c
#	    $(CC) $(CPPFLAGS) -c $< -o $@


	#$(CC) $(CPPFLAGS) $(OPTS) $(DBG) -c $< /Fo$@

$(BDB_C_OBJS): %.obj: ../db/%.c
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TC -c $< 

$(HTLIB_C_OBJS): %.obj: ../htlib/%.c
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TC -c $< 

$(HTLIB_CXX_OBJS): %.obj: ../htlib/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTWORD_CXX_OBJS): %.obj: ../htword/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTCOMMON_CXX_OBJS): %.obj: ../htcommon/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTNET_CXX_OBJS): %.obj: ../htnet/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTDIG_CXX_OBJS): %.obj: ../htdig/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTFUZZY_C_OBJS): %.obj: ../htfuzzy/%.c
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TC -c $< 

$(HTFUZZY_CXX_OBJS): %.obj: ../htfuzzy/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(HTSEARCH_CXX_OBJS): %.obj: ../htsearch/%.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(LIBHTDIG_CXX_OBJS): %.obj: %.cc
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TP -c $< 

$(LIBHTDIG_C_OBJS): %.obj: %.c
	$(CC) $(CFLAGS) $(OPTS) $(DBG) /TC -c $< 

$(LXX_TARGETS): %.cc: ../htcommon/%.lxx
	$(LEX) $(AM_LFLAGS) $< && cat $(LEX_OUTPUT_ROOT).c | sed -e 's/#include <unistd.h>//g' > $@
	#$(LEX) $(AM_LFLAGS) $(LFLAGS) -o$@  $<

$(YXX_TARGETS): %.cc: ../htcommon/%.yxx
	$(YACC) $(AM_YFLAGS) $< && $(MV) $(YACC_OUTPUT_ROOT).c $@
	if test -f y.tab.h; then if cmp -s y.tab.h conf_parser.h; then rm -f y.tab.h; else mv y.tab.h conf_parser.h; fi; else :; fi


		
$(TARGET): $(OBJDIRDEP) $(LIBDIRDEP) $(OBJS)
	$(RM) $(basename $(TARGET))*
	$(DLLLD) $(LDFLAGS) $(OBJS) $(LDLIBS) $(DBLIBS) $(OTHERLIBS)
	$(DLL_SYMLINK_CMD)

include ../Makerules.win32

