From 2f77ef8bbbb8457e7ecab95957bf4290d54bccfe Mon Sep 17 00:00:00 2001 From: Pedro Costa Date: Sun, 7 Aug 2022 15:14:13 +0000 Subject: [PATCH] fixed dependency generation for included files --- learn/building_programs/project_make.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/learn/building_programs/project_make.md b/learn/building_programs/project_make.md index fc2ede288..d4dd28ba4 100644 --- a/learn/building_programs/project_make.md +++ b/learn/building_programs/project_make.md @@ -259,11 +259,16 @@ $1 ~ /^(#:?)?include$/ && $2 ~ /^["'].+["']$/ { # Remove quotes from the included file name gsub(/'|"/, "", $2) - # count included files per file to avoid having duplicates in our list - if (incc[FILENAME,$2]++ == 0) { - # Add the included file to our list, this might be case-sensitive - inc[++ii] = sprintf("$(%s) += $(%s)", FILENAME, $2) - } + # Extract path of included file + file=FILENAME + gsub(".*/","",file) + path = FILENAME + gsub(file,"",path) + # count included files per file to avoid having duplicates in our list + if (incc[FILENAME,$2]++ == 0) { + # Add the included file to our list, this might be case-sensitive + inc[++ii] = sprintf("$(%s) += %s%s", FILENAME, path, $2) + } } # Finally, produce the output for make, loop over all modules, use statements