{
    "content": [
        {
            "type": "text",
            "text": "# ExtUtils::MakeMaker::FAQ (perldoc)\n\n## NAME\n\nExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker\n\n## DESCRIPTION\n\nFAQs, tricks and tips for ExtUtils::MakeMaker.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION** (4 subsections)\n- **DESIGN**\n- **PATCHING**\n- **AUTHOR**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "ExtUtils::MakeMaker::FAQ",
        "section": "",
        "mode": "perldoc",
        "summary": "ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "Module Installation",
                        "lines": 160
                    },
                    {
                        "name": "Common errors and problems",
                        "lines": 8
                    },
                    {
                        "name": "Philosophy and History",
                        "lines": 31
                    },
                    {
                        "name": "Module Writing",
                        "lines": 239
                    }
                ]
            },
            {
                "name": "DESIGN",
                "lines": 76,
                "subsections": []
            },
            {
                "name": "PATCHING",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "FAQs, tricks and tips for ExtUtils::MakeMaker.\n",
                "subsections": [
                    {
                        "name": "Module Installation",
                        "content": "How do I install a module into my home directory?\nIf you're not the Perl administrator you probably don't have permission to install a module\nto its default location. Ways of handling this with a lot less manual effort on your part\nare perlbrew and local::lib.\n\nOtherwise, you can install it for your own use into your home directory like so:\n\n# Non-unix folks, replace ~ with /path/to/your/home/dir\nperl Makefile.PL INSTALLBASE=~\n\nThis will put modules into ~/lib/perl5, man pages into ~/man and programs into ~/bin.\n\nTo ensure your Perl programs can see these newly installed modules, set your \"PERL5LIB\"\nenvironment variable to ~/lib/perl5 or tell each of your programs to look in that directory\nwith the following:\n\nuse lib \"$ENV{HOME}/lib/perl5\";\n\nor if $ENV{HOME} isn't set and you don't want to set it for some reason, do it the long way.\n\nuse lib \"/path/to/your/home/dir/lib/perl5\";\n\nHow do I get MakeMaker and Module::Build to install to the same place?\nModule::Build, as of 0.28, supports two ways to install to the same location as MakeMaker.\n\nWe highly recommend the installbase method, its the simplest and most closely approximates\nthe expected behavior of an installation prefix.\n\n1) Use INSTALLBASE / \"--installbase\"\n\nMakeMaker (as of 6.31) and Module::Build (as of 0.28) both can install to the same locations\nusing the \"installbase\" concept. See \"INSTALLBASE\" in ExtUtils::MakeMaker for details. To\nget MM and MB to install to the same location simply set INSTALLBASE in MM and\n\"--installbase\" in MB to the same location.\n\nperl Makefile.PL INSTALLBASE=/whatever\nperl Build.PL    --installbase /whatever\n\nThis works most like other language's behavior when you specify a prefix. We recommend this\nmethod.\n\n2) Use PREFIX / \"--prefix\"\n\nModule::Build 0.28 added support for \"--prefix\" which works like MakeMaker's PREFIX.\n\nperl Makefile.PL PREFIX=/whatever\nperl Build.PL    --prefix /whatever\n\nWe highly discourage this method. It should only be used if you know what you're doing and\nspecifically need the PREFIX behavior. The PREFIX algorithm is complicated and focused on\nmatching the system installation.\n\nHow do I keep from installing man pages?\nRecent versions of MakeMaker will only install man pages on Unix-like operating systems by\ndefault. To generate manpages on non-Unix operating systems, make the \"manifypods\" target.\n\nFor an individual module:\n\nperl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none\n\nIf you want to suppress man page installation for all modules you have to reconfigure Perl\nand tell it 'none' when it asks where to install man pages.\n\nHow do I use a module without installing it?\nTwo ways. One is to build the module normally...\n\nperl Makefile.PL\nmake\nmake test\n\n...and then use blib to point Perl at the built but uninstalled module:\n\nperl -Mblib script.pl\nperl -Mblib -e '...'\n\nThe other is to install the module in a temporary location.\n\nperl Makefile.PL INSTALLBASE=~/tmp\nmake\nmake test\nmake install\n\nAnd then set PERL5LIB to ~/tmp/lib/perl5. This works well when you have multiple modules to\nwork with. It also ensures that the module goes through its full installation process which\nmay modify it. Again, local::lib may assist you here.\n\nHow can I organize tests into subdirectories and have them run?\nLet's take the following test directory structure:\n\nt/foo/sometest.t\nt/bar/othertest.t\nt/bar/baz/anothertest.t\n\nNow, inside of the \"WriteMakeFile()\" function in your Makefile.PL, specify where your tests\nare located with the \"test\" directive:\n\ntest => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'}\n\nThe first entry in the string will run all tests in the top-level t/ directory. The second\nwill run all test files located in any subdirectory under t/. The third, runs all test files\nwithin any subdirectory within any other subdirectory located under t/.\n\nNote that you do not have to use wildcards. You can specify explicitly which subdirectories\nto run tests in:\n\ntest => {TESTS => 't/*.t t/foo/*.t t/bar/baz/*.t'}\n\nPREFIX vs INSTALLBASE from Module::Build::Cookbook\nThe behavior of PREFIX is complicated and depends closely on how your Perl is configured.\nThe resulting installation locations will vary from machine to machine and even different\ninstallations of Perl on the same machine. Because of this, its difficult to document where\nprefix will place your modules.\n\nIn contrast, INSTALLBASE has predictable, easy to explain installation locations. Now that\nModule::Build and MakeMaker both have INSTALLBASE there is little reason to use PREFIX\nother than to preserve your existing installation locations. If you are starting a fresh\nPerl installation we encourage you to use INSTALLBASE. If you have an existing installation\ninstalled via PREFIX, consider moving it to an installation structure matching INSTALLBASE\nand using that instead.\n\nGenerating *.pm files with substitutions eg of $VERSION\nIf you want to configure your module files for local conditions, or to automatically insert\na version number, you can use EUMM's \"PLFILES\" capability, where it will automatically run\neach *.PL it finds to generate its basename. For instance:\n\n# Makefile.PL:\nrequire 'common.pl';\nmy $version = getversion();\nmy @pms = qw(Foo.pm);\nWriteMakefile(\nNAME => 'Foo',\nVERSION => $version,\nPM => { map { ($ => \"\\$(INSTLIB)/$\") } @pms },\nclean => { FILES => join ' ', @pms },\n);\n\n# common.pl:\nsub getversion { '0.04' }\nsub process { my $v = getversion(); s/VERSION/$v/g; }\n1;\n\n# Foo.pm.PL:\nrequire 'common.pl';\n$ = join '', <DATA>;\nprocess();\nmy $file = shift;\nopen my $fh, '>', $file or die \"$file: $!\";\nprint $fh $;\nDATA\npackage Foo;\nour $VERSION = 'VERSION';\n1;\n\nYou may notice that \"PLFILES\" is not specified above, since the default of mapping each .PL\nfile to its basename works well.\n\nIf the generated module were architecture-specific, you could replace \"$(INSTLIB)\" above\nwith \"$(INSTARCHLIB)\", although if you locate modules under lib, that would involve\nensuring any \"lib/\" in front of the module location were removed.\n"
                    },
                    {
                        "name": "Common errors and problems",
                        "content": "\"No rule to make target `/usr/lib/perl5/CORE/config.h', needed by `Makefile'\"\nJust what it says, you're missing that file. MakeMaker uses it to determine if perl has been\nrebuilt since the Makefile was made. It's a bit of a bug that it halts installation.\n\nSome operating systems don't ship the CORE directory with their base perl install. To solve\nthe problem, you likely need to install a perl development package such as perl-devel\n(CentOS, Fedora and other Redhat systems) or perl (Ubuntu and other Debian systems).\n"
                    },
                    {
                        "name": "Philosophy and History",
                        "content": "Why not just use <insert other build config tool here>?\nWhy did MakeMaker reinvent the build configuration wheel? Why not just use autoconf or\nautomake or ppm or Ant or ...\n\nThere are many reasons, but the major one is cross-platform compatibility.\n\nPerl is one of the most ported pieces of software ever. It works on operating systems I've\nnever even heard of (see perlport for details). It needs a build tool that can work on all\nthose platforms and with any wacky C compilers and linkers they might have.\n\nNo such build tool exists. Even make itself has wildly different dialects. So we have to\nbuild our own.\n\nWhat is Module::Build and how does it relate to MakeMaker?\nModule::Build is a project by Ken Williams to supplant MakeMaker. Its primary advantages\nare:\n\n*       pure perl. no make, no shell commands\n\n*       easier to customize\n\n*       cleaner internals\n\n*       less cruft\n\nModule::Build was long the official heir apparent to MakeMaker. The rate of both its\ndevelopment and adoption has slowed in recent years, though, and it is unclear what the\nfuture holds for it. That said, Module::Build set the stage for *something* to become the\nheir to MakeMaker. MakeMaker's maintainers have long said that it is a dead end and should\nbe kept functioning, while being cautious about extending with new features.\n"
                    },
                    {
                        "name": "Module Writing",
                        "content": "How do I keep my $VERSION up to date without resetting it manually?\nOften you want to manually set the $VERSION in the main module distribution because this is\nthe version that everybody sees on CPAN and maybe you want to customize it a bit. But for\nall the other modules in your dist, $VERSION is really just bookkeeping and all that's\nimportant is it goes up every time the module is changed. Doing this by hand is a pain and\nyou often forget.\n\nProbably the easiest way to do this is using perl-reversion in Perl::Version:\n\nperl-reversion -bump\n\nIf your version control system supports revision numbers (git doesn't easily), the simplest\nway to do it automatically is to use its revision number (you are using version control,\nright?).\n\nIn CVS, RCS and SVN you use $Revision$ (see the documentation of your version control system\nfor details). Every time the file is checked in the $Revision$ will be updated, updating\nyour $VERSION.\n\nSVN uses a simple integer for $Revision$ so you can adapt it for your $VERSION like so:\n\n($VERSION) = q$Revision$ =~ /(\\d+)/;\n\nIn CVS and RCS version 1.9 is followed by 1.10. Since CPAN compares version numbers\nnumerically we use a sprintf() to convert 1.9 to 1.009 and 1.10 to 1.010 which compare\nproperly.\n\n$VERSION = sprintf \"%d.%03d\", q$Revision$ =~ /(\\d+)\\.(\\d+)/g;\n\nIf branches are involved (ie. $Revision: 1.5.3.4$) it's a little more complicated.\n\n# must be all on one line or MakeMaker will get confused.\n$VERSION = do { my @r = (q$Revision$ =~ /\\d+/g); sprintf \"%d.\".\"%03d\" x $#r, @r };\n\nIn SVN, $Revision$ should be the same for every file in the project so they would all have\nthe same $VERSION. CVS and RCS have a different $Revision$ per file so each file will have a\ndifferent $VERSION. Distributed version control systems, such as SVK, may have a different\n$Revision$ based on who checks out the file, leading to a different $VERSION on each\nmachine! Finally, some distributed version control systems, such as darcs, have no concept\nof revision number at all.\n\nWhat's this META.yml thing and how did it get in my MANIFEST?!\nMETA.yml is a module meta-data file pioneered by Module::Build and automatically generated\nas part of the 'distdir' target (and thus 'dist'). See \"Module Meta-Data\" in\nExtUtils::MakeMaker.\n\nTo shut off its generation, pass the \"NOMETA\" flag to \"WriteMakefile()\".\n\nHow do I delete everything not in my MANIFEST?\nSome folks are surprised that \"make distclean\" does not delete everything not listed in\ntheir MANIFEST (thus making a clean distribution) but only tells them what they need to\ndelete. This is done because it is considered too dangerous. While developing your module\nyou might write a new file, not add it to the MANIFEST, then run a \"distclean\" and be sad\nbecause your new work was deleted.\n\nIf you really want to do this, you can use \"ExtUtils::Manifest::manifind()\" to read the\nMANIFEST and File::Find to delete the files. But you have to be careful. Here's a script to\ndo that. Use at your own risk. Have fun blowing holes in your foot.\n\n#!/usr/bin/perl -w\n\nuse strict;\n\nuse File::Spec;\nuse File::Find;\nuse ExtUtils::Manifest qw(maniread);\n\nmy %manifest = map  {( $ => 1 )}\ngrep { File::Spec->canonpath($) }\nkeys %{ maniread() };\n\nif( !keys %manifest ) {\nprint \"No files found in MANIFEST.  Stopping.\\n\";\nexit;\n}\n\nfind({\nwanted   => sub {\nmy $path = File::Spec->canonpath($);\n\nreturn unless -f $path;\nreturn if exists $manifest{ $path };\n\nprint \"unlink $path\\n\";\nunlink $path;\n},\nnochdir => 1\n},\n\".\"\n);\n\nWhich tar should I use on Windows?\nWe recommend ptar from Archive::Tar not older than 1.66 with '-C' option.\n\nWhich zip should I use on Windows for '[ndg]make zipdist'?\nWe recommend InfoZIP: <http://www.info-zip.org/Zip.html>\n\nXS\nHow do I prevent \"object version X.XX does not match bootstrap parameter Y.YY\" errors?\nXS code is very sensitive to the module version number and will complain if the version\nnumber in your Perl module doesn't match. If you change your module's version # without\nrerunning Makefile.PL the old version number will remain in the Makefile, causing the XS\ncode to be built with the wrong number.\n\nTo avoid this, you can force the Makefile to be rebuilt whenever you change the module\ncontaining the version number by adding this to your WriteMakefile() arguments.\n\ndepend => { '$(FIRSTMAKEFILE)' => '$(VERSIONFROM)' }\n\nHow do I make two or more XS files coexist in the same directory?\nSometimes you need to have two and more XS files in the same package. There are three ways:\n\"XSMULTI\", separate directories, and bootstrapping one XS from another.\n\nXSMULTI Structure your modules so they are all located under lib, such that \"Foo::Bar\" is in\nlib/Foo/Bar.pm and lib/Foo/Bar.xs, etc. Have your top-level \"WriteMakefile\" set the\nvariable \"XSMULTI\" to a true value.\n\nEr, that's it.\n\nSeparate directories\nPut each XS files into separate directories, each with their own Makefile.PL. Make\nsure each of those Makefile.PLs has the correct \"CFLAGS\", \"INC\", \"LIBS\" etc. You\nwill need to make sure the top-level Makefile.PL refers to each of these using\n\"DIR\".\n\nBootstrapping\nLet's assume that we have a package \"Cool::Foo\", which includes \"Cool::Foo\" and\n\"Cool::Bar\" modules each having a separate XS file. First we use the following\n*Makefile.PL*:\n\nuse ExtUtils::MakeMaker;\n\nWriteMakefile(\nNAME              => 'Cool::Foo',\nVERSIONFROM      => 'Foo.pm',\nOBJECT              => q/$(OFILES)/,\n# ... other attrs ...\n);\n\nNotice the \"OBJECT\" attribute. MakeMaker generates the following variables in\n*Makefile*:\n\n# Handy lists of source code files:\nXSFILES= Bar.xs \\\nFoo.xs\nCFILES = Bar.c \\\nFoo.c\nOFILES = Bar.o \\\nFoo.o\n\nTherefore we can use the \"OFILES\" variable to tell MakeMaker to use these objects\ninto the shared library.\n\nThat's pretty much it. Now write *Foo.pm* and *Foo.xs*, *Bar.pm* and *Bar.xs*, where\n*Foo.pm* bootstraps the shared library and *Bar.pm* simply loading *Foo.pm*.\n\nThe only issue left is to how to bootstrap *Bar.xs*. This is done from *Foo.xs*:\n\nMODULE = Cool::Foo PACKAGE = Cool::Foo\n\nBOOT:\n# boot the second XS file\nbootCoolBar(aTHX cv);\n\nIf you have more than two files, this is the place where you should boot extra XS\nfiles from.\n\nThe following four files sum up all the details discussed so far.\n\nFoo.pm:\n-------\npackage Cool::Foo;\n\nrequire DynaLoader;\n\nour @ISA = qw(DynaLoader);\nour $VERSION = '0.01';\nbootstrap Cool::Foo $VERSION;\n\n1;\n\nBar.pm:\n-------\npackage Cool::Bar;\n\nuse Cool::Foo; # bootstraps Bar.xs\n\n1;\n\nFoo.xs:\n-------\n#include \"EXTERN.h\"\n#include \"perl.h\"\n#include \"XSUB.h\"\n\nMODULE = Cool::Foo  PACKAGE = Cool::Foo\n\nBOOT:\n# boot the second XS file\nbootCoolBar(aTHX cv);\n\nMODULE = Cool::Foo  PACKAGE = Cool::Foo  PREFIX = coolfoo\n\nvoid\ncoolfooperlrules()\n\nCODE:\nfprintf(stderr, \"Cool::Foo says: Perl Rules\\n\");\n\nBar.xs:\n-------\n#include \"EXTERN.h\"\n#include \"perl.h\"\n#include \"XSUB.h\"\n\nMODULE = Cool::Bar  PACKAGE = Cool::Bar PREFIX = coolbar\n\nvoid\ncoolbarperlrules()\n\nCODE:\nfprintf(stderr, \"Cool::Bar says: Perl Rules\\n\");\n\nAnd of course a very basic test:\n\nt/cool.t:\n--------\nuse Test;\nBEGIN { plan tests => 1 };\nuse Cool::Foo;\nuse Cool::Bar;\nCool::Foo::perlrules();\nCool::Bar::perlrules();\nok 1;\n\nThis tip has been brought to you by Nick Ing-Simmons and Stas Bekman.\n\nAn alternative way to achieve this can be seen in Gtk2::CodeGen and Glib::CodeGen.\n"
                    }
                ]
            },
            "DESIGN": {
                "content": "MakeMaker object hierarchy (simplified)\nWhat most people need to know (superclasses on top.)\n\nExtUtils::MMAny\n|\nExtUtils::MMUnix\n|\nExtUtils::MM{Current OS}\n|\nExtUtils::MakeMaker\n|\nMY\n\nThe object actually used is of the class MY which allows you to override bits of MakeMaker\ninside your Makefile.PL by declaring MY::foo() methods.\n\nMakeMaker object hierarchy (real)\nHere's how it really works:\n\nExtUtils::MMAny\n|\nExtUtils::MMUnix\n|\nExtUtils::Liblist::Kid          ExtUtils::MM{Current OS} (if necessary)\n|                                          |\nExtUtils::Liblist     ExtUtils::MakeMaker        |\n|     |                          |\n|     |   |-----------------------\nExtUtils::MM\n|          |\nExtUtils::MY         MM (created by ExtUtils::MM)\n|                                   |\nMY (created by ExtUtils::MY)        |\n.                       |\n(mixin)                    |\n.                       |\nPACK### (created each call to ExtUtils::MakeMaker->new)\n\nNOTE: Yes, this is a mess. See <http://archive.develooper.com/makemaker@perl.org/msg00134.html>\nfor some history.\n\nNOTE: When ExtUtils::MM is loaded it chooses a superclass for MM from amongst the ExtUtils::MM*\nmodules based on the current operating system.\n\nNOTE: ExtUtils::MM{Current OS} represents one of the ExtUtils::MM* modules except\nExtUtils::MMAny chosen based on your operating system.\n\nNOTE: The main object used by MakeMaker is a PACK### object, *not* ExtUtils::MakeMaker. It is,\neffectively, a subclass of MY, ExtUtils::MakeMaker, ExtUtils::Liblist and ExtUtils::MM{Current\nOS}\n\nNOTE: The methods in MY are simply copied into PACK### rather than MY being a superclass of\nPACK###. I don't remember the rationale.\n\nNOTE: ExtUtils::Liblist should be removed from the inheritance hiearchy and simply be called as\nfunctions.\n\nNOTE: Modules like File::Spec and Exporter have been omitted for clarity.\n\nThe MM* hierarchy\nMMWin95   MMNW5\n\\      /\nMMBeOS  MMCygwin  MMOS2  MMVMS  MMWin32  MMDOS  MMUWIN\n\\        |      |         |        /      /      /\n------------------------------------------------\n|       |\nMMUnix    |\n|    |\nMMAny\n\nNOTE: Each direct MMUnix subclass is also an MMAny subclass. This is a temporary hack because\nMMUnix overrides some MMAny methods with Unix specific code. It allows the non-Unix modules to\nsee the original MMAny implementations.\n\nNOTE: Modules like File::Spec and Exporter have been omitted for clarity.\n",
                "subsections": []
            },
            "PATCHING": {
                "content": "If you have a question you'd like to see added to the FAQ (whether or not you have the answer)\nplease either:\n\n* make a pull request on the MakeMaker github repository\n\n* raise a issue on the MakeMaker github repository\n\n* file an RT ticket\n\n* email makemaker@perl.org\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "The denizens of makemaker@perl.org.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "ExtUtils::MakeMaker\n",
                "subsections": []
            }
        }
    }
}