#$Id: Makefile,v 1.1.6.6 2002/09/04 22:22:49 jetto Exp $
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are

static= 1x1.gif \
bugwritinghelp.html \
bug_status.html \
confirmhelp.html \
helpemailquery.html \
help.html \
how_to_mail.html \
notargetmilestone.html \
votehelp.html \
quicksearch.html \
quicksearchhack.html \
robots.txt \
quicksearch.js \
localconfig.js \
ant.jpg \
bugzilla.dtd \
index.html

cgi= attachment.cgi \
buglist.cgi \
changepassword.cgi \
createaccount.cgi \
colchange.cgi \
describecomponents.cgi \
describekeywords.cgi \
doeditparams.cgi \
duplicates.cgi \
editattachstatuses.cgi \
editcomponents.cgi \
editgroups.cgi \
editkeywords.cgi \
editmilestones.cgi \
editparams.cgi \
editproducts.cgi \
editusers.cgi \
editversions.cgi \
enter_bug.cgi \
index.cgi \
long_list.cgi \
process_bug.cgi \
post_bug.cgi \
sanitycheck.cgi \
show_activity.cgi \
show_bug.cgi \
showattachment.cgi \
showdependencygraph.cgi \
showdependencytree.cgi \
sidebar.cgi \
query.cgi \
queryhelp.cgi \
quips.cgi \
relogin.cgi \
reports.cgi \
token.cgi \
userprefs.cgi \
votes.cgi \
xml.cgi 

lib_noexe=CGI.pl \
Bug.pm \
RelationSet.pm \
Token.pm \
Attachment.pm \
bug_form.pl \
defparams.pl \
globals.pl

lib_exe=checksetup.pl \
collectstats.pl \
importxml.pl \
processmail \
syncshadowdb \
whineatnews.pl \
move.pl 

data_dir= shadow \
data

config_files= localconfig

other= README \
docs \
contrib


INSTALL=/usr/bin/install
PERL=/usr/bin/perl

DIR_MODE= 0755

DESTDIR =

#used for the substition of the dash bang string
TMP_INSTALL_DIR=/tmp/bugzilla

STATIC_DIR= 
STATIC_MODE= 0644
STATIC_GROUP=root
STATIC_OWNER=root

CGI_DIR= 
CGI_MODE= 0754
CGI_GROUP=root
CGI_OWNER=root

LIB_DIR=
LIB_EXE_MODE= 0755
LIB_NOEXE_MODE= 0644
LIB_GROUP=root
LIB_OWNER=root

DATA_DIR_PARENT= 
DATA_DIR_MODE= 0755
DATA_DIR_GROUP=www-data
DATA_DIR_OWNER=www-data

TEMPLATE_DIR=
TEMPLATE_DIR_MODE= 0755
TEMPLATE_MODE= 0644
TEMPLATE_GROUP=root
TEMPLATE_OWNER=root
TEMPLATE_FILES=$(shell find template -type f | sed -e 's!template/!!')


#install: sub_dashbang install_static install_cgi install_lib install_data_dir \
#         install_config_files install_other

install: sub_dashbang install_static install_cgi install_lib install_data_dir \
	 remove_tmp_install_dir install_template

list_files:
	@echo $(static) $(cgi) $(lib_noexe) $(lib_exe) $(TEMPLATE_FILES)

#substitute de the perl path in the #! string
sub_dashbang:
	$(INSTALL) -d $(TMP_INSTALL_DIR)
	for FIC in $(cgi) $(lib_exe) $(lib_noexe) ; do \
		sed -e '1s:#!.*perl:#!$(PERL):' $$FIC >$(TMP_INSTALL_DIR)/$$FIC; \
	done

remove_tmp_install_dir:
	-rm -rf $(TMP_INSTALL_DIR)

install_static:
	$(INSTALL) -d -m $(DIR_MODE) -o $(STATIC_OWNER)  -g $(STATIC_GROUP) $(DESTDIR)$(STATIC_DIR)
	for FIC in $(static) ; do \
		$(INSTALL) -m $(STATIC_MODE) -o $(STATIC_OWNER) -g $(STATIC_GROUP) $$FIC $(DESTDIR)$(STATIC_DIR) ;\
	done
	$(INSTALL) -d -m $(DIR_MODE) -o $(STATIC_OWNER)  -g $(STATIC_GROUP) $(DESTDIR)$(STATIC_DIR)/css
	$(INSTALL) -m $(STATIC_MODE) -o $(STATIC_OWNER) -g $(STATIC_GROUP) css/* $(DESTDIR)$(STATIC_DIR)/css
	
install_cgi:
	$(INSTALL) -d -m $(DIR_MODE) -o $(CGI_OWNER) -g $(CGI_GROUP) $(DESTDIR)$(CGI_DIR)
	for FIC in $(cgi) ; do \
		$(INSTALL) -m $(CGI_MODE) -o $(CGI_OWNER) -g $(CGI_GROUP) $(TMP_INSTALL_DIR)/$$FIC $(DESTDIR)$(CGI_DIR) ;\
	done

install_lib:
	$(INSTALL) -d -m $(DIR_MODE) -o $(LIB_OWNER) -g $(LIB_GROUP) $(DESTDIR)$(LIB_DIR)
	for FIC in $(lib_noexe) ; do \
		$(INSTALL) -m $(LIB_NOEXE_MODE) -o $(LIB_OWNER) -g $(LIB_GROUP) $(TMP_INSTALL_DIR)/$$FIC $(DESTDIR)$(LIB_DIR) ;\
	done ; \
	for FIC in $(lib_exe) ; do \
		$(INSTALL) -m $(LIB_EXE_MODE) -o $(LIB_OWNER) -g $(LIB_GROUP) $(TMP_INSTALL_DIR)/$$FIC $(DESTDIR)$(LIB_DIR) ;\
	done


install_data_dir:
	$(INSTALL) -d -m $(DIR_MODE) -o $(DATA_DIR_OWNER) -g $(DATA_DIR_GROUP) $(DESTDIR)$(DATA_DIR_PARENT)
	for FIC in $(data_dir) ; do \
		$(INSTALL) -d -m $(DATA_DIR_MODE) -o $(DATA_DIR_OWNER) -g $(DATA_DIR_GROUP) $(DESTDIR)$(DATA_DIR_PARENT)/$$FIC ;\
	done

install_template:
	for DIR in $(sort $(dir $(TEMPLATE_FILES) ) ) ; do \
		$(INSTALL) -d -m $(TEMPLATE_DIR_MODE) -o $(TEMPLATE_OWNER) -g $(TEMPLATE_GROUP) $(DESTDIR)$(TEMPLATE_DIR)/$$DIR ; \
	done
	for FIC in $(TEMPLATE_FILES) ; do \
		$(INSTALL) -m $(TEMPLATE_MODE) -o $(TEMPLATE_OWNER) -g $(TEMPLATE_GROUP) template/$$FIC $(DESTDIR)$(TEMPLATE_DIR)/`dirname $$FIC` ;\
	done
	
