TARGETDIR = ./html
INSTALL_TARGETDIR = $(RUBYCOCOA_DIR)/doc

RUBY = ruby
SED = sed
ERB = erb
RD2HTML = rd2 -r rd/rd2html-lib
CSS = rubyStyle.css
RD2HTML_OPTIONS = --with-css=$(CSS)
VERSION_RB = ../lib/tempura/version.rb
VERSION_SCRIPT = 'sub!( /^(.*最新バージョンは ).*( です。.*)/, "\\1"+Tempura::Version.to_s+"\\2")'

TARGET_HTML = \
	$(TARGETDIR)/tempura.ja.html \
	$(TARGETDIR)/changes.ja.html \
	$(TARGETDIR)/references.ja.html

TARGET = $(TARGET_HTML)

all:	$(TARGETDIR) $(TARGET) $(TARGETDIR)/$(CSS)

clean:
	-rm -f $(TARGETDIR)/*.html $(TARGETDIR)/*.css
	-rm -f *~
	-rm -f *.bak

hoge:
	$(RUBY) -r $(VERSION_RB) -pe $(VERSION_SCRIPT) tempura.ja.rd

$(TARGETDIR):
	-mkdir -p $(TARGETDIR)

$(TARGETDIR)/$(CSS):	$(CSS)
	-cp -f $< $(TARGETDIR)/

$(TARGETDIR)/references.ja.html:	references.ja.rd
	$(RD2HTML) $(RD2HTML_OPTIONS) --html-title="Tempura : $<" $< > $@

$(TARGETDIR)/changes.ja.html:	changes.ja.rd
	$(RD2HTML) $(RD2HTML_OPTIONS) --html-title="Tempura : $<" $< > $@

$(TARGETDIR)/tempura.ja.html:	tempura.ja.rd $(VERSION_RB)
	-mv -f $< $<.bak
	$(RUBY) -r $(VERSION_RB) -pe $(VERSION_SCRIPT) $<.bak > $<
	$(RD2HTML) $(RD2HTML_OPTIONS) --html-title="Tempura : $<" $< > $@
	-rm -f $<.bak
