default out-dir = "../../target/examples/c"
default target = "build"

include "config.werk"
include "recipes.werk"

let executable = "{profile}/example{EXE_SUFFIX}"

# Build the executable.
build "{executable}" {
    from glob "*.c" | match {
        "%.c" => "/{profile}%.o"
    }
    run "{ld} -o <out> <in*>"
}

# Build the executable (shorthand).
task build {
    build executable
    info "Build done for profile '{profile}'"
}

# Build and run the executable.
task run {
    build "build"
    run "<executable>"
}

task clean {
    let object-files = glob "*.c" | map "{profile}{:.c=.o}"
    run {
        delete object-files
        delete executable
    }
}

