# directories
base_dir = .
include_dir = $base_dir/include
src_dir = $base_dir/src
out_dir = $base_dir/out

# tools
cc = clang
cflags = -Weverything -std=c11 -I $include_dir
#cc = gcc
#cflags = -pedantic-errors -std=c11 -I $include_dir

rule compile
  command = $cc $cflags -c $in -o $out

rule link
  command = $cc $in -o $out

build $out_dir/hello.o: compile $src_dir/hello.c
build $out_dir/hello: link $out_dir/hello.o

default $out_dir/hello


Add depfile and have a common cflags variable.
# directories
base_dir = .
include_dir = $base_dir/include
src_dir = $base_dir/src
out_dir = $base_dir/out

cflags = -std=c11 -I $include_dir -MMD
# tools
cc = clang
cflags = -Weverything $cflags
#cc = gcc
#cflags = -pedantic-errors $clfags

rule compile
  depfile = $out.d
  command = $cc $cflags -MF $out.d -c $in -o $out

rule link
  command = $cc $in -o $out

build $out_dir/hello.o: compile $src_dir/hello.c
build $out_dir/hello: link $out_dir/hello.o

default $out_dir/hello