File: sysconftoolize.pl.in

package info (click to toggle)
sysconftool 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 516 kB
  • sloc: sh: 527; perl: 356; makefile: 171
file content (76 lines) | stat: -rw-r--r-- 1,357 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! @PERL@
# Copyright 2000-2013 S. Varshavchik.  See COPYING for
# distribution information.

use strict;
use warnings;
use Getopt::Long;

my $copy;

exit 1 unless GetOptions("copy" => \$copy );
$| = 1;

print "Checking for sysconftool: ";

my $aux_dir=".";
my $prefix="@prefix@";
my $datarootdir="@datarootdir@";

if (open(CONF, "configure.in") || open(CONF, "configure.ac"))
{
    my $l;

    while (defined ($l=<CONF>))
    {
	next unless $l =~ /AC_CONFIG_AUX_DIR[ \t]*\((.*)\)/;
	$aux_dir=$l;
	last;
    }
    close(CONF);
}

my $sysconftool="";

foreach ( ($aux_dir, ".", "..", "../.."))
{
	next unless -f "$_/sysconftool";

	$sysconftool="$_/sysconftool";
	print "$sysconftool\n";
	last;
}

unless ($sysconftool)
{
	system(($copy ? "cp -p":"@LN_S@") . " @datadir@/sysconftool/sysconftool .") == 0
		|| die "$!\n";
	print "@datadir@/sysconftool/sysconftool\n";
}

print "Checking Makefile.am: ";

open (MAM, "+<Makefile.am") || die "Makefile.am: $!\n";

my $found=0;
my $l;

while (defined ($l=<MAM>))
{
	next unless $l =~ /^install-configure:/;
	$found=1;
	print "Ok\n";
	last;
}

unless ($found)
{
	seek(MAM, 0, 2);
	open(F, "@datadir@/sysconftool/sysconftoolize.am") || die "sysconftoolize.am: $!\n";
	print MAM <F>;
	close(F);
	print "appended install-configure\n";
}
close(MAM);

print "Don't forget to add AC_PROG_SYSCONFTOOL to configure.in\n";