FAMOUS= guy_keren orr_dunkelman shlomi_fish alon_altman muli_ben-yehuda eli_billauer orna_agmon ohad_lutzky rami_rosen
ELECTURES=index advocate programming util system kernel network video security lectures1 lectures2 lectures3 lectures4 lectures5 lectures6 lectures7 lectures8 lectures9 lectures10 lectures11 lectures12 lectures13 lectures14 lectures15 lectures16 lectures

ELECTURES:=$(ELECTURES) future sil $(FAMOUS)

HLECTURES= $(patsubst %, hebrew/%,$(ELECTURES))

LECTURES:= $(ELECTURES) $(HLECTURES)

LECTURES_HTM:= $(patsubst %, %.htm,  $(LECTURES))

#HTM must be evaluated after the htm files were created
EHTM:=$(wildcard *.htm) cal.htm 
HHTM:=$(wildcard hebrew/*.htm) 
HTM:= $(wildcard *.htm) $(wildcard hebrew/*.htm)

HTML:= $(patsubst %.htm, ../%.html, $(EHTM)) $(patsubst hebrew/%.htm, ../hebrew/%.html, $(HHTM))

$LECTURES_HTML:=$(patsubst %.htm, %.html, $(LECTURES_HTM))

everything: clean ../hebrew $(LECTURES_HTM) index.html ../rss2file ../rss
	make html
	./allhebrew
#index for the source directory
	-./chmod_site  #prevent chmod from failing the makefile
../rss2file:future lectures
	./h2rss.pl future ../rss2file
../rss: future lectures ../lectures
	./altrss.pl future .. ../rss announcement-file

announcement-file: future lectures ../lectures
	./altrss.pl future .. ../rss announcement-file
cal.htm: ../rss2file
	./combine_external.pl

hebrew/%.htm: hebrew/%
	./combine_lectures.pl $(basename $<)
hebrew/%.htm: hebrew/%.1
	./combine_lectures.pl $(basename $<)
hebrew/%.htm:%.1
	./combine_lectures.pl hebrew/$(basename $<)
#hebrew/%.htm:lectures			

%.htm:%
#	./combine_lectures.pl $(basename $<)
%.htm:%.1
	./combine_lectures.pl $(basename $<)
#%.htm:lectures

$(LECTURES_HTM): lectures

#mv hebrew files - do not move the whole directory
#because there may be links in the public hebrew directory,
#that we wish to preserve.

#the hebrew html target must come before the regular one, or the regular one 
#will be taken for hebrew files.
../hebrew/%.html: hebrew/%.htm #make_site.pl outline.pl
	./make_site.pl $<
	\mv -f ./gen/hebrew/$(@F) $@

#dummy dependency, till we get make updated
$(HTML):make_site.pl outline.html
#I am not sure lectures dir should be here, maybe we should have hardlinks instead of symlinks.

../%.html:%.htm# make_site.pl outline.pl
	./make_site.pl $<
	\mv -f ./gen/$(@F) $@
html:$(HTML)
echo_html:
	echo $(HTML)
.phony: clean everything html

#generate an index for the source directory
index.html:.
	./gen_index.pl
clean:
	\rm -f */*~ */*/*~ *~
../hebrew:
	mkdir -p ../hebrew
