Package: almost-make
AlmostMakeA pure-python, not-quite-POSIX-compliant implementation of make.Sample Supported Makefile(s)This example consists of a lightly-edited set of files from AlmostMake's tests.macroDefinitions.mk# Use the mini-shell built into AlmostMakeexport_BUILTIN_SHELL:=1export_CUSTOM_BASE_COMMANDS:=1CC=clangCFLAGS=TEST_MACRO=Testing1234=:=:=This**should**work!# A comment!EXEC_PROGRAM=SEND_MACROS:=EXEC_PROGRAM=$(EXEC_PROGRAM)CC=$(CC)CFLAGS=$(CFLAGS)TEST_MACRO="$(TEST_MACRO)"# Note: '=' defers expansion. ':=' does not.exportMAKEFLAGS:=$(MAKEFLAGS)$(SEND_MACROS)Makefile# To be run with AlmostMake.include *.mkall:testSimpletestPhonytestMacrostestRecursiontestParalleltestMisctest%:$(MAKE)-C$@clean$(MAKE)-C$@check$(MAKE)-C$@clean.PHONY:testSimpletestPhonytestMacrostestRecursiontestParalleltestMisctestSimple/Makefile.POSIX:all:# Note: As of v0.0.19, chmod is not built-in.check:allchmodu+xmain$(EXEC_PROGRAM)./main|grepPASSall:mainclean:-rm-fmain.o-rm-fmainmain:main.o$(CC)main.c-omain.SUFFIXES:.c.o.c.o:$(CC)$(CFLAGS)-c$<-o$@UsageAlmostMake comes with thealmakeandalmake_shellcommand-line utilities. Let's see how to use them!almakeRunningalmakein a directory with a file namedMakefilecausesalmaketo satisfy the first target defined in that file.For example, sayMakefilecontains the following:# A makefile!# This is the first target.# (Pretend `echo 'Hello, world'`# is indented with a single tab)firstTarget:echo'Hello, world'# firstTarget isn't the name of a real file!# Mark it as PHONY. We need this because if# firstTarget were to be a file in the same# folder as Makefile, its existence (and lack# of newer dependencies) would cause `almake`# to do nothing!.PHONY:firstTargetalmakethen runs the commands associated with firstTarget. Each line is given its own shell.Additional options are documented throughalmake's helptext:$almake--help
Help:Summary:Satisfydependenciesofatargetinamakefile.ThisparserisnotquitePOSIX-compliant,butshouldbeabletoparsesimplemakefiles.Usage:almake[targets...][options]whereeachtargetintargetsisavalidtargetandoptionsinclude:-h,--helpPrintthismessage.--versionPrintversionandlicensinginformation.--fileFiletoparse(defaultisMakefile).-kKeepgoingiferrorsareencountered.-n,--just-printJustprintcommandstoberun,withoutevaluating(printcommands,don't send them to the shell). Be aware that $(shell ...) macros are still evaluated. This option only applies to individual commands.-p                           Rather than finding targets, print the makefile, with top-level targets expanded.-C dir                       Switch to directory, dir, before running make.-w, --print-directory        Print the current directory before and after running make.-j, --jobs                   Maximum number of jobs (e.g. almake -j 8).-s, --silent                 In most cases, don'tprintoutput.-b,--built-in-shellUsethebuilt-inshellforcommandsinthemakefile.Thiscanalsobeenabledasfollows:export_BUILTIN_SHELL:=1# Use the built-in shell instead of the system shell.export_CUSTOM_BASE_COMMANDS:=1# Enable built-in overrides for several commands like ls, echo, cat, grep, and pwd.export_SYSTEM_SHELL_PIPES:=1# Send commands that seem related to pipes (e.g. ls | less) directly to the system's shell.Note:AlmostMake'sbuilt-inshelliscurrentlyverylimited.

Note:Macrodefinitionsthatoverridethosefromtheenvironmentcanbeprovidedinadditiontotargetsandoptions.Forexample,maketarget1target2target3CC=gccCFLAGS=-O3
shouldmaketarget1,target2,andtarget3withthemacrosCCandCFLAGSbydefaultsettogccand-O3,respectively.
Note:Optionscanalsobegiventoalmakethroughtheenvironment.ThisisdonethroughtheMAKEFLAGSvariable.Forexample,settingMAKEFLAGSto--built-in-shellcausesalmaketoalwaysuseitsbuilt-inshell,ratherthanthesystemshell.almake_shellIn addition to thealmakecommand, thealmake_shellcommand is available. This command gives access to an interactive version of the (very limited) shell built into AlmostMake.Likealmake, we get usage information as follows:$almake_shell--help
Help:Summary:Runaninteractiveversionoftheshellbuiltintoalmake.ThisisaPOSIX-likeshell.ItisnotPOSIX-compliant.Usage:almake_shell[options][files...]...whereeachfilenamein[files...]isanoptionalfiletointerpret.Iffilesaregiven,interpretthembeforeopeningtheshell.
Optionsinclude:-h,--helpPrintthismessage.--versionPrintversionandlicensinginformation.-B,--without-builtinsDonot(re)definebuilt-incommands(likeecho).Bydefault,echo,ls,dir,pwd,andperhapsothercommands,aredefinedandoverrideanycommandswiththesamenamealreadypresentinthesystem.-p,--system-pipeRatherthanattemptingtopipeoutputbetweencommands(e.g.inls|grepfoo),sendpipedportionsoftheinputtothesystem'sshell.Thealmost_makePython moduleAlmostMake also makes available thealmost_makemodule! Documentation on this is coming, but for now, check out the source onGitHub!InstallationFrom PyPI...AlmostMake is on the Python Package Index! To install it, run:$python3-mpipinstallalmost-makeTo update it,$python3-mpipinstall--upgradealmost-makeFrom GitHub...AsAlmostMakeis hosted on GitHub, it can be installed by cloning:$gitclonehttps://github.com/personalizedrefrigerator/AlmostMake.git
$cdAlmostMake
$makeinstallYou may also need to installsetuptools,wheel, andtwine.See Packaging Python Projectsfor a brief overview of these packages. They can be installed as follows:$python3-mpipinstall--user--upgradesetuptoolswheeltwineNotable Missing FeaturesAt present,AlmostMakedoes not supportthe following, notable features.Inalmake:$(shell ...)that can usealmake_shellBSDMake-style conditionalsBSDMake-style.include < ... >includesDefining recipes viaa:: banda! b.Pre-defined recipes (e.g..ofrom.c)Inalmake_shell/built-in shell:ifstatements, loops, functions.Built-inchmodTestingTo test AlmostMake, run,$maketestNote, however, thatmake testdepends onmake install.Supported PlatformsAt present, it has been tested on the following platforms:Ubuntu with Python 3.8, AlmostMake v0.2.0. All tests pass.Debian with Python 3.7, older AlmostMake. All tests pass.iOS viaa-Shell, AlmostMake v0.19.0. Failing tests.If you find that AlmostMake works on a platform not listed here, please considercreating an issue and/or submitting a pull request to update the list of supported platforms and versions of Python!If AlmostMake doesn't work for you, you may wish to tryPyMake. This package appears to support a wider range of Python versions and platforms, but may have fewer features.