#!/usr/bin/env perl # cmake.wrapper - Wrapper for "cmake" # License: Creative Commons Attribution-NonCommercial-ShareAlike 2.5 # Revision: 180316 # Note: The license indicated above applies to this file. It doesn't # apply to the official version of the target program, or to any file # derived from the official package. #--------------------------------------------------------------------- # license information #--------------------------------------------------------------------- # This section may not be modified except as approved by the author or # licensor, or to make non-content changes such as adjustments to par- # agraph formatting or white space. # This version of this software is distributed under the following # license: # # Creative Commons Attribution-NonCommercial-ShareAlike 2.5 # You may use, modify, and redistribute this software without fees or # royalties, but only under the terms and conditions set forth by the # license. In particular, copies and derived works cannot be used for # commercial purposes. Additionally, the license propagates to copies # and derived works. Furthermore, you must provide attribution "in the # manner specified by the author or licensor". The latter point is # discussed below. # The author [and licensor] hereby specifies that attribution must be # handled in the following manner: a. If the software is interactive, # any About or Credits dialog boxes, windows, or output text provided # by the original version must be preserved and readily accessible to # the end user at runtime. b. If the software is non-interactive, or # if it does not provide About or Credits dialog boxes, windows, or # output text, the operating system and/or desktop environment used # must provide attribution that is visible and/or readily accessible # to the end user at runtime. # The following techniques do not meet the attribution requirements: # Attribution through text files, attribution through printed docu- # mentation, verbal attribution, or postings on external web sites # [i.e., web sites that are not an intrinsic local component of the # operating system or desktop environment used]. These examples are # provided for illustrative purposes only. # It should be noted that trademarks are an additional issue. If this # software uses any trademarks, trademark-related restrictions may # apply. # This is not a complete explanation of the terms and conditions in- # volved. For more information, see the Creative Commons Attribution- # NonCommercial-ShareAlike 2.5 license. #--------------------------------------------------------------------- # explanation #--------------------------------------------------------------------- # To be documented. #--------------------------------------------------------------------- # standard module setup #--------------------------------------------------------------------- require 5.16.1; use strict; use Carp; use warnings; # Trap warnings $SIG {__WARN__} = sub { die @_; }; #--------------------------------------------------------------------- # basic constants #--------------------------------------------------------------------- use constant ZERO => 0; # Zero use constant ONE => 1; # One use constant FALSE => 0; # Boolean FALSE use constant TRUE => 1; # Boolean TRUE #--------------------------------------------------------------------- # program parameters #--------------------------------------------------------------------- # To be documented. my $CMVAR = 'CMAKE_PREFIX_PATH'; my $PKGDIR = '__META_PRODTREE__'; #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { my %pkguse = (); my $str = ""; my %LACDONTFIND = (); $str = $ENV {LACDONTFIND}; $str = "" unless defined $str; $str =~ s@\s*[:,;]+\s*@,@g; for my $pkghide (split (/,/, $str)) { next unless length $pkghide; $LACDONTFIND {$pkghide} = ONE; } opendir (DIR, $PKGDIR) || die; while (defined (my $de = readdir (DIR))) { my $fullde = "$PKGDIR/$de"; next unless -d $fullde; # Skip some special cases next unless $de =~ m@^[a-z0-9_\-]+\z@i; next if $de =~ m@^(glibc|glibc\d.*|perl5-\d.*|small-xorg)\z@; next unless (-d "$fullde/include") || (-d "$fullde/lib"); next if -f "$fullde/lib/hidden"; next if defined $LACDONTFIND {$de}; $pkguse {$de} = TRUE; } closedir (DIR); for my $var (qw (LACLDDIRS LACINCDIRS LD_LIBRARY_PATH PATH)) { $str = $ENV {$var}; $str = "" unless defined $str; for my $part (split (/:+/, $str)) { $part =~ s@^\s+@@; $part =~ s@\s+\z@@; next unless -d $part; next unless $part =~ m@^/\w+/pkg/([a-z0-9_\-]+)/@i; $part = $1; next if $part =~ m@^gcc@; next if ($var eq 'PATH') && !((-d "$PKGDIR/$part/include") || (-d "$PKGDIR/$part/lib")); $pkguse {$part} = TRUE; } } $pkguse {'glibc'} = TRUE; $str = $ENV {$CMVAR}; $str = "" unless defined $str; for my $var (sort keys %pkguse) { $str = "$str:$PKGDIR/$var"; } $str .= ":__META_PRODTREE__/xorg"; $str =~ s@:+@:@g; $str =~ s@^:+@@; $str =~ s@:+\z@@; $ENV {$CMVAR} = $str; unshift (@ARGV, 'cmake'); exec { "__META_PREFIX__/bin/cmake.bin" } @ARGV; } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ZERO; # Normal exit