Removed most hardcoded variables.
This commit is contained in:
parent
9cbf1debce
commit
26a33cca52
10
Makefile
10
Makefile
@ -8,12 +8,6 @@ SHAREDIR := $(PREFIX)/share
|
||||
INCLUDEDIR := $(PREFIX)/include
|
||||
MANDIR := $(SHAREDIR)/man
|
||||
|
||||
CC := cc
|
||||
AR := ar
|
||||
RANLIB := ranlib
|
||||
CFLAGS :=
|
||||
LDFLAGS :=
|
||||
|
||||
Q := @
|
||||
|
||||
all: build.zsh build/binary.zsh build/crystal.zsh build/header.zsh build/library.zsh build/livescript.zsh build/man.zsh build/moon.zsh build/ofile.zsh build/sass.zsh build/scdocman.zsh build/script.zsh build/sharedlib.zsh build/staticlib.zsh
|
||||
@ -320,10 +314,6 @@ help:
|
||||
@echo ' - uninstall Deinstalls the project.'
|
||||
@echo ''
|
||||
@echo 'CLI-modifiable variables:'
|
||||
@echo ' - CC ${CC}'
|
||||
@echo ' - CFLAGS ${CFLAGS}'
|
||||
@echo ' - LDFLAGS ${LDFLAGS}'
|
||||
@echo ' - DESTDIR ${DESTDIR}'
|
||||
@echo ' - PREFIX ${PREFIX}'
|
||||
@echo ' - BINDIR ${BINDIR}'
|
||||
@echo ' - LIBDIR ${LIBDIR}'
|
||||
|
24
build.zsh.in
24
build.zsh.in
@ -75,6 +75,18 @@ function has {
|
||||
return 1
|
||||
}
|
||||
|
||||
function has_array_key {
|
||||
local element="$1"
|
||||
|
||||
shift 1
|
||||
|
||||
for key value ($@) {
|
||||
[[ "$key" == "$element" ]] && return 0
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Specialized helpers
|
||||
|
||||
function get_distfiles {
|
||||
@ -211,13 +223,6 @@ function main {
|
||||
|
||||
write
|
||||
|
||||
write "CC := ${CC:-cc}"
|
||||
write "AR := ${AR:-ar}"
|
||||
write "RANLIB := ${RANLIB:-ranlib}"
|
||||
write "CFLAGS := ${CFLAGS}"
|
||||
write "LDFLAGS := ${LDFLAGS}"
|
||||
write
|
||||
|
||||
write "Q := @"
|
||||
write
|
||||
|
||||
@ -444,15 +449,12 @@ function main {
|
||||
|
||||
write " @echo ''"
|
||||
write " @echo '${fg_bold[white]}CLI-modifiable variables:${reset_color}'"
|
||||
for VAR in CC CFLAGS LDFLAGS DESTDIR; do
|
||||
for VAR __ in ${variables}; do
|
||||
printf " @echo ' - ${fg_bold[blue]}%-14s${fg[white]} \${$VAR}${reset_color}'\n" "$VAR" >> $Makefile
|
||||
done
|
||||
for VAR __ in ${prefixes}; do
|
||||
printf " @echo ' - ${fg_bold[blue]}%-14s${fg[white]} \${$VAR}${reset_color}'\n" "$VAR" >> $Makefile
|
||||
done
|
||||
for VAR __ in ${variables}; do
|
||||
printf " @echo ' - ${fg_bold[blue]}%-14s${fg[white]} \${$VAR}${reset_color}'\n" "$VAR" >> $Makefile
|
||||
done
|
||||
|
||||
write " @echo ''"
|
||||
write " @echo '${fg_bold[white]}Project targets: ${reset_color}'"
|
||||
|
@ -1,4 +1,18 @@
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function binary.build {
|
||||
write -n "${target}:"
|
||||
for i in ${src[@]}; do
|
||||
|
@ -1,15 +1,6 @@
|
||||
|
||||
function crystal.prelude {
|
||||
local has_crflags=false
|
||||
|
||||
for variable value in ${variables[@]}; do
|
||||
if [[ "$variable" == "CRFLAGS" ]]; then
|
||||
has_crflags=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if ! $has_crflags; then
|
||||
if ! has_array_key CRFLAGS; then
|
||||
variables+=(CRFLAGS "--release")
|
||||
fi
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
function library.prelude {
|
||||
binary.prelude "$@"
|
||||
}
|
||||
|
||||
function library.build {
|
||||
write -n "${target}: ${target}.so ${target}.a $(dirdep $target)"
|
||||
write
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
function ofile.prelude {
|
||||
binary.prelude "$@"
|
||||
}
|
||||
|
||||
function ofile.build {
|
||||
local dirname="$(dirname "$target")"
|
||||
write -n "${target}: ${target%.o}.c $(dirdep $target "${target%.o}.c ${sources[$target]}" "${depends[@target]}")"
|
||||
|
Loading…
Reference in New Issue
Block a user