fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / autogen.sh
blobab9c94d3f1659954a252a632a61e14e3ccc375f4
3 # This script checks various configure parameters and uses three files:
4 # * autogen.input (ro)
5 # * autogen.lastrun (rw)
6 # * autogen.lastrun.bak (rw)
8 # If _no_ parmeters:
9 # Read args from autogen.input or autogen.lastrun
10 # Else
11 # Backup autogen.lastrun as autogen.lastrun.bak
12 # Write autogen.lastrun with new commandline args
14 # Run configure with checked args
16 eval 'exec perl -S $0 ${1+"$@"}'
17 if 0;
19 use strict;
20 use Cwd ('cwd', 'realpath');
21 use File::Basename;
23 my $src_path=dirname(realpath($0));
24 my $build_path=realpath(cwd());
25 # since this looks crazy, if you have a symlink on a path up to and including
26 # the current directory, we need our configure to run in the realpath of that
27 # such that compiled (realpath'd) dependency filenames match the filenames
28 # used in our makefiles - ie. this gets dependencies right via SRC_ROOT
29 chdir ($build_path);
30 # more amazingly, if you don't clobber 'PWD' shells will re-assert their
31 # old path from the environment, not cwd.
32 $ENV{PWD} = $build_path;
34 sub clean()
36 system ("rm -Rf autom4te.cache");
37 system ("rm -f missing install-sh mkinstalldirs libtool ltmain.sh");
38 print "Cleaned the build tree\n";
41 my $aclocal;
43 # check we have various vital tools
44 sub sanity_checks($)
46 my $system = shift;
47 my @path = split (':', $ENV{'PATH'});
48 my %required =
50 'pkg-config' => "pkg-config is required to be installed",
51 'autoconf' => "autoconf is required",
52 $aclocal => "$aclocal is required",
55 for my $elem (@path) {
56 for my $app (keys %required) {
57 if (-f "$elem/$app") {
58 delete $required{$app};
62 if ((keys %required) > 0) {
63 print ("Various low-level dependencies are missing, please install them:\n");
64 for my $app (keys %required) {
65 print "\t $app: " . $required{$app} . "\n";
67 exit (1);
71 # one argument per line
72 sub read_args($)
74 my $file = shift;
75 my $fh;
76 my @lst;
77 open ($fh, $file) || die "can't open file: $file";
78 while (<$fh>) {
79 chomp();
80 s/\s+$//;
81 # migrate from the old system
82 if ( substr($_, 0, 1) eq "'" ) {
83 print STDERR "Migrating options from the old autogen.lastrun format, using:\n";
84 my @opts;
85 @opts = split(/'/);
86 foreach my $opt (@opts) {
87 if ( substr($opt, 0, 1) eq "-" ) {
88 push @lst, $opt;
89 print STDERR " $opt\n";
92 } elsif ( substr($_, 0, 1) eq "#" ) {
93 # comment
94 } elsif ( length == 0 ) {
95 # empty line
96 } else {
97 push @lst, $_;
100 close ($fh);
101 # print "read args from file '$file': @lst\n";
102 return @lst;
105 sub invalid_distro($$)
107 my ($config, $distro) = @_;
108 print STDERR "Can't find distro option set: $config\nThis is not necessarily a problem.\n";
109 print STDERR "Distros with distro option sets are:\n";
110 my $dirh;
111 opendir ($dirh, "$src_path/distro-configs");
112 while (($_ = readdir ($dirh))) {
113 /(.*)\.conf$/ || next;
114 print STDERR "\t$1\n";
116 closedir ($dirh);
119 # Avoid confusing "aclocal: error: non-option arguments are not accepted: '.../m4'." error message.
120 die "\$src_path must not contain spaces, but it is '$src_path'." if ($src_path =~ / /);
122 # Alloc $ACLOCAL to specify which aclocal to use
123 $aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
125 my $system = `uname -s`;
126 chomp $system;
128 sanity_checks ($system) unless($system eq 'Darwin');
130 my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
132 $aclocal_flags .= " -I $src_path/m4";
133 $aclocal_flags .= " -I $src_path/m4/mac" if ($system eq 'Darwin');
134 $aclocal_flags .= " -I /opt/freeware/share/aclocal" if ($system eq 'AIX');
136 $ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
138 if ($src_path ne $build_path)
140 system ("ln -sf $src_path/configure.ac configure.ac");
141 system ("ln -sf $src_path/g g");
142 my @modules = <$src_path/*/Makefile>;
143 foreach my $module (@modules)
145 my $dir = basename (dirname ($module));
146 mkdir ($dir);
147 system ("ln -sf $src_path/$dir/Makefile $dir/Makefile");
149 my @external_modules = <$src_path/external/*/Makefile>;
150 mkdir ("external");
151 system ("ln -sf $src_path/external/Module_external.mk external/");
152 foreach my $module (@external_modules)
154 my $dir = basename (dirname ($module));
155 mkdir ("external/$dir");
156 system ("ln -sf $src_path/external/$dir/Makefile external/$dir/Makefile");
159 system ("$aclocal $aclocal_flags") && die "Failed to run aclocal";
160 unlink ("configure");
161 system ("autoconf -I ${src_path}") && die "Failed to run autoconf";
162 die "Failed to generate the configure script" if (! -f "configure");
164 # Handle help arguments first, so we don't clobber autogen.lastrun
165 for my $arg (@ARGV) {
166 if ($arg =~ /^(--help|-h|-\?)$/) {
167 print STDERR "autogen.sh - libreoffice configuration helper\n";
168 print STDERR " --clean forcibly re-generate configuration\n";
169 print STDERR " --best-effort don't fail on un-known configure with/enable options\n";
170 print STDERR "\nOther arguments passed directly to configure:\n\n";
171 system ("./configure --help");
172 exit;
176 my @cmdline_args = ();
178 my $input = "autogen.input";
179 my $lastrun = "autogen.lastrun";
181 if (!@ARGV) {
182 if (-f $input) {
183 if (-f $lastrun) {
184 print STDERR <<WARNING;
185 ********************************************************************
187 * Reading $input and ignoring $lastrun!
188 * Consider removing $lastrun to get rid of this warning.
190 ********************************************************************
191 WARNING
193 @cmdline_args = read_args ($input);
194 } elsif (-f $lastrun) {
195 print STDERR "Reading $lastrun. Please rename it to $input to avoid this message.\n";
196 @cmdline_args = read_args ($lastrun);
198 } else {
199 if (-f $input) {
200 print STDERR <<WARNING;
201 ********************************************************************
203 * Using commandline arguments and ignoring $input!
205 ********************************************************************
206 WARNING
208 @cmdline_args = @ARGV;
211 my @args;
212 my $default_config = "$src_path/distro-configs/default.conf";
213 my $option_checking = 'fatal';
215 if (-f $default_config) {
216 print STDERR "Reading default config file: $default_config.\n";
217 push @args, read_args ($default_config);
219 for my $arg (@cmdline_args) {
220 if ($arg eq '--clean') {
221 clean();
222 } elsif ($arg =~ m/--with-distro=(.*)$/) {
223 my $config = "$src_path/distro-configs/$1.conf";
224 if (! -f $config) {
225 invalid_distro ($config, $1);
226 } else {
227 push @args, read_args ($config);
229 } elsif ($arg =~ m/--best-effort$/) {
230 $option_checking = 'warn';
231 } else {
232 push @args, $arg;
235 for my $arg (@args) {
236 if ($arg =~ /^([A-Z]+)=(.*)/) {
237 $ENV{$1} = $2;
241 if (defined $ENV{NOCONFIGURE}) {
242 print "Skipping configure process.";
243 } else {
244 # Save autogen.lastrun only if we did get some arguments on the command-line
245 if (! -f $input && @ARGV) {
246 if (scalar(@cmdline_args) > 0) {
247 # if there's already an autogen.lastrun, make a backup first
248 if (-e $lastrun) {
249 open (my $fh, $lastrun) || warn "Can't open $lastrun.\n";
250 open (BAK, ">$lastrun.bak") || warn "Can't create backup file $lastrun.bak.\n";
251 while (<$fh>) {
252 print BAK;
254 close (BAK) && close ($fh);
256 # print "Saving command-line args to $lastrun\n";
257 my $fh;
258 open ($fh, ">autogen.lastrun") || die "Can't open autogen.lastrun: $!";
259 for my $arg (@cmdline_args) {
260 print $fh "$arg\n";
262 close ($fh);
265 push @args, "--srcdir=$src_path";
266 push @args, "--enable-option-checking=$option_checking";
268 print "Running ./configure with '" . join ("' '", @args), "'\n";
269 system ("./configure", @args) && die "Error running configure";
272 # Local Variables:
273 # mode: perl
274 # cperl-indent-level: 4
275 # tab-width: 4
276 # indent-tabs-mode: nil
277 # End:
279 # vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #