Make can be seen as a multi-paradigm programming language.
It supports at least three paradigms:
- Declarative
- Imperative
- 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")
endifFunctional
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