Specify Dependency Targets
Specifying dependency targets
final_target: sub_target final_target.c
Recipe_to_create_final_target
sub_target: sub_target.c
Recipe_to_create_sub_target
say_hello:
echo "Hello World"
say_hello:
== The Target
- prerequisites or dependencies follow the target
echo "Hello World"
== The Recipe
- The target, prerequisites, and recipes together make a rule.
- Suppress command text and only show output with
@
like @echo "hello world"
say_hello:
@echo "Hello World"
generate:
@echo "Creating empty text files..."
touch file-{1..10}.txt
clean:
@echo "Cleaning up..."
rm *.txt
- This will only run the
say_hello
function because it's the default target ( the first thing )
- to hard code the default target, include this at beginning of file:
.DEFAULT_GOAL := generate
- To instead run all targets the target
all
is used to call all other targets
all: say_hello generate
say_hello:
@echo "Hello World"
generate:
@echo "Creating empty text files..."
touch file-{1..10}.txt
clean:
@echo "Cleaning up..."
rm *.txt