Removed most hardcoded variables.

master
Luka Vandervelden 2019-11-14 14:49:35 +01:00
parent 9cbf1debce
commit 26a33cca52
6 changed files with 36 additions and 31 deletions

View File

@ -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}'

View File

@ -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}'"

View File

@ -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

View File

@ -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
}

View File

@ -1,4 +1,8 @@
function library.prelude {
binary.prelude "$@"
}
function library.build {
write -n "${target}: ${target}.so ${target}.a $(dirdep $target)"
write

View File

@ -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]}")"