1# =========================================================================== 2# 3# PUBLIC DOMAIN NOTICE 4# National Center for Biotechnology Information 5# 6# This software/database is a "United States Government Work" under the 7# terms of the United States Copyright Act. It was written as part of 8# the author's official duties as a United States Government employee and 9# thus cannot be copyrighted. This software/database is freely available 10# to the public for use. The National Library of Medicine and the U.S. 11# Government have not placed any restriction on its use or reproduction. 12# 13# Although all reasonable efforts have been taken to ensure the accuracy 14# and reliability of the software and data, the NLM and the U.S. 15# Government do not and cannot warrant the performance or results that 16# may be obtained by using this software or data. The NLM and the U.S. 17# Government disclaim all warranties, express or implied, including 18# warranties of performance, merchantability or fitness for any particular 19# purpose. 20# 21# Please cite the author in any work or product based on this material. 22# 23# =========================================================================== 24 25use strict; 26 27use Cwd 'abs_path'; 28use File::Basename 'dirname'; 29use lib dirname( abs_path $0 ); 30 31sub println { print @_; print "\n" } 32 33my ($filename, $directories, $suffix) = fileparse($0); 34if ($directories ne "./") { 35 println "configure: error: $filename should be run as ./$filename"; 36 exit 1; 37} 38 39require 'package.prl'; 40require 'os-arch.prl'; 41 42use Cwd qw(abs_path getcwd); 43use File::Basename 'fileparse'; 44use File::Spec 'catdir'; 45use FindBin qw($Bin); 46use Getopt::Long "GetOptions"; 47 48chdir '..' or die "cannot cd to package root"; 49 50check(); 51 52my $LOCAL_BUILD_OUT 53 = -e File::Spec->catdir($ENV{HOME}, 'tmp', 'local-build-out'); 54 55my ($CONFIGURED, $RECONFIGURE) = (''); 56if (@ARGV) { 57 foreach (@ARGV) { 58 $CONFIGURED .= "\t" if ($CONFIGURED); 59 $CONFIGURED .= "'$_'"; 60 } 61} elsif (-f 'reconfigure') { 62 ++$RECONFIGURE unless ($LOCAL_BUILD_OUT); 63} 64 65my %PKG = PKG(); 66 67my $PACKAGE_NAME = PACKAGE_NAME(); 68my $OUT_MAKEFILE = 'Makefile.config'; 69my $INS_MAKEFILE = 'Makefile.config.install'; 70 71my $PACKAGE = PACKAGE(); 72 73my $HOME = $ENV{HOME} || $ENV{USERPROFILE} 74 || $ENV{LOGDIR} || getcwd || (getpwuid($<))[7] || abs_path('.'); 75 76$PKG{UPATH} = expand($PKG{UPATH}); 77 78my $package_default_prefix = $PKG{PATH}; 79my $schema_default_dir = $PKG{SCHEMA_PATH} if ($PKG{SCHEMA_PATH}); 80 81my @REQ = REQ(); 82 83my @options = ( 'build-prefix=s', 84 'clean', 85 'debug', 86 'help', 87 'prefix=s', 88 'reconfigure', 89 'relative-build-out-dir', 90 'status', 91 'with-debug', 92 'without-debug', ); 93{ 94 my ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch(); 95 push @options, 'arch=s' if (@ARCHITECTURES); 96} 97push @options, 'source=s' if ($PKG{LNG} eq 'JAVA'); 98push @options, 'enable-static' if (PACKAGE_TYPE() eq 'B'); 99foreach my $href (@REQ) { 100 my %a = %$href; 101 push @options, "$a{option}=s" if ($a {option}); 102 push @options, "$a{boption}=s" if ($a{boption}); 103 $href->{usrpath} = '' unless ($href->{usrpath}); 104 $href->{usrpath} = expand($href->{usrpath}); 105} 106push @options, "shemadir" if ($PKG{SCHEMA_PATH}); 107 108my %OPT; 109die "configure: error" unless (GetOptions(\%OPT, @options)); 110++$OPT{'reconfigure'} if ($RECONFIGURE); 111 112if ($OPT{'reconfigure'}) { 113 unless (eval 'use Getopt::Long qw(GetOptionsFromString); 1') { 114 print <<EndText; 115configure: error: your perl does not support Getopt::Long::GetOptionsFromString 116 reconfigure option is not avaliable. 117Run "sh ./reconfigure" instead. 118EndText 119 exit 1; 120 } 121 println "reconfiguring..."; 122 open F, 'reconfigure' or die 'cannot open reconfigure'; 123 $_ = <F>; 124 chomp; 125 unless (m|^\./configure\s*(.*)$|) { 126 println 'configure: error: cannot reconfigure'; 127 println 'run "./configure --clean" then run "./configure [OPTIONS]"'; 128 exit 1; 129 } 130 131 my $ARG = $1; 132 println "running \"./configure $ARG\"..."; 133 undef %OPT; 134 die "configure: error" unless (GetOptionsFromString($ARG, \%OPT, @options)); 135 $CONFIGURED = $ARG if ($#ARGV == -1 && $RECONFIGURE); 136 ++$OPT{reconfigure}; 137} 138 139$OPT{'local-build-out'} = $LOCAL_BUILD_OUT; 140unless ($OPT{'local-build-out'}) 141{ $OPT{'local-build-out'} = $OPT{'relative-build-out-dir'} } 142my $OUTDIR = File::Spec->catdir($HOME, $PKG{OUT}); 143my $REL_OUTDIR = expand_path(File::Spec->catdir($Bin, $PKG{LOCOUT})); 144if ($OPT{'local-build-out'}) 145{ $OUTDIR = $REL_OUTDIR if ($REL_OUTDIR) } 146 147if ($OPT{'help'}) { 148 help(); 149 exit 0; 150} elsif ($OPT{'clean'}) { 151 { 152 foreach ('reconfigure', glob(CONFIG_OUT() . '/Makefile.config*'), 153 File::Spec->catdir(CONFIG_OUT(), 'Makefile.userconfig'), 154 File::Spec->catdir(CONFIG_OUT(), 'user.status')) 155 { 156 my $f = $_; 157 print "removing $f... "; 158 if (-e $f) { 159 if (unlink $f) { 160 println "ok"; 161 } else { 162 println "failed"; 163 } 164 } else { 165 println "not found"; 166 } 167 } 168 } 169 if (CONFIG_OUT() ne '.') { 170 foreach 171 (glob('Makefile.config*'), 'user.status', 'Makefile.userconfig') 172 { 173 my $f = $_; 174 print "removing $f... "; 175 if (-e $f) { 176 if (unlink $f) { 177 println "ok"; 178 } else { 179 println "failed"; 180 } 181 } else { 182 println "not found"; 183 } 184 } 185 } 186 exit 0; 187} elsif ($OPT{'status'}) { 188 status(1); 189 exit 0; 190} 191 192foreach (@ARGV) { 193 @_ = split('='); 194 next if ($#_ != 1); 195 $OPT{$_[0]} = $_[1] if ($_[0] eq 'CXX' || $_[0] eq 'LDFLAGS'); 196} 197 198println "Configuring $PACKAGE_NAME package"; 199 200$OPT{'prefix'} = $package_default_prefix unless ($OPT{'prefix'}); 201 202my $AUTORUN = $OPT{status}; 203print "checking system type... " unless ($AUTORUN); 204my ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch(); 205println $OSTYPE unless ($AUTORUN); 206 207unless ($OSTYPE =~ /linux/i || $OSTYPE =~ /darwin/i || $OSTYPE eq 'win' || $OSTYPE =~ /dragonfly/i) { 208 println "configure: error: unsupported system '$OSTYPE'"; 209 exit 1; 210} 211 212my $OS_DISTRIBUTOR = ''; 213if ($OS eq 'linux') { 214 print "checking OS distributor... " unless ($AUTORUN); 215 $OS_DISTRIBUTOR = `lsb_release -si 2> /dev/null`; 216 if ( $? != 0 ) { 217 $_ = `cat /etc/redhat-release 2> /dev/null`; 218 @_ = split ( / / ); 219 $OS_DISTRIBUTOR = $_[0] if ( $_[0] ); 220 } 221 $OS_DISTRIBUTOR = '' unless ( $OS_DISTRIBUTOR ); 222 chomp $OS_DISTRIBUTOR; 223 println $OS_DISTRIBUTOR unless ($AUTORUN); 224} 225 226print "checking machine architecture... " unless ($AUTORUN); 227println $MARCH unless ($AUTORUN); 228unless ($MARCH =~ /x86_64/i || $MARCH =~ /amd64/i || $MARCH =~ /i?86/i || $MARCH =~ /aarch64/) { 229 println "configure: error: unsupported architecture '$OSTYPE':'$MARCH'"; 230 exit 1; 231} 232 233{ 234 $OPT{'prefix'} = expand_path($OPT{'prefix'}); 235 my $prefix = $OPT{'prefix'}; 236 $OPT{'eprefix'} = $prefix unless ($OPT{'eprefix'} || $OS eq 'win'); 237 my $eprefix = $OPT{'eprefix'}; 238 unless ($OPT{'bindir'} || $OS eq 'win') { 239 $OPT{'bindir'} = File::Spec->catdir($eprefix, 'bin') ; 240 } 241 unless ($OPT{'libdir'} || $OS eq 'win') { 242 $OPT{'libdir'} = File::Spec->catdir($eprefix, 'lib'); 243 } 244 unless ($OPT{'includedir'} || $OS eq 'win') { 245 $OPT{'includedir'} = File::Spec->catdir($eprefix, 'include'); 246 } 247 if ($PKG{LNG} eq 'PYTHON' && ! $OPT{'pythondir'} && $OS ne 'win') { 248 $OPT{'pythondir'} = $eprefix; 249 } 250 if ($PKG{LNG} eq 'JAVA' && ! $OPT{'javadir'} && $OS ne 'win') { 251 $OPT{'javadir'} = File::Spec->catdir($eprefix, 'jar'); 252 } 253 if ($PKG{EXAMP} && ! $OPT{'sharedir'} && $OS ne 'win') { 254 $OPT{'sharedir'} = File::Spec->catdir($eprefix, 'share'); 255 } 256} 257 258# initial values 259my $TARGDIR = File::Spec->catdir($OUTDIR, $PACKAGE); 260if ($OPT{'build-prefix'}) { 261 $TARGDIR = $OPT{'build-prefix'} = expand_path($OPT{'build-prefix'}); 262 unless ($TARGDIR =~ /$PACKAGE$/) { 263 $TARGDIR = File::Spec->catdir($TARGDIR, $PACKAGE); 264 } 265} 266my $BUILD_PREFIX = $TARGDIR; 267 268my $BUILD = 'rel'; 269 270# parse command line 271$BUILD = 'dbg' if ($OPT{'with-debug'}); 272$BUILD = 'rel' if ($OPT{'without-debug'}); 273 274my $BUILD_TYPE = "release"; 275$BUILD_TYPE = "debug" if ( $BUILD eq "dbg" ); 276 277$OPT{arch} = $ARCH if (@ARCHITECTURES && ! $OPT{arch}); 278 279if ($OPT{arch}) { 280 my $found; 281 foreach (@ARCHITECTURES) { 282 if ($_ eq $OPT{arch}) { 283 ++$found; 284 last; 285 } 286 } 287 if ($found) { 288 $ARCH = $MARCH = $OPT{arch}; 289 while (1) { 290 open F, ">Makefile.config.$OS.arch" or last; 291 print F "$ARCH\n"; 292 close F; 293 last; 294 } 295 println "build architecture: $ARCH" unless ($AUTORUN); 296 } else { 297 delete $OPT{arch}; 298 } 299} 300 301$OUT_MAKEFILE = File::Spec->catdir(CONFIG_OUT(), "$OUT_MAKEFILE.$OS.$ARCH"); 302$INS_MAKEFILE = File::Spec->catdir(CONFIG_OUT(), "$INS_MAKEFILE.$OS.$ARCH.prl"); 303 304my $TOOLS = ""; 305$TOOLS = "jdk" if ($PKG{LNG} eq 'JAVA'); 306 307# determine architecture 308 309print "checking for supported architecture... " unless ($AUTORUN); 310 311my $BITS; 312 313if ($MARCH =~ /x86_64/i || $MARCH =~ /amd64/i) { 314 $BITS = 64; 315} elsif ($MARCH eq 'fat86') { 316 $BITS = '32_64'; 317} elsif ($MARCH =~ /i?86/i) { 318 $BITS = 32; 319} elsif ($MARCH =~ /aarch64/) { 320 $BITS = 64; 321} else { 322 die "unrecognized Architecture '$ARCH'"; 323} 324println "$MARCH ($BITS bits) is supported" unless ($AUTORUN); 325 326# determine OS and related norms 327my ($LPFX, $OBJX, $LOBX, $LIBX, $SHLX, $EXEX, $OSINC, $PYTHON); 328 329print "checking for supported OS... " unless ($AUTORUN); 330if ($OSTYPE =~ /linux/i) { 331 $LPFX = 'lib'; 332 $OBJX = 'o'; 333 $LOBX = 'pic.o'; 334 $LIBX = 'a'; 335 $SHLX = 'so'; 336 $EXEX = ''; 337 $OSINC = 'unix'; 338 $TOOLS = 'gcc' unless ($TOOLS); 339 $PYTHON = 'python'; 340} elsif ($OSTYPE =~ /dragonfly/i) { 341 $LPFX = 'lib'; 342 $OBJX = 'o'; 343 $LOBX = 'pic.o'; 344 $LIBX = 'a'; 345 $SHLX = 'so'; 346 $EXEX = ''; 347 $OSINC = 'unix'; 348 $TOOLS = 'gcc' unless ($TOOLS); 349 $PYTHON = 'python'; 350} elsif ($OSTYPE =~ /darwin/i) { 351 $LPFX = 'lib'; 352 $OBJX = 'o'; 353 $LOBX = 'pic.o'; 354 $LIBX = 'a'; 355 $SHLX = 'dylib'; 356 $EXEX = ''; 357 $OSINC = 'unix'; 358 $TOOLS = 'gcc' unless ($TOOLS); 359 $PYTHON = 'python'; 360} elsif ($OSTYPE eq 'win') { 361 $TOOLS = 'vc++'; 362} else { 363 die "unrecognized OS '$OSTYPE'"; 364} 365 366println "$OSTYPE ($OS) is supported" unless ($AUTORUN); 367 368# tool chain 369my ($CPP, $CC, $CP, $AR, $ARX, $ARLS, $LD, $LP, $MAKE_MANIFEST); 370my ($JAVAC, $JAVAH, $JAR); 371my ($ARCH_FL, $DBG, $OPT, $PIC, $INC, $MD, $LDFLAGS) = (''); 372 373print "checking for supported tool chain... " unless ($AUTORUN); 374 375$CPP = $OPT{CXX } if ($OPT{CXX }); 376$LDFLAGS = $OPT{LDFLAGS} if ($OPT{LDFLAGS}); 377 378if ($TOOLS =~ /gcc$/) { 379 $CPP = 'g++' unless ($CPP); 380 $CC = "$TOOLS -c"; 381 $CP = "$CPP -c"; 382 $AR = 'ar rc'; 383 $ARX = 'ar x'; 384 $ARLS = 'ar t'; 385 $LD = $TOOLS; 386 $LP = $CPP; 387 388 $DBG = '-g -DDEBUG'; 389 $OPT = '-O3'; 390 $PIC = '-fPIC'; 391 $INC = '-I'; 392 $MD = '-MD'; 393} elsif ($TOOLS eq 'clang') { 394 $CPP = 'clang++' unless ($CPP); 395 $CC = 'clang -c'; 396 my $versionMin = '-mmacosx-version-min=10.10'; 397 $CP = "$CPP -c $versionMin"; 398 if ($BITS ne '32_64') { 399 $ARCH_FL = '-arch i386' if ($BITS == 32); 400 $OPT = '-O3'; 401 $AR = 'ar rc'; 402 $LD = "clang $ARCH_FL"; 403 $LP = "$CPP $versionMin $ARCH_FL"; 404 } else { 405 $MAKE_MANIFEST = '( echo "$^" > $@/manifest )'; 406 $ARCH_FL = '-arch i386 -arch x86_64'; 407 $OPT = '-O3'; 408 $AR = 'libtool -static -o'; 409 $LD = "clang -Wl,-arch_multiple $ARCH_FL -Wl,-all_load"; 410 $LP = "$CPP $versionMin -Wl,-arch_multiple $ARCH_FL -Wl,-all_load"; 411 } 412 $ARX = 'ar x'; 413 $ARLS = 'ar t'; 414 415 $DBG = '-g -DDEBUG'; 416 $PIC = '-fPIC'; 417 $INC = '-I'; 418 $MD = '-MD'; 419} elsif ($TOOLS eq 'jdk') { 420 $JAVAC = 'javac'; 421 if ($OPT{source}) { 422 $JAVAC .= ' -target ' . $OPT{source} . ' -source ' . $OPT{source}; 423 } 424 $JAVAH = 'javah'; 425 $JAR = 'jar cf'; 426 427 $DBG = '-g'; 428} elsif ($TOOLS eq 'vc++') { 429} else { 430 die "unrecognized tool chain '$TOOLS'"; 431} 432println "$TOOLS tool chain is supported" unless ($AUTORUN); 433 434if ($OS ne 'win' && $PKG{LNG} ne 'JAVA') { 435 $TARGDIR = File::Spec->catdir($TARGDIR, $OS, $TOOLS, $ARCH, $BUILD); 436} 437 438if ($CPP) { 439 unless (check_tool__h($CPP)) { 440 println "configure: error: '$CPP' cannot be found"; 441 exit 1; 442 } 443} 444 445if ($JAVAC) { 446 unless (check_tool_h($JAVAC)) { 447 println "configure: error: '$JAVAC' cannot be found"; 448 exit 1; 449 } 450} 451 452print 'checking for Python 3... ' unless $AUTORUN; 453if ($PYTHON) { 454 my $p3; 455 for my $dir (File::Spec->path()) { 456 $p3 = File::Spec->join($dir, 'python3'); 457 my $pX = substr($p3, 0, -1); 458 if (-x $pX && `$pX --version 2>&1` =~ /^\s*Python\s+(\d+)/i && $1 == 3) { 459 $p3 = $pX; 460 last; 461 } 462 if (-x $p3 && `$p3 --version 2>&1` =~ /^\s*Python\s+(\d+)/i && $1 == 3) { 463 last; 464 } 465 undef $p3; 466 } 467 if ($p3) { 468 $PYTHON = $p3; 469 println $PYTHON unless $AUTORUN; 470 } 471 else { 472 undef $PYTHON; 473 println 'no' unless $AUTORUN; 474 } 475} 476else { 477 println 'skipped' unless $AUTORUN; 478} 479 480my $NO_ARRAY_BOUNDS_WARNING = ''; 481if ($TOOLS =~ /gcc$/ && check_no_array_bounds()) { 482 $NO_ARRAY_BOUNDS_WARNING = '-Wno-array-bounds'; 483} 484 485my $STATIC_LIBSTDCPP = ''; 486if ($TOOLS =~ /gcc$/) { 487 $STATIC_LIBSTDCPP = check_static_libstdcpp(); 488} 489 490if ( $PKG{REQ} ) { 491 foreach ( @{ $PKG{REQ} } ) { 492 unless (check_tool__h($_)) { 493 println "configure: error: '$_' cannot be found"; 494 exit 1; 495 } 496 } 497} 498 499my @dependencies; 500 501if ( $PKG{OPT} ) { 502 foreach ( @{ $PKG{OPT} } ) { 503 if ( /^qmake$/ ) { 504 my $qmake = check_qmake(); 505 push @dependencies, "QMAKE_BIN = $qmake"; 506 } else { die; } 507 } 508} 509 510my %DEPEND_OPTIONS; 511foreach my $href (DEPENDS()) { 512 $_ = $href->{name}; 513 my $I = $href->{Include}; 514 my @L; 515 my $o = "with-$_-prefix"; 516 ++$DEPEND_OPTIONS{$o}; 517 if ($OPT{$o}) { 518 $OPT{$o} = expand_path($OPT{$o}); 519 $I = File::Spec->catdir($OPT{$o}, 'include'); 520 if (/^xml2$/) { 521 my $t = File::Spec->catdir($I, 'libxml2'); 522 $I = $t if (-e $t); 523 } 524 push ( @L, File::Spec->catdir($OPT{$o}, 'lib') ); 525 #push ( @L, File::Spec->catdir($OPT{$o}, 'lib64') ); 526 } 527 my ($i, $l) = find_lib($_, $I, @L); 528 if (defined $i || $l) { 529 my $d = 'HAVE_' . uc($_) . ' = 1'; 530 push @dependencies, $d; 531 println "\t\t$d" if ($OPT{'debug'}); 532 } 533 if ($i) { 534 my $d = uc($_) . "_INCDIR = $i"; 535 push @dependencies, $d; 536 println "\t\t$d" if ($OPT{'debug'}); 537 } 538 if ($l) { 539 my $d = uc($_) . "_LIBDIR = $l"; 540 push @dependencies, $d; 541 println "\t\t$d" if ($OPT{'debug'}); 542 } 543} 544 545foreach my $href (@REQ) { 546 $href->{ bldpath} = expand($href->{ bldpath}) if ($href->{ bldpath}); 547 $href->{locbldpath} = expand($href->{locbldpath}) if ($href->{locbldpath}); 548 549 # found directories 550 my 551 ($found_itf, $found_bin, $found_lib, $found_ilib, $found_jar, $found_src); 552 553 my %a = %$href; 554 next if ($a{option} && $DEPEND_OPTIONS{$a{option}}); 555 my $is_optional = optional($a{type}); 556 my $quasi_optional = $a{type} =~ /Q/; 557 my $need_source = $a{type} =~ /S/; 558 my $need_bin = $a{type} =~ /E/; 559 my $need_build = $a{type} =~ /B/; 560 my $need_lib = $a{type} =~ /L|D/; 561 my $need_itf = ! ($a{type} =~ /D/ || $a{type} =~ /E/ || $a{type} =~ /J/); 562 $need_itf = 1 if ($a{type} =~ /I/); 563 my $need_jar = $a{type} =~ /J/; 564 565 my ($bin, $inc, $lib, $ilib, $src) 566 = ($a{bin}, $a{include}, $a{lib}, undef, $a{src}); # file names to check 567 $lib = '' unless ($lib); 568 $lib = expand($lib); 569 570 if ($need_build) { 571 $ilib = $a{ilib}; 572 ++$need_lib; 573 } 574 unless ($AUTORUN) { 575 if ($need_source && $need_build) { 576 println 577 "checking for $a{name} package source files and build results..." 578 } elsif ($need_source) { 579 println "checking for $a{name} package source files..."; 580 } else { 581 println "checking for $a{name} package..."; 582 } 583 } 584 my %has_option; 585 my $tolib = $need_itf || $need_lib; 586 my $tojar = $need_jar; 587 foreach my $option ($a{option}, $a{boption}) { 588 next unless ($option); 589 if ($OPT{$option}) { 590 my $try = expand_path($OPT{$option}); 591 if ($tojar && ! $found_jar && -f $try) { 592 println "\tjar... $try" unless ($AUTORUN); 593 $found_jar = $try; 594 } 595 elsif ($tolib) { 596 my ($i, $l, $il) = ($inc, $lib, $ilib); 597 if ($option =~ /-build$/) { 598 undef $i; 599 ++$has_option{build}; 600 } elsif ($option =~ /-prefix$/) { 601 undef $il; 602 ++$has_option{prefix}; 603 } elsif ($option =~ /-sources$/) { 604 undef $l; 605 undef $il; 606 ++$has_option{sources}; 607 } 608 my ($fi, $fl, $fil, $fs) 609 = find_in_dir($try, $i, $l, $il, undef, undef, $src); 610 if ($fi || $fl || $fil) { 611 $found_itf = $fi if (! $found_itf && $fi); 612 $found_lib = $fl if (! $found_lib && $fl); 613 $found_ilib = $fil if (! $found_ilib && $fil); 614 $found_src = $fs if (! $found_src && $fs); 615 } elsif (! ($try =~ /$a{name}$/)) { 616 $try = File::Spec->catdir($try, $a{name}); 617 ($fi, $fl, $fil, $fs) 618 = find_in_dir($try, $i, $l, $il, undef, undef, $src); 619 $found_itf = $fi if (! $found_itf && $fi); 620 $found_lib = $fl if (! $found_lib && $fl); 621 $found_ilib = $fil if (! $found_ilib && $fil); 622 $found_src = $fs if (! $found_src && $fs); 623 } 624 } elsif ($need_bin) { 625 my (undef, $fl, $fil) 626 = find_in_dir($try, undef, $lib, $ilib, undef, $bin); 627 $found_bin = $fl if ($fl); 628 } 629 } 630 } 631 if (! $found_itf && ! $has_option{sources} && $a{srcpath}) { 632 my $try = $a{srcpath}; 633 ($found_itf, undef, undef, $found_src) 634 = find_in_dir($try, $inc, undef, undef, undef, undef, $src); 635 } 636 if (! $has_option{prefix}) { 637 my $try = $a{pkgpath}; 638 if (($need_itf && ! $found_itf) || ($need_lib && ! $found_lib)) { 639 my ($fi, $fl) = find_in_dir($try, $inc, $lib); 640 $found_itf = $fi if (! $found_itf && $fi); 641 $found_lib = $fl if (! $found_lib && $fl); 642 } 643 644 if ($need_jar && ! $found_jar) { 645 (undef, $found_jar) = find_in_dir($try, undef, undef, undef, $lib); 646 } 647 648 $try = $a{usrpath}; 649 if (($need_itf && ! $found_itf) || ($need_lib && ! $found_lib)) { 650 my ($fi, $fl) = find_in_dir($try, $inc, $lib); 651 $found_itf = $fi if (! $found_itf && $fi); 652 $found_lib = $fl if (! $found_lib && $fl); 653 } 654 655 if ($need_jar && ! $found_jar) { 656 (undef, $found_jar) = find_in_dir($try, undef, undef, undef, $lib); 657 } 658 } 659 if (! $has_option{build}) { 660 if ($a{bldpath}) { 661 my $tolib = $need_build || ($need_lib && ! $found_lib); 662 my $tobin = $need_bin && ! $found_bin; 663 my $tojar = $need_jar && ! $found_jar; 664 if ($tolib || $tobin || $tojar) { 665 my ($fl, $fil, $found); 666 if ($OPT{'build-prefix'}) { 667 my $try = $OPT{'build-prefix'}; 668 if ($tolib) { 669 (undef, $fl, $fil) 670 = find_in_dir($try, undef, $lib, $ilib); 671 if ($fl || $fil) { 672 $found_lib = $fl if (! $found_lib && $fl); 673 $found_ilib = $fil if (! $found_ilib && $fil); 674 ++$found; 675 } 676 } 677 if ($tojar) { 678 (undef, $found_jar) 679 = find_in_dir($try, undef, undef, undef, $lib); 680 } 681 if (! ($try =~ /$a{name}$/)) { 682 $try = File::Spec->catdir($try, $a{name}); 683 if ($tolib && ! $found) { 684 (undef, $fl, $fil) 685 = find_in_dir($try, undef, $lib, $ilib); 686 if ($fl || $fil) { 687 $found_lib = $fl if (! $found_lib && $fl); 688 $found_ilib = $fil if (! $found_ilib && $fil); 689 ++$found; 690 } 691 } 692 if ($need_jar && ! $found_jar) { 693 (undef, $found_jar) 694 = find_in_dir($try, undef, undef, undef, $lib); 695 } 696 } 697 } 698 unless ($found || $fl || $fil) { 699 my $try = $a{bldpath}; 700 $try = $a{locbldpath} if ($OPT{'local-build-out'}); 701 if ($tolib && ! $found) { 702 (undef, $fl, $fil) 703 = find_in_dir($try, undef, $lib, $ilib); 704 my $resetLib = ! $found_lib; 705 if (! $found_ilib && $fil) { 706 $found_ilib = $fil; 707 ++$resetLib; 708 } 709 $found_lib = $fl if ($resetLib && $fl); 710 } 711 if ($tobin && ! $found) { 712 (undef, $fl, $fil) = 713 find_in_dir($try, undef, $lib, $ilib, undef, $bin); 714 $found_bin = $fl if ($fl); 715 } 716 if ($need_jar && ! $found_jar) { 717 (undef, $found_jar) 718 = find_in_dir($try, undef, undef, undef, $lib); 719 } 720 } 721 } 722 } 723 } 724 if (($need_itf && ! $found_itf) || ($need_lib && ! $found_lib) || 725 ($need_jar && ! $found_jar) || ($ilib && ! $found_ilib) || 726 ($need_bin && ! $found_bin)) 727 { 728 if ($is_optional) { 729 println "configure: optional $a{name} package not found: skipped."; 730 } elsif ($quasi_optional && $found_itf && ($need_lib && ! $found_lib)) { 731 println "configure: $a{name} package: " 732 . "found interface files but not libraries."; 733 $found_itf = abs_path($found_itf); 734 push(@dependencies, "$a{aname}_INCDIR = $found_itf"); 735 println "includes: $found_itf"; 736 } else { 737 if ($OPT{'debug'}) { 738 $_ = "$a{name}: includes: "; 739 $found_itf = '' unless $found_itf; 740 $_ .= $found_itf; 741 unless ($need_lib) { 742 $_ .= "; libs: not needed"; 743 } else { 744 $found_lib = '' unless $found_lib; 745 $_ .= "; libs: " . $found_lib; 746 } 747 unless ($ilib) { 748 $_ .= "; ilibs: not needed"; 749 } else { 750 $found_ilib = '' unless $found_ilib; 751 $_ .= "; ilibs: " . $found_ilib; 752 } 753 println "\t\t$_"; 754 } 755 println "configure: error: required $a{name} package not found."; 756 exit 1; 757 } 758 } else { 759 if ($found_itf) { 760 $found_itf = abs_path($found_itf); 761 push(@dependencies, "$a{aname}_INCDIR = $found_itf"); 762 println "includes: $found_itf"; 763 } 764 if ($found_src) { 765 $found_src = abs_path($found_src); 766 push(@dependencies, "$a{aname}_SRCDIR = $found_src"); 767 println "sources: $found_src"; 768 } 769 if ($found_lib) { 770 $found_lib = abs_path($found_lib); 771 if ($a{aname} eq 'NGS' || $a{aname} eq 'VDB') { 772 if ($OPT{PYTHON_LIB_PATH}) { 773 $OPT{PYTHON_LIB_PATH} .= ':'; 774 } else { 775 $OPT{PYTHON_LIB_PATH} = ''; 776 } 777 $OPT{PYTHON_LIB_PATH} .= $found_lib; 778 } 779 push(@dependencies, "$a{aname}_LIBDIR = $found_lib"); 780 println "libraries: $found_lib"; 781 } 782 if ($ilib && $found_ilib) { 783 $found_ilib = abs_path($found_ilib); 784 push(@dependencies, "$a{aname}_ILIBDIR = $found_ilib"); 785 println "ilibraries: $found_ilib"; 786 } 787 if ($found_bin) { 788 $found_bin = abs_path($found_bin); 789 push(@dependencies, "$a{aname}_BINDIR = $found_bin"); 790 println "bin: $found_bin"; 791 } 792 if ($found_jar) { 793 $found_jar = abs_path($found_jar); 794 push(@dependencies, "$a{aname}_JAR = $found_jar"); 795 println "jar: $found_jar"; 796 } 797 } 798} 799 800my ($E_BINDIR, $E_LIBDIR, $E_VERSION_LIBX, $E_MAJVERS_LIBX, 801 $E_VERSION_EXEX, $E_MAJVERS_EXEX) 802 = ('' , ''); 803 804println unless ($AUTORUN); 805 806if ($OS ne 'win' && ! $OPT{'status'}) { 807 if ($OSTYPE =~ /darwin/i && CONFIG_OUT() ne '.') { 808 my $COMP = File::Spec->catdir(CONFIG_OUT(), 'COMP.mac'); 809 println "configure: creating '$COMP' ($TOOLS)" unless ($AUTORUN); 810 open F, ">$COMP" or die "cannot open $COMP to write"; 811 print F "$TOOLS\n"; 812 close F; 813 } 814 815 if ($TOOLS =~ /gcc$/) { 816 my $EXECMDF = File::Spec->catdir(CONFIG_OUT(), 'ld.linux.exe_cmd.sh'); 817 println "configure: creating '$EXECMDF'" unless ($AUTORUN); 818 open F, ">$EXECMDF" or die "cannot open $EXECMDF to write"; 819 print F "EXE_CMD=\"\$LD $STATIC_LIBSTDCPP -static-libgcc\"\n"; 820 close F; 821 } 822 823 # create Makefile.config 824 println "configure: creating '$OUT_MAKEFILE'" unless ($AUTORUN); 825 open my $F, ">$OUT_MAKEFILE" or die "cannot open $OUT_MAKEFILE to write"; 826 827 print $F <<EndText; 828### AUTO-GENERATED FILE ### 829 830# configuration command 831 832CONFIGURED = $CONFIGURED 833 834OS_ARCH = \$(shell perl \$(TOP)/setup/os-arch.perl) 835 836# install paths 837EndText 838 839 L($F, "INST_BINDIR = $OPT{'bindir'}" ) if ($OPT{'bindir'}); 840 L($F, "INST_LIBDIR = $OPT{'libdir'}" ) if ($OPT{'libdir'}); 841 L($F, "INST_INCDIR = $OPT{'includedir'}" ) if ($OPT{'includedir'}); 842 L($F, "INST_SCHEMADIR = $OPT{'shemadir'}" ) if ($OPT{'shemadir'}); 843 L($F, "INST_SHAREDIR = $OPT{'sharedir'}" ) if ($OPT{'sharedir'}); 844 L($F, "INST_JARDIR = $OPT{'javadir'}" ) if ($OPT{'javadir'}); 845 L($F, "INST_PYTHONDIR = $OPT{'pythondir'}") if ($OPT{'pythondir'}); 846 847 my ($E_VERSION_SHLX, $VERSION_SHLX, 848 $E_MAJVERS_SHLX , $MAJMIN_SHLX, $MAJVERS_SHLX); 849 if ($OSTYPE =~ /darwin/i) { 850 $E_VERSION_SHLX = '$VERSION.$SHLX'; 851 $VERSION_SHLX = '$(VERSION).$(SHLX)'; 852 $MAJMIN_SHLX = '$(MAJMIN).$(SHLX)'; 853 $E_MAJVERS_SHLX = '$MAJVERS.$SHLX'; 854 $MAJVERS_SHLX = '$(MAJVERS).$(SHLX)'; 855 } else { 856 $E_VERSION_SHLX = '$SHLX.$VERSION'; 857 $VERSION_SHLX = '$(SHLX).$(VERSION)'; 858 $MAJMIN_SHLX = '$(SHLX).$(MAJMIN)'; 859 $E_MAJVERS_SHLX = '$SHLX.$MAJVERS'; 860 $MAJVERS_SHLX = '$(SHLX).$(MAJVERS)'; 861 } 862 863 $E_VERSION_LIBX = '$LIBX.$VERSION'; 864 $E_MAJVERS_LIBX = '$LIBX.$MAJVERS'; 865 866 L($F); 867 L($F, "# build type"); 868 869 if ($OPT{'enable-static'}) { 870 L($F, "WANTS_STATIC = 1"); 871 } 872 873 $E_VERSION_EXEX = '$EXEX.$VERSION'; 874 $E_MAJVERS_EXEX = '$LIBX.$MAJVERS'; 875 876 print $F <<EndText; 877BUILD = $BUILD 878 879# target OS 880OS = $OS 881OSINC = $OSINC 882OS_DISTRIBUTOR = $OS_DISTRIBUTOR 883 884# prefix string for system libraries 885LPFX = $LPFX 886 887# suffix strings for system libraries 888LIBX = $LIBX 889VERSION_LIBX = \$(LIBX).\$(VERSION) 890MAJMIN_LIBX = \$(LIBX).\$(MAJMIN) 891MAJVERS_LIBX = \$(LIBX).\$(MAJVERS) 892 893SHLX = $SHLX 894VERSION_SHLX = $VERSION_SHLX 895MAJMIN_SHLX = $MAJMIN_SHLX 896MAJVERS_SHLX = $MAJVERS_SHLX 897 898# suffix strings for system object files 899OBJX = $OBJX 900LOBX = $LOBX 901 902# suffix string for system executable 903EXEX = $EXEX 904VERSION_EXEX = \$(EXEX).\$(VERSION) 905MAJMIN_EXEX = \$(EXEX).\$(MAJMIN) 906MAJVERS_EXEX = \$(EXEX).\$(MAJVERS) 907 908# system architecture and wordsize 909ARCH = $ARCH 910EndText 911 912 L($F, "# ARCH = $ARCH ( $MARCH )") if ($ARCH ne $MARCH); 913 914 print $F <<EndText; 915BITS = $BITS 916 917# tools 918EndText 919 920 L($F, "CC = $CC" ) if ($CC); 921 L($F, "CPP = $CPP" ) if ($CPP); 922 L($F, "CP = $CP" ) if ($CP); 923 L($F, "AR = $AR" ) if ($AR); 924 L($F, "ARX = $ARX" ) if ($ARX); 925 L($F, "ARLS = $ARLS" ) if ($ARLS); 926 L($F, "LD = $LD" ) if ($LD); 927 L($F, "LP = $LP" ) if ($LP); 928 L($F, "PYTHON = $PYTHON" ) if ($PYTHON); 929 L($F, "JAVAC = $JAVAC" ) if ($JAVAC); 930 L($F, "JAVAH = $JAVAH" ) if ($JAVAH); 931 L($F, "JAR = $JAR" ) if ($JAR); 932 L($F, "MAKE_MANIFEST = $MAKE_MANIFEST") if ($MAKE_MANIFEST); 933 L($F); 934 935 L($F, '# tool options'); 936 if ($BUILD eq "dbg") { 937 L($F, "DBG = $DBG"); 938 L($F, "OPT = "); 939 } else { 940 L($F, "DBG = -DNDEBUG") if ($PKG{LNG} eq 'C'); 941 L($F, "OPT = $OPT" ) if ($OPT); 942 } 943 L($F, "PIC = $PIC") if ($PIC); 944 if ($PKG{LNG} eq 'C') { 945 if ($TOOLS =~ /clang/i) { 946 L($F, 'SONAME = -install_name ' . 947 '$(INST_LIBDIR)/$(subst $(VERSION),$(MAJVERS),$(@F)) \\'); 948 L($F, ' -compatibility_version $(MAJMIN) -current_version $(VERSION) \\'); 949 L($F, ' -flat_namespace -undefined suppress'); 950 } else { 951 L($F, 'SONAME = -Wl,-soname=$(subst $(VERSION),$(MAJVERS),$(@F))'); 952 } 953 L($F, "SRCINC = $INC. $INC\$(SRCDIR)"); 954 } elsif ($PKG{LNG} eq 'JAVA') { 955 L($F, 'SRCINC = -sourcepath $(INCPATHS)'); 956 } 957 if ($PIC) { 958 if (PACKAGE_NAMW() eq 'NGS') { 959 L($F, "INCDIRS = \$(SRCINC) $INC\$(TOP) " 960 . "$INC\$(TOP)/ngs/\$(OSINC)/\$(ARCH)") 961 } elsif (PACKAGE_NAMW() eq 'NGS_BAM') { 962 L($F, "INCDIRS = \$(SRCINC) $INC\$(TOP) " 963 . "$INC\$(NGS_INCDIR)/ngs/\$(OSINC)/\$(ARCH)") 964 } else { 965 L($F, "INCDIRS = \$(SRCINC) $INC\$(TOP)") 966 } 967 } 968 if ($PKG{LNG} eq 'C') { 969 L($F, "CFLAGS = \$(DBG) \$(OPT) \$(INCDIRS) $MD $ARCH_FL"); 970 } 971 L($F, "LDFLAGS = $LDFLAGS") if ($LDFLAGS); 972 973 L($F, 'CLSPATH = -classpath $(CLSDIR)'); 974 L($F, "NO_ARRAY_BOUNDS_WARNING = $NO_ARRAY_BOUNDS_WARNING"); 975 L($F); 976 977# $PACKAGE_NAME and library version 978# \$(VERSION) is defined in a separate file which is updated every release 979 L($F, "include \$(TOP)/" . CONFIG_OUT() . "/Makefile.vers" ); 980 981 print $F <<EndText; 982 983empty := 984space := \$(empty) \$(empty) 985MAJMIN = \$(subst \$(space),.,\$(wordlist 1,2,\$(subst .,\$(space),\$(VERSION)))) 986MAJVERS = \$(firstword \$(subst .,\$(space),\$(VERSION))) 987 988# output path 989BUILD_PREFIX = $BUILD_PREFIX 990TARGDIR = $TARGDIR 991 992# derived paths 993MODPATH ?= \$(subst \$(TOP)/,,\$(CURDIR)) 994SRCDIR ?= \$(TOP)/\$(MODPATH) 995MAKEFILE ?= \$(abspath \$(firstword \$(MAKEFILE_LIST))) 996BINDIR = \$(TARGDIR)/bin 997EndText 998 999 if ($PKG{LNG} eq 'C') { 1000 $E_BINDIR = '$TARGDIR/bin'; 1001 $E_LIBDIR = '$TARGDIR/lib'; 1002 L($F, 'LIBDIR = $(TARGDIR)/lib'); 1003 } elsif ($PKG{LNG} eq 'JAVA') { 1004 $E_LIBDIR = '$TARGDIR/jar'; 1005 L($F, 'LIBDIR = $(TARGDIR)/jar'); 1006 } 1007 1008 L($F, 'ILIBDIR = $(TARGDIR)/ilib'); 1009 if ($PKG{NOMODPATH}) { 1010 L($F, 'OBJDIR = $(TARGDIR)/obj'); 1011 } else { 1012 L($F, 'OBJDIR = $(TARGDIR)/obj/$(MODPATH)'); 1013 } 1014 L($F, 'CLSDIR = $(TARGDIR)/cls'); 1015 1016 if ($PKG{LNG} eq 'JAVA') { 1017 L($F, 1018 "INCPATHS = \$(SRCDIR):\$(SRCDIR)/itf:\$(TOP)/gov/nih/nlm/ncbi/ngs") 1019 } 1020 1021 print $F <<EndText; 1022 1023# exports 1024export TOP 1025export MODPATH 1026export SRCDIR 1027export MAKEFILE 1028 1029# auto-compilation rules 1030EndText 1031 1032 if ($PKG{LNG} eq 'C') { 1033 L($F, '$(OBJDIR)/%.$(OBJX): %.c'); 1034 T($F, '$(CC) -o $@ $< $(CFLAGS)'); 1035 L($F, '$(OBJDIR)/%.$(LOBX): %.c'); 1036 T($F, '$(CC) -o $@ $< $(PIC) $(CFLAGS)'); 1037 } 1038 L($F, '$(OBJDIR)/%.$(OBJX): %.cpp'); 1039 T($F, '$(CP) -std=c++11 -o $@ $< $(CFLAGS)'); 1040 L($F, '$(OBJDIR)/%.$(LOBX): %.cpp'); 1041 T($F, '$(CP) -std=c++11 -o $@ $< $(PIC) $(CFLAGS)'); 1042 L($F); 1043 1044 # this is part of Makefile 1045 L($F, 'VPATH = $(SRCDIR)'); 1046 L($F); 1047 1048 # we know how to find jni headers 1049 if ($PKG{LNG} eq 'JAVA' and $OPT{'with-ngs-sdk-src'}) { 1050 L($F, "JNIPATH = $OPT{'with-ngs-sdk-src'}/language/java"); 1051 } 1052 1053 L($F, '# directory rules'); 1054 if ($PKG{LNG} eq 'C') { 1055 L($F, '$(BINDIR) $(LIBDIR) $(ILIBDIR) ' 1056 . '$(OBJDIR) $(INST_LIBDIR) $(INST_LIBDIR):'); 1057 T($F, 'mkdir -p $@'); 1058 } elsif ($PKG{LNG} eq 'JAVA') { 1059 # test if we have jni header path 1060 L($F, '$(LIBDIR) $(CLSDIR) $(INST_JARDIR):'); 1061 T($F, 'mkdir -p $@'); 1062 } 1063 L($F); 1064 1065 L($F, '# not real targets'); 1066 L($F, '.PHONY: default clean install all std $(TARGETS)'); 1067 L($F); 1068 1069 L($F, '# dependencies'); 1070 if ($PKG{LNG} eq 'C') { 1071 L($F, 'include $(wildcard $(OBJDIR)/*.d)'); 1072 } elsif ($PKG{LNG} eq 'JAVA') { 1073 L($F, 'include $(wildcard $(CLSDIR)/*.d)'); 1074 } 1075 L($F, $_) foreach (@dependencies); 1076 L($F); 1077 1078 # pass HAVE_XML2 to build scripts 1079 L($F, 'ifeq (,$(HAVE_XML2))'); 1080 L($F, ' HAVE_XML2=0'); 1081 L($F, 'endif'); 1082 L($F, 'CONFIGURE_FOUND_XML2=$(HAVE_XML2)'); 1083 L($F, 'export CONFIGURE_FOUND_XML2'); 1084 L($F); 1085 1086 if ($OS eq 'linux' || $OS eq 'mac') { 1087 L($F, '# installation rules'); 1088 L($F, 1089 '$(INST_LIBDIR)/%.$(VERSION_LIBX): $(LIBDIR)/%.$(VERSION_LIBX)'); 1090 T($F, '@ echo -n "installing \'$(@F)\'... "'); 1091 T($F, '@ if cp $^ $@ && chmod 644 $@; \\'); 1092 T($F, ' then \\'); 1093 T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) ' 1094 . '$(patsubst %$(VERSION_LIBX),%$(LIBX),$@) ' 1095 . '$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$@); \\'); 1096 T($F, ' ln -s $(@F) $(patsubst %$(VERSION),%$(MAJVERS),$@); \\'); 1097 T($F, ' ln -s $(patsubst %$(VERSION),%$(MAJVERS),$(@F)) ' 1098 . '$(patsubst %$(VERSION_LIBX),%$(LIBX),$@); \\'); 1099 T($F, ' ln -s $(patsubst %$(VERSION_LIBX),%$(LIBX),$(@F)) ' . 1100 '$(INST_LIBDIR)/$(patsubst %.$(VERSION_LIBX),%-static.$(LIBX),$(@F));' 1101 . ' \\'); 1102 T($F, ' echo success; \\'); 1103 T($F, ' else \\'); 1104 T($F, ' echo failure; \\'); 1105 T($F, ' false; \\'); 1106 T($F, ' fi'); 1107 L($F); 1108 1109 L($F, 1110 '$(INST_LIBDIR)/%.$(VERSION_SHLX): $(LIBDIR)/%.$(VERSION_SHLX)'); 1111 T($F, '@ echo -n "installing \'$(@F)\'... "'); 1112 T($F, '@ if cp $^ $@ && chmod 755 $@; \\'); 1113 T($F, ' then \\'); 1114 if ($OS ne 'mac') { 1115 T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) ' 1116 . '$(patsubst %$(VERSION_SHLX),%$(SHLX),$@); \\'); 1117 } 1118 if ($OS eq 'linux') { 1119 T($F, ' ln -s $(@F) $(patsubst %$(VERSION),%$(MAJVERS),$@); \\'); 1120 } elsif ($OS eq 'mac') { 1121 T($F, ' ln -sf $(@F) ' 1122 . '$(patsubst %$(VERSION_SHLX),%$(MAJVERS).$(SHLX),$@); \\'); 1123 } else { 1124 die; 1125 } 1126 T($F, ' ln -sf $(patsubst %$(VERSION),%$(MAJVERS),$(@F)) ' 1127 . '$(patsubst %$(VERSION_SHLX),%$(SHLX),$@); \\'); 1128 T($F, ' echo success; \\'); 1129 T($F, ' else \\'); 1130 T($F, ' echo failure; \\'); 1131 T($F, ' false; \\'); 1132 T($F, ' fi'); 1133 L($F); 1134 1135 L($F, '$(INST_BINDIR)/%$(VERSION_EXEX): $(BINDIR)/%$(VERSION_EXEX)'); 1136 T($F, '@ echo -n "installing \'$(@F)\'... "'); 1137 T($F, '@ if cp $^ $@ && chmod 755 $@; \\'); 1138 T($F, ' then \\'); 1139 T($F, ' rm -f $(patsubst %$(VERSION),%$(MAJVERS),$@) ' 1140 . '$(patsubst %$(VERSION_EXEX),%$(EXEX),$@); \\'); 1141 T($F, ' ln -s $(@F) $(patsubst %$(VERSION),%$(MAJVERS),$@); \\'); 1142 T($F, ' ln -s $(patsubst %$(VERSION),%$(MAJVERS),$(@F)) ' 1143 . '$(patsubst %$(VERSION_EXEX),%$(EXEX),$@); \\'); 1144 T($F, ' echo success; \\'); 1145 T($F, ' else \\'); 1146 T($F, ' echo failure; \\'); 1147 T($F, ' false; \\'); 1148 T($F, ' fi'); 1149 } 1150 close $F; 1151 1152 # creation of Makefile.config.install is disabled, since nobody uses it now 1153 # and I need to remove versions from prl scripts 1154 if (0) { 1155 # create Makefile.config.install 1156 println "configure: creating '$INS_MAKEFILE'" unless ($AUTORUN); 1157 open $F, ">$INS_MAKEFILE" or die "cannot open $INS_MAKEFILE to write"; 1158 1159 $OPT{'javadir' } = '' unless ($OPT{'javadir' }); 1160 $OPT{'sharedir'} = '' unless ($OPT{'sharedir'}); 1161 1162 print $F "sub CONFIGURE {\n"; 1163 print $F " \$_{PACKAGE_NAME } = '$PACKAGE_NAME';\n"; 1164 print $F " \$_{VERSION } = '\$VERSION';\n"; 1165 print $F " \$_{LNG } = '$PKG{LNG}';\n"; 1166 print $F " \$_{OS } = '$OS';\n"; 1167 print $F " \$_{BITS } = $BITS;\n"; 1168 print $F " \$_{MAJVERS } = \$MAJVERS;\n"; 1169 print $F " \$_{LPFX } = '$LPFX';\n"; 1170 print $F " \$_{LIBX } = '$LIBX';\n"; 1171 print $F " \$_{MAJVERS_LIBX } = '" . expand($E_MAJVERS_LIBX) . "';\n"; 1172 print $F " \$_{VERSION_LIBX } = '" . expand($E_VERSION_LIBX) . "';\n"; 1173 print $F " \$_{SHLX } = '$SHLX';\n"; 1174 print $F " \$_{MAJVERS_SHLX } = '" . expand($E_MAJVERS_SHLX) . "';\n"; 1175 print $F " \$_{VERSION_SHLX } = '" . expand($E_VERSION_SHLX) . "';\n"; 1176 print $F " \$_{VERSION_EXEX } = '" . expand($E_VERSION_EXEX) . "';\n"; 1177 print $F " \$_{MAJVERS_EXEX } = '" . expand($E_MAJVERS_EXEX) . "';\n"; 1178 print $F " \$_{INCDIR } = '" . expand("$Bin/.." ) . "';\n"; 1179 if ($PKG{LNG} ne 'PYTHON') { 1180 print $F " \$_{BINDIR$BITS} = '" . expand($E_BINDIR ) . "';\n"; 1181 print $F " \$_{LIBDIR} = '" . expand($E_LIBDIR ) . "';\n"; 1182 } elsif ($OPT{PYTHON_LIB_PATH}) { 1183 print $F " \$_{LIBDIR} = '$OPT{PYTHON_LIB_PATH}';\n"; 1184 } 1185 print $F " \$_{OTHER_PREFIX } = '$PKG{UPATH}';\n"; 1186 print $F " \$_{PREFIX } = '$OPT{'prefix'}';\n"; 1187 print $F " \$_{INST_INCDIR } = '$OPT{'includedir'}';\n"; 1188 print $F " \$_{INST_BINDIR } = '$OPT{'bindir'}';\n"; 1189 print $F " \$_{INST_LIBDIR } = '$OPT{'libdir'}';\n"; 1190 print $F " \$_{INST_JARDIR } = '$OPT{'javadir'}';\n"; 1191 print $F " \$_{INST_SHAREDIR} = '$OPT{'sharedir'}';\n"; 1192 print $F "\n"; 1193 print $F " \@_\n"; 1194 print $F "}\n"; 1195 print $F "\n"; 1196 print $F "1\n"; 1197 1198 close $F; 1199 } 1200} 1201 1202if (! $OPT{'status'} ) { 1203 if ($OS eq 'win') { 1204 my $OUT = File::Spec->catdir(CONFIG_OUT(), 'Makefile.config.win'); 1205 println "configure: creating '$OUT'"; 1206 open OUT, ">$OUT" or die "cannot open $OUT to write"; 1207 my $name = PACKAGE_NAMW(); 1208 my $outdir = $name . '_OUTDIR'; 1209 my $root = $name . '_ROOT'; 1210 1211 print OUT <<EndText; 1212<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 1213 <PropertyGroup Label="Globals"> 1214 <$outdir>$TARGDIR/\</$outdir> 1215EndText 1216 foreach my $href (@REQ) { 1217 my %a = %$href; 1218 my $NGS_SDK_PREFIX = ''; 1219 $NGS_SDK_PREFIX = $a{found_itf} if ($a{found_itf}); 1220 if ($a{name} eq 'ngs-sdk') { 1221 my $root = "$a{aname}_ROOT"; 1222 print OUT " <$root>$NGS_SDK_PREFIX\/</$root>\n"; 1223 last; 1224 } 1225 } 1226 print OUT <<EndText; 1227 <$root>$Bin/\</$root> 1228 </PropertyGroup> 1229</Project> 1230EndText 1231 close OUT; 1232 } else { 1233 println "configure: creating 'Makefile.config'" unless ($AUTORUN); 1234 my $CONFIG_OUT = CONFIG_OUT(); 1235 my $out = File::Spec->catdir($CONFIG_OUT, 'Makefile.config'); 1236 open COUT, ">$out" or die "cannot open $out to write"; 1237 print COUT "### AUTO-GENERATED FILE ###\n"; 1238 print COUT "\n"; 1239 print COUT "OS_ARCH = \$(shell perl \$(TOP)/setup/os-arch.perl)\n"; 1240 print COUT "include \$(TOP)/$CONFIG_OUT/Makefile.config.\$(OS_ARCH)\n"; 1241 close COUT; 1242 } 1243} 1244 1245unless ($OPT{'reconfigure'}) { 1246 println "configure: creating 'reconfigure'" unless ($AUTORUN); 1247 $CONFIGURED =~ s/\t/ /g; 1248 open my $F, '>reconfigure' or die 'cannot open reconfigure to write'; 1249 print $F "./configure $CONFIGURED\n"; 1250 close $F; 1251 # my $perm = (stat $fh)[2] & 07777; 1252# print "==================================================== $perm\n"; 1253} 1254 1255status() if ($OS ne 'win'); 1256 1257unlink 'a.out'; 1258 1259sub L { $_[1] = '' unless ($_[1]); print { $_[0] } "$_[1]\n" } 1260sub T { print { $_[0] } "\t$_[1]\n" } 1261 1262sub status { 1263 my ($load) = @_; 1264 if ($load) { 1265 ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch(); 1266 my $MAKEFILE 1267 = File::Spec->catdir(CONFIG_OUT(), "$OUT_MAKEFILE.$OS.$ARCH"); 1268 println "\t\tloading $MAKEFILE" if ($OPT{'debug'}); 1269 unless (-e $MAKEFILE) { 1270 print STDERR "configure: error: run ./configure [OPTIONS] first.\n"; 1271 exit 1; 1272 } 1273 open F, $MAKEFILE or die "cannot open $MAKEFILE"; 1274 foreach (<F>) { 1275 chomp; 1276 if (/BUILD = (.+)/) { 1277 $BUILD_TYPE = $1; 1278 } elsif (/BUILD \?= /) { 1279 $BUILD_TYPE = $_ unless ($BUILD_TYPE); 1280 } elsif (/BUILD_PREFIX = /) { 1281 $BUILD_PREFIX = $_; 1282 } elsif (/^CC += (.+)/) { 1283 $CC = $1; 1284 } elsif (/CONFIGURED = (.*)/) { 1285 $CONFIGURED = $1; 1286 } elsif (/CPP += (.+)/) { 1287 $CPP = $1; 1288 } elsif (/LDFLAGS += (.+)/) { 1289 $LDFLAGS = $1; 1290 } elsif (/TARGDIR = /) { 1291 $TARGDIR = $_; 1292 println "\t\tgot $_" if ($OPT{'debug'}); 1293 } elsif (/TARGDIR \?= (.+)/) { 1294 $TARGDIR = $1 unless ($TARGDIR); 1295 println "\t\tgot $_" if ($OPT{'debug'}); 1296 } 1297 elsif (/INST_INCDIR = (.+)/) { 1298 $OPT{'includedir'} = $1; 1299 } 1300 elsif (/INST_BINDIR = (.+)/) { 1301 $OPT{'bindir'} = $1; 1302 } 1303 elsif (/INST_LIBDIR = (.+)/) { 1304 $OPT{'libdir'} = $1; 1305 } 1306 } 1307 } 1308 1309 println "build type: $BUILD_TYPE"; 1310 println "build prefix: $BUILD_PREFIX" if ($OS ne 'win'); 1311 println "build output path: $TARGDIR" if ($OS ne 'win'); 1312 1313# print "prefix: "; print $OPT{'prefix'} if ($OS ne 'win'); println; 1314# print "eprefix: "; print $OPT{'eprefix'} if ($OPT{'eprefix'}); println; 1315 1316 print "includedir: "; 1317 print $OPT{'includedir'} if ($OPT{'includedir'}); 1318 println; 1319 1320 print "bindir: "; 1321 print $OPT{'bindir'} if ($OPT{'bindir'}); 1322 println; 1323 1324 print "libdir: "; 1325 print $OPT{'libdir'} if ($OPT{'libdir'}); 1326 println; 1327 1328 println "schemadir: $OPT{'shemadir'}" if ($OPT{'shemadir'}); 1329 println "sharedir: $OPT{'sharedir'}" if ($OPT{'sharedir'}); 1330 println "javadir: $OPT{'javadir'}" if ($OPT{'javadir'}); 1331 println "pythondir: $OPT{'pythondir'}" if ($OPT{'pythondir'}); 1332 1333 println "CC = $CC" if ($CC ); 1334 println "CPP = $CPP" if ($CPP); 1335 println "LDFLAGS = $LDFLAGS" if ($LDFLAGS); 1336 1337 $CONFIGURED =~ s/\t/ /g; 1338 println "configured with: \"$CONFIGURED\""; 1339} 1340 1341sub expand { $_[0] =~ s/(\$\w+)/$1/eeg; $_[0]; } 1342 1343sub expand_path { 1344 my ($filename) = @_; 1345 return unless ($filename); 1346 1347 if ($filename =~ /^~/) { 1348 if ($filename =~ m|^~([^/]*)|) { 1349 if ($1 && ! getpwnam($1)) { 1350 print "configure: error: bad path: '$filename'\n"; 1351 exit 1; 1352 } 1353 } 1354 1355 $filename =~ s{ ^ ~ ( [^/]* ) } 1356 { $1 1357 ? (getpwnam($1))[7] 1358 : ( $ENV{HOME} || $ENV{USERPROFILE} || $ENV{LOGDIR} 1359 || (getpwuid($<))[7] 1360 ) 1361 }ex; 1362 } 1363 1364 my $a = abs_path($filename); 1365 $filename = $a if ($a); 1366 $filename; 1367} 1368 1369sub find_in_dir { 1370 my ($dir, $include, $lib, $ilib, $jar, $bin, $src) = @_; 1371 unless (-d $dir) { 1372 println "\t\tnot found $dir" if ($OPT{'debug'}); 1373 return; 1374 } 1375 my ($found_inc, $found_lib, $found_ilib, $found_src); 1376 if ($include) { 1377 print "\tincludes... " unless ($AUTORUN); 1378 if (-e "$dir/$include") { 1379 println $dir unless ($AUTORUN); 1380 $found_inc = $dir; 1381 } elsif (-e "$dir/include/$include") { 1382 println $dir unless ($AUTORUN); 1383 $found_inc = "$dir/include"; 1384 } elsif (-e "$dir/interfaces/$include") { 1385 println $dir unless ($AUTORUN); 1386 $found_inc = "$dir/interfaces"; 1387 } else { 1388 print "$dir: " if ($OPT{'debug'}); 1389 println 'no' unless ($AUTORUN); 1390 } 1391 } 1392 if ($lib || $ilib) { 1393 print "\tlibraries... " unless ($AUTORUN); 1394 if ($lib) { 1395 my $builddir = File::Spec->catdir($dir, $OS, $TOOLS, $ARCH, $BUILD); 1396 my $libdir = File::Spec->catdir($builddir, 'lib'); 1397 my $ilibdir = File::Spec->catdir($builddir, 'ilib'); 1398 my $f = File::Spec->catdir($libdir, $lib); 1399 print "\n\t\tchecking $f\n\t" if ($OPT{'debug'}); 1400 my $found; 1401 if (-e $f) { 1402 $found_lib = $libdir; 1403 if ($ilib) { 1404 my $f = File::Spec->catdir($ilibdir, $ilib); 1405 print "\tchecking $f\n\t" if ($OPT{'debug'}); 1406 if (-e $f) { 1407 println $ilibdir; 1408 $found_ilib = $ilibdir; 1409 } else { 1410 println 'no' unless ($AUTORUN); 1411 return; 1412 } 1413 } else { 1414 println $libdir; 1415 } 1416 ++$found; 1417 } 1418 if (! $found) { 1419 my $libdir = File::Spec->catdir($dir, 'lib'); 1420 my $f = File::Spec->catdir($libdir, $lib); 1421 print "\tchecking $f\n\t" if ($OPT{'debug'}); 1422 if (-e $f) { 1423 println $libdir; 1424 $found_lib = $libdir; 1425 ++$found; 1426 } 1427 } 1428 if (! $found) { 1429 my $builddir = File::Spec->catdir 1430 ($dir, $OS, $TOOLS, $ARCH, reverse_build($BUILD)); 1431 my $libdir = File::Spec->catdir($builddir, 'lib'); 1432 my $ilibdir = File::Spec->catdir($builddir, 'ilib'); 1433 my $f = File::Spec->catdir($libdir, $lib); 1434 print "\tchecking $f\n\t" if ($OPT{'debug'}); 1435 if (-e $f) { 1436 $found_lib = $libdir; 1437 if ($ilib) { 1438 my $f = File::Spec->catdir($ilibdir, $ilib); 1439 print "\tchecking $f\n\t" if ($OPT{'debug'}); 1440 if (-e $f) { 1441 println $ilibdir; 1442 $found_ilib = $ilibdir; 1443 } else { 1444 println 'no' unless ($AUTORUN); 1445 return; 1446 } 1447 } else { 1448 println $libdir; 1449 } 1450 ++$found; 1451 } else { 1452 println 'no' unless ($AUTORUN); 1453 } 1454 } 1455 } 1456 if ($found_lib && $ilib && ! $found_ilib) { 1457 println "\n\t\tfound $found_lib but no ilib/" if ($OPT{'debug'}); 1458 print "\t" if ($OPT{'debug'}); 1459 println 'no' unless ($AUTORUN); 1460 undef $found_lib; 1461 } 1462 } 1463 if ($bin) { 1464 print "\t... " unless ($AUTORUN); 1465 my $builddir = File::Spec->catdir($dir, $OS, $TOOLS, $ARCH, $BUILD); 1466 my $bdir = File::Spec->catdir($builddir, 'bin'); 1467 my $f = File::Spec->catdir($bdir, $bin); 1468 print "\n\t\tchecking $f\n\t" if ($OPT{'debug'}); 1469 if (-e $f) { 1470 $found_lib = $bdir; 1471 println $bdir; 1472 } else { 1473 println 'no' unless ($AUTORUN); 1474 } 1475 } 1476 if ($jar) { 1477 print "\tjar... " unless ($AUTORUN); 1478 my $try = "$dir/jar/$jar"; 1479 if (-e "$try") { 1480 println $try unless ($AUTORUN); 1481 $found_lib = $try; 1482 } 1483 } 1484 if ($src) { 1485 print "\tsrc... " unless ($AUTORUN); 1486 my $try = "$dir/$src"; 1487 if (-e "$try") { 1488 println $dir unless ($AUTORUN); 1489 $found_src = $dir; 1490 } 1491 } 1492 return ($found_inc, $found_lib, $found_ilib, $found_src); 1493} 1494 1495sub reverse_build { 1496 ($_) = @_; 1497 if ($_ eq 'rel') { 1498 return 'dbg'; 1499 } elsif ($_ eq 'dbg') { 1500 return 'rel'; 1501 } else { 1502 die $_; 1503 } 1504} 1505 1506################################################################################ 1507 1508sub check_tool_h { return check_tool(@_, '-help'); } 1509sub check_tool__h { return check_tool(@_, '--help'); } 1510 1511sub check_tool { 1512 my ($tool, $o) = @_; 1513 print "checking for $tool... "; 1514 my $cmd = "$tool $o"; 1515 print "\n\t\trunning $cmd\n\t" if ($OPT{'debug'}); 1516 my $out = `$cmd 2>&1`; 1517 if ($? == 0) { 1518 println "yes"; 1519 return 1; 1520 } else { 1521 println "no"; 1522 return 0; 1523 } 1524} 1525 1526sub check_qmake { 1527 print "checking for QMake... "; 1528 1529 my $tool = 'qmake'; 1530 print "\n\t\trunning $tool... " if ($OPT{'debug'}); 1531 my $out = `$tool -v 2>&1`; 1532 if ($? == 0) { 1533 my $out = `( $tool -v | grep QMake ) 2>&1`; 1534 if ($? == 0) { 1535 print "$out " if ($OPT{'debug'}); 1536 println $tool; 1537 return $tool; 1538 } 1539 1540 println "wrong qmake" if ($OPT{'debug'}); 1541 1542 print "\t\tchecking $ENV{PATH}...\n" if ($OPT{'debug'}); 1543 foreach ( split(/:/, $ENV{PATH})) { 1544 my $cmd = "$_/$tool"; 1545 print "\t\trunning $cmd... " if ($OPT{'debug'}); 1546 my $out = `( $cmd -v | grep QMake ) 2>&1`; 1547 if ($? == 0) { 1548 print "$out " if ($OPT{'debug'}); 1549 if ( $out =~ /QMake/ ) { 1550 println $cmd; 1551 return $cmd; 1552 } 1553 } 1554 1555 println "no" if ($OPT{'debug'}); 1556 } 1557 } 1558 1559 if ( $OS eq 'linux' ) { 1560 if ( $OS_DISTRIBUTOR eq 'CentOS' ) { 1561 foreach ( glob ( "$ENV{HOME}/Qt/*/gcc_64" ) ) { 1562 $tool = "$_/bin/qmake"; 1563 print "\n\t\tchecking $tool... " if ($OPT{'debug'}); 1564 my $out = `( $tool -v | grep QMake ) 2>&1`; 1565 if ($? == 0) { 1566 print "$out " if ($OPT{'debug'}); 1567 println $tool; 1568 return $tool; 1569 } 1570 } 1571 1572 $tool = '/usr/lib64/qt5/bin/qmake'; 1573 1574 } elsif ( $OS_DISTRIBUTOR eq 'Ubuntu' ) { 1575 foreach ( glob ( "$ENV{HOME}/Qt*/*/gcc_64" ) ) { 1576 $tool = "$_/bin/qmake"; 1577 print "\n\t\tchecking $tool... " if ($OPT{'debug'}); 1578 my $out = `( $tool -v | grep QMake ) 2>&1`; 1579 if ($? == 0) { 1580 print "$out " if ($OPT{'debug'}); 1581 println $tool; 1582 return $tool; 1583 } 1584 } 1585 1586 $tool = ''; 1587 } 1588 } elsif ( $OS eq 'mac' ) { 1589 $tool = '/Applications/QT/5.10.1/clang_64/bin/qmake'; 1590 } 1591 1592 if ( $tool ) { 1593 print "\n\t\tchecking $tool... " if ($OPT{'debug'}); 1594 my $out = `( $tool -v | grep QMake ) 2>&1`; 1595 if ($? == 0) { 1596 print "$out " if ($OPT{'debug'}); 1597 println $tool; 1598 return $tool; 1599 } 1600 } 1601 1602 println "no"; 1603 return ''; 1604} 1605 1606sub check_static_libstdcpp { 1607 my $option = '-static-libstdc++'; 1608 1609 print "checking whether $CPP accepts $option... "; 1610 1611 my $log = 'int main() {}\n'; 1612 my $cmd = $log; 1613 $cmd =~ s/\\n/\n/g; 1614 my $gcc = "echo -e '$log' | $CPP -xc $option - 2>&1"; 1615 print "\n\t\trunning $gcc\n" if ($OPT{'debug'}); 1616 my $out = `$gcc`; 1617 my $ok = $? == 0; 1618 if ( $ok && $out ) { 1619 $ok = 0 if ( $out =~ /unrecognized option '-static-libstdc\+\+'/ ); 1620 } 1621 print "$out\t" if ($OPT{'debug'}); 1622 println $ok ? 'yes' : 'no'; 1623 1624 unlink 'a.out'; 1625 1626 return '' if (!$ok); 1627 1628 return $option; 1629} 1630 1631sub check_no_array_bounds { 1632 check_compiler('O', '-Wno-array-bounds'); 1633} 1634 1635sub find_lib { 1636 check_compiler('L', @_); 1637} 1638 1639sub check_compiler { 1640 my ($t, $n, $I, @l) = @_; 1641 my $tool = $TOOLS; 1642 1643 if ($t eq 'L') { 1644 print "checking for $n library... "; 1645 } elsif ($t eq 'O') { 1646 if ($tool && ($tool =~ /gcc$/ || $tool =~ /g\+\+$/)) { 1647 print "checking whether $tool accepts $n... "; 1648 } else { 1649 return; 1650 } 1651 } else { 1652 die "Unknown check_compiler option: '$t'"; 1653 } 1654 1655 unless ($tool) { 1656 println "warning: unknown tool"; 1657 return; 1658 } 1659 1660 while (1) { 1661 my ($flags, $library, $log) = ('', ''); 1662 1663 if ($t eq 'O') { 1664 $flags = $n; 1665 $log = ' int main() { }\n' 1666 } elsif ($n eq 'hdf5') { 1667 $library = '-Wl,-Bstatic -lhdf5 -Wl,-Bdynamic -ldl -lm -lz'; 1668 $log = '#include <hdf5.h> \n int main() { H5close (); }\n' 1669 } elsif ($n eq 'fuse') { 1670 $flags = '-D_FILE_OFFSET_BITS=64'; 1671 $library = '-lfuse'; 1672 $log = '#include <fuse.h> \n int main() { fuse_get_context(); }\n' 1673 } elsif ($n eq 'magic') { 1674 $library = '-lmagic'; 1675 $log = '#include <magic.h> \n int main() { magic_open (0); }\n' 1676 } elsif ($n eq 'xml2') { 1677 $library = '-lxml2'; 1678 $library .= ' -liconv' if ($OS eq 'mac'); 1679 $log = '#include <libxml/xmlreader.h>\n' . 1680 'int main() { xmlInitParser ( ); }\n' 1681 } else { 1682 println 'unknown: skipped'; 1683 return; 1684 } 1685 1686 if ($I && ! -d $I) { 1687 print "'$I': " if ($OPT{'debug'}); 1688 println 'no'; 1689 return; 1690 } 1691 1692 for ( my $i = 0; $i <= $#l; ++ $i ) { 1693 print "'$l[$i]': " if ($OPT{'debug'}); 1694 if ( $l [ $i ] ) { 1695 if ( -d $l [ $i ] ) { 1696 last; 1697 } elsif ( $i == $#l ) { 1698 println 'no'; 1699 return; 1700 } 1701 } 1702 } 1703 1704 my $cmd = $log; 1705 $cmd =~ s/\\n/\n/g; 1706 1707 push ( @l, '' ) unless ( @l ); 1708 for my $i ( 0 .. $#l ) { 1709 my $l = $l [ $i ]; 1710 if ( $l && ! -d $l ) { 1711 if ( $i == $#l ) { 1712 println 'no'; 1713 return; 1714 } else { 1715 next; 1716 } 1717 } 1718 my $gcc = "| $tool -xc $flags " . ($I ? "-I$I " : ' ') 1719 . ($l ? "-L$l " : ' ') . "- $library"; 1720 $gcc .= ' 2> /dev/null' unless ($OPT{'debug'}); 1721 1722 open GCC, $gcc or last; 1723 print "\n\t\trunning echo -e '$log' $gcc\n" if ($OPT{'debug'}); 1724 print GCC "$cmd" or last; 1725 my $ok = close GCC; 1726 print "\t" if ($OPT{'debug'}); 1727 if ( $ok ) { 1728 println 'yes'; 1729 } else { 1730 println 'no' if ( $i == $#l ); 1731 } 1732 1733 unlink 'a.out'; 1734 1735 return if ( ! $ok && ( $i == $#l ) ); 1736 1737 return 1 if ($t eq 'O'); 1738 1739 return ($I, $l) if ( $ok) ; 1740 } 1741 } 1742 1743 println "cannot run $tool: skipped"; 1744} 1745 1746################################################################################ 1747 1748sub check { 1749 die "No CONFIG_OUT" unless CONFIG_OUT(); 1750 die "No PACKAGE" unless PACKAGE(); 1751 die "No PACKAGE_NAME" unless PACKAGE_NAME(); 1752 die "No PACKAGE_NAMW" unless PACKAGE_NAMW(); 1753 die "No PACKAGE_TYPE" unless PACKAGE_TYPE(); 1754 1755 my %PKG = PKG(); 1756 1757 die "No LNG" unless $PKG{LNG}; 1758 die "No LOCOUT" unless $PKG{LOCOUT}; 1759 die "No OUT" unless $PKG{OUT}; 1760 die "No PATH" unless $PKG{PATH}; 1761 die "No UPATH" unless $PKG{UPATH}; 1762 1763 foreach my $href (DEPENDS()) { die "No DEPENDS::name" unless $href->{name} } 1764 1765 foreach my $href (REQ()) { 1766 die "No REQ::name" unless $href->{name}; 1767 1768 die "No $href->{name}:option" unless $href->{option} 1769 || $href->{boption}; 1770 1771 die "No $href->{name}:type" unless $href->{type}; 1772 unless ($href->{type} =~ /I/) { 1773 unless ($href->{type} =~ /E/) { 1774 die "No $href->{name}:lib" unless $href->{lib}; 1775 } 1776 die "No $href->{name}:pkgpath" unless $href->{pkgpath}; 1777 die "No $href->{name}:usrpath" unless $href->{usrpath}; 1778 } 1779 1780 die "No $href->{name}:origin" unless $href->{origin}; 1781 if ($href->{origin} eq 'I') { 1782 die "No $href->{name}:aname" unless $href->{aname}; 1783 unless ($href->{type} =~ /D/ || $href->{type} =~ /E/ 1784 || $href->{type} =~ /J/) 1785 { 1786 die "No $href->{name}:include" unless $href->{include}; 1787 die "No $href->{name}:srcpath" unless $href->{srcpath}; 1788 } 1789 unless ($href->{type} =~ /I/) { 1790 die "No $href->{name}:bldpath" unless $href->{bldpath }; 1791 die "No $href->{name}:locbldpath" unless $href->{locbldpath}; 1792 } 1793 if ($href->{type} =~ /B/) { 1794 die "No $href->{name}:ilib" unless $href->{ilib}; 1795 } 1796 } 1797 } 1798} 1799 1800################################################################################ 1801 1802sub optional { $_[0] =~ /O/ } 1803 1804sub help { 1805# --prefix=PREFIX install architecture-independent files in PREFIX 1806 print <<EndText; 1807`configure' configures $PACKAGE_NAME to adapt to many kinds of systems. 1808 1809Usage: ./configure [OPTION]... 1810 1811Defaults for the options are specified in brackets. 1812 1813Configuration: 1814 -h, --help display this help and exit 1815 1816EndText 1817 1818 if ($^O ne 'MSWin32') { 1819 print <<EndText; 1820Installation directories: 1821 --prefix=PREFIX install all files in PREFIX 1822 [$package_default_prefix] 1823 1824EndText 1825 1826 my $other_prefix = $PKG{UPATH}; 1827 if ($PACKAGE eq 'sra-tools' && 0) { 1828 print <<EndText; 1829 --shemadir=DIR install schema files in DIR 1830 [$schema_default_dir] 1831 1832EndText 1833 } 1834 1835 print "By default, \`make install' will install all the files in\n"; 1836 1837 if (PACKAGE_TYPE() eq 'B') { 1838 print "\`$package_default_prefix/bin', "; 1839 } elsif (PACKAGE_TYPE() eq 'L') { 1840 print "\`$package_default_prefix/include', "; 1841 } 1842 if (PACKAGE_TYPE() eq 'P') { 1843 println "\`$package_default_prefix/share' etc."; 1844 } else { 1845 println "\`$package_default_prefix/lib' etc."; 1846 } 1847 1848 print <<EndText; 1849You can specify an installation prefix other than \`$package_default_prefix' 1850using \`--prefix', for instance \`--prefix=$other_prefix'. 1851EndText 1852 } 1853 1854 print <<EndText; 1855 1856For better control, use the options below. 1857 1858EndText 1859 1860 my ($required, $optional); 1861 foreach my $href (@REQ) { 1862 if (optional($href->{type})) { 1863 ++$optional; 1864 } else { 1865 ++$required; 1866 } 1867 } 1868 1869 if ($required) { 1870 print "Required Packages:\n"; 1871 foreach my $href (@REQ) { 1872 next if (optional($href->{type})); 1873 my %a = %$href; 1874 if ($a{type} =~ /S/) { 1875 println " --$a{option}=DIR search for $a{name} package"; 1876 println " source files in DIR"; 1877 } else { 1878 unless ($a{type} =~ /E/) { 1879 println 1880 " --$a{option}=DIR search for $a{name} package in DIR" 1881 } 1882 } 1883 if ($a{boption}) { 1884 println " --$a{boption}=DIR search for $a{name} package"; 1885 println " build output in DIR"; 1886 } 1887 println; 1888 } 1889 } 1890 1891 if ($optional) { 1892 print "Optional Packages:\n"; 1893 foreach my $href (@REQ) { 1894 next unless (optional($href->{type})); 1895 my %a = %$href; 1896 if ($a{option} && $a{option} =~ /-sources$/) { 1897 println " --$a{option}=DIR search for $a{name} package"; 1898 println " source files in DIR"; 1899 } elsif ($a{boption} && $a{boption} =~ /-build$/) { 1900 println " --$a{boption}=DIR search for $a{name} package"; 1901 println " build output in DIR"; 1902 } else { 1903 println " --$a{option}=DIR search for $a{name} files in DIR" 1904 } 1905 } 1906 println; 1907 } 1908 1909 print <<EndText if (PACKAGE_TYPE() eq 'B'); 1910Optional Features: 1911 --enable-static build static executable [default=no] 1912 1913EndText 1914 1915 my ($OS, $ARCH, $OSTYPE, $MARCH, @ARCHITECTURES) = OsArch(); 1916 1917 if ($^O ne 'MSWin32') { 1918 print "Build tuning:\n"; 1919 if ($PKG{LNG} ne 'JAVA') { 1920 print <<EndText; 1921 --with-debug 1922 --without-debug 1923EndText 1924 } 1925 1926 if (@ARCHITECTURES) { 1927 print 1928" --arch=name specify the name of the target architecture\n"; 1929 } 1930 1931 if ($PKG{LNG} eq 'JAVA') { 1932 print <<EndText; 1933 --source=release provide source compatibility with specified release, 1934 generate class files for specified VM version. 1935 e.g. `--source=1.6' 1936EndText 1937 } else { 1938 print "\n"; 1939 } 1940 1941 print <<EndText; 1942 --relative-build-out-dir generate build output into directory 1943 relative to sources [$OUTDIR] 1944 --build-prefix=DIR generate build output into DIR directory 1945 [$OUTDIR] 1946 1947EndText 1948 } 1949 1950 println 'Miscellaneous:'; 1951 println ' --reconfigure rerun `configure\''; 1952 println ' using the same command-line arguments'; 1953 if ($^O ne 'MSWin32') { 1954 println 1955 ' --status print current configuration information' 1956 } 1957 print <<EndText; 1958 --clean remove all configuration results 1959 --debug print lots of debugging information 1960 1961If `configure' was already run running `configure' without options 1962will rerun `configure' using the same command-line arguments. 1963 1964Report bugs to sra-tools\@ncbi.nlm.nih.gov 1965EndText 1966} 1967 1968################################################################################ 1969