Package: extmake
ExtMake -makewrapper withinclude git=...and moreExtMake is a loose wordplay on a "makewith an ability to includeexternal Makefiles".Whilemakesupports theincludedirective, it can only include files from a
local file system. ExtMake adds an ability to include files from Git
repositories and stays out of the way for everything else. You can see ExtMake
as a preprocessor or a wrapper aroundmake.Features:backward-comptible syntax: any validMakefileis valid forextmakeno new syntax except for the added support ofgit=...extension for theincludedirectivestraightforward implementation reusesmakefor everything elseforward-compatible: ability to eject the configuration into a single
self-containedMakefileMotivationMakefiles are often (ab?)used for task automation in the projects not related
to C. But they are hardly reusable and often get copy-pasted between projects.
Tools for project templating - for example, Cookicutter or Copier in the Python
ecosystem - may be used to facilitate this, but have their drawbacks. Instead,
why not apply the same approach as in all other code - declare a dependency and
load a reusable implementation from a "library"? This is the problem ExtMake is
set to solve, with a touch of simplicity and minimalism.ExampleFilepytest.mkin a GitHub repository "example/test":test:
    poetry run pytest --cov-report term --cov=myproj tests/FileMakefile:include git=git@github.com:example/test.git;rev=1.0.0;path=pytest.mk

build:
    poetry build

all: test buildUsage:extmake allInstallationInstall from PyPI:pip install extmakeIf you prefer so, you can safely aliasextmaketomake. ExtMake will
process regular Makefiles by simply proxying them tomake, albeit with some
overhead.DependenciesMakeGitUsageextmakeextmakeis a wrapper overmakeand proxies all inputs and outputs almost
unchanged. As such, usage in the command line is exactly the same as with a
regularmake.To avoid ambiguity,extmakemay remind the user that they use theextmakewrapper in case of errors, for example. A dedicated message is added to the
stdout in this case, keeping the rest of the originalmakeoutput intact.extmake-editTo keep theextmakeusage transparent with regard tomake, all commands
specific to ExtMake are available throughextmake-edit.extmake-editmay be used to debug the Makefile resolution, or eject from
ExtMake, altogether.For usage, run:extmake-edit --helpSyntaxTheincludedirective is supported bymakenatively and interprets the
arguments as file paths. On top of that, ExtMake can interpret the argument as
a reference to a Git repository. For simplicity, a single Git reference is
allowed for eachincludedirective.include git=URL[;key=value]...The argument is aDSNformatted as a series ofkey=valuepairs separated by a semicolon;.
Following keys are supported:git: a Git repository URL, such that can be used withgit clone; this
is the only mandatory keyrev: a Git commit reference, such as a branch name, a tag name, or a SHA;
defaults tomasterpath: a path within a repository pointing to the file to be included;
defaults toMakefileAs with the originalincludedirective, included resources are inserted
verbatim at the location of the directive. Issues such as conflicting target
names, for example, are not controlled andmakeis left to do its job and
report any further syntax warning or errors.Nested includes are supported.Best practicesTo keep the builds reproducible, it is best to set therevto a tagIf you don't use tags for therev, you can runextmake-edit updateto force the update of the dependencies*.mkis a common naming convention for the files that are to be includedUsing public or private Git serversExtMake uses Git to clone the repository and will effectively reuse the SSH
config to authenticate with a private server, for example.For example, in a file~/.ssh/config:Host gitlab.example.com
    HostName gitlab.example.com
    User git
    IdentityFile ~/.ssh/my_rsaEjectAt any time you can stop using ExtMake. Ejecting will resolve all includes and
generate a single complete Makefile with all included content embedded into it:extmake-edit eject [--file FILE]TroubleshootingFor better performance, both the dependencies and the resolvedMakefilesare cached in the user data directory (somewhere in user$HOME, depending
on the OS). In case of problems, try clearing the cache withextmake-edit cache clear.Feel free toreport a bug.Future featuresA command to list all dependenciesA hint about the use of ExtMake in case of errors raised bymake.Better error handling: whenmakeorgitare not available, all internal
errors.PyPI distribution.Resolve included target names, allow overrides.Add the#super make TARGETdirective (or interpretmake super.TARGET?)A command to generate an override, likeextmake-edit override TARGET.Allow overriding the variables defined in the included files with?=.Update policy to control how often the cloned repositories are updated.
E.g.,update=manual|alwaysin the DSN.