###############################################################################
# Copyright (C) 2006 Tetsuya Kimata <kimata@acapulco.dyndns.org>
#
# All rights reserved.
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the authors be held liable for any
# damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any
# purpose, including commercial applications, and to alter it and
# redistribute it freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must
#    not claim that you wrote the original software. If you use this
#    software in a product, an acknowledgment in the product
#    documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must
#    not be misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source
#    distribution.
#
# $Id: GNUmakefile.in 726 2005-09-24 14:19:32Z svn $
###############################################################################
#
# * 動作
#   - make dist     : 配布アーカイブの作成
#
###############################################################################

###############################################################################
# 基本設定
PACKAGE     := @PACKAGE_NAME@
VERSION     := @PACKAGE_VERSION@

TARGET      := $(PACKAGE).so
PKGDIR   	:= $(PACKAGE)-$(VERSION)
DISTFILE 	:= $(PKGDIR).tgz
DISTWINTFILE:= $(PACKAGE)-$(VERSION).msi

SVN         := @SVN@
TAR         := @TAR@

###############################################################################
# ターゲット
all: dist

dist: TMPDIR := $(shell mktemp -d -t @PACKAGE_NAME@.XXXXXX 2>/dev/null)
dist:
	svn export . $(TMPDIR)/$(PKGDIR)
	rm -rf $(TMPDIR)/$(PKGDIR)/pseudo
	touch -t `date "+%m%d"`0000 `find $(TMPDIR)`
	tar zcvf $(DISTFILE) -C $(TMPDIR) $(PKGDIR)
	rm -Rf $(TMPDIR)

dist-sf: DIST_FILE = $(shell ls -t | grep -E 'mod_uploader-.*\.tgz' | head -n 1)
dist-sf: DIST_VERSION = $(shell echo $(DIST_FILE) | sed 's/mod_uploader-\(.*\)\.tgz/\1/')
dist-sf: dist
	perl -I util util/sf_upload.pl --mode=release --package=mod_uploader --version=$(DIST_VERSION) --file=$(DIST_FILE)

dist-win-sf: DIST_FILE = $(shell ls -t | grep -E 'mod_uploader-.*\.msi' | head -n 1)
dist-win-sf: DIST_VERSION = $(shell echo $(DIST_FILE) | sed 's/mod_uploader-\(.*\)\.msi/\1/')
dist-win-sf:
	perl -I util util/sf_upload.pl --mode=release --package=mod_uploader-win32 --version=$(DIST_VERSION) --file=$(DIST_FILE)

doc-update:
	cd doc && $(MAKE) $@

cvs-check:
	./util/cvs_check.sh
	@echo -e "\033[1;32mOK\033[0m"

distclean: clean
	@ls -1 | egrep '$(PACKAGE)-.*\.tgz' | xargs rm -f

clean:
	@rm -f *~ \#*\#
	@find /tmp -name "@PACKAGE_NAME@.*" -user `whoami` -maxdepth 1 -mmin +5 | xargs rm -rf {}


.SUFFIXES: 
.PHONY: dist dist-win dist-sf dist-win-sf doc-update cvs-check distclean clean

# Local Variables:
# mode: makefile
# coding: utf-8-unix
# End:
