# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../sancp/sancp.conf
# Copyright (C) 2007 - 2011 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

if [ "$prefix_auto" == 1 ]; then
        sysconfdir="$sysconfdir/$pkg"
fi

var_append makeopt ' ' "linux"

makeinstopt=

pkg_sancp_prelude_prepatch() {
	echo_status "Enabling Prelude-IDS Support"
	var_append patchfiles ' ' "$confdir/*prelude*.diff"
}

pkg_sancp_premake() {
	# adjusting default config file location
	sed -i "/CONFIG_DIR/s,/.*,$sysconfdir\"," sancp.h
}

pkg_sancp_install() {

	# copying sancp binary
        mkdir -p $root/$prefix/bin
	cp -v sancp $root/$prefix/bin/sancp

	# copying default config file
	mkdir -p $root/$sysconfdir
	cp -v etc/sancp/sancp.conf $root/$sysconfdir/

	# creating log directory
	mkdir -p $root/$localstatedir/log
}

hook_add premake 5 'pkg_sancp_premake'
hook_add postmake 5 'pkg_sancp_install'

# including the officially released sancp patches from our package
var_append patchfiles ' ' "`match_source_file -p patch | tr '\n' ' '`"

# if libprelude is available patch sancp to become a prelude sensor
if pkginstalled libprelude ; then
	hook_add prepatch 5 'pkg_sancp_prelude_prepatch'
fi