2014-11-05 13:32:11 +01:00
|
|
|
|
2019-11-14 14:49:35 +01:00
|
|
|
function binary.prelude {
|
|
|
|
has_array_key CC $variables || \
|
|
|
|
variables+=(CC "cc")
|
|
|
|
has_array_key CXX $variables || \
|
|
|
|
variables+=(CXX "c++")
|
|
|
|
has_array_key LD $variables || \
|
|
|
|
variables+=(LD "\${CC}")
|
|
|
|
|
|
|
|
for variable in CFLAGS CXXFLAGS LDFLAGS; do
|
|
|
|
has_array_key $variable $variables || \
|
|
|
|
variables+=($variable " ")
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-11-05 13:32:11 +01:00
|
|
|
function binary.build {
|
|
|
|
write -n "${target}:"
|
|
|
|
for i in ${src[@]}; do
|
|
|
|
write -n " ${i%.*}.o"
|
|
|
|
done
|
2019-06-09 19:19:50 +02:00
|
|
|
write " ${depends[$target]} $(dirdep $target)"
|
2014-11-05 13:32:11 +01:00
|
|
|
write "\t@echo '$(LD ${target})'"
|
2019-11-14 17:49:41 +01:00
|
|
|
write -n "\t$Q\$(CC) -o ${target}"
|
|
|
|
write -n "${ldflags[$target]}"
|
|
|
|
write -n " ${src[@]//.c/.o} \$(LDFLAGS)"
|
2014-11-05 13:32:11 +01:00
|
|
|
write
|
|
|
|
|
|
|
|
for i in ${src[@]}; do
|
2015-04-06 22:42:56 +02:00
|
|
|
targets+=("${i%.c}.o")
|
|
|
|
type[${i%.c}.o]=ofile
|
|
|
|
auto[${i%.c}.o]=true
|
|
|
|
cflags[${i%.c}.o]="${cflags[$target]}"
|
2014-11-05 13:32:11 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function binary.install {
|
|
|
|
local install="${install[$target]:-\$(BINDIR)}"
|
2016-04-06 10:12:06 +02:00
|
|
|
local basename="${filename[$target]}"
|
|
|
|
if [[ -z "$basename" ]]; then
|
|
|
|
basename="$(basename "${target}")"
|
|
|
|
fi
|
|
|
|
|
2014-11-05 13:32:11 +01:00
|
|
|
write "${target}.install: ${target}"
|
2015-04-06 23:00:08 +02:00
|
|
|
write "\t@echo '$(IN "${install}/${basename}")'"
|
2015-04-06 22:42:56 +02:00
|
|
|
write "\t${Q}mkdir -p '\$(DESTDIR)${install}'"
|
2019-10-24 00:45:47 +02:00
|
|
|
write "\t${Q}install -m${chmod[$target]:-0755} ${target} \$(DESTDIR)${install}/${basename}"
|
2014-11-05 13:32:11 +01:00
|
|
|
write
|
|
|
|
}
|
|
|
|
|
|
|
|
function binary.uninstall {
|
|
|
|
local install="${install[$target]:-\$(BINDIR)}"
|
2016-04-06 10:12:06 +02:00
|
|
|
local basename="${filename[$target]}"
|
|
|
|
if [[ -z "$basename" ]]; then
|
|
|
|
basename="$(basename "${target}")"
|
|
|
|
fi
|
|
|
|
|
2014-11-05 13:32:11 +01:00
|
|
|
write "${target}.uninstall:"
|
2015-04-06 23:00:08 +02:00
|
|
|
write "\t@echo '$(RM ${install}/${basename})'"
|
|
|
|
write "\t${Q}rm -f '\$(DESTDIR)${install}/${basename}'"
|
2014-11-05 13:32:11 +01:00
|
|
|
write
|
|
|
|
}
|
|
|
|
|
|
|
|
function binary.clean {
|
2016-04-23 01:29:36 +02:00
|
|
|
write -n "${target}.clean: "
|
|
|
|
src=($(echo ${sources[$target]}))
|
2016-04-06 10:12:06 +02:00
|
|
|
|
2016-04-23 01:29:36 +02:00
|
|
|
for file in ${src[@]}; do
|
|
|
|
write -n " ${file%.c}.o.clean"
|
2016-04-06 10:12:06 +02:00
|
|
|
done
|
2016-05-05 09:49:25 +02:00
|
|
|
write
|
2016-04-06 10:12:06 +02:00
|
|
|
|
2014-11-05 13:32:11 +01:00
|
|
|
write "\t@echo '$(RM ${target})'"
|
|
|
|
write "\t${Q}rm -f ${target}"
|
|
|
|
write
|
|
|
|
}
|
|
|
|
|