Search code examples
python-3.xmakefileterminalpython-sphinxbazel

Convert MakeFile to command line input or bazel


I am currently working on a project that that specifically is asking me to not use a Makefile to build all of the dependencies because their entire repo uses bazel to build files instead. I have zero knowledge on MakeFile. I want to know how to convert the following Makefile to command line arguments that I can then throw into a simply Python script. Thank you in advance! Your solution is greatly appreciated!

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS    =
SPHINXBUILD   = sphinx-build
SOURCEDIR     = .
BUILDDIR      = _build

# Put it first so that "make" without argument is like "make help".
help:
    @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
    @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Solution

  • remove the @ and then all the make commands will be printed out for you (the @ suppresses the make echo'ing the commands it uses):

    help:
        $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    
    %: Makefile
        $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    

    Then run make or make help and view the exact lines the make uses... copy/past into a script... or explicitly echo them instead:

    help:
        echo $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    
    %: Makefile
        echo $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
    

    Then nothing should actually run, but the commands that it would have run will be printed...