/*
 *	aegis - project change supervisor
 *	Copyright (C) 1991-1996, 1998, 2001, 2002, 2004-2008 Peter Miller
 *	Copyright (C) 2007, 2009 Walter Franzini
 *
 *	This program 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 3 of the License, or
 *	(at your option) any later version.
 *
 *	This program 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 this program. If not, see
 *	<http://www.gnu.org/licenses/>.
 */

configuration_directory = "aegis.conf.d";

/*
 * how to build the project
 * mandatory
 */
build_command =
        "PATH=${path_reduce /usr/local/bin:${env PATH}} "
        "SHELL=${sh} "
	"cook -b ${source etc/Howto.cook} -nl -st "
	"project=$project "
	"change=$change "
	"version=$version "
	"arch=$uname "
	"search_path=$search_path "
        "autoconf=${Project_Specific autoconf} "
        "autoheader=${Project_Specific autoheader} "
	"configure_args=${Project_Specific configure_args} "
        "${uname}_c++=${Project_Specific ${uname}_c++} "
        "c++=${Project_Specific c++} "
	"${uname}_c++_flags=${Project_Specific ${uname}_c++_flags} "
	"${uname}_ld_flags=${Project_Specific ${uname}_ld_flags} "
	"${uname}_libs=${Project_Specific ${uname}_libs} "
	"primary_arch=${Project_Specific primary_arch} "
	;


/*
 * When do -Integrate_Begin, link the baseline to the integration directory,
 * rather than copying it.  This should be much faster.
 *
 * There is a gotcha: all the recipes in Howto.cook must unlink their targets
 * before re-creating them, otherwise the baseline will be trashed.
 */
link_integration_directory = true;

/* don't link/copy the bin dir */
integrate_begin_exceptions = [ "linux-*/bin/*" ];

/*
 * At integrate pass time, the modification times of the files are
 * updated.  This commands gives cook a channce to get the fingerprints
 * back in sync, which in turn speeds up development builds.
 * We don't want to execute an empty rm, but xargs -r is not portable,
 * so use a while read loop.
 */
build_time_adjust_notify_command =
    "set +e; "
    "find . -name .cook.fp -print | while read f;do rm -f ${$}f;done; "
    "cook -nl -st --fp-update"
    ;

/*
 * create a new history
 * always executed as the project owner
 */
history_create_command =
	"fhist ${quote ${basename $history}} -cr -cu -i ${quote $input} \
-p ${quote ${dirname $history}} -r";

/*
 * get a file from history
 * may be executed by developers
 */
history_get_command =
	"fhist ${quote ${basename $history}} -e ${quote $edit} \
-o ${quote $output} -p ${quote ${dirname $history}} -v 0";

/*
 * add a new change to the history
 * always executed as the project owner
 */
history_put_command =
	"fhist ${quote ${basename $history}} -cr -cu -i ${quote $input} \
-p ${quote ${dirname $history}} -r";

/*
 * query the topmost edit of a history file
 * Result to be printed on stdout.
 * may be executed by developers
 */
history_query_command =
	"fhist ${quote ${basename $history}} -l 0 \
-p ${quote ${dirname $history}} -q";

/*
 * difference of 2 files
 */
diff_command =
	"fcomp -w -s ${quote $original} ${quote $input} -o ${quote $output}";

patch_diff_command =
	"set +e; "
	"diff -u -L ${quote $index} -L ${quote $index} "
	"${quote $original} ${quote $input} > ${quote $output}; "
	"test $? -le 1";

/*
 * difference of 3 files
 */
merge_command =
	"fmerge -ignore_identical_conflicts "
        "${quote $original} ${quote $mostrecent} ${quote $input} "
        "-o ${quote $output} -c ${quote $output,C}";

/*
 * whenever files are added to or removed from the change,
 * execute the following command.
 *
 * The project files are wiped, too, because a removed file will alter
 * the project file list.
 */
change_file_command =
    "rm -f etc/cook/change_files.$version etc/cook/project_files.$version";
project_file_command = "rm -f etc/cook/project_files.$version";

/*
 * make sure the filenames are OK with Windows.
 */
windows_filename_required = true;

/*
 * watch out for these
 */
trojan_horse_suspect =
[
	"*.awk",
	"*.cook",
	"*.sh",
];

/*
 * Limit filenames to 15 characters.
 *
 * For a while the Aegis sources could be compiled on old V7 14
 * character filename systems, however that hasn't be true for some
 * time (due to all sorts of files being constructed at build time, all
 * of which were longer than the source files).
 *
 * When the langauge was change from C to C++, the file name length
 * increased to 15.  Any limit could have been chosen, including 255,
 * but I have this feeling that shorter filenames are better.
 */
maximum_filename_length = 15;
posix_filename_charset = true;

filename_pattern_reject =
[
    /* No Aegis-special file names. */
    "*,*",

    /* No C source files */
    "*.c",

    /* No C++ files with upper case letters in their names. */
    "*[A-Z]*.cc"
    "*[A-Z]*.h"

    /* No alternative C++ file names. */
    "*.C",
    "*.CC",
    "*.[cC][xX][xX]",
    "*.H",
    "*.[hH][hH]",
    "*.[hH][xX][xX]",
];

/*
 * new file templates
 */
file_template =
[
        {
                pattern = [ "aegis.conf.d/site.conf" ];
                body = "${read_file ${source etc/template/site.conf abs}}";
        },
	{
		pattern = [ "*.[cyl]" ];
		body = "${read_file ${source etc/template/c abs}}";
	},
	{
		pattern = [ "*.cc" ];
		body = "${read_file ${source etc/template/cc abs}}";
	},
	{
		pattern = [ "*.h" ];
		body = "${read_file ${source etc/template/h abs}}";
	},
	{
		pattern = [ "test/*/*.sh" ];
		body = "${read_file ${source etc/template/test abs}}";
	},
	{
		pattern = [ "*.sh" ];
		body = "${read_file ${source etc/template/sh abs}}";
	},
	{
		pattern = [ "*.man", "*.[12345678]" ];
		body = "${read_file ${source etc/template/man abs}}";
	},
	{
		pattern = [ "*.rpt" ];
		body = "${read_file ${source etc/template/report abs}}";
	},
	{
		pattern = [ "*.so", "*.ms", "*.me" ];
		body = "${read_file ${source etc/template/ms abs}}";
	},
	{
		pattern = [ "*.po" ];
		body = "${read_file ${source etc/template/po abs}}";
	},
	{
		pattern = [ "*" ];
		body = "${read_file ${source etc/template/generic abs}}";
	}
];

develop_begin_command = "ln -s $baseline bl";

/*
 * Remove these files before we start integrating, to ensure that they
 * will be rebuild containing the correct version information.
 */
integrate_begin_command =
	"rm -f \
etc/cook/change_files* \
etc/cook/project_files* \
etc/version.so \
common/patchlevel.h \
bl blbl blblbl blblblbl \
";

test_command =
	"AEGIS_SEARCH_PATH=$search_path "
	"EXEC_SEARCH_PATH=${search_path_exe} "
	"PATH=${path_reduce ${addpathsuffix $arch/bin ${search_path_exe}} "
            "/usr/local/bin ${env PATH}} "
        # for shared library, eventually...
        # "LD_LIBRARY_PATH=${path_reduce "
        #    "${addpathsuffix $arch/libaegis/.libs ${search_path_exe}} "
        #    " ${env LD_LIBRARY_PATH} /lib /usr/lib} "
	"$shell ${quote $filename} ${quote $arch}";

new_test_filename =
    "test/"
    "${zpad $hundred 2}/"
    "t${zpad $number 4}${left $type 1}-${left $user 4}.sh"
    ;

project_specific =
[
    {
	name = "html:body-begin";
	value =
            @<a href="http://aegis.sourceforge.net/"> <img
            src="http://aegis.sourceforge.net/aegis.png" align=left
            border=0></a><a href="http://aegis.sourceforge.net/"><img
            src="http://aegis.sourceforge.net/aegis.png" align=right
            border=0></a>@;
    },
    {
	name = "html:body-end";
	value =
            @<hr>Using the <i>aeget</i> interface, you can set HTML
            headers and footers for this listing separately for each
            project using the &ldquo;html:body-begin&rdquo; and
            &ldquo;html:body-end&rdquo; project specific attributes, see
            <i>aeget</i>(1) for more information.@;
    },
];

/*
 * Add Signed-Off-By: lines to all change sets as they flow through the
 * process.
 */
signed_off_by = true;
