From 711e92c22d4f49b861a0b35b1d9c177efe1c8911 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Wed, 6 Apr 2016 10:12:06 +0200 Subject: [PATCH] Various. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nodist[file] can be used to prevent inclusion of something in the tarballs, even if it’s a source or something that should normally be included. - filename[target] can be used to rename files at installation-time. - A moonscript module was added. - Many modules update. - Some grooming, some deprecated code removed. - Makefile regenerated. --- Makefile | 24 +++++++++++++--- build.zsh.in | 53 ++++++++++++++++++++++------------- build/binary.zsh | 25 +++++++++++++++-- build/moon.zsh | 67 +++++++++++++++++++++++++++++++++++++++++++++ build/ofile.zsh | 4 --- build/script.zsh | 24 +++++++++++++--- build/sharedlib.zsh | 7 ----- build/staticlib.zsh | 7 ----- 8 files changed, 163 insertions(+), 48 deletions(-) create mode 100644 build/moon.zsh diff --git a/Makefile b/Makefile index e055275..39b7d0e 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ LDFLAGS := Q := @ -all: build.zsh build/binary.zsh build/library.zsh build/ofile.zsh build/script.zsh build/sharedlib.zsh build/staticlib.zsh +all: build.zsh build/binary.zsh build/library.zsh build/moon.zsh build/ofile.zsh build/script.zsh build/sharedlib.zsh build/staticlib.zsh build.zsh: build.zsh.in @echo ' [SED] build.zsh' @@ -62,6 +62,19 @@ build/library.zsh.uninstall: @echo ' [RM] $(SHAREDIR)/build.zsh/library.zsh' $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/library.zsh' +build/moon.zsh: + +build/moon.zsh.install: build/moon.zsh + @echo ' [IN] $(SHAREDIR)/build.zsh/moon.zsh' + $(Q)mkdir -p '$(DESTDIR)$(SHAREDIR)/build.zsh' + $(Q)install -m0755 build/moon.zsh $(DESTDIR)$(SHAREDIR)/build.zsh/moon.zsh + +build/moon.zsh.clean: + +build/moon.zsh.uninstall: + @echo ' [RM] $(SHAREDIR)/build.zsh/moon.zsh' + $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/moon.zsh' + build/ofile.zsh: build/ofile.zsh.install: build/ofile.zsh @@ -129,12 +142,12 @@ $(DESTDIR)$(SHAREDIR): $(DESTDIR)$(INCLUDEDIR): @echo ' [DIR] $(INCLUDEDIR)' $(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR) -install: subdirs.install build.zsh.install build/binary.zsh.install build/library.zsh.install build/ofile.zsh.install build/script.zsh.install build/sharedlib.zsh.install build/staticlib.zsh.install +install: subdirs.install build.zsh.install build/binary.zsh.install build/library.zsh.install build/moon.zsh.install build/ofile.zsh.install build/script.zsh.install build/sharedlib.zsh.install build/staticlib.zsh.install @: subdirs.install: -uninstall: subdirs.uninstall build.zsh.uninstall build/binary.zsh.uninstall build/library.zsh.uninstall build/ofile.zsh.uninstall build/script.zsh.uninstall build/sharedlib.zsh.uninstall build/staticlib.zsh.uninstall +uninstall: subdirs.uninstall build.zsh.uninstall build/binary.zsh.uninstall build/library.zsh.uninstall build/moon.zsh.uninstall build/ofile.zsh.uninstall build/script.zsh.uninstall build/sharedlib.zsh.uninstall build/staticlib.zsh.uninstall @: subdirs.uninstall: @@ -144,7 +157,7 @@ test: all subdirs subdirs.test subdirs.test: -clean: build.zsh.clean build/binary.zsh.clean build/library.zsh.clean build/ofile.zsh.clean build/script.zsh.clean build/sharedlib.zsh.clean build/staticlib.zsh.clean +clean: build.zsh.clean build/binary.zsh.clean build/library.zsh.clean build/moon.zsh.clean build/ofile.zsh.clean build/script.zsh.clean build/sharedlib.zsh.clean build/staticlib.zsh.clean distclean: clean @@ -161,6 +174,7 @@ $(PACKAGE)-$(VERSION).tar.gz: distdir $(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \ $(PACKAGE)-$(VERSION)/build/binary.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ @@ -174,6 +188,7 @@ $(PACKAGE)-$(VERSION).tar.xz: distdir $(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \ $(PACKAGE)-$(VERSION)/build/binary.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ @@ -187,6 +202,7 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir $(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \ $(PACKAGE)-$(VERSION)/build/binary.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ diff --git a/build.zsh.in b/build.zsh.in index 39b9f3b..3a05d2e 100644 --- a/build.zsh.in +++ b/build.zsh.in @@ -116,7 +116,9 @@ function subdirs { function get_distfiles { for file in "${dist[@]}" $(echo ${sources[@]}) $(echo ${depends[@]}); do - echo "$file" + if [[ -z "${nodist[$file]}" ]]; then + echo "$file" + fi done typeset -a src @@ -184,7 +186,7 @@ done function main { typeset -a prefixes directories - typeset -A ldflags cflags sources type depends install auto + typeset -A ldflags cflags sources type depends install auto filename nodist prefixes=( PREFIX '/usr/local' @@ -278,18 +280,28 @@ function main { fi fi - if exists "${type[$target]}.install"; then - ${type[$target]}.install + if [[ "${installdir}" == "-" ]]; then + write "${target}.install:" + write "" else - if [[ -z "${installdir}" ]]; then - error "No install[${type[${target}]}] and no default installation directory." - error "Your “install” rule will be broken!" + if exists "${type[$target]}.install"; then + ${type[$target]}.install else - write "${target}.install: \$(DESTDIR)${installdir}" - write "\t@echo '$(IN ${installdir}/${target})'" - write "\t@mkdir -p '\$(DESTDIR)/${installdir}'" - write "\t${Q}install -m755 $target \$(DESTDIR)${installdir}/$target" - write + if [[ -z "${installdir}" ]]; then + error "No install[${type[${target}]}] and no default installation directory." + error "Your “install” rule will be broken!" + else + local F="${filename[$target]}" + if [[ -z "$F" ]]; then + F="${target}" + fi + + write "${target}.install: \$(DESTDIR)${installdir}" + write "\t@echo '$(IN ${installdir}/${filename})'" + write "\t@mkdir -p '\$(DESTDIR)/${installdir}'" + write "\t${Q}install -m755 $target \$(DESTDIR)${installdir}/$filename" + write + fi fi fi @@ -375,14 +387,14 @@ function main { (( ${#targets[@]} > 0 )) && { for target in ${targets[@]}; do write -n " ${target}.clean" - ( - typeset -a src - src=($(echo ${sources[$target]})) + #( + # typeset -a src + # src=($(echo ${sources[$target]})) - for file in ${src[@]}; do - write -n " ${file%.c}.o.clean" - done - ) + # for file in ${src[@]}; do + # write -n " ${file%.c}.o.clean" + # done + #) done } write @@ -460,6 +472,9 @@ function main { 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}'" diff --git a/build/binary.zsh b/build/binary.zsh index 66c8adf..822fc76 100644 --- a/build/binary.zsh +++ b/build/binary.zsh @@ -21,7 +21,11 @@ function binary.build { function binary.install { local install="${install[$target]:-\$(BINDIR)}" - local basename="$(basename "${target}")" + local basename="${filename[$target]}" + if [[ -z "$basename" ]]; then + basename="$(basename "${target}")" + fi + write "${target}.install: ${target}" write "\t@echo '$(IN "${install}/${basename}")'" write "\t${Q}mkdir -p '\$(DESTDIR)${install}'" @@ -31,7 +35,11 @@ function binary.install { function binary.uninstall { local install="${install[$target]:-\$(BINDIR)}" - local basename="$(basename "${target}")" + local basename="${filename[$target]}" + if [[ -z "$basename" ]]; then + basename="$(basename "${target}")" + fi + write "${target}.uninstall:" write "\t@echo '$(RM ${install}/${basename})'" write "\t${Q}rm -f '\$(DESTDIR)${install}/${basename}'" @@ -39,7 +47,18 @@ function binary.uninstall { } function binary.clean { - write "${target}.clean:" + for target in ${targets[@]}; do + write -n " ${target}.clean" + ( + typeset -a src + src=($(echo ${sources[$target]})) + + for file in ${src[@]}; do + write -n " ${file%.c}.o.clean" + done + ) + done + write "\t@echo '$(RM ${target})'" write "\t${Q}rm -f ${target}" write diff --git a/build/moon.zsh b/build/moon.zsh new file mode 100644 index 0000000..eccc200 --- /dev/null +++ b/build/moon.zsh @@ -0,0 +1,67 @@ + +function MOON { + echo "${fg_bold[yellow]} [MOON] ${fg_bold[white]}$@${reset_color}" +} + +function moon.build { + write -n "${target}:" + + typeset -l S + + if [[ -n "${sources[$target]}" ]]; then + S="${sources[$target]}" + else + S="${target%.lua}.moon" + fi + + if [[ -e "${S%% *}" ]]; then + write " ${S}" + write "\t@echo '$(MOON "${target}")'" +# write "\t@echo '$(SED "${basename}")'" +# write -n "\t${Q}sed -e '" +# write -n "s&@LIBDIR@&\$(LIBDIR)&;" +# write -n "s&@BINDIR@&\$(BINDIR)&;" +# write -n "s&@SHAREDIR@&\$(SHAREDIR)&;" +# write "' '${basename}.in' > '${basename}'" + write "\t${Q}moonc -p $S > '${target}'" +# write "\t${Q}chmod +x '${basename}'" + fi + + write "\n" +} + +function moon.install { + binary.install "$@" +} + +function moon.uninstall { + binary.uninstall "$@" +} + +function moon.clean { + typeset -l S + + if [[ -n "${sources[$target]}" ]]; then + S="${sources[$target]}" + else + S="${target%.lua}.moon" + fi + + write "${target}.clean:" + + if [[ -e "${S%% *}" ]]; then + write "\t@echo '$(RM ${target})'" + write "\t${Q}rm -f ${target}" + fi + + write +} + +function moon.distfiles { + if [[ -e "${target}.moon" ]]; then + echo "${target}.moon" + else + echo "${target}" + fi +} + diff --git a/build/ofile.zsh b/build/ofile.zsh index 7c63fe8..41d6f88 100644 --- a/build/ofile.zsh +++ b/build/ofile.zsh @@ -28,7 +28,3 @@ function ofile.uninstall { write } -function ofile.clean { - binary.clean "$@" -} - diff --git a/build/script.zsh b/build/script.zsh index dc673ce..52da3ee 100644 --- a/build/script.zsh +++ b/build/script.zsh @@ -1,15 +1,23 @@ function script.build { + typeset -l S + + if [[ -n "${sources[$target]}" ]]; then + S="${sources[$target]}" + else + S="${target}.in" + fi + write -n "${target}:" - if [[ -e "${target}.in" ]]; then - write " ${target}.in" + if [[ -e "${S%% *}" ]]; then + write " $S" write "\t@echo '$(SED "${target}")'" write -n "\t${Q}sed -e '" write -n "s&@LIBDIR@&\$(LIBDIR)&;" write -n "s&@BINDIR@&\$(BINDIR)&;" write -n "s&@SHAREDIR@&\$(SHAREDIR)&;" - write "' '${target}.in' > '${target}'" + write "' $S > '${target}'" write "\t${Q}chmod +x '${target}'" fi @@ -25,9 +33,17 @@ function script.uninstall { } function script.clean { + typeset -l S + + if [[ -n "${sources[$target]}" ]]; then + S="${sources[$target]}" + else + S="${target}.in" + fi + write "${target}.clean:" - if [[ -e "${target}.in" ]]; then + if [[ -e "${S%% *}" ]]; then write "\t@echo '$(RM ${target})'" write "\t${Q}rm -f ${target}" fi diff --git a/build/sharedlib.zsh b/build/sharedlib.zsh index b2af472..9234dd1 100644 --- a/build/sharedlib.zsh +++ b/build/sharedlib.zsh @@ -59,10 +59,3 @@ function sharedlib.uninstall { write } -function sharedlib.clean { - write "${target}.clean:" - write "\t@echo '$(RM ${target})'" - write "\t${Q}rm -f ${target}" - write -} - diff --git a/build/staticlib.zsh b/build/staticlib.zsh index f2a9ca8..e6eac8a 100644 --- a/build/staticlib.zsh +++ b/build/staticlib.zsh @@ -37,10 +37,3 @@ function staticlib.uninstall { write } -function staticlib.clean { - write "${target}.clean:" - write "\t@echo '$(RM ${target})'" - write "\t${Q}rm -f ${target}" - write -} -