X11-GUITest

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

# with much older Perls (see the 5.005/5.008 guards below), so probing is
# simply skipped -- falling back to the old directory-existence guesses --
# on anything old enough not to have it.
my $HAVE_FILE_TEMP = eval { require File::Temp; File::Temp->import('tempdir'); 1 };

# --- CLI Handler for "make docs" Callback ---
if (@ARGV && $ARGV[0] eq '--build-docs') {
    BuildDocs();
    exit 0;
}

# --- EUMM Version Compatibility Guards ---
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version =~ s/_//g;

my %extra_params;

if ($eumm_version >= 6.31) {
    $extra_params{LICENSE} = 'gpl_2';
}

if ($eumm_version >= 6.46) {
    $extra_params{META_ADD} = {
        resources => {
            homepage   => 'https://sourceforge.net/projects/x11guitest/',
            bugtracker => {
                web => 'https://sourceforge.net/p/x11guitest/tickets/',
            },
        },
    };
    $extra_params{META_MERGE} = {
        resources => {
            repository => {
                type => 'svn',
                url  => 'https://svn.code.sf.net/p/x11guitest/code/trunk',
                web  => 'https://sourceforge.net/p/x11guitest/code/HEAD/tree/trunk/',
            },
        },
    };
}

# --- Compiler Flag Portability Guard ---
# Only append -Wall if using GCC/Clang to avoid breaking native compilers on HP-UX/Solaris/AIX
my $ccflags = $Config{ccflags} || '';
if ($Config{gccversion}) {
    $ccflags .= ' -Wall';
}

# --- Locate X11/XTest headers & libraries ---
# Rather than trusting a fixed list of "does this directory exist" guesses,
# determine what actually works: prefer pkg-config when it knows about x11/
# xtst, otherwise probe candidate locations with a real compile+link and
# keep the first one that succeeds. Only if neither approach can confirm a
# working combination (e.g. no usable compiler available at configure time,
# or File::Temp is unavailable on a very old Perl) do we fall back to the
# previous directory-existence heuristic.
my ($X11_LIBS, $X11_INC) = DetermineX11Flags();

WriteMakefile(
    'NAME'          => 'X11::GUITest',
    ($] ge '5.005') ? (
        'AUTHOR'    => 'Dennis K. Paulsen <ctrondlp@cpan.org>',
    ) : (),
    'VERSION_FROM'  => 'GUITest.pm',
    'ABSTRACT_FROM' => 'GUITest.pm',
    ($] lt '5.008') ? (
        'INST_MAN3DIR' => './blib/man3',
        'MAN3EXT'      => '3pm'
    ) : (),
    'MAN3PODS'      => {'GUITest.pm' => '$(INST_MAN3DIR)/X11::GUITest.$(MAN3EXT)'},
    'LIBS'          => $X11_LIBS,
    # If the target X server has Xinerama active, XTestFakeMotionEvent() is
    # known to misbehave for MoveMouseAbs(). An alternate XWarpPointer()-based
    # implementation exists but isn't auto-detected -- see the DEPENDENCIES
    # section in GUITest.pm for how to opt in via X11_GUITEST_USING_XINERAMA.
    'DEFINE'        => '-DNDEBUG -DX11_GUITEST_ALT_L_FALLBACK_META_L',
    'INC'           => $X11_INC,
    'CCFLAGS'       => $ccflags,
    'OBJECT'        => 'GUITest$(OBJ_EXT) KeyUtil$(OBJ_EXT)',
    'OPTIMIZE'      => '-O2',
    %extra_params,
);


# --- Candidate (include, lib) install-tree pairs to probe, in preference order ---
# Each pair represents one plausible self-contained X11 installation prefix.
# These are only ever used if pkg-config can't tell us, and even then only
# the first pair that actually compiles & links a real X11/XTest test
# program is kept -- see DetermineX11Flags()/CanBuildX11Test() below.
my @X11_PROFILES = (
    # Linux
    ['/usr/X11R6/include',         '/usr/X11R6/lib64'],
    ['/usr/X11R6/include',         '/usr/X11R6/lib'],
    ['/usr/include',               '/usr/lib64'],
    ['/usr/include',               '/usr/lib'],
    # FreeBSD / OpenBSD (ports/pkg install under /usr/local)
    ['/usr/local/include/X11',     '/usr/local/lib'],
    ['/usr/local/include',         '/usr/local/lib'],
    # NetBSD pkgsrc
    ['/usr/pkg/include',           '/usr/pkg/lib'],
    # Solaris: legacy OpenWindows tree (32-bit and 64-bit), modern /usr/X11
    # alias, and the two third-party package managers admins commonly rely
    # on when the base OS has no X11 dev files or toolchain at all.
    ['/usr/openwin/include',       '/usr/openwin/lib'],
    ['/usr/openwin/include',       '/usr/openwin/lib/64'],
    ['/usr/X11/include',           '/usr/X11/lib'],
    ['/opt/csw/include',           '/opt/csw/lib'],
    ['/usr/sfw/include',           '/usr/sfw/lib'],
    # HP-UX: HP shipped both a "base" and a separate "contrib" X11R6 tree
    ['/usr/include/X11R6',         '/usr/lib/X11R6'],
    ['/usr/contrib/X11R6/include', '/usr/contrib/X11R6/lib'],
    ['/opt/X11R6/include',         '/opt/X11R6/lib'],
    # AIX: base X11 fileset, and the AIX Toolbox for Linux Applications
    # (the common source of open-source dependencies on AIX)
    ['/usr/lpp/X11/include',       '/usr/lpp/X11/lib'],
    ['/usr/lpp/X11/include',       '/usr/lpp/X11/lib64'],
    ['/opt/freeware/include',      '/opt/freeware/lib'],
    # Misc legacy alias seen on some Unixes
    ['/usr/X/include',             undef],
);

# --- Determines the LIBS/INC WriteMakefile args for X11 + XTest ---
sub DetermineX11Flags {
    if (my ($libs, $inc) = TryPkgConfig()) {
        print "Using pkg-config for X11/XTest build flags.\n";
        return ($libs, $inc);



( run in 1.599 second using v1.01-cache-2.11-cpan-5e09290becf )