Content
    Declarative

Make as multi-paradigm language

Make can be seen as a multi-paradigm programming language.

It supports at least three paradigms:

  1. Declarative
  2. Imperative
  3. Functional

Declarative

Rules in makefiles are written in a declarative way:

%.o: %.c
	gcc -c $< -o $@

Imperative

Conditionals can be used as an imperative way to describe alternative actions in makefiles .

ifeq ($(MSG),)
$(warning "No message provided")
endif

Functional

Functions in make are evaluated in a functional way:

Example: Calculate the factorial with help of bc

fact=$(if $(filter 0, $(1)), 1, $(shell echo "$(1) * \
	$(call fact, $(shell echo "$(1) - 1" | bc))" | bc))
result=$(call fact, 4) # 24


  • Category

  • Programming

  • Tags

  • Build Tools
    Computer Science

  • Created

  • 29. November 2017


  • Modified

  • 10. April 2022