## $Id: Makefile-files 2483 2007-02-01 12:56:20Z dhozac $  -*- makefile -*-

## Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
##  
## 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 2, 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, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##  

AM_INSTALLCHECK_STD_OPTIONS_EXEMPT +=	\
			$(sysv_src_SCRPTS) \
			$(sysv_gen_SCRPTS)

sysv_src_SCRPTS =	sysv/rebootmgr \
			sysv/vprocunhide \
			sysv/vservers-default \
			sysv/vservers-legacy \
			sysv/util-vserver
sysv_gen_SCRPTS =	sysv/v_gated \
			sysv/v_httpd \
			sysv/v_named \
			sysv/v_portmap \
			sysv/v_sendmail \
			sysv/v_smb \
			sysv/v_sshd \
			sysv/v_xinetd
sysv_conf_DTA =		sysv/vservers.conf

EXTRA_DIST +=		sysv/v_gated.subst \
			sysv/v_httpd.subst \
			sysv/v_named.subst \
			sysv/v_portmap.subst \
			sysv/v_sendmail.subst \
			sysv/v_smb.subst \
			sysv/v_sshd.subst \
			sysv/v_xinetd.subst \
			$(sysv_src_SCRPTS) \
			$(sysv_conf_DTA)

if HAVE_SYSV_INIT
sysconf_DATA +=		$(sysv_conf_DTA)
initrd_SCRIPTS +=	$(sysv_src_SCRPTS) \
			$(sysv_gen_SCRPTS)
endif

CLEANFILES +=		$(sysv_gen_SCRPTS)

sysv_SUBSTRULE =	s!/usr/lib/util-vserver!$(pkglibdir)!g; \
			s!^USR_SBIN=/usr/sbin$$!USR_SBIN=$(sbindir)!g; \
                        s!^DEFAULT_VSERVERDIR=/vservers$$!DEFAULT_VSERVERDIR=$(vserverdir)!g

sysv/%:			sysv/%.subst
			@mkdir -p $$(dirname '$@')
			sed -e '$(sysv_SUBSTRULE)' '$<' >'$@.tmp'
			@rm -f '$@'
			@if cmp -s '$<' '$@.tmp'; then \
				cp -p '$<' '$@'; \
			else \
				mv -f '$@.tmp' '$@'; \
			fi
			@rm -f '$@.tmp'
			@chmod a-w '$@'
