diff --git a/build.zsh.in b/build.zsh.in index 85405cb..d2ff1fa 100644 --- a/build.zsh.in +++ b/build.zsh.in @@ -337,6 +337,19 @@ function main { ((target_index++)) done + typeset -l -a target_directories + for target in "${targets[@]}"; do + directory="${target%/*}" + if [[ "$target" =~ .*/ ]] && ! has "${directory}" "${target_directories[@]}"; then + target_directories+=(${directory}) + fi + done + + for dir in ${target_directories[@]}; do + write "${dir}:" + write "\t${Q}mkdir -p ${dir}" + done + for dir in ${directories[@]}; do write "\$(DESTDIR)${dir}:" write "\t@echo '$(DIR ${dir})'" diff --git a/build/binary.zsh b/build/binary.zsh index acbd677..4dddbad 100644 --- a/build/binary.zsh +++ b/build/binary.zsh @@ -4,7 +4,7 @@ function binary.build { for i in ${src[@]}; do write -n " ${i%.*}.o" done - write " ${depends[$target]}" + write " ${depends[$target]} $(dirname $target)" write "\t@echo '$(LD ${target})'" write -n "\t$Q\$(CC) -o ${target} \$(LDFLAGS)" write -n " ${src[@]//.c/.o}" diff --git a/build/crystal.zsh b/build/crystal.zsh index 263cdab..dee1f7a 100644 --- a/build/crystal.zsh +++ b/build/crystal.zsh @@ -1,6 +1,6 @@ function crystal.build { - write "${target}: ${src[@]} ${depends[$target]}" + write "${target}: ${src[@]} ${depends[$target]} $(dirname $target)" write "\t@echo '${fg_bold[magenta]} CR > ${fg_bold[white]}$target${reset_color}'" write "\t${Q}crystal ${src[@]} -o '${target}'" diff --git a/build/header.zsh b/build/header.zsh index 882466e..73c071d 100644 --- a/build/header.zsh +++ b/build/header.zsh @@ -10,7 +10,7 @@ function header.install { basename="$(basename "${target}")" fi - write "${target}.install: ${target}" + write "${target}.install: ${target} $(dirname $target)" write "\t@echo '$(IN "${install}/${basename}")'" write "\t${Q}mkdir -p '\$(DESTDIR)${install}'" write "\t${Q}install -m0644 ${target} \$(DESTDIR)${install}/${basename}" diff --git a/build/library.zsh b/build/library.zsh index 0684c50..4271104 100644 --- a/build/library.zsh +++ b/build/library.zsh @@ -1,6 +1,6 @@ function library.build { - write -n "${target}: ${target}.so ${target}.a" + write -n "${target}: ${target}.so ${target}.a $(dirname $target)" write write "\t@:" diff --git a/build/man.zsh b/build/man.zsh index 91ee173..4b41af7 100644 --- a/build/man.zsh +++ b/build/man.zsh @@ -11,7 +11,7 @@ function man.build { write -n "${target}:" if [[ -n "${S}" ]]; then - write " $S" + write " $S $(dirname $target)" write "\t@echo '$(SED "${target}" | sed 's|SED|MAN|')'" write "\t${Q}pandoc -s --from markdown --to man '$S' -o '${target}'" fi diff --git a/build/moon.zsh b/build/moon.zsh index 909c894..c779682 100644 --- a/build/moon.zsh +++ b/build/moon.zsh @@ -15,7 +15,7 @@ function moon.build { fi if [[ -n "${S}" ]]; then - write " ${S}" + write " ${S} $(dirname $target)" write "\t@echo '$(MOON "${target}")'" if [[ -z "${install[$target]}" ]]; then write "\t${Q}echo '#!/usr/bin/env lua' > '${target}'" diff --git a/build/ofile.zsh b/build/ofile.zsh index 41d6f88..185a975 100644 --- a/build/ofile.zsh +++ b/build/ofile.zsh @@ -1,7 +1,7 @@ function ofile.build { local dirname="$(dirname "$target")" - write -n "${target}: ${target%.o}.c" + write -n "${target}: ${target%.o}.c $(dirname $target)" sed '/^#include "/!d;s/^#include "//;s/"$//' "${target%.o}.c" | \ while read h; do diff --git a/build/script.zsh b/build/script.zsh index f2daa47..2827d7e 100644 --- a/build/script.zsh +++ b/build/script.zsh @@ -11,7 +11,7 @@ function script.build { write -n "${target}:" if [[ -n "${S}" ]]; then - write " $S" + write " $S $(dirname $target)" write "\t@echo '$(SED "${target}")'" write -n "\t${Q}sed -e '" write -n "s&@LIBDIR@&\$(LIBDIR)&;" diff --git a/build/sharedlib.zsh b/build/sharedlib.zsh index 9234dd1..1992f84 100644 --- a/build/sharedlib.zsh +++ b/build/sharedlib.zsh @@ -4,7 +4,7 @@ function sharedlib.build { for i in ${src[@]}; do write -n " ${i%.*}.o" done - write " ${depends[$target]}" + write " ${depends[$target]} $(dirname $target)" write "\t@echo '$(LD ${target})'" write -n "\t$Q\$(CC) -o ${target} -shared \$(LDFLAGS)" write -n " ${src[@]//.c/.o}" diff --git a/build/staticlib.zsh b/build/staticlib.zsh index e6eac8a..a6d6345 100644 --- a/build/staticlib.zsh +++ b/build/staticlib.zsh @@ -4,7 +4,7 @@ function staticlib.build { for i in ${src[@]} ${depends[@]}; do write -n " ${i%.c}.o" done - write " ${depends[$target]}" + write " ${depends[$target]} $(dirname $target)" write "\t@echo '$(LD ${target})'" write -n "\t$Q\$(AR) rc '${target}'" write " ${src[@]//.c/.o}"