Added Makefile for SDK Python example.
[LibreOffice.git] / autogen.sh
bloba37953cb81b6415cd2e47680c14f4d1f0116ea87
2 eval 'exec perl -S $0 ${1+"$@"}'
3 if 0;
5 use strict;
7 sub clean()
9 system ("rm -Rf autom4te.cache");
10 system ("rm -f missing install-sh mkinstalldirs libtool ltmain.sh");
11 print "cleaned the build tree\n";
14 my $aclocal;
16 # check we have various vital tools
17 sub sanity_checks($)
19 my $system = shift;
20 my @path = split (':', $ENV{'PATH'});
21 my %required =
23 'pkg-config' => "pkg-config is required to be installed",
24 'autoconf' => "autoconf is required",
25 $aclocal => "$aclocal is required",
28 for my $elem (@path) {
29 for my $app (keys %required) {
30 if (-f "$elem/$app") {
31 delete $required{$app};
35 if ((keys %required) > 0) {
36 print ("Various low-level dependencies are missing, please install them:\n");
37 for my $app (keys %required) {
38 print "\t $app: " . $required{$app} . "\n";
40 exit (1);
44 # one argument per line
45 sub read_args($)
47 my $file = shift;
48 my $fh;
49 my @lst;
50 open ($fh, $file) || die "can't open file: $file";
51 while (<$fh>) {
52 chomp();
53 # migrate from the old system
54 if ( substr($_, 0, 1) eq "'" ) {
55 print "Migrating options from the old autogen.lastrun format, using:\n";
56 my @opts;
57 @opts = split(/'/);
58 foreach my $opt (@opts) {
59 if ( substr($opt, 0, 1) eq "-" ) {
60 push @lst, $opt;
61 print " $opt\n";
64 } elsif ( substr($_, 0, 1) eq "#" ) {
65 # comment
66 } else {
67 push @lst, $_;
70 close ($fh);
71 # print "read args from file '$file': @lst\n";
72 return @lst;
75 sub invalid_distro($$)
77 my ($config, $distro) = @_;
78 print STDERR "Can't find distro option set: $config\nThis is not necessarily a problem.\n";
79 print STDERR "Distros with distro option sets are:\n";
80 my $dirh;
81 opendir ($dirh, "distro-configs");
82 while (($_ = readdir ($dirh))) {
83 /(.*)\.conf$/ || next;
84 print STDERR "\t$1\n";
86 closedir ($dirh);
89 my @cmdline_args = ();
90 if (!@ARGV) {
91 my $lastrun = "autogen.lastrun";
92 @cmdline_args = read_args ($lastrun) if (-f $lastrun);
93 } else {
94 @cmdline_args = @ARGV;
97 my @args;
98 for my $arg (@cmdline_args) {
99 if ($arg eq '--clean') {
100 clean();
101 } elsif ($arg =~ m/--with-distro=(.*)$/) {
102 my $config = "distro-configs/$1.conf";
103 if (! -f $config) {
104 invalid_distro ($config, $1);
105 } else {
106 push @args, read_args ($config);
108 } else {
109 push @args, $arg;
112 for my $arg (@args) {
113 if ($arg =~ /^([A-Z]+)=(.*)/) {
114 $ENV{$1} = $2;
118 # Alloc $ACLOCAL to specify which aclocal to use
119 $aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
121 my $system = `uname -s`;
122 chomp $system;
124 sanity_checks ($system) unless($system eq 'Darwin');
126 my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
128 $aclocal_flags = "-I ./m4/mac" if (($aclocal_flags eq "") && ($system eq 'Darwin'));
130 $ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
132 system ("$aclocal $aclocal_flags") && die "Failed to run aclocal";
133 unlink ("configure");
134 system ("autoconf") && die "Failed to run autoconf";
135 die "failed to generate configure" if (! -x "configure");
137 if (defined $ENV{NOCONFIGURE}) {
138 print "Skipping configure process.";
139 } else {
140 # Save autogen.lastrun only if we did get some arguments on the command-line
141 if (@ARGV) {
142 if (scalar(@cmdline_args) > 0) {
143 # print "writing args to autogen.lastrun\n";
144 my $fh;
145 open ($fh, ">autogen.lastrun") || die "can't open autogen.lastrun: $!";
146 for my $arg (@cmdline_args) {
147 print $fh "$arg\n";
149 close ($fh);
152 elsif ( ! -e "autogen.lastrun")
154 system("touch autogen.lastrun");
156 print "running ./configure with '" . join ("' '", @args), "'\n";
157 system ("./configure", @args) && die "Error running configure";
160 # Local Variables:
161 # mode: perl
162 # cperl-indent-level: 4
163 # tab-width: 4
164 # indent-tabs-mode: nil
165 # End:
167 # vim:set shiftwidth=4 softtabstop=4 expandtab: #