blob: a8eb12abd8a5c1ae7eee27a4875c1b262ebd0c0e [file] [log] [blame]
Reid Spencerb195d9d2006-03-23 23:21:29 +00001#!@PERL@
Chris Lattner584073a2006-06-02 18:58:21 +00002##===- tools/llvm-config ---------------------------------------*- perl -*-===##
3#
4# The LLVM Compiler Infrastructure
Reid Spencerf2722ca2006-03-22 15:59:55 +00005#
Chris Lattner584073a2006-06-02 18:58:21 +00006# This file was developed by Eric Kidd and is distributed under
7# the University of Illinois Open Source License. See LICENSE.TXT for details.
8#
9##===----------------------------------------------------------------------===##
Reid Spencerf2722ca2006-03-22 15:59:55 +000010#
11# Synopsis: Prints out compiler options needed to build against an installed
12# copy of LLVM.
13#
Chris Lattner7f71e212006-04-13 04:21:31 +000014# Syntax: llvm-config OPTIONS... [COMPONENTS...]
Chris Lattner584073a2006-06-02 18:58:21 +000015#
16##===----------------------------------------------------------------------===##
Reid Spencerf2722ca2006-03-22 15:59:55 +000017
Reid Spencerb195d9d2006-03-23 23:21:29 +000018use 5.006;
Reid Spencerf2722ca2006-03-22 15:59:55 +000019use strict;
20use warnings;
21
22#---- begin autoconf values ----
Reid Spencer2d2c2f22006-06-02 18:31:41 +000023my $PACKAGE_NAME = q{@PACKAGE_NAME@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000024my $VERSION = q{@PACKAGE_VERSION@};
25my $PREFIX = q{@LLVM_PREFIX@};
Reid Spencer2d2c2f22006-06-02 18:31:41 +000026my $LLVM_CONFIGTIME = q{@LLVM_CONFIGTIME@};
27my $LLVM_SRC_ROOT = q{@abs_top_srcdir@};
28my $LLVM_OBJ_ROOT = q{@abs_top_builddir@};
29my $LLVM_ON_WIN32 = q{@LLVM_ON_WIN32@};
30my $LLVM_ON_UNIX = q{@LLVM_ON_UNIX@};
31my $LLVMGCCDIR = q{@LLVMGCCDIR@};
32my $LLVMGCC = q{@LLVMGCC@};
33my $LLVMGXX = q{@LLVMGXX@};
34my $LLVMGCC_VERSION = q{@LLVMGCC_VERSION@};
35my $LLVMGCC_MAJVERS = q{@LLVMGCC_MAJVERS@};
36my $ENDIAN = q{@ENDIAN@};
37my $SHLIBEXT = q{@SHLIBEXT@};
38my $EXEEXT = q{@EXEEXT@};
39my $OS = q{@OS@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000040my $ARCH = lc(q{@ARCH@});
Reid Spencer2d2c2f22006-06-02 18:31:41 +000041my $TARGET_TRIPLE = q{@target@};
42my $TARGETS_TO_BUILD = q{@TARGETS_TO_BUILD@};
Reid Spencerb195d9d2006-03-23 23:21:29 +000043my $TARGET_HAS_JIT = q{@TARGET_HAS_JIT@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000044my @TARGETS_BUILT = map { lc($_) } qw{@TARGETS_TO_BUILD@};
David Greenea696d242007-06-28 19:36:08 +000045my $EXPENSIVE_CHECKS = q{@EXPENSIVE_CHECKS@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000046#---- end autoconf values ----
47
Jeff Cohen02c91ef2007-03-28 04:45:02 +000048# Must pretend x86_64 architecture is really x86, otherwise the native backend
49# won't get linked in.
50$ARCH = "x86" if $ARCH eq "x86_64";
51
Reid Spencerf2722ca2006-03-22 15:59:55 +000052#---- begin Makefile values ----
David Greenea696d242007-06-28 19:36:08 +000053my $CPPFLAGS = q{@LLVM_CPPFLAGS@};
Reid Spencerf72538e2007-01-06 02:48:03 +000054my $CFLAGS = q{@LLVM_CFLAGS@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000055my $CXXFLAGS = q{@LLVM_CXXFLAGS@};
56my $LDFLAGS = q{@LLVM_LDFLAGS@};
Reid Spencer1bc68642006-07-27 23:00:30 +000057my $SYSTEM_LIBS = q{@LIBS@};
Chris Lattnerabdbae72006-06-02 19:13:29 +000058my $LLVM_BUILDMODE = q{@LLVM_BUILDMODE@};
Reid Spencerf2722ca2006-03-22 15:59:55 +000059#---- end Makefile values ----
60
Chris Lattner16ad6182006-06-02 21:48:10 +000061# Figure out where llvm-config is being run from. Primarily, we care if it has
62# been installed, or is running from the build directory, which changes the
63# locations of some files.
64
Chris Lattnere02b97b2006-06-02 01:23:18 +000065# Convert the current executable name into its directory (e.g. ".").
Chris Lattner16ad6182006-06-02 21:48:10 +000066my ($RUN_DIR) = ($0 =~ /^(.*)\/.*$/);
67
68# Turn the directory into an absolute directory on the file system, also pop up
69# from "bin" into the build or prefix dir.
70my $ABS_RUN_DIR = `cd $RUN_DIR/..; pwd`;
71chomp($ABS_RUN_DIR);
72
73# Compute the absolute object directory build, e.g. "foo/llvm/Debug".
Chris Lattner3e347f22006-06-06 23:54:15 +000074my $ABS_OBJ_ROOT = "$LLVM_OBJ_ROOT/$LLVM_BUILDMODE";
75$ABS_OBJ_ROOT = `cd $ABS_OBJ_ROOT; pwd` if (-d $ABS_OBJ_ROOT);
Chris Lattner16ad6182006-06-02 21:48:10 +000076chomp($ABS_OBJ_ROOT);
77
Chris Lattner0cd059e2006-06-02 22:03:50 +000078my $INCLUDEDIR = "$ABS_RUN_DIR/include";
79my $LIBDIR = "$ABS_RUN_DIR/lib";
80my $BINDIR = "$ABS_RUN_DIR/bin";
Chris Lattner16ad6182006-06-02 21:48:10 +000081if ($ABS_RUN_DIR eq $ABS_OBJ_ROOT) {
82 # If we are running out of the build directory, the include dir is in the
83 # srcdir.
84 $INCLUDEDIR = "$LLVM_SRC_ROOT/include";
85} else {
Chris Lattner0cd059e2006-06-02 22:03:50 +000086 # If installed, ignore the prefix the tree was configured with, use the
87 # current prefix.
88 $PREFIX = $ABS_RUN_DIR;
Chris Lattner16ad6182006-06-02 21:48:10 +000089}
Chris Lattnere02b97b2006-06-02 01:23:18 +000090
Reid Spencerf2722ca2006-03-22 15:59:55 +000091sub usage;
92sub fix_library_names (@);
Chris Lattnerd179de52006-06-06 22:38:29 +000093sub fix_library_files (@);
Reid Spencerd8c20a92006-08-03 21:45:35 +000094sub expand_dependencies (@);
Reid Spencerf2722ca2006-03-22 15:59:55 +000095sub name_map_entries;
96
97# Parse our command-line arguments.
98usage if @ARGV == 0;
99my @components;
100my $has_opt = 0;
101my $want_libs = 0;
102my $want_libnames = 0;
Chris Lattnerd179de52006-06-06 22:38:29 +0000103my $want_libfiles = 0;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000104my $want_components = 0;
105foreach my $arg (@ARGV) {
106 if ($arg =~ /^-/) {
107 if ($arg eq "--version") {
108 $has_opt = 1; print "$VERSION\n";
109 } elsif ($arg eq "--prefix") {
110 $has_opt = 1; print "$PREFIX\n";
111 } elsif ($arg eq "--bindir") {
Chris Lattner16ad6182006-06-02 21:48:10 +0000112 $has_opt = 1; print "$BINDIR\n";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000113 } elsif ($arg eq "--includedir") {
Chris Lattner16ad6182006-06-02 21:48:10 +0000114 $has_opt = 1; print "$INCLUDEDIR\n";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000115 } elsif ($arg eq "--libdir") {
Chris Lattner16ad6182006-06-02 21:48:10 +0000116 $has_opt = 1; print "$LIBDIR\n";
David Greenea696d242007-06-28 19:36:08 +0000117 } elsif ($arg eq "--cppflags") {
118 $has_opt = 1;
119 my $cppopts = get_cpp_opts();
120 print "$cppopts\n";
Reid Spencerf72538e2007-01-06 02:48:03 +0000121 } elsif ($arg eq "--cflags") {
David Greenea696d242007-06-28 19:36:08 +0000122 $has_opt = 1;
123 my $cppopts = get_cpp_opts();
124 print "$cppopts $CFLAGS\n";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000125 } elsif ($arg eq "--cxxflags") {
David Greenea696d242007-06-28 19:36:08 +0000126 $has_opt = 1;
127 my $cppopts = get_cpp_opts();
128 print "$cppopts $CXXFLAGS\n";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000129 } elsif ($arg eq "--ldflags") {
Reid Spencer1bc68642006-07-27 23:00:30 +0000130 $has_opt = 1; print "-L$LIBDIR $LDFLAGS $SYSTEM_LIBS\n";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000131 } elsif ($arg eq "--libs") {
132 $has_opt = 1; $want_libs = 1;
133 } elsif ($arg eq "--libnames") {
134 $has_opt = 1; $want_libnames = 1;
Chris Lattnerd179de52006-06-06 22:38:29 +0000135 } elsif ($arg eq "--libfiles") {
136 $has_opt = 1; $want_libfiles = 1;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000137 } elsif ($arg eq "--components") {
138 $has_opt = 1; print join(' ', name_map_entries), "\n";
139 } elsif ($arg eq "--targets-built") {
140 $has_opt = 1; print join(' ', @TARGETS_BUILT), "\n";
Reid Spencer3b87d6a2007-04-22 05:05:36 +0000141 } elsif ($arg eq "--host-target") {
142 $has_opt = 1; print "$TARGET_TRIPLE\n";
Chris Lattner0cd059e2006-06-02 22:03:50 +0000143 } elsif ($arg eq "--build-mode") {
144 $has_opt = 1; print "$LLVM_BUILDMODE\n";
145 } elsif ($arg eq "--obj-root") {
Reid Spencerb43ce5a2006-08-11 21:50:24 +0000146 $has_opt = 1; print `cd $LLVM_OBJ_ROOT/; pwd`;
Chris Lattner0cd059e2006-06-02 22:03:50 +0000147 } elsif ($arg eq "--src-root") {
Reid Spencerb43ce5a2006-08-11 21:50:24 +0000148 $has_opt = 1; print `cd $LLVM_SRC_ROOT/; pwd`;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000149 } else {
150 usage();
151 }
152 } else {
153 push @components, $arg;
154 }
155}
156
157# If no options were specified, fail.
158usage unless $has_opt;
159
160# If no components were specified, default to 'all'.
161if (@components == 0) {
162 push @components, 'all';
163}
164
Chris Lattner54eae9e2006-09-04 05:35:23 +0000165# Force component names to lower case.
166@components = map lc, @components;
167
Reid Spencerf2722ca2006-03-22 15:59:55 +0000168# Handle any arguments which require building our dependency graph.
Chris Lattnerd179de52006-06-06 22:38:29 +0000169if ($want_libs || $want_libnames || $want_libfiles) {
Reid Spencerd8c20a92006-08-03 21:45:35 +0000170 my @libs = expand_dependencies(@components);
Chris Lattnerd179de52006-06-06 22:38:29 +0000171 print join(' ', fix_library_names(@libs)), "\n" if ($want_libs);
172 print join(' ', @libs), "\n" if ($want_libnames);
173 print join(' ', fix_library_files(@libs)), "\n" if ($want_libfiles);
Reid Spencerf2722ca2006-03-22 15:59:55 +0000174}
175
176exit 0;
177
178#==========================================================================
179# Support Routines
180#==========================================================================
181
182sub usage {
183 print STDERR <<__EOD__;
184Usage: llvm-config <OPTION>... [<COMPONENT>...]
185
186Get various configuration information needed to compile programs which use
187LLVM. Typically called from 'configure' scripts. Examples:
188 llvm-config --cxxflags
189 llvm-config --ldflags
Reid Spencerb195d9d2006-03-23 23:21:29 +0000190 llvm-config --libs engine bcreader scalaropts
Reid Spencerf2722ca2006-03-22 15:59:55 +0000191
192Options:
Chris Lattner0cd059e2006-06-02 22:03:50 +0000193 --version Print LLVM version.
194 --prefix Print the installation prefix.
195 --src-root Print the source root LLVM was built from.
196 --obj-root Print the object root used to build LLVM.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000197 --bindir Directory containing LLVM executables.
198 --includedir Directory containing LLVM headers.
199 --libdir Directory containing LLVM libraries.
David Greenea696d242007-06-28 19:36:08 +0000200 --cppflags C preprocessor flags for files that include LLVM headers.
Reid Spencerf72538e2007-01-06 02:48:03 +0000201 --cflags C compiler flags for files that include LLVM headers.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000202 --cxxflags C++ compiler flags for files that include LLVM headers.
Chris Lattner0cd059e2006-06-02 22:03:50 +0000203 --ldflags Print Linker flags.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000204 --libs Libraries needed to link against LLVM components.
205 --libnames Bare library names for in-tree builds.
Chris Lattnerd179de52006-06-06 22:38:29 +0000206 --libfiles Fully qualified library filenames for makefile depends.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000207 --components List of all possible components.
208 --targets-built List of all targets currently built.
Jeff Cohenb5594e32007-04-22 18:33:20 +0000209 --host-target Target triple used to configure LLVM.
Chris Lattner0cd059e2006-06-02 22:03:50 +0000210 --build-mode Print build mode of LLVM tree (e.g. Debug or Release).
Reid Spencerf2722ca2006-03-22 15:59:55 +0000211Typical components:
212 all All LLVM libraries (default).
Reid Spencerb195d9d2006-03-23 23:21:29 +0000213 backend Either a native backend or the C backend.
214 engine Either a native JIT or a bytecode interpreter.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000215__EOD__
216 exit(1);
217}
218
David Greenea696d242007-06-28 19:36:08 +0000219# Return cpp flags used to build llvm.
220sub get_cpp_opts {
221 my $opts = "";
222
223 if ($EXPENSIVE_CHECKS eq "yes") {
224 $opts = "-D_GLIBCXX_DEBUG -I$INCLUDEDIR $CPPFLAGS";
225 }
226 else {
227 $opts = "-I$INCLUDEDIR $CPPFLAGS";
228 }
229
230 return $opts;
231}
232
Reid Spencerf2722ca2006-03-22 15:59:55 +0000233# Use -lfoo instead of libfoo.a whenever possible, and add directories to
234# files which can't be found using -L.
235sub fix_library_names (@) {
236 my @libs = @_;
237 my @result;
238 foreach my $lib (@libs) {
239 # Transform the bare library name appropriately.
240 my ($basename) = ($lib =~ /^lib([^.]*)\.a/);
241 if (defined $basename) {
242 push @result, "-l$basename";
243 } else {
Chris Lattner16ad6182006-06-02 21:48:10 +0000244 push @result, "$LIBDIR/$lib";
Reid Spencerf2722ca2006-03-22 15:59:55 +0000245 }
246 }
247 return @result;
248}
249
Chris Lattnerd179de52006-06-06 22:38:29 +0000250# Turn the list of libraries into a list of files.
251sub fix_library_files(@) {
252 my @libs = @_;
253 my @result;
254 foreach my $lib (@libs) {
255 # Transform the bare library name into a filename.
256 push @result, "$LIBDIR/$lib";
257 }
258 return @result;
259}
Reid Spencerf2722ca2006-03-22 15:59:55 +0000260
261#==========================================================================
262# Library Dependency Analysis
263#==========================================================================
264# Given a few human-readable library names, find all their dependencies
265# and sort them into an order which the linker will like. If we packed
266# our libraries into fewer archives, we could make the linker do much
267# of this work for us.
268#
269# Libraries have two different types of names in this code: Human-friendly
270# "component" names entered on the command-line, and the raw file names
271# we use internally (and ultimately pass to the linker).
272#
273# To understand this code, you'll need a working knowledge of Perl 5,
274# and possibly some quality time with 'man perlref'.
275
276sub load_dependencies;
277sub build_name_map;
Reid Spencerb195d9d2006-03-23 23:21:29 +0000278sub have_native_backend;
279sub find_best_engine;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000280sub expand_names (@);
281sub find_all_required_sets (@);
282sub find_all_required_sets_helper ($$@);
Reid Spencerf2722ca2006-03-22 15:59:55 +0000283
284# Each "set" contains one or more libraries which must be included as a
285# group (due to cyclic dependencies). Sets are represented as a Perl array
286# reference pointing to a list of internal library names.
287my @SETS;
288
289# Various mapping tables.
290my %LIB_TO_SET_MAP; # Maps internal library names to their sets.
291my %SET_DEPS; # Maps sets to a list of libraries they depend on.
292my %NAME_MAP; # Maps human-entered names to internal names.
293
294# Have our dependencies been loaded yet?
295my $DEPENDENCIES_LOADED = 0;
296
297# Given a list of human-friendly component names, translate them into a
298# complete set of linker arguments.
Reid Spencerd8c20a92006-08-03 21:45:35 +0000299sub expand_dependencies (@) {
Reid Spencerf2722ca2006-03-22 15:59:55 +0000300 my @libs = @_;
301 load_dependencies;
302 my @required_sets = find_all_required_sets(expand_names(@libs));
303 my @sorted_sets = topologically_sort_sets(@required_sets);
304
Chris Lattner06e752e2006-06-02 00:56:15 +0000305 # Expand the library sets into libraries.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000306 my @result;
307 foreach my $set (@sorted_sets) { push @result, @{$set}; }
Chris Lattner06e752e2006-06-02 00:56:15 +0000308 return @result;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000309}
310
311# Load in the raw dependency data stored at the end of this file.
312sub load_dependencies {
313 return if $DEPENDENCIES_LOADED;
314 $DEPENDENCIES_LOADED = 1;
315 while (<DATA>) {
316 # Parse our line.
Anton Korobeynikovde9c02b2006-08-04 21:52:23 +0000317 my ($libs, $deps) = /^\s*([^:]+):\s*(.*)\s*$/;
Reid Spencerf2722ca2006-03-22 15:59:55 +0000318 die "Malformed dependency data" unless defined $deps;
319 my @libs = split(' ', $libs);
320 my @deps = split(' ', $deps);
321
322 # Record our dependency data.
323 my $set = \@libs;
324 push @SETS, $set;
325 foreach my $lib (@libs) { $LIB_TO_SET_MAP{$lib} = $set; }
326 $SET_DEPS{$set} = \@deps;
327 }
328 build_name_map;
329}
330
331# Build a map converting human-friendly component names into internal
332# library names.
333sub build_name_map {
334 # Add entries for all the actual libraries.
335 foreach my $set (@SETS) {
336 foreach my $lib (sort @$set) {
337 my $short_name = $lib;
338 $short_name =~ s/^(lib)?LLVM([^.]*)\..*$/$2/;
339 $short_name =~ tr/A-Z/a-z/;
340 $NAME_MAP{$short_name} = [$lib];
341 }
342 }
343
344 # Add virtual entries.
Reid Spencerb195d9d2006-03-23 23:21:29 +0000345 $NAME_MAP{'native'} = have_native_backend() ? [$ARCH] : [];
346 $NAME_MAP{'backend'} = have_native_backend() ? ['native'] : ['cbackend'];
347 $NAME_MAP{'engine'} = find_best_engine;
348 $NAME_MAP{'all'} = [name_map_entries]; # Must be last.
Reid Spencerf2722ca2006-03-22 15:59:55 +0000349}
350
Reid Spencerb195d9d2006-03-23 23:21:29 +0000351# Return true if we have a native backend to use.
352sub have_native_backend {
Reid Spencerf2722ca2006-03-22 15:59:55 +0000353 my %BUILT;
354 foreach my $target (@TARGETS_BUILT) { $BUILT{$target} = 1; }
Reid Spencerb195d9d2006-03-23 23:21:29 +0000355 return defined $NAME_MAP{$ARCH} && defined $BUILT{$ARCH};
356}
357
358# Find a working subclass of ExecutionEngine for this platform.
359sub find_best_engine {
360 if (have_native_backend && $TARGET_HAS_JIT) {
Reid Spencer1c070fc2006-03-24 01:10:39 +0000361 return ['jit', 'native'];
Reid Spencerf2722ca2006-03-22 15:59:55 +0000362 } else {
Reid Spencerb195d9d2006-03-23 23:21:29 +0000363 return ['interpreter'];
Reid Spencerf2722ca2006-03-22 15:59:55 +0000364 }
365}
366
367# Get all the human-friendly component names.
368sub name_map_entries {
369 load_dependencies;
370 return sort keys %NAME_MAP;
371}
372
373# Map human-readable names to internal library names.
374sub expand_names (@) {
375 my @names = @_;
376 my @result;
377 foreach my $name (@names) {
378 if (defined $LIB_TO_SET_MAP{$name}) {
379 # We've hit bottom: An actual library name.
380 push @result, $name;
381 } elsif (defined $NAME_MAP{$name}) {
382 # We've found a short name to expand.
383 push @result, expand_names(@{$NAME_MAP{$name}});
384 } else {
385 print STDERR "llvm-config: unknown component name: $name\n";
386 exit(1);
387 }
388 }
389 return @result;
390}
391
392# Given a list of internal library names, return all sets of libraries which
393# will need to be included by the linker (in no particular order).
394sub find_all_required_sets (@) {
395 my @libs = @_;
396 my %sets_added;
397 my @result;
398 find_all_required_sets_helper(\%sets_added, \@result, @libs);
399 return @result;
400}
401
402# Recursive closures are pretty broken in Perl, so we're going to separate
403# this function from find_all_required_sets and pass in the state we need
404# manually, as references. Yes, this is fairly unpleasant.
405sub find_all_required_sets_helper ($$@) {
406 my ($sets_added, $result, @libs) = @_;
407 foreach my $lib (@libs) {
408 my $set = $LIB_TO_SET_MAP{$lib};
409 next if defined $$sets_added{$set};
410 $$sets_added{$set} = 1;
411 push @$result, $set;
412 find_all_required_sets_helper($sets_added, $result, @{$SET_DEPS{$set}});
413 }
414}
415
416# Print a list of sets, with a label. Used for debugging.
417sub print_sets ($@) {
418 my ($label, @sets) = @_;
419 my @output;
420 foreach my $set (@sets) { push @output, join(',', @$set); }
421 print "$label: ", join(';', @output), "\n";
422}
423
424# Returns true if $lib is a key in $added.
425sub has_lib_been_added ($$) {
426 my ($added, $lib) = @_;
427 return defined $$added{$LIB_TO_SET_MAP{$lib}};
428}
429
430# Returns true if all the dependencies of $set appear in $added.
431sub have_all_deps_been_added ($$) {
432 my ($added, $set) = @_;
433 #print_sets(" Checking", $set);
434 #print_sets(" Wants", $SET_DEPS{$set});
435 foreach my $lib (@{$SET_DEPS{$set}}) {
436 return 0 unless has_lib_been_added($added, $lib);
437 }
438 return 1;
439}
440
441# Given a list of sets, topologically sort them using dependencies.
442sub topologically_sort_sets (@) {
443 my @sets = @_;
444 my %added;
445 my @result;
446 SCAN: while (@sets) { # We'll delete items from @sets as we go.
447 #print_sets("So far", reverse(@result));
448 #print_sets("Remaining", @sets);
449 for (my $i = 0; $i < @sets; ++$i) {
450 my $set = $sets[$i];
451 if (have_all_deps_been_added(\%added, $set)) {
452 push @result, $set;
453 $added{$set} = 1;
454 #print "Removing $i.\n";
455 splice(@sets, $i, 1);
456 next SCAN; # Restart our scan.
457 }
458 }
459 die "Can't find a library with no dependencies";
460 }
461 return reverse(@result);
462}
463
Reid Spencerf2722ca2006-03-22 15:59:55 +0000464# Our library dependency data will be added after the '__END__' token, and will
465# be read through the magic <DATA> filehandle.
466__END__