# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../clockspeed/clockspeed.conf
# Copyright (C) 2008 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 ---

makeopt="$makeopt it leapsecs.dat"

clockspeed_config() {
	echo $CC > conf-cc
	echo $CC > conf-ld
	echo /$prefix > conf-home
	# clockspeed is x86 / solaris only ...
	[[ $arch = x86* ]] || sed -i 's/ clockspeed / /' Makefile
}

# the included install procedure is gather grave and not cross compile aware,
# since it builds a custom install binary doing the work ...
makeinstopt=
clockspeed_install() {
	while read dir file ; do
		# only available on x86*
		[[ $arch != x86* ]] && [[ $file = clockspeed* ]] && continue
		mkdir -p $root/$prefix/$dir
		cp $file $root/$prefix/$dir/$file
	done < <( grep "c(.*man\|c(.*bin" hier.c | cut -d \" --output-delimiter ' '  -f 2,4 )

	# install leapsecs.dat
	mkdir -p $root/var/state/clockspeed
	cp leapsecs.dat $root/var/state/clockspeed/

	# install clockctl
	rock_substitute "$confdir/clockctl.sh" > "$root$bindir/clockctl"
	chmod +x "$root$bindir/clockctl"
}

hook_add premake 5 'clockspeed_config'
hook_add postmake 5 "clockspeed_install"

hook_add preconf 5 "cp -v $( match_source_file -p leapsecs ) leapsecs.dat"