SCRIPTS=\
history-ls.pl \
history-list.pl \
history-db-list.pl \
show-history.pl \
show-history-ebw3-result.pl

HTMLS=\
history-list.linux.html \
history-list.solaris.html \
history-list.ebw3-result.html \
history-list.ac.jp.html \
history-list.edu.html \
history-list.chaos.html \
#private-dictionary.html \
private-dictionary-19990320.html

CC=gcc
CPPFLAGS=-g -Wall
LDLIBS=-ldb

SRCS=\
history-db-list.c

EXES=$(SRCS:%.c=%)

all: $(EXES) $(HTMLS)
#all: $(EXES)

#
# As on-line usage,
# please ln -s show-history.pl show-history.cgi and use via HTTP.
#

history-list.linux.html: $(HOME)/.netscape/history.db
	show-history.pl -g '[Li]inux' -s +1 > $@

history-list.ebw3-result.html: $(HOME)/.netscape/history.db
	show-history.pl -g ebw3 -e Result -s +1 > $@

#
# As off-line usage,
# please create HTML files as follows:
#

history-list.solaris.html: history-list.all
	grep '[Ss]olaris' $< | show-history.pl - > $@

history-list.ac.jp.html: history-list.all
	grep '\.ac\.jp/' $< | show-history.pl - > $@

history-list.edu.html: history-list.all
	grep '\.edu/' $< | show-history.pl - > $@

history-list.chaos.html: history-list.all
	grep '\([Cc]haos\|елеке╣\)' $< | show-history.pl - > $@

history-list.all: $(HOME)/.netscape/history.db
	history-db-list -a | sort +1 > $@

#
# To create private dictionary,
# this is only for ebw3.
#

private-dictionary.html: history-list.all
	show-history-ebw3-result.pl - < history-list.all > $@

private-dictionary-19990320.html: history-list.all
	show-history-ebw3-result.pl -a 1999/03/20 - < history-list.all > $@


clean:
	rm -f $(EXES)
	rm -f $(HTMLS) history-list.all
	rm -f *~


distribute: history-db-0.4.tar.gz
	if [ ! -d $(HOME)/public_html/netscape/history-db ]; then mkdir $(HOME)/public_html/netscape/history-db; fi
	cp -p index-j.html show-history-ebw3-result.pl.sample.gif history-db-0.4.tar.gz $(HOME)/public_html/netscape/history-db

history-db-0.4.tar.gz: makefile $(SCRIPTS) $(SRCS) index-j.html show-history-ebw3-result.pl.sample.gif
	cd ..; tar cvzf history-db/$@ $(addprefix history-db/, makefile $(SCRIPTS) $(SRCS) index-j.html show-history-ebw3-result.pl.sample.gif)


test:
	if [ ! -d tmp ]; then mkdir tmp; fi
	history-ls.pl > tmp/history-ls.pl.out
	history-list.pl > tmp/history-list.pl.out
	# diff tmp/history-ls.pl.out tmp/history-list.pl.out
	history-list.pl -a > tmp/history-list.pl.a.out
	sort tmp/history-list.pl.a.out > tmp/history-list.pl.a.out.s
	history-db-list.pl > tmp/history-db-list.pl.out
	sort tmp/history-db-list.pl.out > tmp/history-db-list.pl.out.s
	history-db-list.pl -a > tmp/history-db-list.pl.a.out
	sort tmp/history-db-list.pl.a.out > tmp/history-db-list.pl.a.out.s
	# diff tmp/history-list.pl.a.out.s tmp/history-db-list.pl.a.out.s
	sort +1 tmp/history-db-list.pl.a.out > tmp/history-db-list.pl.a.out.s1
	history-db-list.pl -a -T > tmp/history-db-list.pl.a.T.out
	sort +1 tmp/history-db-list.pl.a.T.out > tmp/history-db-list.pl.a.T.out.s1
	# diff tmp/history-db-list.pl.a.out.s1 tmp/history-db-list.pl.a.T.out.s1
	history-db-list > tmp/history-db-list.out
	sort tmp/history-db-list.out > tmp/history-db-list.out.s
	# diff tmp/history-db-list.pl.out.s tmp/history-db-list.out.s
	history-db-list -a > tmp/history-db-list.a.out
	sort tmp/history-db-list.a.out > tmp/history-db-list.a.out.s
	# diff tmp/history-db-list.pl.a.out.s tmp/history-db-list.a.out.s
	history-db-list -a -T > tmp/history-db-list.a.T.out
	sort +1 tmp/history-db-list.a.T.out > tmp/history-db-list.a.T.out.s1
	# diff tmp/history-db-list.pl.a.T.out.s1 tmp/history-db-list.a.T.out.s1

clean.test:
	rm -rf tmp
