all: all0 another
all0: v.rd rd2html rd2txt
package: package0 another-package
package0: todo.rd changes.rd all0 clear-sample-v.rd cp-readme delbak

RootDir = ..
WorkDir = $(RootDir)/work
AnotherDir = $(RootDir)/$(Another)
SampleDir = $(RootDir)/sample
SampleRB = $(SampleDir)/sample-*.rb
Sample = $(wildcard $(SampleRB))
SampleVRD = $(Sample:$(SampleDir)/%.rb=%.rb.v.rd)

#setver:
# why? twice
index.rd: $(RootDir)/VERSION
	ruby $(WorkDir)/move-version.rb `cat ../VERSION` README*.rd index*.rd

index-ja.rd: $(RootDir)/VERSION
	ruby $(WorkDir)/move-version.rb `cat ../VERSION` README*.rd index*.rd

todo.rd: $(AnotherDir)/todo.rd
	cp -p $(AnotherDir)/todo.rd .
#	cp $(AnotherDir)/todo.rd .
#	touch todo.rd -r $(AnotherDir)/todo.rd

changes.rd: $(AnotherDir)/changes.rd
	cp -p $(AnotherDir)/changes.rd .
#	cp $(AnotherDir)/changes.rd .
#	touch changes.rd -r $(AnotherDir)/changes.rd

v.rd: $(SampleVRD)

clear-sample-v.rd:
	@echo "rm -f *.rb.v.rd"
	@rm -f $(SampleVRD)

cp-readme:
	cp README*.txt $(RootDir)

delbak:
	rm -f *~

%.rb.v.rd: $(SampleDir)/%.rb
	$(TXT2RD) $< > $@

samples$(PostFix).html: $(SampleVRD) samples$(PostFix).rd
	$(RD2HTML) samples$(PostFix).rd | $(ADDSTY) > $@ || rm -f $@

another:
	cd $(AnotherDir); make all0

another-package:
	cd $(AnotherDir); make package0
