# Copyright (C) 2004, 2005  National Institute of Advanced Industrial Science and Technology
#
# This file is part of msgcab.
#
# msgcab is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# msgcab is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with msgcab; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

RUBY=ruby

SRC_CGI = $(wildcard *.cgi)
DST_CGI = $(patsubst %.cgi,cgi-bin/%.cgi,$(SRC_CGI))

all: $(DST_CGI)

cgi-bin:
	mkdir cgi-bin

$(DST_CGI): cgistub.erb cgi-bin
	$(RUBY) -rerb -e 'ERB.new(STDIN.read).run' $(patsubst cgi-bin/%.cgi,%.cgi,$@) < cgistub.erb > $@
	chmod 755 $@
