diff --git a/Makefile b/Makefile index f7ac403..23afc36 100644 --- a/Makefile +++ b/Makefile @@ -18,12 +18,15 @@ all: build-chibi README.md: doc/compile-scheme.1 printf "
\n$$(MANWIDTH=80 man -l doc/compile-scheme.1)\n" > README.md -build-chibi: +replace-version: + sed 's/DEVELOPMENT_VERSION/${VERSION}/' compile-scheme.scm + +build-chibi: replace-version echo "#!/bin/sh" > compile-scheme echo "chibi-scheme -A ${PREFIX}/lib/compile-scheme ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compile-scheme chmod +x compile-scheme -build-chicken: +build-chicken: replace-version csc -R r7rs -X r7rs -static -c -J -unit libs.util -o libs.util.o libs/util.sld ar rcs libs.util.a libs.util.o csc -R r7rs -X r7rs -static -c -J -unit libs.library-util -o libs.library-util.o libs/library-util.sld @@ -48,33 +51,33 @@ deb: build-chicken dpkg-deb -b deb # FIXME -#build-gauche: +#build-gauche: replace-version #echo "#!/bin/sh" > compile-scheme #echo "gosh -r -I ${PREFIX}/lib/compile-scheme -I ${PREFIX}/lib/compile-scheme/libs ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compilescheme- #chmod +x compile-scheme -build-guile: +build-guile: replace-version echo "#!/bin/sh" > compile-scheme echo "guile --r7rs --auto-compile -I -q -L ${PREFIX}/lib/compile-scheme ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compile-scheme chmod +x compile-scheme # FIXME -#build-kawa: +#build-kawa: replace-version #echo "#!/bin/sh" > compile-scheme #echo "kawa -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED -J--enable-native-access=ALL-UNNAMED -Dkawa.import.path=/usr/local/share/kawa/lib/*.sld:${PREFIX}/lib/compile-scheme/*.sld --r7rs ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\" 2> /dev/null" >> compile-scheme #chmod +x compile-scheme # FIXME -#build-racket: +#build-racket: replace-version #echo "#!/bin/sh" > compile-scheme #echo "racket -I r7rs -S ${PREFIX}/lib/compile-scheme --script ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compile-scheme -build-sagittarius: +build-sagittarius: replace-version echo "#!/bin/sh" > compile-scheme echo "sash -A ${PREFIX}/lib/compile-scheme ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compile-scheme chmod +x compile-scheme -build-stklos: +build-stklos: replace-version echo "#!/bin/sh" > compile-scheme echo "stklos -I ${PREFIX}/lib/compile-scheme ${PREFIX}/lib/compile-scheme/compile-scheme.scm \"\$$@\"" >> compile-scheme chmod +x compile-scheme @@ -85,6 +88,9 @@ install: cp -r libs ${PREFIX}/lib/compile-scheme/ cp compile-scheme.scm ${PREFIX}/lib/compile-scheme/compile-scheme.scm install compile-scheme ${PREFIX}/bin/compile-scheme + mkdir -p ${PREFIX}/share/man/man1 + cp doc/compile-scheme.1 ${PREFIX}/share/man/man1/ + if [ -d /etc/bash_completion.d ]; then cp bash_completion.sh /etc/bash_completion.d/compile-scheme; fi uninstall: rm -rf ${PREFIX}/lib/compile-scheme diff --git a/bash_completion.sh b/bash_completion.sh new file mode 100644 index 0000000..8186c18 --- /dev/null +++ b/bash_completion.sh @@ -0,0 +1,101 @@ +_compile_scheme() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + shortopts="-A -I" + longopts="--list-r6rs --list-r7rs --list-all --help --version" + targets="unix windows php" + outputfound=false + for i in "${COMP_WORDS[@]}"; do + if [[ "$i" == "-o" ]] ; then + outputfound=true + fi + done + targetfound=false + for i in "${COMP_WORDS[@]}"; do + if [[ "$i" == "-t" ]] ; then + targetfound=true + fi + done + + if [[ "$outputfound" == "false" ]]; then + shortopts="${shortopts} -o" + fi + if [[ "$targetfound" == "false" ]]; then + shortopts="${shortopts} -t" + fi + + opts="${shortopts} ${longopts}" + + if [[ ${prev} == -o ]] ; then + COMPREPLY=( $(compgen -W "" -- ${cur}) ) + return 0 + elif [[ ${prev} == -I ]] ; then + COMPREPLY=() + return 0 + elif [[ ${prev} == -A ]] ; then + COMPREPLY=() + return 0 + elif [[ ${prev} == -t ]] ; then + COMPREPLY=( $(compgen -W "${targets}" -- ${cur}) ) + return 0 + elif [[ ${cur} == -o ]] ; then + COMPREPLY=("") + return 0 + elif [[ ${cur} == -t ]] ; then + COMPREPLY=("") + return 0 + elif [[ ${prev} == *.sps ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + elif [[ ${prev} == *.scm ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + elif [[ ${cur} == -* ]] ; then + for i in "${COMP_WORDS[@]}"; do + if [[ "$i" == *.sps ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + if [[ "$i" == *.scm ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + done + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + elif [[ ${cur} == --* ]] ; then + for i in "${COMP_WORDS[@]}"; do + if [[ "$i" == *.sps ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + if [[ "$i" == *.scm ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + done + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + elif [[ ${cur} == * ]] ; then + for i in "${COMP_WORDS[@]}"; do + if [[ "$i" == *.sps ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + if [[ "$i" == *.scm ]] ; then + COMPREPLY=( $(compgen -W "${shortopts}" -- ${cur}) ) + return 0 + fi + done + COMPREPLY=( $(compgen -W "$(find . -maxdepth 1 -type f -name "*.sps" -o -name "*.scm" -printf '%f\n')" -- ${cur}) ) + return 0 + fi +} +# `foo`