~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/tools/llvm-config/llvm-config.in.in

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@PERL@
 
2
##===- tools/llvm-config ---------------------------------------*- perl -*-===##
 
3
 
4
#                     The LLVM Compiler Infrastructure
 
5
#
 
6
# This file is distributed under the University of Illinois Open Source
 
7
# License. See LICENSE.TXT for details.
 
8
 
9
##===----------------------------------------------------------------------===##
 
10
#
 
11
# Synopsis: Prints out compiler options needed to build against an installed
 
12
#           copy of LLVM.
 
13
#
 
14
# Syntax:   llvm-config OPTIONS... [COMPONENTS...]
 
15
 
16
##===----------------------------------------------------------------------===##
 
17
 
 
18
use 5.006;
 
19
use strict;
 
20
use warnings;
 
21
use Cwd 'abs_path';
 
22
 
 
23
#---- begin autoconf values ----
 
24
my $PACKAGE_NAME        = q{@PACKAGE_NAME@};
 
25
my $VERSION             = q{@PACKAGE_VERSION@};
 
26
my $PREFIX              = q{@LLVM_PREFIX@};
 
27
my $LLVM_CONFIGTIME     = q{@LLVM_CONFIGTIME@};
 
28
my $LLVM_SRC_ROOT       = q{@abs_top_srcdir@};
 
29
my $LLVM_OBJ_ROOT       = q{@abs_top_builddir@};
 
30
my $ARCH                = lc(q{@ARCH@});
 
31
my $TARGET_TRIPLE       = q{@target@};
 
32
my $TARGETS_TO_BUILD    = q{@TARGETS_TO_BUILD@};
 
33
my $TARGET_HAS_JIT      = q{@TARGET_HAS_JIT@};
 
34
my @TARGETS_BUILT       = map { lc($_) } qw{@TARGETS_TO_BUILD@};
 
35
#---- end autoconf values ----
 
36
 
 
37
# Must pretend x86_64 architecture is really x86, otherwise the native backend
 
38
# won't get linked in.
 
39
$ARCH = "x86" if $ARCH eq "x86_64";
 
40
 
 
41
#---- begin Makefile values ----
 
42
my $CPPFLAGS            = q{@LLVM_CPPFLAGS@};
 
43
my $CFLAGS              = q{@LLVM_CFLAGS@};
 
44
my $CXXFLAGS            = q{@LLVM_CXXFLAGS@};
 
45
my $LDFLAGS             = q{@LLVM_LDFLAGS@};
 
46
my $SYSTEM_LIBS         = q{@LIBS@};
 
47
my $LLVM_BUILDMODE      = q{@LLVM_BUILDMODE@};
 
48
#---- end Makefile values ----
 
49
 
 
50
# Figure out where llvm-config is being run from.  Primarily, we care if it has
 
51
# been installed, or is running from the build directory, which changes the
 
52
# locations of some files.
 
53
 
 
54
# Convert the current executable name into its directory (e.g. ".").
 
55
my ($RUN_DIR) = ($0 =~ /^(.*)\/.*$/);
 
56
 
 
57
# Turn the directory into an absolute directory on the file system, also pop up
 
58
# from "bin" into the build or prefix dir.
 
59
my $ABS_RUN_DIR = abs_path("$RUN_DIR/..");
 
60
chomp($ABS_RUN_DIR);
 
61
 
 
62
# Compute the absolute object directory build, e.g. "foo/llvm/Debug".
 
63
my $ABS_OBJ_ROOT = "$LLVM_OBJ_ROOT/$LLVM_BUILDMODE";
 
64
$ABS_OBJ_ROOT = abs_path("$ABS_OBJ_ROOT") if (-d $ABS_OBJ_ROOT);
 
65
chomp($ABS_OBJ_ROOT);
 
66
 
 
67
my $INCLUDEDIR = "$ABS_RUN_DIR/include";
 
68
my $INCLUDEOPTION = "-I$INCLUDEDIR";
 
69
my $LIBDIR     = "$ABS_RUN_DIR/lib";
 
70
my $BINDIR     = "$ABS_RUN_DIR/bin";
 
71
if ($ABS_RUN_DIR eq $ABS_OBJ_ROOT) {
 
72
  # If we are running out of the build directory, the include dir is in the
 
73
  # srcdir.
 
74
  $INCLUDEDIR = "$LLVM_SRC_ROOT/include";
 
75
  # We need include files from both the srcdir and objdir.
 
76
  $INCLUDEOPTION = "-I$INCLUDEDIR -I$LLVM_OBJ_ROOT/include"
 
77
} else {
 
78
  # If installed, ignore the prefix the tree was configured with, use the
 
79
  # current prefix.
 
80
  $PREFIX = $ABS_RUN_DIR;
 
81
}
 
82
 
 
83
sub usage;
 
84
sub fix_library_names (@);
 
85
sub fix_library_files (@);
 
86
sub expand_dependencies (@);
 
87
sub name_map_entries;
 
88
 
 
89
# Parse our command-line arguments.
 
90
usage if @ARGV == 0;
 
91
my @components;
 
92
my $has_opt = 0;
 
93
my $want_libs = 0;
 
94
my $want_libnames = 0;
 
95
my $want_libfiles = 0;
 
96
my $want_components = 0;
 
97
foreach my $arg (@ARGV) {
 
98
    if ($arg =~ /^-/) {
 
99
        if ($arg eq "--version") {
 
100
            $has_opt = 1; print "$VERSION\n";
 
101
        } elsif ($arg eq "--prefix") {
 
102
            $has_opt = 1; print "$PREFIX\n";
 
103
        } elsif ($arg eq "--bindir") {
 
104
            $has_opt = 1; print "$BINDIR\n";
 
105
        } elsif ($arg eq "--includedir") {
 
106
            $has_opt = 1; print "$INCLUDEDIR\n";
 
107
        } elsif ($arg eq "--libdir") {
 
108
            $has_opt = 1; print "$LIBDIR\n";
 
109
        } elsif ($arg eq "--cppflags") {
 
110
            $has_opt = 1; print "$INCLUDEOPTION $CPPFLAGS\n";
 
111
        } elsif ($arg eq "--cflags") {
 
112
            $has_opt = 1; print "$INCLUDEOPTION $CFLAGS\n";
 
113
        } elsif ($arg eq "--cxxflags") {
 
114
            $has_opt = 1; print "$INCLUDEOPTION $CXXFLAGS\n";
 
115
        } elsif ($arg eq "--ldflags") {
 
116
            $has_opt = 1; print "-L$LIBDIR $LDFLAGS $SYSTEM_LIBS\n";
 
117
        } elsif ($arg eq "--libs") {
 
118
            $has_opt = 1; $want_libs = 1;
 
119
        } elsif ($arg eq "--libnames") {
 
120
            $has_opt = 1; $want_libnames = 1;
 
121
        } elsif ($arg eq "--libfiles") {
 
122
            $has_opt = 1; $want_libfiles = 1;
 
123
        } elsif ($arg eq "--components") {
 
124
            $has_opt = 1; print join(' ', name_map_entries), "\n";
 
125
        } elsif ($arg eq "--targets-built") {
 
126
            $has_opt = 1; print join(' ', @TARGETS_BUILT), "\n";
 
127
        } elsif ($arg eq "--host-target") {
 
128
            $has_opt = 1; print "$TARGET_TRIPLE\n";
 
129
        } elsif ($arg eq "--build-mode") {
 
130
            $has_opt = 1; print "$LLVM_BUILDMODE\n";
 
131
        } elsif ($arg eq "--obj-root") {
 
132
            $has_opt = 1; print abs_path("$LLVM_OBJ_ROOT/");
 
133
        } elsif ($arg eq "--src-root") {
 
134
            $has_opt = 1; print abs_path("$LLVM_SRC_ROOT/");
 
135
        } else {
 
136
            usage();
 
137
        }
 
138
    } else {
 
139
        push @components, $arg;
 
140
    }
 
141
}
 
142
 
 
143
# If no options were specified, fail.
 
144
usage unless $has_opt;
 
145
 
 
146
# If no components were specified, default to 'all'.
 
147
if (@components == 0) {
 
148
    push @components, 'all';
 
149
}
 
150
 
 
151
# Force component names to lower case.
 
152
@components = map lc, @components;
 
153
 
 
154
# Handle any arguments which require building our dependency graph.
 
155
if ($want_libs || $want_libnames || $want_libfiles) {
 
156
    my @libs = expand_dependencies(@components);
 
157
    print join(' ', fix_library_names(@libs)), "\n" if ($want_libs);
 
158
    print join(' ',  @libs), "\n" if ($want_libnames);
 
159
    print join(' ', fix_library_files(@libs)), "\n" if ($want_libfiles);
 
160
}
 
161
 
 
162
exit 0;
 
163
 
 
164
#==========================================================================
 
165
#  Support Routines
 
166
#==========================================================================
 
167
 
 
168
sub usage {
 
169
    print STDERR <<__EOD__;
 
170
Usage: llvm-config <OPTION>... [<COMPONENT>...]
 
171
 
 
172
Get various configuration information needed to compile programs which use
 
173
LLVM.  Typically called from 'configure' scripts.  Examples:
 
174
  llvm-config --cxxflags
 
175
  llvm-config --ldflags
 
176
  llvm-config --libs engine bcreader scalaropts
 
177
 
 
178
Options:
 
179
  --version          Print LLVM version.
 
180
  --prefix           Print the installation prefix.
 
181
  --src-root         Print the source root LLVM was built from.
 
182
  --obj-root         Print the object root used to build LLVM.
 
183
  --bindir           Directory containing LLVM executables.
 
184
  --includedir       Directory containing LLVM headers.
 
185
  --libdir           Directory containing LLVM libraries.
 
186
  --cppflags         C preprocessor flags for files that include LLVM headers.
 
187
  --cflags           C compiler flags for files that include LLVM headers.
 
188
  --cxxflags         C++ compiler flags for files that include LLVM headers.
 
189
  --ldflags          Print Linker flags.
 
190
  --libs             Libraries needed to link against LLVM components.
 
191
  --libnames         Bare library names for in-tree builds.
 
192
  --libfiles         Fully qualified library filenames for makefile depends.
 
193
  --components       List of all possible components.
 
194
  --targets-built    List of all targets currently built.
 
195
  --host-target      Target triple used to configure LLVM.
 
196
  --build-mode       Print build mode of LLVM tree (e.g. Debug or Release).
 
197
Typical components:
 
198
  all                All LLVM libraries (default).
 
199
  backend            Either a native backend or the C backend.
 
200
  engine             Either a native JIT or a bytecode interpreter.
 
201
__EOD__
 
202
    exit(1);
 
203
}
 
204
 
 
205
# Use -lfoo instead of libfoo.a whenever possible, and add directories to
 
206
# files which can't be found using -L.
 
207
sub fix_library_names (@) {
 
208
    my @libs = @_;
 
209
    my @result;
 
210
    foreach my $lib (@libs) {
 
211
        # Transform the bare library name appropriately.
 
212
        my ($basename) = ($lib =~ /^lib([^.]*)\.a/);
 
213
        if (defined $basename) {
 
214
            push @result, "-l$basename";
 
215
        } else {
 
216
            push @result, "$LIBDIR/$lib";
 
217
        }
 
218
    }
 
219
    return @result;
 
220
}
 
221
 
 
222
# Turn the list of libraries into a list of files.
 
223
sub fix_library_files(@) {
 
224
    my @libs = @_;
 
225
    my @result;
 
226
    foreach my $lib (@libs) {
 
227
        # Transform the bare library name into a filename.
 
228
        push @result, "$LIBDIR/$lib";
 
229
    }
 
230
    return @result;
 
231
}
 
232
 
 
233
#==========================================================================
 
234
#  Library Dependency Analysis
 
235
#==========================================================================
 
236
#  Given a few human-readable library names, find all their dependencies
 
237
#  and sort them into an order which the linker will like.  If we packed
 
238
#  our libraries into fewer archives, we could make the linker do much
 
239
#  of this work for us.
 
240
#
 
241
#  Libraries have two different types of names in this code: Human-friendly
 
242
#  "component" names entered on the command-line, and the raw file names
 
243
#  we use internally (and ultimately pass to the linker).
 
244
#
 
245
#  To understand this code, you'll need a working knowledge of Perl 5,
 
246
#  and possibly some quality time with 'man perlref'.
 
247
 
 
248
sub load_dependencies;
 
249
sub build_name_map;
 
250
sub have_native_backend;
 
251
sub find_best_engine;
 
252
sub expand_names (@);
 
253
sub find_all_required_sets (@);
 
254
sub find_all_required_sets_helper ($$@);
 
255
 
 
256
# Each "set" contains one or more libraries which must be included as a
 
257
# group (due to cyclic dependencies).  Sets are represented as a Perl array
 
258
# reference pointing to a list of internal library names.
 
259
my @SETS;
 
260
 
 
261
# Various mapping tables.
 
262
my %LIB_TO_SET_MAP; # Maps internal library names to their sets.
 
263
my %SET_DEPS;       # Maps sets to a list of libraries they depend on.
 
264
my %NAME_MAP;       # Maps human-entered names to internal names.
 
265
 
 
266
# Have our dependencies been loaded yet?
 
267
my $DEPENDENCIES_LOADED = 0;
 
268
 
 
269
# Given a list of human-friendly component names, translate them into a
 
270
# complete set of linker arguments.
 
271
sub expand_dependencies (@) {
 
272
    my @libs = @_;
 
273
    load_dependencies;
 
274
    my @required_sets = find_all_required_sets(expand_names(@libs));
 
275
    my @sorted_sets = topologically_sort_sets(@required_sets);
 
276
 
 
277
    # Expand the library sets into libraries.
 
278
    my @result;
 
279
    foreach my $set (@sorted_sets) { push @result, @{$set}; }
 
280
    return @result;
 
281
}
 
282
 
 
283
# Load in the raw dependency data stored at the end of this file.
 
284
sub load_dependencies {
 
285
    return if $DEPENDENCIES_LOADED;
 
286
    $DEPENDENCIES_LOADED = 1;
 
287
    while (<DATA>) {
 
288
        # Parse our line.
 
289
        my ($libs, $deps) = /^\s*([^:]+):\s*(.*)\s*$/;
 
290
        die "Malformed dependency data" unless defined $deps;
 
291
        my @libs = split(' ', $libs);
 
292
        my @deps = split(' ', $deps);
 
293
 
 
294
        # Record our dependency data.
 
295
        my $set = \@libs;
 
296
        push @SETS, $set;
 
297
        foreach my $lib (@libs) { $LIB_TO_SET_MAP{$lib} = $set; }
 
298
        $SET_DEPS{$set} = \@deps;
 
299
    }
 
300
    build_name_map;
 
301
}
 
302
 
 
303
# Build a map converting human-friendly component names into internal
 
304
# library names.
 
305
sub build_name_map {
 
306
    # Add entries for all the actual libraries.
 
307
    foreach my $set (@SETS) {
 
308
        foreach my $lib (sort @$set) {
 
309
            my $short_name = $lib;
 
310
            $short_name =~ s/^(lib)?LLVM([^.]*)\..*$/$2/;
 
311
            $short_name =~ tr/A-Z/a-z/;
 
312
            $NAME_MAP{$short_name} = [$lib];
 
313
        }
 
314
    }
 
315
 
 
316
    # Add target-specific entries
 
317
    foreach my $target (@TARGETS_BUILT) {
 
318
        # FIXME: Temporary, until we don't switch all targets
 
319
        if (defined $NAME_MAP{$target.'asmprinter'}) {
 
320
            $NAME_MAP{$target} = [$target.'info',
 
321
                                  $target.'asmprinter', 
 
322
                                  $target.'codegen']
 
323
        } else {
 
324
            $NAME_MAP{$target} = [$target.'info',
 
325
                                  $NAME_MAP{$target}[0]]
 
326
        }
 
327
 
 
328
        if (defined $NAME_MAP{$target.'asmparser'}) {
 
329
            push @{$NAME_MAP{$target}},$target.'asmparser'
 
330
        }
 
331
 
 
332
        if (defined $NAME_MAP{$target.'disassembler'}) {
 
333
            push @{$NAME_MAP{$target}},$target.'disassembler'
 
334
        }
 
335
    }
 
336
 
 
337
    # Add virtual entries.
 
338
    $NAME_MAP{'native'}  = have_native_backend() ? [$ARCH] : [];
 
339
    $NAME_MAP{'nativecodegen'} = have_native_backend() ? [$ARCH.'codegen'] : [];
 
340
    $NAME_MAP{'backend'} = have_native_backend() ? ['native'] : ['cbackend'];
 
341
    $NAME_MAP{'engine'}  = find_best_engine;
 
342
    $NAME_MAP{'all'}     = [name_map_entries];   # Must be last.
 
343
}
 
344
 
 
345
# Return true if we have a native backend to use.
 
346
sub have_native_backend {
 
347
    my %BUILT;
 
348
    foreach my $target (@TARGETS_BUILT) { $BUILT{$target} = 1; }
 
349
    return defined $NAME_MAP{$ARCH} && defined $BUILT{$ARCH};
 
350
}
 
351
 
 
352
# Find a working subclass of ExecutionEngine for this platform.
 
353
sub find_best_engine {
 
354
    if (have_native_backend && $TARGET_HAS_JIT) {
 
355
        return ['jit', 'native'];
 
356
    } else {
 
357
        return ['interpreter'];
 
358
    }
 
359
}
 
360
 
 
361
# Get all the human-friendly component names.
 
362
sub name_map_entries {
 
363
    load_dependencies;
 
364
    return sort keys %NAME_MAP;
 
365
}
 
366
 
 
367
# Map human-readable names to internal library names.
 
368
sub expand_names (@) {
 
369
    my @names = @_;
 
370
    my @result;
 
371
    foreach my $name (@names) {
 
372
        if (defined $LIB_TO_SET_MAP{$name}) {
 
373
            # We've hit bottom: An actual library name.
 
374
            push @result, $name;
 
375
        } elsif (defined $NAME_MAP{$name}) {
 
376
            # We've found a short name to expand.
 
377
            push @result, expand_names(@{$NAME_MAP{$name}});
 
378
        } else {
 
379
            print STDERR "llvm-config: unknown component name: $name\n";
 
380
            exit(1);
 
381
        }
 
382
    }
 
383
    return @result;
 
384
}
 
385
 
 
386
# Given a list of internal library names, return all sets of libraries which
 
387
# will need to be included by the linker (in no particular order).
 
388
sub find_all_required_sets (@) {
 
389
    my @libs = @_;
 
390
    my %sets_added;
 
391
    my @result;
 
392
    find_all_required_sets_helper(\%sets_added, \@result, @libs);
 
393
    return @result;
 
394
}
 
395
 
 
396
# Recursive closures are pretty broken in Perl, so we're going to separate
 
397
# this function from find_all_required_sets and pass in the state we need
 
398
# manually, as references.  Yes, this is fairly unpleasant.
 
399
sub find_all_required_sets_helper ($$@) {
 
400
    my ($sets_added, $result, @libs) = @_;
 
401
    foreach my $lib (@libs) {
 
402
        my $set = $LIB_TO_SET_MAP{$lib};
 
403
        next if defined $$sets_added{$set};
 
404
        $$sets_added{$set} = 1;
 
405
        push @$result, $set;
 
406
        find_all_required_sets_helper($sets_added, $result, @{$SET_DEPS{$set}});
 
407
    }
 
408
}
 
409
 
 
410
# Print a list of sets, with a label.  Used for debugging.
 
411
sub print_sets ($@) {
 
412
    my ($label, @sets) = @_;
 
413
    my @output;
 
414
    foreach my $set (@sets) { push @output, join(',', @$set); }
 
415
    print "$label: ", join(';', @output), "\n";
 
416
}
 
417
 
 
418
# Returns true if $lib is a key in $added.
 
419
sub has_lib_been_added ($$) {
 
420
    my ($added, $lib) = @_;
 
421
    return defined $$added{$LIB_TO_SET_MAP{$lib}};
 
422
}
 
423
 
 
424
# Returns true if all the dependencies of $set appear in $added.
 
425
sub have_all_deps_been_added ($$) {
 
426
    my ($added, $set) = @_;
 
427
    #print_sets("  Checking", $set);
 
428
    #print_sets("     Wants", $SET_DEPS{$set});
 
429
    foreach my $lib (@{$SET_DEPS{$set}}) {
 
430
        return 0 unless has_lib_been_added($added, $lib);
 
431
    }
 
432
    return 1;
 
433
}
 
434
 
 
435
# Given a list of sets, topologically sort them using dependencies.
 
436
sub topologically_sort_sets (@) {
 
437
    my @sets = @_;
 
438
    my %added;
 
439
    my @result;
 
440
    SCAN: while (@sets) { # We'll delete items from @sets as we go.
 
441
        #print_sets("So far", reverse(@result));
 
442
        #print_sets("Remaining", @sets);
 
443
        for (my $i = 0; $i < @sets; ++$i) {
 
444
            my $set = $sets[$i];
 
445
            if (have_all_deps_been_added(\%added, $set)) {
 
446
                push @result, $set;
 
447
                $added{$set} = 1;
 
448
                #print "Removing $i.\n";
 
449
                splice(@sets, $i, 1);
 
450
                next SCAN; # Restart our scan.
 
451
            }
 
452
        }
 
453
        die "Can't find a library with no dependencies";
 
454
    }
 
455
    return reverse(@result);
 
456
}
 
457
 
 
458
# Our library dependency data will be added after the '__END__' token, and will
 
459
# be read through the magic <DATA> filehandle.
 
460
__END__