MakeFile

    Example see more, or gnu manual

    Hello Summary

    Makefile

    DEBUG ?= 0
    CONTAINER := $(shell command -v podman 2>/dev/null)
    
    # consider empty variable
    CONTAINER_NETWORK_OPTION=
    
    ifneq ($(CONTAINER_NETWORK_OPTION),)
    CONTAINER_NETWORK_OPTION=--net=$(CONTAINER_NETWORK_OPTION)
    endif
    
    CONTAINER_OPTIONS=run $(CONTAINER_NETWORK_OPTION) -v "$$PWD":/workdir -w /workdir blang/latex:ubuntu \
    /bin/sh -c
    
    PDF_GENERATION=pdflatex file.tex $(OUTPUT)
    
    ifeq ($(DEBUG), 1)
      OUTPUT=
    else
      OUTPUT=>/dev/null
    endif
    
    -include second_rules.Makefile
    
    
    # default call (can be changed by setting `.DEFAULT_GOAL := all`)
    all: pdf
    
    .PHONY: environment pdf clean
    
    environment:
    ifdef CONTAINER
      podman pull blang/latex:ubuntu
    endif
    
    pdf: environment
    ifdef CONTAINER
      podman $(CONTAINER_OPTIONS) "$(PDF_GENERATION)"
    else
      $(PDF_GENERATION)
    endif
    
    # NOTE '@' permits to silent the echo in terminal
    clean:
      @rm -f file.pdf
    # if you want silent comments, it shouldn't be indented
    

    second_rules.Makefile

    # This kind of files can help avoid pollutes the main one
    
    test:
      echo "hello world from another makefile"
    

    Usage: make DEBUG=1