-
Notifications
You must be signed in to change notification settings - Fork 6
/
midgard-config.in
91 lines (78 loc) · 2.62 KB
/
midgard-config.in
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
exec perl -x $0 $@
#!perl
#$Id$
use Getopt::Long;
@options = (
"version",
"prefix",
"exec-prefix",
"cppflags",
"libs",
"sitegroups",
"filetemplates",
"pagelinks",
"cache-fix",
"multilang",
"page-owner",
"vc",
"repligard-enhance",
"quota",
"host",
"report",
);
@optspecs = map { "$_+"; } @options;
%option = ();
GetOptions(\%option, @optspecs);
if ((scalar keys %option) == 0) {
@optspecs = map { "[--$_]"; } @options;
print "Usage: $0 ", join(' ', @optspecs), "\n";
}
$eol = "\n";
if ($option{report}) {
foreach (@options) { $option{$_} = 1; }
}
if ($option{version}) { print prompt('version'), "@VERSION@$eol"; }
if ($option{sitegroups}) { print prompt('sitegroups'), "@USE_MIDGARD_SITEGROUPS@$eol"; }
if ($option{filetemplates}) { print prompt('filetemplates'), "@USE_MIDGARD_FILETEMPLATES@$eol"; }
if ($option{pagelinks}) { print prompt('pagelinks'), "@USE_MIDGARD_PAGELINKS@$eol"; }
if ($option{cache-fix}) { print prompt('cache-fix'), "@USE_CACHE_FIX@$eol"; }
if ($option{multilang}) { print prompt('multilang'), "@USE_MIDGARD_MULTILANG@$eol"; }
if ($option{page-owner}) { print prompt('page-owner'), "@USE_MIDGARD_PAGE_OWNER@$eol"; }
if ($option{vc}) { print prompt('vc'), "@USE_MIDGARD_VC@$eol"; }
if ($option{repligard-enhance}) { print prompt('repligard-enhance'), "@USE_MIDGARD_REPLIGARD_ENHANCE@$eol"; }
if ($option{quota}) { print prompt('quota'), "@USE_MIDGARD_QUOTA@$eol"; }
if ($option{prefix}) { print prompt('prefix'), "@prefix@$eol"; }
if ($option{host}) { print prompt('host'), "@host@$eol"; }
$prefix = "@prefix@";
$exec_prefix="@exec_prefix@";
if ($option{'exec-prefix'}) { print prompt('exec-prefix'), "@exec_prefix@$eol"; }
if ($option{'cppflags'}) {
my @flags = ();
push @flags, "@CPPFLAGS@" if "@CPPFLAGS@";
push @flags, "@MIDGARD_CFLAGS@" if "@MIDGARD_CFLAGS@";
my $incdir = "@includedir@";
$incdir =~ s[/midgard/?$][];
push @flags, "-I$incdir" if $incdir ne "/usr/include";
print prompt('cppflags'), join(" ", @flags), $eol;
}
if ($option{libs}) {
my @libs = ();
push @libs, "@LDFLAGS@" if "@LDFLAGS@";
push @libs, "@LIBS@" if "@LIBS@";
push @libs, "@MIDGARD_LIBS@" if "@MIDGARD_LIBS@";
my $libdir = "@libdir@";
push @libs, "-L$libdir" if $libdir ne "/usr/lib";
push @libs, "-lmidgard";
print prompt('libs'), join(" ", @libs);
}
sub prompt
{
if (!$option{report}) { return ""; }
if (!$prompt_length) {
foreach (@options) {
if (length > $prompt_length) { $prompt_length = length; }
}
}
return sprintf("%-${prompt_length}s: ", $_[0]);
}