# Makefile for qtm_clock
# Satofumi KAMIMURA
# $Id$

# Compile options
RUBY = ruby
CREATE_HISTORY_SCRIPT = ../../scripts/createHistory.rb

COPY_SOURCES = qtmclock_src/qtmclock/ConvertStdStringPath.h qtmclock_src/qtmclock/ConvertStdStringPath.cpp qtmclock_src/qtmclock/split.h qtmclock_src/qtmclock/split.cpp

VERSION = 0.1.5

all : $(COPY_SOURCES) counter_copy #bbs_copy

dist :
	-cd qtmclock_src/qtmclock/ && $(RM) -rf .tmp/
	-cd qtmclock_src/qtmclock_config/ && $(RM) -rf .tmp/
	-cd qtmclock_src/parts_generator/ && $(RM) -rf .tmp/
	-cd qtmclock_src/ && (if test -f Makefile; then $(MAKE) distclean; fi)
	$(RM) -rf qtmclock_src-$(VERSION)
	cp -R qtmclock_src qtmclock_src-$(VERSION)
	cd qtmclock_src-$(VERSION) && find -name '*.svn*' | xargs $(RM) -rf
	tar cvzf qtmclock_src-$(VERSION).tar.gz qtmclock_src-$(VERSION)
	$(RM) -rf qtmclock_src-$(VERSION)

clean :
	-cd qtmclock_src/ && (if test -f Makefile; then $(MAKE) distclean; fi)
	-cd qtmclock_src/qtmclock && (if test -f Makefile; then $(MAKE) distclean; fi)
	-cd qtmclock_src/qtmclock_config && (if test -f Makefile; then $(MAKE) distclean; fi)
	-cd qtmclock_src/parts_generator && (if test -f Makefile; then $(MAKE) distclean; fi)
	-cd qtmclock_src/qtmclock/ && $(RM) -rf .tmp/
	-cd qtmclock_src/qtmclock_config/ && $(RM) -rf .tmp/
	-cd output_html/ && $(RM) -rf *.* img includes dox
	-cd html/ && $(RM) index.html history.html
	-cd unittest/ && (if test -f Makefile; then $(MAKE) distclean; fi)
	-$(RM) unittest/save_archive_sample.txt unittest/save_setting_sample.txt

html : html_copy counter_copy #bbs_copy

html_copy :
	if ! test -d output_html/img; then mkdir output_html/img; fi
	if ! test -d output_html/includes; then mkdir output_html/includes; fi
	cp html/includes/*.php html/includes/*.tpl output_html/includes
	-cp html/favicon.ico output_html/
	-cp ~/sourceforge/qtmclock/config.php output_html/includes/
	cp html/img/*.png html/img/*.jpg html/img/*.gif output_html/img/
	$(RUBY) $(CREATE_HISTORY_SCRIPT) history_conf.txt history_log.txt
	nkf -e html/includes/recent_history_utf.tpl > html/includes/recent_history.tpl
	nkf -e html/includes/all_history_utf.tpl > html/includes/all_history.tpl
	cp  html/*.css html/*.php html/theme_parts.lzh output_html/
	mv qtmclock.rdf qtmclock.xml output_html/

counter_copy : html/includes/counter.php html/includes/CounterManager.php
html/includes/CounterManager.php : ../../../web/counter/CounterManager.php
	-cp $? $@

html/includes/counter.php : ../../../web/counter/counter.php
	-cp $? $@

#bbs_copy : html/includes/bbs_functions.php html/includes/AccessBbsData.php
#html/includes/bbs_functions.php : ../../../web/bbs/bbs_functions.php
#	-cp $? $@

#html/includes/AccessBbsData.php : ../../../web/bbs/AccessBbsData.php
#	-cp $? $@

upload : html
	rsync -avz -e ssh --delete output_html/* shell.sourceforge.jp:/home/groups/q/qt/qtmclock/htdocs/
	ssh shell.sourceforge.jp 'cd /home/groups/q/qt/qtmclock/htdocs && ln -fs ../Smarty Smarty && chmod a+rw includes'

.PHONY : all clean html html_copy upload
######################################################################

qtmclock_src/qtmclock/ConvertStdStringPath.h : ../../libs/system/qt/ConvertStdStringPath.h
	cp $< $@

qtmclock_src/qtmclock/ConvertStdStringPath.cpp : ../../libs/system/qt/ConvertStdStringPath.cpp
	cp $< $@

qtmclock_src/qtmclock/split.h : ../../libs/common/split.h
	cp $< $@

qtmclock_src/qtmclock/split.cpp : ../../libs/common/split.cpp
	cp $< $@
